public class DefinePackageHelper extends Object
ClassLoader.defineClass(String,byte[],int,int)
.Modifier and Type | Method | Description |
---|---|---|
static void |
definePackage(String className,
ClassLoader loader) |
Defines a new package.
|
public static void definePackage(String className, ClassLoader loader) throws CannotCompileException
You do not necessarily need to
call this method. If this method is called, then
getPackage()
on the Class
object returned
by toClass()
will return a non-null object.
The jigsaw module introduced by Java 9 has broken this method.
In Java 9 or later, the VM argument
--add-opens java.base/java.lang=ALL-UNNAMED
has to be given to the JVM so that this method can run.
loader
- the class loader passed to toClass()
or
the default one obtained by getClassLoader()
.className
- the package name.CannotCompileException
Class.getClassLoader()
,
CtClass.toClass()
Copyright © 2018 Shigeru Chiba, www.javassist.org. All rights reserved.