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

JSInterop NullPointerException in Compilation #9346

Closed
BenDol opened this issue May 19, 2016 · 17 comments
Closed

JSInterop NullPointerException in Compilation #9346

BenDol opened this issue May 19, 2016 · 17 comments
Assignees

Comments

@BenDol
Copy link

BenDol commented May 19, 2016

I am getting this compilation error and I'm not sure why. Seems to happen when I have optimization set > 0. I realize that I am probably doing something wrong here, but I have little to no hint as to what the error is here. Perhaps if it is the case that I have implemented incorrectly that it tells me about the possible error.

Note that I did check the issue tracker to see if anyone else has had this issue, but wasn't able to find anything. My goal here is to help identify possible faults that could require feedback for developers to resolve quickly.

Sorry if this is something I have done wrong I appreciate the patience and assistance.

Using GWT 2.8.0-SNAPSHOT

[INFO] --- gwt-maven-plugin:2.8.0-SNAPSHOT:compile (default) @ gwt-material-table-sample ---
[INFO] Loading inherited module 'gwt.material.design.sample.GwtMaterialTableSample'
[INFO]    Loading inherited module 'gwt.material.design.GwtMaterialWithJQueryDebug'
[INFO]       Loading inherited module 'gwt.material.design.GwtMaterialDesignBase'
[INFO]          [WARN] Line 40: Setting configuration property named 'CssResource.legacy' in module 'gwt.material.design.GwtMaterialDesignBase' that has not been previously defined
[INFO] Compiling module gwt.material.design.sample.GwtMaterialTableSample
[INFO]    Compiling 1 permutation
[INFO]       Compiling permutation 0...
[INFO]       [ERROR] An internal compiler exception occurred
[INFO] com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.translateException(JVisitor.java:111)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:276)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
[INFO]  at com.google.gwt.dev.jjs.ast.JMethodCall.visitChildren(JMethodCall.java:264)
[INFO]  at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:257)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
[INFO]  at com.google.gwt.dev.jjs.ast.JBinaryOperation.traverse(JBinaryOperation.java:89)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
[INFO]  at com.google.gwt.dev.jjs.ast.JBinaryOperation.traverse(JBinaryOperation.java:87)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
[INFO]  at com.google.gwt.dev.jjs.ast.JBinaryOperation.traverse(JBinaryOperation.java:87)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:88)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:331)
[INFO]  at com.google.gwt.dev.jjs.ast.js.JMultiExpression.traverse(JMultiExpression.java:150)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
[INFO]  at com.google.gwt.dev.jjs.ast.JReturnStatement.traverse(JReturnStatement.java:40)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:88)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:331)
[INFO]  at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:92)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:139)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:135)
[INFO]  at com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:83)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO]  at com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:788)
[INFO]  at com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:780)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor$ListContextImmutable.traverse(JModVisitor.java:169)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemoveImmutable(JModVisitor.java:336)
[INFO]  at com.google.gwt.dev.jjs.ast.JClassType.traverse(JClassType.java:147)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO]  at com.google.gwt.dev.jjs.ast.JProgram.visitModuleTypes(JProgram.java:1284)
[INFO]  at com.google.gwt.dev.jjs.ast.JProgram.traverse(JProgram.java:1249)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
[INFO]  at com.google.gwt.dev.jjs.impl.ImplementCastsAndTypeChecks.execImpl(ImplementCastsAndTypeChecks.java:310)
[INFO]  at com.google.gwt.dev.jjs.impl.ImplementCastsAndTypeChecks.exec(ImplementCastsAndTypeChecks.java:277)
[INFO]  at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.normalizeSemantics(JavaToJavaScriptCompiler.java:506)
[INFO]  at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compilePermutation(JavaToJavaScriptCompiler.java:364)
[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.lang.Thread.run(Thread.java:745)
[INFO] Caused by: java.lang.NullPointerException
[INFO]  at com.google.gwt.dev.jjs.ast.js.JsniMethodRef.<init>(JsniMethodRef.java:37)
[INFO]  at com.google.gwt.dev.jjs.impl.ImplementCastsAndTypeChecks.implementCastOrInstanceOfOperation(ImplementCastsAndTypeChecks.java:269)
[INFO]  at com.google.gwt.dev.jjs.impl.ImplementCastsAndTypeChecks.access$400(ImplementCastsAndTypeChecks.java:49)
[INFO]  at com.google.gwt.dev.jjs.impl.ImplementCastsAndTypeChecks$ReplaceTypeChecksVisitor.endVisit(ImplementCastsAndTypeChecks.java:106)
[INFO]  at com.google.gwt.dev.jjs.ast.JCastOperation.traverse(JCastOperation.java:74)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
[INFO]  ... 60 more
[INFO]          [ERROR] at StandardTable.java(285): (MouseEvent) arg1
[INFO]             com.google.gwt.dev.jjs.ast.JCastOperation
[INFO]          [ERROR] at StandardTable.java(286): ((MouseEvent) arg1).getPageX()
[INFO]             com.google.gwt.dev.jjs.ast.JMethodCall
[INFO]          [ERROR] at StandardTable.java(286): "Row Long Pressed: " + Cast.castTo(arg2, /* JRuntimeTypeReference */"gwt.material.design.sample.shared.model.Person").id + ", x:" + ((MouseEvent) arg1).getPageX()
[INFO]             com.google.gwt.dev.jjs.ast.JBinaryOperation
[INFO]          [ERROR] at StandardTable.java(286): "Row Long Pressed: " + Cast.castTo(arg2, /* JRuntimeTypeReference */"gwt.material.design.sample.shared.model.Person").id + ", x:" + ((MouseEvent) arg1).getPageX() + ", y: "
[INFO]             com.google.gwt.dev.jjs.ast.JBinaryOperation
[INFO]          [ERROR] at StandardTable.java(286): "Row Long Pressed: " + Cast.castTo(arg2, /* JRuntimeTypeReference */"gwt.material.design.sample.shared.model.Person").id + ", x:" + ((MouseEvent) arg1).getPageX() + ", y: " + ((MouseEvent) arg1).getPageY()
[INFO]             com.google.gwt.dev.jjs.ast.JBinaryOperation
[INFO]          [ERROR] at StandardTable.java(285): (StandardTable.$clinit(), "Row Long Pressed: " + Cast.castTo(arg2, /* JRuntimeTypeReference */"gwt.material.design.sample.shared.model.Person").id + ", x:" + ((MouseEvent) arg1).getPageX() + ", y: " + ((MouseEvent) arg1).getPageY(), (Boolean.$clinit(), Boolean.createNative(true)))
[INFO]             com.google.gwt.dev.jjs.ast.js.JMultiExpression
[INFO]          [ERROR] at StandardTable.java(285): return (StandardTable.$clinit(), "Row Long Pressed: " + Cast.castTo(arg2, /* JRuntimeTypeReference */"gwt.material.design.sample.shared.model.Person").id + ", x:" + ((MouseEvent) arg1).getPageX() + ", y: " + ((MouseEvent) arg1).getPageY(), (Boolean.$clinit(), Boolean.createNative(true)))
[INFO]             com.google.gwt.dev.jjs.ast.JReturnStatement
[INFO]          [ERROR] at StandardTable.java(285): {
[INFO]   return (StandardTable.$clinit(), "Row Long Pressed: " + Cast.castTo(arg2, /* JRuntimeTypeReference */"gwt.material.design.sample.shared.model.Person").id + ", x:" + ((MouseEvent) arg1).getPageX() + ", y: " + ((MouseEvent) arg1).getPageY(), (Boolean.$clinit(), Boolean.createNative(true)));
[INFO] }
[INFO]             com.google.gwt.dev.jjs.ast.JBlock
[INFO]          [ERROR] at StandardTable.java(285): {
[INFO]   return (StandardTable.$clinit(), "Row Long Pressed: " + Cast.castTo(arg2, /* JRuntimeTypeReference */"gwt.material.design.sample.shared.model.Person").id + ", x:" + ((MouseEvent) arg1).getPageX() + ", y: " + ((MouseEvent) arg1).getPageY(), (Boolean.$clinit(), Boolean.createNative(true)));
[INFO] }
[INFO]             com.google.gwt.dev.jjs.ast.JMethodBody
[INFO]          [ERROR] at StandardTable.java(285): gwt.material.design.sample.client.ui.StandardTable$lambda$8$Type.call(Lcom/workingflows/js/jquery/client/api/Event;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
[INFO]             com.google.gwt.dev.jjs.ast.JMethod
[INFO]          [ERROR] at StandardTable.java(285): gwt.material.design.sample.client.ui.StandardTable$lambda$8$Type (final extends Object implements Functions$EventFunc3)
[INFO]             com.google.gwt.dev.jjs.ast.JClassType
[INFO]          [ERROR] at Unknown(0): <JProgram>
[INFO]             com.google.gwt.dev.jjs.ast.JProgram
[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.lang.Thread.run(Thread.java:745)
[INFO]       [ERROR] Not all permutation were compiled , completed (0/1)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Here is the code that caused it:

@JsType(isNative=true)
public class MouseEvent extends KeyEvent {
    @JsProperty public native int getPageX();
    @JsProperty public native int getPageY();
}

@JsType(isNative=true)
public class KeyEvent extends Event {
   // snip
}

@JsType(name = "jQuery", isNative=true)
public class Event {
   // snip
}
table.addRowContextMenuHandler((e, mouseEvent, model, row) -> {
    GWT.log("Row Context Menu: " + model.getId() + ", x:" + mouseEvent.getPageX() + ", y: " + mouseEvent.getPageY());
    return true;
});
@Override
public void addRowContextMenuHandler(EventFunc3<MouseEvent, T, Element> handler) {
    $this().on(TableEvents.ROW_CONTEXTMENU, handler);
}

Any ideas what is going on here? Thanks!

@gkdn
Copy link
Contributor

gkdn commented May 20, 2016

Seems like you are using the snapshot version?

@BenDol
Copy link
Author

BenDol commented May 20, 2016

Yeah sorry forgot to mention that.

@gkdn
Copy link
Contributor

gkdn commented May 20, 2016

This looks like a problem that is already fixed; you should use snapshot instead.
Please reopen if you can reproduce in snapshot.

@gkdn gkdn closed this as completed May 20, 2016
@BenDol
Copy link
Author

BenDol commented May 20, 2016

I am using snapshot is what my last comment mean't.

@gkdn gkdn reopened this May 20, 2016
@rluble
Copy link
Contributor

rluble commented May 20, 2016

Can you put together a minimal case? It looks that you already have
narrowed down the problem so just make a one .java file project that
reproduces the error and I will have a look.

On Thu, May 19, 2016 at 10:47 PM, Goktug Gokdogan notifications@github.com
wrote:

Assigned #9346 #9346 to @rluble
https://github.com/rluble.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#9346 (comment)

@BenDol
Copy link
Author

BenDol commented May 20, 2016

You can reproduce the issue here https://github.com/BenDol/jsinterop-issue
This is as minimal as I could make it for you, runs "out of the box"

@BenDol
Copy link
Author

BenDol commented May 20, 2016

You'll notice that if you comment out the addContextMenuHandler lines in JsInteropIssueEntry, it will compile fine.

@rluble
Copy link
Contributor

rluble commented May 20, 2016

There seems to be an error in the lambda. EventFunc1 takes only one
parameter and a 2 parameter lambda is passes in that slot in the
addContextMenuHandler.

Strange that there is not JDT (java) compilation error. I'll have a look
tomorrow.

On Thu, May 19, 2016 at 11:35 PM, Ben Dol notifications@github.com wrote:

You'll notice that if you comment out the addContextMenuHandler lines in
JsInteropIssueEntry, it will compile fine.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#9346 (comment)

@BenDol
Copy link
Author

BenDol commented May 20, 2016

If you look at EventFunc1 it takes 1 custom parameter but also handles the jquery event passed in every jquery event trigger.

    @FunctionalInterface
    @JsFunction
    interface EventFunc1<A> {
        Object call(Event e, A param1);
    }

@rluble
Copy link
Contributor

rluble commented May 20, 2016

I see. I was browsing https://github.com/workingflows/gwt-jquery.

On Fri, May 20, 2016 at 12:05 AM, Ben Dol notifications@github.com wrote:

If you look at EventFunc1 it takes 1 custom parameter but also handles the
jquery event passed in every jquery event trigger.

@FunctionalInterface
@JsFunction
interface EventFunc1<A> {
    Object call(Event e, A param1);
}


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#9346 (comment)

@BenDol
Copy link
Author

BenDol commented May 21, 2016

Am I correct in assuming the latest commit resolved this? I compiled with the latest snapshot successfully.

@rluble
Copy link
Contributor

rluble commented May 22, 2016

No. The last few commit were not addressing your issue specifically. I haven't have the time to reproduce your issue in my repo yet, but as AFAICT it is unrelated to the last few commits.

@BenDol
Copy link
Author

BenDol commented May 22, 2016

Yeah nevermind, I removed the case in my other project, you can still reproduce it in the repo I linked.

@rluble
Copy link
Contributor

rluble commented May 22, 2016

Could not reproduce with your example repo.

Reopen with a reproducible MINIMAL case that does not require maven and is completely self contained (one or very few classes and 1 gwt.xml file) and provide a command line invocation parameters.

@rluble rluble closed this as completed May 22, 2016
@rluble
Copy link
Contributor

rluble commented May 22, 2016

Got a repro case. Thanks.

@rluble rluble reopened this May 22, 2016
@rluble
Copy link
Contributor

rluble commented May 23, 2016

Preliminary review is at: https://gwt-review.googlesource.com/#/c/14941

@rluble
Copy link
Contributor

rluble commented May 25, 2016

Submitted.

@rluble rluble closed this as completed May 25, 2016
bauna pushed a commit to bauna/gwt that referenced this issue May 26, 2016
JsConstructors for native types provide support for cast and instanceof.
This patch makes native JsTypes and their constructors live if they are
referenced at all (but should not have any effect on codesize).

Bug: gwtproject#9346
Bug-Link: http://github.com/gwtproject/gwt/issues/9346
Change-Id: I6c1621e41705a0ff84a9fefe8c02d77440ca1936
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

No branches or pull requests

3 participants