Class RuntimePackageCheck
java.lang.Object
org.codehaus.groovy.classgen.asm.sc.RuntimePackageCheck
Reports what statically compiled code accesses in another run-time package,
which is the package name and the class loader, when
CompilerConfiguration.RUNTIME_PACKAGE_CHECK applies. The language
allows such access, as the package name is the same, but the JVM refuses it
at run time with IllegalAccessError.- Since:
- 6.0.1
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckAnonymousClass(WriterController controller, ConstructorCallExpression call) Checks the constructor of the superclass that the generated constructor of an anonymous class calls.static voidcheckConstructor(WriterController controller, ConstructorNode ctor, boolean superCall, ASTNode call) Checks a call of a constructor.static voidcheckField(WriterController controller, FieldNode field, ClassNode receiverType, ASTNode expression) Checks a read or write of a field.static voidcheckMethod(WriterController controller, MethodNode method, ClassNode receiverType, ASTNode call) Checks a call of a method.static org.objectweb.asm.MethodVisitorcheckNamedClasses(WriterController controller, org.objectweb.asm.MethodVisitor delegate) Returns a visitor that reports the instructions of a statically compiled method that name a class the JVM refuses: a class that is not public, with the same package name as the current class, of another run-time package.static voidcheckSuperTypes(WriterController controller) Checks the superclass and interfaces of a statically compiled class.
-
Method Details
-
checkConstructor
public static void checkConstructor(WriterController controller, ConstructorNode ctor, boolean superCall, ASTNode call) Checks a call of a constructor. There is no subclass rule fornew: onlysuper(...)can call a protected constructor from a subclass.A
super(...)call without a source position in a generated constructor, as@InheritConstructorsadds for each constructor of the superclass, is not reported: it fails only if that constructor is called. Dynamic code calls a super constructor without the meta-class too, so the report of such a call does not advise@CompileDynamic.- Parameters:
controller- the writer of the current classctor- the constructor that is calledsuperCall- whether the call issuper(...)call- where to report it
-
checkAnonymousClass
Checks the constructor of the superclass that the generated constructor of an anonymous class calls. That call is selected at run time, so the arguments of the anonymous class creation tell which constructor it is, if they tell.- Parameters:
controller- the writer of the current classcall- the creation of the anonymous class
-
checkMethod
public static void checkMethod(WriterController controller, MethodNode method, ClassNode receiverType, ASTNode call) Checks a call of a method.- Parameters:
controller- the writer of the current classmethod- the method that is calledreceiverType- the type of the receiver, ornullforthisorsupercall- where to report it
-
checkField
public static void checkField(WriterController controller, FieldNode field, ClassNode receiverType, ASTNode expression) Checks a read or write of a field.- Parameters:
controller- the writer of the current classfield- the field that is accessedreceiverType- the type of the receiver, ornullforthisorsuperexpression- where to report it
-
checkSuperTypes
Checks the superclass and interfaces of a statically compiled class. The JVM refuses to load a class whose superclass or interface it cannot access, in dynamic code too, so the report does not advise@CompileDynamic.- Parameters:
controller- the writer of the class
-
checkNamedClasses
public static org.objectweb.asm.MethodVisitor checkNamedClasses(WriterController controller, org.objectweb.asm.MethodVisitor delegate) Returns a visitor that reports the instructions of a statically compiled method that name a class the JVM refuses: a class that is not public, with the same package name as the current class, of another run-time package. The JVM checks that wherever an instruction names the class, so a value of such a class can still be stored and passed on as long as none of them does.- Parameters:
controller- the writer of the current classdelegate- the visitor of the method- Returns:
- the visitor to use for the instructions of the method
-