Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in jsinterop varargs causing internal compiler error #9932

Open
niloc132 opened this issue Feb 26, 2024 · 3 comments · May be fixed by #9957
Open

Regression in jsinterop varargs causing internal compiler error #9932

niloc132 opened this issue Feb 26, 2024 · 3 comments · May be fixed by #9957

Comments

@niloc132
Copy link
Contributor

niloc132 commented Feb 26, 2024

GWT version: HEAD-SNAPSHOT
Browser (with version): any
Operating System: linux


Description

It looks like the JDT update might have changed how we build JMethodCall instances, and broken some jsinterop vararg usages. I'm still working out exactly what is wrong, this ticket is a work in progress, but it looks like the JMethodCall now has multiple arguments where previously it had an array of arguments.

Steps to reproduce

The sample line of code is

DomGlobal.console.error("Request", req, " failed with reason ", reason);`

This should be compiled to (in GWT 2.11.0) something like

$wnd.goog.global.console.error('Request ',b,Mkc,d);

but in HEAD-SNAPSHOT we see an exception instead:

com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
        at com.google.gwt.dev.js.ast.JsVisitor.translateException(JsVisitor.java:482)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:469)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:115)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:115)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAcceptList(JsVisitor.java:450)
        at com.google.gwt.dev.js.ast.JsVisitor.acceptList(JsVisitor.java:113)
        at com.google.gwt.dev.js.ast.JsInvocation.traverse(JsInvocation.java:89)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsConditional.traverse(JsConditional.java:85)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsExprStmt.traverse(JsExprStmt.java:42)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAcceptWithInsertRemove(JsVisitor.java:461)
        at com.google.gwt.dev.js.ast.JsVisitor.acceptWithInsertRemove(JsVisitor.java:121)
        at com.google.gwt.dev.js.ast.JsBlock.traverse(JsBlock.java:53)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsFunction.traverse(JsFunction.java:181)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsExprStmt.traverse(JsExprStmt.java:42)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAcceptWithInsertRemove(JsVisitor.java:461)
        at com.google.gwt.dev.js.ast.JsVisitor.acceptWithInsertRemove(JsVisitor.java:121)
        at com.google.gwt.dev.js.ast.JsBlock.traverse(JsBlock.java:53)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsProgramFragment.traverse(JsProgramFragment.java:41)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsProgram.traverse(JsProgram.java:120)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.JsSymbolResolver.execImpl(JsSymbolResolver.java:69)
        at com.google.gwt.dev.js.JsSymbolResolver.exec(JsSymbolResolver.java:58)
        at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:391)
        at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:272)
        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:1583)
Caused by: java.lang.NullPointerException
        at com.google.gwt.thirdparty.guava.common.base.Preconditions.checkNotNull(Preconditions.java:212)
        at com.google.gwt.thirdparty.guava.common.collect.MapMakerInternalMap.putIfAbsent(MapMakerInternalMap.java:3521)
        at com.google.gwt.thirdparty.guava.common.collect.Interners$WeakInterner.intern(Interners.java:88)
        at com.google.gwt.dev.js.ast.JsNormalScope.doCreateName(JsNormalScope.java:49)
        at com.google.gwt.dev.js.ast.JsScope.declareName(JsScope.java:60)
        at com.google.gwt.dev.js.ast.JsScope.declareUnobfuscatableName(JsScope.java:91)
        at com.google.gwt.dev.js.JsSymbolResolver$JsResolveSymbolsVisitor.resolveQualifiedName(JsSymbolResolver.java:38)
        at com.google.gwt.dev.js.JsAbstractSymbolResolver.endVisit(JsAbstractSymbolResolver.java:52)
        at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:118)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        ... 54 more
         [ERROR] at Callbacks.java(64): <source info not available>
         [ERROR] at Callbacks.java(64): <source info not available>
         [ERROR] at Callbacks.java(64): <source info not available>
         [ERROR] at Callbacks.java(64): <source info not available>
         [ERROR] at Callbacks.java(61): <source info not available>
         [ERROR] at Callbacks.java(61): <source info not available>
         [ERROR] at Callbacks.java(42): <source info not available>
         [ERROR] at Callbacks.java(42): <source info not available>
         [ERROR] at Callbacks.java(42): <source info not available>
         [ERROR] at com.google.gwt.dev.js.ast.JsProgram(0): var _, prototypesByTypeId, initFnList, permutationId = -1;
function getPermutationId(){
  return permutationId;
}

function $$init(){
}

function setGwtProperty(propertyName, propertyValue){
  if (typeof window === 'object' && typeof window['$gwt'] === 'object') {
    window['$gwt'][propertyName] = propertyValue;
  }
}

[...]

         [ERROR] at com.google.gwt.dev.js.ast.JsProgram(0): <JsProgramFragment>
         [ERROR] at com.google.gwt.dev.js.ast.JsProgram(0): <JsProgram>
      [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:459)
        at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:272)
        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:1583)
      [ERROR] Not all permutation were compiled , completed (0/1)

That exception seems to come from the fact that the JsSafeCloner only considers the name property of a JsNameRef and not the ident

public void endVisit(JsNameRef x, JsContext ctx) {
if (x.getQualifier() == null && x.getIdent() == "arguments") {
// References to the arguments object can not be hoisted.
successful = false;
stack.push(null);
}
JsNameRef toReturn = new JsNameRef(x.getSourceInfo(), x.getName());
if (x.getQualifier() != null) {
toReturn.setQualifier(stack.pop());
}
stack.push(toReturn);
}

However, there are cases where name can be null, and ident then has the relevant information. Applying this fix gets around that stack trace:

-      JsNameRef toReturn = new JsNameRef(x.getSourceInfo(), x.getName());
+      final JsNameRef toReturn;
+      if (x.getName() == null) {
+        toReturn = new JsNameRef(x.getSourceInfo(), x.getIdent(), x.getQualifier());
+      } else {
+        toReturn = new JsNameRef(x.getSourceInfo(), x.getName());
+      }

This at least leads us to emit correct code:

$wnd.goog.global.console.error.apply($wnd.goog.global.console, ['Request ',b,Mkc].concat(d));

however, this is unnecessarily using the USING_APPLY_FOR_VARARGS_ARRAY call style - it appears that the first three vararg elements were detected as being earlier parameters (which do not exist), rather than just components of the vararg parameter. Seeming to confirm that, when debugging 2.11.0, lastArgument ends up being a JsArrayLiteral with all four arguments, so that DIRECT call style can be used entirely with non-vararg arguments.

JsExpression lastArgument = Iterables.getLast(args, null);
boolean needsVarargsApply =
method.isJsMethodVarargs() && !(lastArgument instanceof JsArrayLiteral);
List<JsExpression> nonVarargArguments = args;
JsExpression varargArgument = null;
if (method.isJsMethodVarargs()) {
nonVarargArguments = nonVarargArguments.subList(0, args.size() - 1);
if (!needsVarargsApply) {
nonVarargArguments.addAll(((JsArrayLiteral) lastArgument).getExpressions());
} else {
varargArgument = lastArgument;
callStyle = CallStyle.USING_APPLY_FOR_VARARGS_ARRAY;
}
}

Debugging this same code in HEAD-SNAPSHOT ends up with the first three args in nonVarargArguments, and lastArgument is a single local reference.

Both issues should be tested, fixed as part of this ticket.

@niloc132
Copy link
Contributor Author

Looks like I never added the original stack trace to the issue above, edited now.

Likely related stack trace, from building domino-ui-demo with HEAD-SNAPSHOT:

[INFO] com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.translateException(JsVisitor.java:482)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:469)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO] 	at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:115)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO] 	at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:115)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO] 	at com.google.gwt.dev.js.ast.JsBinaryOperation.traverse(JsBinaryOperation.java:87)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAcceptList(JsVisitor.java:450)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.acceptList(JsVisitor.java:113)
[INFO] 	at com.google.gwt.dev.js.ast.JsInvocation.traverse(JsInvocation.java:89)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO] 	at com.google.gwt.dev.js.ast.JsBinaryOperation.traverse(JsBinaryOperation.java:87)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO] 	at com.google.gwt.dev.js.ast.JsExprStmt.traverse(JsExprStmt.java:42)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAcceptWithInsertRemove(JsVisitor.java:461)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.acceptWithInsertRemove(JsVisitor.java:121)
[INFO] 	at com.google.gwt.dev.js.ast.JsBlock.traverse(JsBlock.java:53)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO] 	at com.google.gwt.dev.js.ast.JsFunction.traverse(JsFunction.java:181)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO] 	at com.google.gwt.dev.js.ast.JsExprStmt.traverse(JsExprStmt.java:42)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAcceptWithInsertRemove(JsVisitor.java:461)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.acceptWithInsertRemove(JsVisitor.java:121)
[INFO] 	at com.google.gwt.dev.js.ast.JsBlock.traverse(JsBlock.java:53)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO] 	at com.google.gwt.dev.js.ast.JsProgramFragment.traverse(JsProgramFragment.java:41)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO] 	at com.google.gwt.dev.js.ast.JsProgram.traverse(JsProgram.java:120)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO] 	at com.google.gwt.dev.js.JsSymbolResolver.execImpl(JsSymbolResolver.java:69)
[INFO] 	at com.google.gwt.dev.js.JsSymbolResolver.exec(JsSymbolResolver.java:58)
[INFO] 	at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:391)
[INFO] 	at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:272)
[INFO] 	at com.google.gwt.dev.CompilePerms.compile(CompilePerms.java:198)
[INFO] 	at com.google.gwt.dev.ThreadedPermutationWorkerFactory$ThreadedPermutationWorker.compile(ThreadedPermutationWorkerFactory.java:50)
[INFO] 	at com.google.gwt.dev.PermutationWorkerFactory$Manager$WorkerThread.run(PermutationWorkerFactory.java:74)
[INFO] 	at java.base/java.lang.Thread.run(Thread.java:1583)
[INFO] Caused by: java.lang.NullPointerException
[INFO] 	at com.google.gwt.thirdparty.guava.common.base.Preconditions.checkNotNull(Preconditions.java:212)
[INFO] 	at com.google.gwt.thirdparty.guava.common.collect.MapMakerInternalMap.putIfAbsent(MapMakerInternalMap.java:3521)
[INFO] 	at com.google.gwt.thirdparty.guava.common.collect.Interners$WeakInterner.intern(Interners.java:88)
[INFO] 	at com.google.gwt.dev.js.ast.JsNormalScope.doCreateName(JsNormalScope.java:49)
[INFO] 	at com.google.gwt.dev.js.ast.JsScope.declareName(JsScope.java:60)
[INFO] 	at com.google.gwt.dev.js.ast.JsScope.declareUnobfuscatableName(JsScope.java:91)
[INFO] 	at com.google.gwt.dev.js.JsSymbolResolver$JsResolveSymbolsVisitor.resolveQualifiedName(JsSymbolResolver.java:38)
[INFO] 	at com.google.gwt.dev.js.JsAbstractSymbolResolver.endVisit(JsAbstractSymbolResolver.java:52)
[INFO] 	at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:118)
[INFO] 	at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
[INFO] 	... 58 more
[INFO]          [ERROR] at ConsoleLoggerAdapter.java(157): <source info not available>
[INFO]             com.google.gwt.dev.js.ast.JsNameRef
[INFO]          [ERROR] at ConsoleLoggerAdapter.java(157): <source info not available>
[INFO]             com.google.gwt.dev.js.ast.JsNameRef
[INFO]          [ERROR] at ConsoleLoggerAdapter.java(157): <source info not available>
[INFO]             com.google.gwt.dev.js.ast.JsNameRef
[INFO]          [ERROR] at DomGlobal.java(417): <source info not available>
[INFO]             com.google.gwt.dev.js.ast.JsBinaryOperation
[INFO]          [ERROR] at ConsoleLoggerAdapter.java(157): <source info not available>
[INFO]             com.google.gwt.dev.js.ast.JsInvocation
[INFO]          [ERROR] at ConsoleLoggerAdapter.java(156): <source info not available>
[INFO]             com.google.gwt.dev.js.ast.JsBinaryOperation
[INFO]          [ERROR] at ConsoleLoggerAdapter.java(156): <source info not available>
[INFO]             com.google.gwt.dev.js.ast.JsExprStmt
[INFO]          [ERROR] at org_00046dominokit_00046domino_00046ui_00046demo_00046AppClientModule__EntryMethodHolder.java(3): {
[INFO]   scheduleUserAgentCheck();
[INFO]   $onModuleLoad();
[INFO]   $clinit_LogConfiguration();
[INFO]   $onModuleLoad();
[INFO]   [...]
[INFO] }
[INFO] 
[INFO]             com.google.gwt.dev.js.ast.JsBlock
[INFO]          [ERROR] at org_00046dominokit_00046domino_00046ui_00046demo_00046AppClientModule__EntryMethodHolder.java(3): function init(){
[INFO]   scheduleUserAgentCheck();
[INFO]   $onModuleLoad();
[INFO]   $clinit_LogConfiguration();
[INFO]   $onModuleLoad();
[INFO]   [...]
[INFO] }
[INFO] 
[INFO]             com.google.gwt.dev.js.ast.JsFunction
[INFO]          [ERROR] at org_00046dominokit_00046domino_00046ui_00046demo_00046AppClientModule__EntryMethodHolder.java(3): function init(){
[INFO]   scheduleUserAgentCheck();
[INFO]   $onModuleLoad();
[INFO]   $clinit_LogConfiguration();
[INFO]   $onModuleLoad();
[INFO]   [...]
[INFO] }
[INFO] 
[INFO]             com.google.gwt.dev.js.ast.JsExprStmt
[INFO]          [ERROR] at com.google.gwt.dev.js.ast.JsProgram(0): var _, prototypesByTypeId, initFnList, permutationId = -1;
[INFO] function getPermutationId(){
[INFO]   return permutationId;
[INFO] }
[INFO] 
[INFO] function create_com_google_gwt_useragent_client_UserAgent(){
[INFO]   if (permutationId == 0) {
[INFO]     return new UserAgentImplGecko1_8;
[INFO]   }
[INFO]   return new UserAgentImplSafari;
[INFO] }
[INFO] 
[INFO] function create_com_google_gwt_user_client_impl_WindowImpl(){
[INFO]   if (permutationId == 0) {
[INFO]     return new WindowImplMozilla;
[INFO]   }
[INFO]   return new WindowImpl;
[INFO] }
[INFO] 
[INFO] [...]
[INFO] 
[INFO]             com.google.gwt.dev.js.ast.JsGlobalBlock
[INFO]          [ERROR] at com.google.gwt.dev.js.ast.JsProgram(0): <JsProgramFragment>
[INFO]             com.google.gwt.dev.js.ast.JsProgramFragment
[INFO]          [ERROR] at com.google.gwt.dev.js.ast.JsProgram(0): <JsProgram>
[INFO]             com.google.gwt.dev.js.ast.JsProgram
[INFO]       [ERROR] Unrecoverable exception, shutting down
[INFO] com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
[INFO] 	at com.google.gwt.dev.javac.CompilationProblemReporter.logAndTranslateException(CompilationProblemReporter.java:106)
[INFO] 	at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:459)
[INFO] 	at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:272)
[INFO] 	at com.google.gwt.dev.CompilePerms.compile(CompilePerms.java:198)
[INFO] 	at com.google.gwt.dev.ThreadedPermutationWorkerFactory$ThreadedPermutationWorker.compile(ThreadedPermutationWorkerFactory.java:50)
[INFO] 	at com.google.gwt.dev.PermutationWorkerFactory$Manager$WorkerThread.run(PermutationWorkerFactory.java:74)
[INFO] 	at java.base/java.lang.Thread.run(Thread.java:1583)
[INFO]       [ERROR] Not all permutation were compiled , completed (0/1)

@niloc132
Copy link
Contributor Author

niloc132 commented Apr 29, 2024

(removed, the sample was tested using a newer GWT build than I thought)

@niloc132
Copy link
Contributor Author

For real this time... This test fails in GWT 2.9.0, with very nearly the same errors shown above for >2.11.

    public void testVarargsFromJavaToJsinterop() {
        nonNativeMethod("A", "B", "C");
    }

    @JsType(isNative = true, namespace = JsPackage.GLOBAL, name="Console")
    public static class Console {
        public native void log(Object... values);
    }

    @JsType(isNative = true, namespace = JsPackage.GLOBAL, name="window")
    public static class Global {
        public static Console console;
    }

    private static void nonNativeMethod(Object... values) {
        Global.console.log(values);
    }

Compile error:

com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
        at com.google.gwt.dev.js.ast.JsVisitor.translateException(JsVisitor.java:482)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:469)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:110)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:110)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAcceptList(JsVisitor.java:450)
        at com.google.gwt.dev.js.ast.JsVisitor.acceptList(JsVisitor.java:113)
        at com.google.gwt.dev.js.ast.JsInvocation.traverse(JsInvocation.java:89)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsExprStmt.traverse(JsExprStmt.java:42)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAcceptWithInsertRemove(JsVisitor.java:461)
        at com.google.gwt.dev.js.ast.JsVisitor.acceptWithInsertRemove(JsVisitor.java:121)
        at com.google.gwt.dev.js.ast.JsBlock.traverse(JsBlock.java:53)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsFunction.traverse(JsFunction.java:181)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsExprStmt.traverse(JsExprStmt.java:42)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAcceptWithInsertRemove(JsVisitor.java:461)
        at com.google.gwt.dev.js.ast.JsVisitor.acceptWithInsertRemove(JsVisitor.java:121)
        at com.google.gwt.dev.js.ast.JsBlock.traverse(JsBlock.java:53)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsProgramFragment.traverse(JsProgramFragment.java:41)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.ast.JsProgram.traverse(JsProgram.java:120)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
        at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
        at com.google.gwt.dev.js.JsSymbolResolver.execImpl(JsSymbolResolver.java:69)
        at com.google.gwt.dev.js.JsSymbolResolver.exec(JsSymbolResolver.java:58)
        at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:391)
        at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:272)
        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:1583)
Caused by: java.lang.NullPointerException
        at com.google.gwt.thirdparty.guava.common.base.Preconditions.checkNotNull(Preconditions.java:212)
        at com.google.gwt.thirdparty.guava.common.collect.MapMakerInternalMap.putIfAbsent(MapMakerInternalMap.java:3521)
        at com.google.gwt.thirdparty.guava.common.collect.Interners$WeakInterner.intern(Interners.java:88)
        at com.google.gwt.dev.js.ast.JsNormalScope.doCreateName(JsNormalScope.java:49)
        at com.google.gwt.dev.js.ast.JsScope.declareName(JsScope.java:60)
        at com.google.gwt.dev.js.ast.JsScope.declareUnobfuscatableName(JsScope.java:91)
        at com.google.gwt.dev.js.JsSymbolResolver$JsResolveSymbolsVisitor.resolveUnqualifiedName(JsSymbolResolver.java:51)
        at com.google.gwt.dev.js.JsAbstractSymbolResolver.endVisit(JsAbstractSymbolResolver.java:54)
        at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:113)
        at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
        ... 50 more
         [ERROR] at WorkerConnection.java(194): <source info not available>
            com.google.gwt.dev.js.ast.JsNameRef
         [ERROR] at WorkerConnection.java(194): <source info not available>
            com.google.gwt.dev.js.ast.JsNameRef
         [ERROR] at WorkerConnection.java(194): <source info not available>
            com.google.gwt.dev.js.ast.JsNameRef
         [ERROR] at WorkerConnection.java(194): <source info not available>
            com.google.gwt.dev.js.ast.JsInvocation
         [ERROR] at WorkerConnection.java(194): <source info not available>
            com.google.gwt.dev.js.ast.JsExprStmt
         [ERROR] at WorkerConnection.java(193): <source info not available>
            com.google.gwt.dev.js.ast.JsBlock
         [ERROR] at WorkerConnection.java(193): <source info not available>
            com.google.gwt.dev.js.ast.JsFunction
         [ERROR] at WorkerConnection.java(193): <source info not available>
            com.google.gwt.dev.js.ast.JsExprStmt
         [ERROR] at com.google.gwt.dev.js.ast.JsProgram(0): var _, prototypesByTypeId, initFnList, permutationId = -1;
function getPermutationId(){
  if (permutationId == -1) {
    debugger;
    throw toJs(new AssertionError('The bootstrap linker did not provide a soft permutation id to the gwtOnLoad function'));
  }
  return permutationId;
}

function $$init(){
}

function setGwtProperty(propertyName, propertyValue){
  if (typeof window === 'object' && typeof window['$gwt'] === 'object') {
    window['$gwt'][propertyName] = propertyValue;
  }
}

[...]

            com.google.gwt.dev.js.ast.JsGlobalBlock
         [ERROR] at com.google.gwt.dev.js.ast.JsProgram(0): <JsProgramFragment>
            com.google.gwt.dev.js.ast.JsProgramFragment
         [ERROR] at com.google.gwt.dev.js.ast.JsProgram(0): <JsProgram>
            com.google.gwt.dev.js.ast.JsProgram
      [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:459)
        at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:272)
        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:1583)
      [ERROR] Not all permutation were compiled , completed (0/1)

Something still has changed in latest GWT after the JDT upgrade that makes this bug easier to encounter, and should be explored to ensure that change isn't also a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant