Closed mkoncek closed 3 years ago
Maybe relevant with commit of "allow passing flags to javac?"
[2021-10-25T15:38:35.112Z] java.lang.IllegalArgumentException: error: invalid flag:
at jdk.compiler/com.sun.tools.javac.main.Arguments.reportDiag(Arguments.java:891)
at jdk.compiler/com.sun.tools.javac.main.Arguments.doProcessArgs(Arguments.java:366)
at jdk.compiler/com.sun.tools.javac.main.Arguments.processArgs(Arguments.java:347)
at jdk.compiler/com.sun.tools.javac.main.Arguments.init(Arguments.java:246)
at jdk.compiler/com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:185)
at jdk.compiler/com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:119)
at jdk.compiler/com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:68)
at io.github.mkoncek.classpathless.impl.CompilerJavac.compileClass(CompilerJavac.java:195)
at org.jrd.frontend.frame.overwrite.OverwriteClassDialog$CompilationWithResult.run(OverwriteClassDialog.java:613)
at org.jrd.frontend.frame.main.DecompilationController$QuickCompiler$2.run(DecompilationController.java:425)
at java.base/java.lang.Thread.run(Thread.java:829)
error: invalid flag:
I agree, that seems to be the error reported by javac thru MessagesListener
.
Looks to me as if the invalid flag it is reporting is empty. Which is weird because we split the compiler arguments on \s+
, so this should not happen. We also pass the useHostClasses separately from the compiler args via the CPLC Argument builder pattern:
boolean useHostClasses = Config.getConfig().doUseHostSystemClasses();
List<String> compilerArgs = Config.getConfig().getCompilerArgs();
ClasspathlessCompiler.Arguments arguments =
new ClasspathlessCompiler.Arguments().useHostSystemClasses(useHostClasses).compilerOptions(compilerArgs);
rc = new io.github.mkoncek.classpathless.impl.CompilerJavac(arguments);
This is probably an issue with compiler args... looking into it.
This is completely unrelated to Use host system classes. By saving settings and having compiler args blank, the split on whitespace returns and empty string, resulting in, you know, a list containing one empty string...
If you have not set and saved the args before, the config has no listing of them, in which case it correctly returns an empty list in a getter for the args. Which is why this was allowed to be overlooked.
No action required on CPLC side?
I tested the proposed version and it seems like it works fine.
No action required on CPLC side?
Correct.
I tested the proposed version and it seems like it works fine.
Good! Thank you :)
Found more issues, to reproduce:
1) Have "Use host classes" unchecked from last session
2) "Compile and upload" from the running JRD process the class com.google.gson.JsonArray
3) You will get an error (among other warnings):
compiler message file broken: key=compiler.misc.msg.bug arguments=11.0.12, {1}, {2}, {3}, {4}, {5}, {6}, {7}
If you check the box again, compile, uncheck, compile then it works.
Have "Use host classes" unchecked from last session
What is in the config file ~/.config/java-runtime-decompiler/conf/config.json
at this point?
Also, did you test this on the issues
branch, which already implements a fix to the original issue here, or on master?
Attempting to reproduce with the steps you mentioned only produces this result:
Compiler diagnostic at [-1, -1]: unknown enum constant java.lang.annotation.ElementType.METHOD
reason: class file for java.lang.annotation.ElementType not found
(code: compiler.warn.unknown.enum.constant.reason)
[2021-10-27T08:51:03.019Z] Compiler diagnostic at [-1, -1]: unknown enum constant java.lang.annotation.ElementType.METHOD
reason: class file for java.lang.annotation.ElementType not found
(code: compiler.warn.unknown.enum.constant.reason)
Compiler diagnostic at [-1, -1]: unknown enum constant java.lang.annotation.ElementType.ANNOTATION_TYPE
(code: compiler.warn.unknown.enum.constant)
[2021-10-27T08:51:03.105Z] Compiler diagnostic at [-1, -1]: unknown enum constant java.lang.annotation.ElementType.ANNOTATION_TYPE
(code: compiler.warn.unknown.enum.constant)
Compiler diagnostic at [-1, -1]: unknown enum constant java.lang.annotation.ElementType.ANNOTATION_TYPE
(code: compiler.warn.unknown.enum.constant)
[2021-10-27T08:51:03.108Z] Compiler diagnostic at [-1, -1]: unknown enum constant java.lang.annotation.ElementType.ANNOTATION_TYPE
(code: compiler.warn.unknown.enum.constant)
Compiler diagnostic at (/com/google/gson/JsonArray.java) [-1, -1]: unknown enum constant java.lang.annotation.ElementType.METHOD
(code: compiler.warn.unknown.enum.constant)
[2021-10-27T08:51:03.125Z] Compiler diagnostic at (/com/google/gson/JsonArray.java) [-1, -1]: unknown enum constant java.lang.annotation.ElementType.METHOD
(code: compiler.warn.unknown.enum.constant)
Compiler diagnostic at (/com/google/gson/JsonArray.java) [-1, -1]: /com/google/gson/JsonArray.java uses or overrides a deprecated API.
(code: compiler.note.deprecated.filename)
[2021-10-27T08:51:03.847Z] Compiler diagnostic at (/com/google/gson/JsonArray.java) [-1, -1]: /com/google/gson/JsonArray.java uses or overrides a deprecated API.
(code: compiler.note.deprecated.filename)
Compiler diagnostic at (/com/google/gson/JsonArray.java) [-1, -1]: Recompile with -Xlint:deprecation for details.
(code: compiler.note.deprecated.recompile)
[2021-10-27T08:51:03.851Z] Compiler diagnostic at (/com/google/gson/JsonArray.java) [-1, -1]: Recompile with -Xlint:deprecation for details.
(code: compiler.note.deprecated.recompile)
Attempt to compile finished, you may close dialog
[2021-10-27T08:51:03.901Z] uploaded: com.google.gson.JsonArray
Unlikely to be caused by usehostsystemclass checkbox itself. What do you have in your compiler flags text field? Also, full trace please rather than one error line?
You are right, this was on master
, on your issues
branch i do not get this error.
You are right, this was on
master
, on yourissues
branch i do not get this error.
Mystery solved! Note that this issue will still close automatically when #206 is merged.
The behaviour seems weird but the troubles start when you uncheck the box in Configuration -> Settings. Attempting to compile any class will result in:
error: invalid flag:
Re-checking the box does not fix it and the setting seems to be remembered somehow.I was trying different combinations of latest versions / snapshots of JRD and CPLC, but it seems unrelated.