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

I get an AST compiler error when trying to use gwt-beans-validator (which includes gwt-time 2.0.10) with GWT 2.10.0 #14

Closed
dnouls opened this issue Mar 10, 2023 · 3 comments

Comments

@dnouls
Copy link

dnouls commented Mar 10, 2023

I have a large project where I am trying to migrate to GWT 2.10.0. We are depending on gwt-beans-validator, which is now depending on gwt-time 2.0.10.

For some reason I cannot even compile a simple utility library and run the GWTTestCases there.
When trying to run the GWTTestCase I get the following compiler exception:

[ERROR] Compiler aborted with an exception 
com.google.gwt.dev.jjs.InternalCompilerException: Error constructing Java AST
	at com.google.gwt.dev.jjs.impl.GwtAstBuilder.translateException(GwtAstBuilder.java:4033)
	at com.google.gwt.dev.jjs.impl.GwtAstBuilder$AstVisitor.endVisit(GwtAstBuilder.java:647)
	at org.eclipse.jdt.internal.compiler.ast.ConditionalExpression.traverse(ConditionalExpression.java:827)
	at org.eclipse.jdt.internal.compiler.ast.BinaryExpression.traverse(BinaryExpression.java:1920)
	at org.eclipse.jdt.internal.compiler.ast.BinaryExpression.traverse(BinaryExpression.java:1919)
	at org.eclipse.jdt.internal.compiler.ast.BinaryExpression.traverse(BinaryExpression.java:1919)
	at org.eclipse.jdt.internal.compiler.ast.BinaryExpression.traverse(BinaryExpression.java:1919)
	at org.eclipse.jdt.internal.compiler.ast.CombinedBinaryExpression.traverse(CombinedBinaryExpression.java:370)
	at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse(ReturnStatement.java:402)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:365)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1560)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1432)
	at com.google.gwt.dev.jjs.impl.GwtAstBuilder.processImpl(GwtAstBuilder.java:3969)
	at com.google.gwt.dev.jjs.impl.GwtAstBuilder.process(GwtAstBuilder.java:4007)
	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:1020)
	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:423)
	at com.google.gwt.dev.Precompile.precompile(Precompile.java:210)
	at com.google.gwt.dev.Precompile.precompile(Precompile.java:190)
	at com.google.gwt.dev.Precompile.precompile(Precompile.java:131)
	at com.google.gwt.dev.Compiler.compile(Compiler.java:192)
	at com.google.gwt.dev.Compiler.compile(Compiler.java:143)
	at com.google.gwt.junit.JUnitShell.compileForWebMode(JUnitShell.java:1093)
	at com.google.gwt.junit.JUnitShell.maybeCompileForWebMode(JUnitShell.java:1158)
	at com.google.gwt.junit.CompileStrategy.maybeCompileModuleImpl2(CompileStrategy.java:183)
	at com.google.gwt.junit.CompileStrategy.maybeCompileModuleImpl(CompileStrategy.java:113)
	at com.google.gwt.junit.SimpleCompileStrategy.maybeCompileModule(SimpleCompileStrategy.java:36)
	at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1349)
	at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1317)
	at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:681)
	at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:421)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:247)
	at junit.framework.TestSuite.runTest(TestSuite.java:252)
	at junit.framework.TestSuite.run(TestSuite.java:247)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.AssertionError
	at com.google.gwt.dev.javac.JdtUtil.signature(JdtUtil.java:369)
	at com.google.gwt.dev.jjs.impl.ReferenceMapper.get(ReferenceMapper.java:121)
	at com.google.gwt.dev.jjs.impl.GwtAstBuilder$AstVisitor.endVisit(GwtAstBuilder.java:641)
	... 60 more

When I run the debugger and put a breakpoint when this exception happens, I see that it is seems to be related to compiling DateTimeFormatterBuilder$LocalizedPrinterParser::toString

Is this a known issue ?

--- Class Scope ---
Member type : LocalizedPrinterParser (id=NoId)
static final class java.time.format.DateTimeFormatterBuilder$LocalizedPrinterParser
	extends java.lang.Object
	implements : java.time.format.DateTimeFormatterBuilder.DateTimePrinterParser
	enclosing type : java.time.format.DateTimeFormatterBuilder
/*   fields   */
private final java.time.format.FormatStyle dateStyle
private final java.time.format.FormatStyle timeStyle
/*   methods   */
void <init>(java.time.format.FormatStyle, java.time.format.FormatStyle) 
private java.time.format.DateTimeFormatter formatter(java.util.Locale, java.time.chrono.Chronology) 
public int parse(java.time.format.DateTimeParseContext, java.lang.CharSequence, int) 
public boolean print(java.time.format.DateTimePrintContext, java.lang.StringBuilder) 
public java.lang.String toString()
@dnouls
Copy link
Author

dnouls commented Mar 14, 2023

It turns out that there is a problem with assertions in GWT 2.9/2.10 due to changes in JDT.
There will be a fix when the patch gets merged and a newer GWT is released.

@dnouls
Copy link
Author

dnouls commented Mar 17, 2023

In the meantime it would be smart to refrain from using that ternary operation in the DateTimeFormatterBuilder@LocalizedPrinterParser::toString method.
It seems that you were already aware of this AST error problem some time ago since I saw you linked to this bug with a previous commit: gwtproject/gwt#9694

@foal
Copy link
Owner

foal commented Dec 24, 2023

Yes, I am already aware of this issue. Unfortunately, it is not a single place in the code that affected by this issue. So, for existing versions of GWT (2.9.0/2.10.0) I suggest to use the workaround - disable JVM asserts as it suggested in gwtproject/gwt#9694.

I will update the readme to mentioned that.

foal added a commit that referenced this issue Dec 24, 2023
@foal foal closed this as completed Dec 24, 2023
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

2 participants