fixed NPE with Jaxb proxy classes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1692598 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f5e9adea84
commit
5d267dd16d
@ -24,6 +24,9 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.security.CodeSource;
|
||||||
|
import java.security.ProtectionDomain;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -35,6 +38,7 @@ import java.util.jar.JarFile;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.internal.TextListener;
|
import org.junit.internal.TextListener;
|
||||||
import org.junit.runner.JUnitCore;import org.junit.runner.Result;
|
import org.junit.runner.JUnitCore;import org.junit.runner.Result;
|
||||||
@ -211,12 +215,14 @@ public final class OOXMLLite {
|
|||||||
Map<String, Class<?>> map = new HashMap<String, Class<?>>();
|
Map<String, Class<?>> map = new HashMap<String, Class<?>>();
|
||||||
for (Class<?> cls : classes) {
|
for (Class<?> cls : classes) {
|
||||||
// e.g. proxy-classes, ...
|
// e.g. proxy-classes, ...
|
||||||
if(cls.getProtectionDomain() == null ||
|
ProtectionDomain pd = cls.getProtectionDomain();
|
||||||
cls.getProtectionDomain().getCodeSource() == null) {
|
if (pd == null) continue;
|
||||||
continue;
|
CodeSource cs = pd.getCodeSource();
|
||||||
}
|
if (cs == null) continue;
|
||||||
|
URL loc = cs.getLocation();
|
||||||
|
if (loc == null) continue;
|
||||||
|
|
||||||
String jar = cls.getProtectionDomain().getCodeSource().getLocation().toString();
|
String jar = loc.toString();
|
||||||
if(jar.indexOf(ptrn) != -1) map.put(cls.getName(), cls);
|
if(jar.indexOf(ptrn) != -1) map.put(cls.getName(), cls);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
|
Loading…
Reference in New Issue
Block a user