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

gwt-editor-processor fails when the Driver has to edit JavaScriptObject #22

Open
nchamouard opened this issue Jun 21, 2022 · 5 comments

Comments

@nchamouard
Copy link

nchamouard commented Jun 21, 2022

Simple example :


import com.google.gwt.core.client.JavaScriptObject;

public class Pojo extends JavaScriptObject {

    protected Pojo(){}

    public final native String getTest() /*-{ return this.test; }-*/;
    public final native void setTest(String value) /*-{ this.test = value; }-*/;
    
}
import org.dominokit.domino.ui.forms.TextBox;
import org.gwtproject.editor.client.Editor;
import org.gwtproject.editor.client.SimpleBeanEditorDriver;
import org.gwtproject.editor.client.annotation.IsDriver;


public class TestEditor implements  Editor<Pojo> {

    @IsDriver
    interface EditorDriver extends SimpleBeanEditorDriver<Pojo, TestEditor> {
    }

    TextBox test;
    
}

Here is the produced stacktrace :

Caused by: java.lang.ClassCastException: class com.sun.tools.javac.code.Type$TypeVar cannot be cast to class javax.lang.model.type.DeclaredType (com.sun.tools.javac.code.Type$TypeVar is in module jdk.compiler of loader 'app'; javax.lang.model.type.DeclaredType is in module java.compiler of loader 'platform')
at org.gwtproject.editor.processor.model.BeanMethod.deepCompare (BeanMethod.java:169)
at org.gwtproject.editor.processor.model.BeanMethod.isReturnTypeEnclosingElement (BeanMethod.java:162)
at org.gwtproject.editor.processor.model.BeanMethod.access$100 (BeanMethod.java:25)
at org.gwtproject.editor.processor.model.BeanMethod$3.matches (BeanMethod.java:82)
at org.gwtproject.editor.processor.model.BeanMethod.which (BeanMethod.java:114)
at org.gwtproject.editor.processor.model.EditorProperty$Builder.findBeanPropertyMethods (EditorProperty.java:176)
at org.gwtproject.editor.processor.model.EditorProperty$Builder.access (EditorProperty.java:149)
at org.gwtproject.editor.processor.model.EditorProperty$Builder.access (EditorProperty.java:60)
at org.gwtproject.editor.processor.model.EditorModel.calculateEditorData (EditorModel.java:115)
at org.gwtproject.editor.processor.model.EditorModel. (EditorModel.java:68)
at org.gwtproject.editor.processor.DriverProcessor.process (DriverProcessor.java:110)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor (JavacProcessingEnvironment.java:985)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs (JavacProcessingEnvironment.java:901)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run (JavacProcessingEnvironment.java:1227)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing (JavacProcessingEnvironment.java:1340)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations (JavaCompiler.java:1258)
at com.sun.tools.javac.main.JavaCompiler.compile (JavaCompiler.java:936)
at com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0 (JavacTaskImpl.java:104)
at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions (JavacTaskImpl.java:147)
at com.sun.tools.javac.api.JavacTaskImpl.doCall (JavacTaskImpl.java:100)
at com.sun.tools.javac.api.JavacTaskImpl.call (JavacTaskImpl.java:94)
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess (JavaxToolsCompiler.java:136)
at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile (JavacCompiler.java:182)
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1209)
at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:198)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

@FrankHossfeld
Copy link
Member

FrankHossfeld commented Jun 21, 2022

The exception is caused by a cast-method from the JavaScriptObject-class:

  /**
   * A helper method to enable cross-casting from any {@link JavaScriptObject}
   * type to any other {@link JavaScriptObject} type.
   *
   * @param <T> the target type
   * @return this object as a different type
   */
  @SuppressWarnings("unchecked")
  public final <T extends JavaScriptObject> T cast() {
    return (T) this;
  }

The error occurs inside the class BeanMethod during a deepCompare.

I think a simple check using instanceOf should solve the problem.

@nchamouard
Copy link
Author

nchamouard commented Aug 1, 2022

Hello,

As the problem lies in the JavaScriptObject file, I suppose that a fix would need to be in the main gwt package ?
And therefore i cannot expect to see a solution any time soon ?
The alternative for me is to get rid of the JavaScriptObjects, which is feasible (and probably a good thing to do) but would mess with our own schedule :)
Any timing info you could give me would greatly help us to organise ourselves.

Thank you in advance !

@FrankHossfeld
Copy link
Member

@nchamouard ATM I am not on my computer. IIRC I had a solution, which needs more testing. I'll came back to you later.

@nchamouard
Copy link
Author

We ended replacing all JavaScriptObject and JSNI of our project with JsType(isNative=true)
It took a lot less time than I thought it would
The issue is not a very big problem for us now :)

@FrankHossfeld
Copy link
Member

Thanks for the update. I had no time to test. I'll put it on top of the To-Do list.

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