]> source.dussan.org Git - javassist.git/commitdiff
changes getDefinedPackage back to getPackage when Java is < 9.
authorchibash <chiba@javassist.org>
Tue, 14 Nov 2017 18:05:05 +0000 (03:05 +0900)
committerchibash <chiba@javassist.org>
Tue, 14 Nov 2017 18:05:05 +0000 (03:05 +0900)
build.xml
javassist.jar
src/main/javassist/Loader.java

index 38a2cc8d7109c96bff12c3f48fb14dbb22f29fdd..5273c49494ed01b5877ac905d1bd84a283185802 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -32,6 +32,7 @@
   <path id="test.compile.classpath">
     <pathelement location="${build.classes.dir}"/>
     <pathelement location="${lib.dir}/junit.jar"/>
+    <pathelement location="${lib.dir}/hamcrest.jar"/>
   </path>
 
   <property name="test.compile.classpath" refid="test.compile.classpath"/>
@@ -39,7 +40,8 @@
   <path id="test.classpath">
     <pathelement location="${test.build.dir}"/>
     <pathelement location="${lib.dir}/junit.jar"/>
-       <pathelement location="${build.classes.dir}"/>
+    <pathelement location="${lib.dir}/hamcrest.jar"/>
+    <pathelement location="${build.classes.dir}"/>
   </path>
 
   <property name="test.classpath" refid="test.classpath"/>
index 78328e6326860356d9eee3b6d1ad629ec0e280d4..823d1cc94b5dfa9830e501f27c9abf77ffe5ea56 100644 (file)
Binary files a/javassist.jar and b/javassist.jar differ
index cbbf09e5dd0567b346ed14c947bceeb15800b78f..8eb067c4cb192f5b23115ec17fad41f13b77d281 100644 (file)
@@ -23,6 +23,8 @@ import java.util.Arrays;
 import java.util.Hashtable;
 import java.util.Vector;
 
+import javassist.bytecode.ClassFile;
+
 /**
  * The class loader for Javassist.
  *
@@ -360,7 +362,7 @@ public class Loader extends ClassLoader {
         int i = name.lastIndexOf('.');
         if (i != -1) {
             String pname = name.substring(0, i);
-            if (getDefinedPackage(pname) == null)
+            if (isDefinedPackage(pname))
                 try {
                     definePackage(
                         pname, null, null, null, null, null, null, null);
@@ -376,6 +378,13 @@ public class Loader extends ClassLoader {
         return defineClass(name, classfile, 0, classfile.length, domain);
     }
 
+    private boolean isDefinedPackage(String name) {
+        if (ClassFile.MAJOR_VERSION >= ClassFile.JAVA_9)
+            return getDefinedPackage(name) == null;
+        else
+            return getPackage(name) == null;
+    }
+
     protected Class<?> loadClassByDelegation(String name)
         throws ClassNotFoundException
     {