-
Notifications
You must be signed in to change notification settings - Fork 382
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
java.lang.ClassCastException: class com.google.gwt.dev.jjs.ast.JPrimitiveType cannot be cast to class com.google.gwt.dev.jjs.ast.JArrayType #10086
Comments
Thanks for the report - this appears to say that the compiler encountered something like I've added some quick tests to the 2.12.0 tagged commit to verify that primitive arrays are handled as expected - though this isn't quite the exception that you're seeing. Instead, the JDT seems to be saying that Would you be able to build with a snapshot of 2.12.0 but with that PR landed, so we can see more specifically what is happening there? I can make a custom build that should log better information in the stack trace about what the code looked like that was being processed at the time. |
yes replacing with a snapshot to try should be doable I've some things like this in my code |
Thanks, I'll put together a build asap for you to try. That pattern should be well supported - I am also using it all over, with no problems on GWT 2.12.1. |
A snapshot build of GWT, based on 2.12.0, with the change from #10080 cherry-picked on it is now available at https://repo.vertispan.com/gwt-snapshot/ with version |
here is the exception with the snapshot build :
and the winner is that line :
|
of course using |
Thanks, I don't yet understand the issue, but I can reproduce it. Modifying the HelloWorld sample to this causes the bug to happen: public class Hello implements EntryPoint {
@Override
@SuppressWarnings("ReturnValueIgnored")
public void onModuleLoad() {
Stream.of("hello").map(PathInfo::new).toArray(PathInfo[]::new);
}
public class PathInfo {
public PathInfo(String value) {
}
}
} My first thought is that there is a name collision of some kind between the two method references, but replacing the line in the entrypoint with DoubleStream.of(1.0).mapToObj(Double::new).toArray(Double[]::new); doesn't cause the issue.
As a developer, writing code, yes, I agree. As a developer reviewing the size of your application... lambdas generate significantly more code than the two extra method call. Almost certainly not enough for you to care about it, but it is worth keeping in mind. |
well... if I had to search for particularities of PathInfo compared to Double, I would say that :
Then maybe the fact it's an inner class has something to do with this ? |
It looks like it might be specific to being a non- For some reason, the array constructor factory method is marked as belonging to the current method's enclosing type (e.g. Hello in the sample above) if the type is static (or top-level), but if non-static, there are a few oddities that arise, according to JDT (not yet in GWT itself):
So, there are at least two things about the AST that JDT is giving us that need to be worked out here - presumably this is a change in JDT, possibly a bug that a newer version will resolve for us. I'll test an older release, and also see if #10082 might resolve this. |
Ok, thank you |
GWT version:
2.12.0 + 2.12.1
Browser (with version):
any
Operating System:
windows 11 and Temurin Java 17
Description
[ERROR] Unexpected internal compiler error
java.lang.ClassCastException: class com.google.gwt.dev.jjs.ast.JPrimitiveType cannot be cast to class com.google.gwt.dev.jjs.ast.JArrayType (com.google.gwt.dev.jjs.ast.JPrimitiveType and com.google.gwt.dev.jjs.ast.JArrayType are in unnamed module of loader 'app')
at com.google.gwt.dev.jjs.impl.GwtAstBuilder$AstVisitor.visit(GwtAstBuilder.java:1215)
at org.eclipse.jdt.internal.compiler.ast.ReferenceExpression.traverse(ReferenceExpression.java:1111)
at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1173)
at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1173)
at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:154)
at org.eclipse.jdt.internal.compiler.ast.IfStatement.traverse(IfStatement.java:331)
at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:154)
at org.eclipse.jdt.internal.compiler.ast.IfStatement.traverse(IfStatement.java:333)
at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:154)
at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.traverse(LambdaExpression.java:795)
at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1173)
at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:154)
at org.eclipse.jdt.internal.compiler.ast.Initializer.traverse(Initializer.java:159)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1758)
at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:693)
at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1173)
at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.traverse(ConstructorDeclaration.java:708)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1699)
at com.google.gwt.dev.jjs.impl.GwtAstBuilder.processImpl(GwtAstBuilder.java:4122)
at com.google.gwt.dev.jjs.impl.GwtAstBuilder.process(GwtAstBuilder.java:4160)
at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater$UnitProcessorImpl.process(CompilationStateBuilder.java:128)
at com.google.gwt.dev.javac.JdtCompiler$CompilerImpl.process(JdtCompiler.java:322)
at org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:575)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:475)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
at com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:1021)
at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:322)
at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:532)
at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:464)
at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:426)
at com.google.gwt.dev.Precompile.validate(Precompile.java:145)
at com.google.gwt.dev.Compiler.compile(Compiler.java:184)
at com.google.gwt.dev.Compiler.compile(Compiler.java:143)
at com.google.gwt.dev.Compiler.compile(Compiler.java:132)
at com.google.gwt.dev.Compiler$1.run(Compiler.java:110)
at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55)
at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50)
at com.google.gwt.dev.Compiler.main(Compiler.java:113)
Steps to reproduce
Problem started with 2.12.0, no problem with 2.11.0
No idea on what could be wrong with 2.12.0, but there is many things like this in my code :
May this be related?
Known workarounds
switch back 2.11.0
Links to further discussions
The text was updated successfully, but these errors were encountered: