aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/Loader.java
diff options
context:
space:
mode:
authorchibash <chiba@javassist.org>2017-11-15 03:05:05 +0900
committerchibash <chiba@javassist.org>2017-11-15 03:05:05 +0900
commitb86c14888230d12d3844a469e3b34be11dbf4053 (patch)
tree29150acb663add9381ec1b21fc20a86085b85266 /src/main/javassist/Loader.java
parentb7e59d4dc0222d34732c8efd87872b562501e14b (diff)
downloadjavassist-b86c14888230d12d3844a469e3b34be11dbf4053.tar.gz
javassist-b86c14888230d12d3844a469e3b34be11dbf4053.zip
changes getDefinedPackage back to getPackage when Java is < 9.
Diffstat (limited to 'src/main/javassist/Loader.java')
-rw-r--r--src/main/javassist/Loader.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/javassist/Loader.java b/src/main/javassist/Loader.java
index cbbf09e5..8eb067c4 100644
--- a/src/main/javassist/Loader.java
+++ b/src/main/javassist/Loader.java
@@ -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
{