https://github.com/gwtproject/gwt/issues/10005


On Saturday, September 28, 2024 at 8:05:53 PM UTC+1 Colin Alworth wrote:

> Thanks, can you file that? Optimizations (in this case method inlining) 
> that need to clone a switch-expr _should_ be disabled, but clearly we 
> missed preventing that in at least this case.
>
> On Saturday, September 28, 2024 at 2:03:39 PM UTC-5 Filipe Sousa wrote:
>
>> Hi,
>>
>> Regarding switched expressions, is this supposed to work?
>>
>> public class Basic implements EntryPoint {
>>   @Override
>>   public void onModuleLoad() {
>>     getKind(Kind.A);
>>   }
>>
>>   private static String getKind(Kind kind) {
>>     return switch (kind) {
>>       case A -> "1";
>>       case B -> "2";
>>       case C -> "3";
>>       case D -> "4";
>>       case E -> "5";
>>       case F -> "6";
>>       case G -> "7";
>>       case H -> "8";
>>       case I -> "9";
>>       case J -> "10";
>>       case K -> "11";
>>       case L -> "12";
>>       case M -> "13";
>>       case N -> "14";
>>       case O -> "15";
>>      };
>>   }
>> }
>>
>> Because I'm getting an error that says:
>>
>> Compiling module it.pkg.Basic
>>    Compiling 2 permutations
>>       Compiling permutation 0...
>>       [ERROR] An internal compiler exception occurred
>> com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during 
>> visit.
>> at 
>> com.google.gwt.dev.jjs.ast.JVisitor.translateException(JVisitor.java:111)
>> at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:130)
>> at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:122)
>> at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
>> at 
>> com.google.gwt.dev.jjs.impl.CloneExpressionVisitor.cloneExpression(CloneExpressionVisitor.java:78)
>> at 
>> com.google.gwt.dev.jjs.impl.MethodInliner$InliningVisitor.extractExpressionsFromBody(MethodInliner.java:265)
>> at 
>> com.google.gwt.dev.jjs.impl.MethodInliner$InliningVisitor.tryInlineMethodCall(MethodInliner.java:147)
>> at 
>> com.google.gwt.dev.jjs.impl.MethodInliner$InliningVisitor.endVisit(MethodInliner.java:112)
>> at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:268)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
>> at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
>> at 
>> com.google.gwt.dev.jjs.ast.JExpressionStatement.traverse(JExpressionStatement.java:42)
>> at 
>> com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:88)
>> at 
>> com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:331)
>> at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:94)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
>> at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:139)
>> at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:135)
>> at com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:83)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
>> at com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:786)
>> at com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:778)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
>> at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
>> at 
>> com.google.gwt.dev.jjs.impl.FullOptimizerContext.traverse(FullOptimizerContext.java:224)
>> at 
>> com.google.gwt.dev.jjs.impl.MethodInliner.execImpl(MethodInliner.java:611)
>> at com.google.gwt.dev.jjs.impl.MethodInliner.exec(MethodInliner.java:588)
>> at 
>> com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.optimizeJavaOneTime(JavaToJavaScriptCompiler.java:1514)
>> at 
>> com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.optimizeJavaToFixedPoint(JavaToJavaScriptCompiler.java:1443)
>> at 
>> com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.optimizeJava(JavaToJavaScriptCompiler.java:525)
>> at 
>> com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:362)
>> at 
>> com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:274)
>> at com.google.gwt.dev.CompilePerms.compile(CompilePerms.java:198)
>> at 
>> com.google.gwt.dev.ThreadedPermutationWorkerFactory$ThreadedPermutationWorker.compile(ThreadedPermutationWorkerFactory.java:50)
>> at 
>> com.google.gwt.dev.PermutationWorkerFactory$Manager$WorkerThread.run(PermutationWorkerFactory.java:74)
>> at java.base/java.lang.Thread.run(Thread.java:840)
>> Caused by: java.lang.UnsupportedOperationException: switch expression 
>> cannot be cloned
>> at 
>> com.google.gwt.dev.jjs.impl.CloneExpressionVisitor.visit(CloneExpressionVisitor.java:261)
>> at 
>> com.google.gwt.dev.jjs.ast.JSwitchExpression.traverse(JSwitchExpression.java:50)
>> at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:127)
>> ... 40 more
>>          [ERROR] at Basic.java(12): switch (Enum.$ordinal(kind))  {
>>   case Enum.$ordinal(Kind.A): 
>>   yield  "1";
>>   case Enum.$ordinal(Kind.B): 
>>   yield  "2";
>>   case Enum.$ordinal(Kind.C): 
>>   yield  "3";
>>   case Enum.$ordinal(Kind.D): 
>>   yield  "4";
>>   case Enum.$ordinal(Kind.E): 
>>   yield  "5";
>>   case Enum.$ordinal(Kind.F): 
>>   yield  "6";
>>   case Enum.$ordinal(Kind.G): 
>>   yield  "7";
>>   case Enum.$ordinal(Kind.H): 
>>   yield  "8";
>>   case Enum.$ordinal(Kind.I): 
>>   yield  "9";
>>   case Enum.$ordinal(Kind.J): 
>>   yield  "10";
>>   case Enum.$ordinal(Kind.K): 
>>   yield  "11";
>>   case Enum.$ordinal(Kind.L): 
>>   yield  "12";
>>   case Enum.$ordinal(Kind.M): 
>>   yield  "13";
>>   case Enum.$ordinal(Kind.N): 
>>   yield  "14";
>>   case Enum.$ordinal(Kind.O): 
>>   yield  "15";
>> }
>>             com.google.gwt.dev.jjs.ast.JSwitchExpression
>>          [ERROR] at Basic.java(8): Basic.getKind(Kind.A)
>>             com.google.gwt.dev.jjs.ast.JMethodCall
>>          [ERROR] at Basic.java(8): Basic.getKind(Kind.A)
>>             com.google.gwt.dev.jjs.ast.JExpressionStatement
>>          [ERROR] at Basic.java(7): {
>>   Basic.getKind(Kind.A);
>> }
>>             com.google.gwt.dev.jjs.ast.JBlock
>>          [ERROR] at Basic.java(7): {
>>   Basic.getKind(Kind.A);
>> }
>>             com.google.gwt.dev.jjs.ast.JMethodBody
>>          [ERROR] at Basic.java(7): it.pkg.client.Basic.onModuleLoad()V
>>             com.google.gwt.dev.jjs.ast.JMethod
>>       [ERROR] Unrecoverable exception, shutting down
>> com.google.gwt.core.ext.UnableToCompleteException: (see previous log 
>> entries)
>> at 
>> com.google.gwt.dev.javac.CompilationProblemReporter.logAndTranslateException(CompilationProblemReporter.java:106)
>> at 
>> com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:461)
>> at 
>> com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:274)
>> at com.google.gwt.dev.CompilePerms.compile(CompilePerms.java:198)
>> at 
>> com.google.gwt.dev.ThreadedPermutationWorkerFactory$ThreadedPermutationWorker.compile(ThreadedPermutationWorkerFactory.java:50)
>> at 
>> com.google.gwt.dev.PermutationWorkerFactory$Manager$WorkerThread.run(PermutationWorkerFactory.java:74)
>> at java.base/java.lang.Thread.run(Thread.java:840)
>>       [ERROR] Not all permutation were compiled , completed (0/2)
>>
>> I'm using java 17 with gwt HEAD
>> On Saturday, September 28, 2024 at 2:19:15 PM UTC+1 Colin Alworth wrote:
>>
>>> We're down to two PRs left to merge, one deprecating unused code and 
>>> deleting already deprecated types, and one phasing out use of a browser 
>>> event that Chrome has removed. I'm leaving both up for another day and then 
>>> I'll land them and we should be on our way.
>>>
>>> This is the part of the release where we need some testers, running a 
>>> variety of operating systems, browsers, and Java versions. If you're 
>>> interested, please email me off-list with the various setups you can test, 
>>> and I'll make sure we have good coverage as we give the release a shakedown.
>>>
>>> Quick summary of the release:
>>>  * Java 8 is no longer supported for running tests, dev mode, or the 
>>> compiler, and while it should still work for RPC/RequestFactory server 
>>> components, it is untested in this release - if this is important to you, 
>>> please make sure you take a close look here.
>>>  * Java 17 language features are supported - records, switch 
>>> expressions, text blocks, sealed classes, pattern matching instanceof
>>>  * SDM can be restarted more easily without waiting for the 9876 port to 
>>> be freed up
>>>  * JRE improvements, Java 10 changes for Collections, BigInteger 
>>> constructors
>>>  * CSP improvements for RPC, linkers, SDM
>>>  * Sourcemap improvements, better cross browser support, ability to 
>>> generate a single map file rather than copy all sources as individual files
>>>
>>> Once we have a few volunteers covering Java 11-23, Windows/MacOS/Linux, 
>>> Edge/Chrome/Firefox, and the last two PRs are landed, I'll make a staging 
>>> release and share the details so we can all get started.
>>>
>>> Thanks in advance, and thanks for all of your help in getting to this 
>>> point!
>>>
>>> -Colin
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/740fb423-ceed-4a8f-ba41-31ff11a32d34n%40googlegroups.com.

Reply via email to