From 45ce3617423eeedca6c556543329208e540922cb Mon Sep 17 00:00:00 2001 From: chibash Date: Thu, 13 Apr 2017 03:45:51 +0900 Subject: modifies to use sun.misc.Unsafe#defineClass so that Javassist can run with jigsaw --- src/test/javassist/JvstTest4.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/test/javassist') 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(); -- cgit v1.2.3