gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.51k stars 372 forks source link

Passing empty array to array valued annotation causes application crash on startup in development mode. #7511

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 7514

(If this is your first time submitting an issue report to the GWT Issue
Tracker, please see the sample issue report linked below for an example of
a well reported issue)
Sample issue report:
http://code.google.com/p/google-web-toolkit/wiki/IssueReportSample

Found in GWT Release (e.g. 2.4.0, 2.5.0 RC):
2.4.0 (com.google.gwt.eclipse.sdkbundle_2.4.0.v201206290133-rel-r36)

Encountered on OS / Browser (e.g. WinXP, IE8-9, FF7):

Detailed description (please be as specific as possible):
Passing empty array to array valued annotation causes application crash while initializing
module in development mode.

Shortest code snippet which demonstrates issue (please indicate where
actual result differs from expected result):
interface A{
    @SuppressWarnings({ })
    void a();
}

Workaround if you have one:
I've just removed this unnecessary annotation.

Stacktrace:

03:32:16.699 [ERROR] [accounts] Exception initializing module

java.lang.NullPointerException: null
    at com.google.gwt.dev.javac.JsniChecker.getSuppressedWarnings(JsniChecker.java:577)
    at com.google.gwt.dev.javac.JsniChecker$JsniDeclChecker.visit(JsniChecker.java:122)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:209)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1350)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1223)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:687)
    at com.google.gwt.dev.javac.JsniChecker.check(JsniChecker.java:615)
    at com.google.gwt.dev.javac.JsniChecker.check(JsniChecker.java:559)
    at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater$UnitProcessorImpl.process(CompilationStateBuilder.java:83)
    at com.google.gwt.dev.javac.JdtCompiler$CompilerImpl.process(JdtCompiler.java:247)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
    at com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:701)
    at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:235)
    at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:447)
    at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:370)
    at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:360)
    at com.google.gwt.dev.DevModeBase$UiBrowserWidgetHostImpl.createModuleSpaceHost(DevModeBase.java:110)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:197)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Unknown Source)

[ERROR] [accounts] - Failed to load module 'accounts' from user agent 'Mozilla/5.0
(Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'
at auth.ksi.ii.uj.edu.pl:55330
...

Reported by NiematojakTomasz on 2012-07-13 01:39:02

dankurka commented 9 years ago
Submitted too fast.
Missing details:
Encountered on OS / Browser:
Windows 7 Professional 64bit, Chrome 19.0.1084.56 m

Probably one more "if" in 
at com.google.gwt.dev.javac.JsniChecker.getSuppressedWarnings(JsniChecker.java:577)
or somewhere else to prevent null value would solve the problem.

Ant to be clear:
Annotations like "@SuppressWarnings("rawtypes")", "@SuppressWarnings({ "unchecked",
"rawtypes" })" works  fine.

Reported by NiematojakTomasz on 2012-07-13 01:49:03

dankurka commented 9 years ago
Looking at the code of ArrayInitializer, clearly the 'expressions' field can be 'null'
(and not only technically, they do null checks everywhere, treating a null just like
an empty array), so JsniChecker should account for it (and exit early with an empty
Set).

Reported by t.broyer on 2012-07-13 08:26:54

dankurka commented 9 years ago
@rlubble seems like an easy win, wanna look into it?

Reported by dankurka@google.com on 2013-05-28 03:14:50

dankurka commented 9 years ago
Not exactly the same issue but they have the same cause.

Reported by rluble@google.com on 2013-05-28 19:14:43