aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/javassist
diff options
context:
space:
mode:
authorchibash <chiba@javassist.org>2017-04-13 03:45:51 +0900
committerchibash <chiba@javassist.org>2017-04-13 03:45:51 +0900
commit45ce3617423eeedca6c556543329208e540922cb (patch)
tree7ed91b96009b940de4250b4600212c2d0eb95c45 /src/test/javassist
parent6a3ed31976e54f2523a6e41dfee9001b3cce58c8 (diff)
downloadjavassist-45ce3617423eeedca6c556543329208e540922cb.tar.gz
javassist-45ce3617423eeedca6c556543329208e540922cb.zip
modifies to use sun.misc.Unsafe#defineClass so that Javassist can run with jigsaw
Diffstat (limited to 'src/test/javassist')
-rw-r--r--src/test/javassist/JvstTest4.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/test/javassist/JvstTest4.java b/src/test/javassist/JvstTest4.java
index 1fdec977..56a89335 100644
--- a/src/test/javassist/JvstTest4.java
+++ b/src/test/javassist/JvstTest4.java
@@ -599,11 +599,29 @@ public class JvstTest4 extends JvstTestRoot {
});
}
+ public void testMakePackage() throws Exception {
+ if (ClassFile.MAJOR_VERSION >= ClassFile.JAVA_9) {
+ ClassPool pool = ClassPool.getDefault();
+ try {
+ pool.makePackage(pool.getClassLoader(), "test4.pack2");
+ fail("makePackage() ran");
+ }
+ catch (CannotCompileException e) {}
+ }
+ }
+
public void testPackage() throws Throwable { // JASSIST-147
String packageName = "test4.pack";
ClassPool pool = ClassPool.getDefault();
- pool.makePackage(pool.getClassLoader(), packageName);
- pool.makePackage(pool.getClassLoader(), packageName);
+ try {
+ pool.makePackage(pool.getClassLoader(), packageName);
+ pool.makePackage(pool.getClassLoader(), packageName);
+ }
+ catch (CannotCompileException e) {
+ if (ClassFile.MAJOR_VERSION >= ClassFile.JAVA_9)
+ return; // makePackage() does not work in Java 9.
+ }
+
CtClass ctcl = pool.makeClass("test4.pack.Clazz");
Class cl = ctcl.toClass();
Object obj = cl.getConstructor().newInstance();