Class FlexibleMainRetrofittingTaskListener
java.lang.Object
com.github.bsideup.jabel.FlexibleMainRetrofittingTaskListener
- All Implemented Interfaces:
TaskListener
Will adapts flexible entry points (
And Jabel cannot create a bridge for the first main, because there would be a signature duplication with the second declared main.
void main();, void main(String[]);, static void main();,
static void main(String[])) by attempting to create a bridge.
This is pretty limited as non-static main entry points with arguments cannot be adapted, due to a signature duplication with the static one.
Moreover, classes containing multiple entry points with ones that are private,
will not work properly on older JVMs.
For example this code:
class Main {
static void main() {}
private static void main(String[] args) {}
}
The first main method will be selected by Java 25's JVM, because the standard one is private,
whereas on an older JVM, an error will be displayed. And Jabel cannot create a bridge for the first main, because there would be a signature duplication with the second declared main.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddMainBridge(com.sun.tools.javac.tree.JCTree.JCClassDecl classDecl, boolean toLocalMain) Creates a main bridge in the specified class.voidbooleanisMain(com.sun.tools.javac.tree.JCTree.JCMethodDecl method) booleanisPrivate(com.sun.tools.javac.tree.JCTree.JCMethodDecl m) booleanisStatic(com.sun.tools.javac.tree.JCTree.JCMethodDecl m) com.sun.tools.javac.tree.JCTree.JCMethodDeclmakeMainBridge(com.sun.tools.javac.tree.JCTree.JCClassDecl classDecl, boolean toLocalMain) IftoLocalMainistrue, a zero-arg constructor must be present.voidvoidtransformClass(com.sun.tools.javac.tree.JCTree.JCClassDecl classDecl)
-
Method Details
-
started
- Specified by:
startedin interfaceTaskListener
-
finished
- Specified by:
finishedin interfaceTaskListener
-
transformClass
public void transformClass(com.sun.tools.javac.tree.JCTree.JCClassDecl classDecl) -
isPrivate
public boolean isPrivate(com.sun.tools.javac.tree.JCTree.JCMethodDecl m) -
isStatic
public boolean isStatic(com.sun.tools.javac.tree.JCTree.JCMethodDecl m) -
isMain
public boolean isMain(com.sun.tools.javac.tree.JCTree.JCMethodDecl method) -
makeMainBridge
public com.sun.tools.javac.tree.JCTree.JCMethodDecl makeMainBridge(com.sun.tools.javac.tree.JCTree.JCClassDecl classDecl, boolean toLocalMain) IftoLocalMainistrue, a zero-arg constructor must be present. -
addMainBridge
public void addMainBridge(com.sun.tools.javac.tree.JCTree.JCClassDecl classDecl, boolean toLocalMain) Creates a main bridge in the specified class.
-