gwtproject / gwt

GWT Open Source Project

Home Page:http://www.gwtproject.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JDK 17 and GIN

dgeiselmanMOO opened this issue · comments

GWT version: 2.11.0
Browser (with version): Chrome
Operating System: Windows 10


Description

Trying to build a project that is being upgraded from 2.9.0 to 2.11.0 and JDK 17 so I can update some dependencies with vulnerabilities. I'm running into a problem with gin I believe which is 2.1.2.

bind(PlaceController.class).toProvider(PlaceControllerProvider.class).in(Singleton.class);

error: cannot access Provider
bind(PlaceController.class).toProvider(PlaceControllerProvider.class).in(Singleton.class);
^
class file for javax.inject.Provider not found

Steps to reproduce

Using these versions
gwt 2.11.0
JDK 17
com.google.gwt.inject:gin:2.1.2
com.google.inject:guice:7.0.0
com.google.inject.extensions:guice-assistedinject:7.0.0
com.google.inject.extensions:guice-servlet:7.0.0

Trying to do bind to a provider in Singleton Class

Guice 7 moved to jakarta.inject, you need to use Guice 6 or earlier with GIN to stay on javax.inject.

https://github.com/google/guice/wiki/Guice700#jee-jakarta-transition

I am using Guice 7 as noted in my steps to reproduce

…which is the problem. Downgrade to Guice 6 and it should work 🤞

Shouldn't I be using Jakarta since I'm upgrading to JDK 17?

The problem is that Gin doesn't support Jakarta, and is unmaintained, so will likely not get a new update. Someone at Google would need to initiate this, or at least support it.

There is no requirement to stop using javax packages and switch to jakarta when using Java 17.

That solved that, now
filterRegex(FILTER_STRING).through(AuthFilter.class); is giving

C:\SVNWorkspace\life-uiSpring\src\main\java\com\mutualofomaha\nbs\ui\utils\AppServletModule.java:63: error: no suitable method found for through(Class)
filterRegex(FILTER_STRING).through(AuthFilter.class);
^
method FilterKeyBindingBuilder.through(Class<? extends Filter>) is not applicable
(argument mismatch; Class cannot be converted to Class<? extends Filter>)
method FilterKeyBindingBuilder.through(Key<? extends Filter>) is not applicable
(argument mismatch; Class cannot be converted to Key<? extends Filter>)
method FilterKeyBindingBuilder.through(Filter) is not applicable
(argument mismatch; Class cannot be converted to Filter)

Is there a library I missed?

Actually, I think that is due to more jakarta's that need to change

I am now running into this

Computing all possible rebind results for 'com.mutualofomaha.nbs.ui.client.AppGinjector'
Rebinding com.mutualofomaha.nbs.ui.client.AppGinjector
Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
[WARN] Class jdk.internal.reflect.ConstructorAccessorImpl is used in Gin, but not available in GWT client code.
[ERROR] Errors in 'com/google/gwt/user/client/DOM.java'
[ERROR] Line 65: Rebind result 'com.google.gwt.user.client.impl.DOMImpl' cannot be abstract
[ERROR] Errors in 'com/google/gwt/dom/client/DOMImpl.java'
[ERROR] Line 23: Rebind result 'com.google.gwt.dom.client.DOMImpl' cannot be abstract

Their are libraries from google.gwt listed
import com.google.gwt.core.shared.GWT;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.inject.client.GinModules;
import com.google.gwt.inject.client.Ginjector;
import com.google.gwt.place.shared.PlaceController;

Also seeing this error after a lot of warnings about a private that will not be serialized because it is final

[ERROR] Errors in 'com/google/gwt/user/cellview/client/CellBasedWidgetImpl.java'
[ERROR] Line 50: Rebind result 'com.google.gwt.user.cellview.client.CellBasedWidgetImpl' cannot be abstract
[ERROR] Error saving compilation unit to cache file: C:\SVNWorkspace\life-uiSpring\build\gwt\cache\gwt-unitCache\gwt-unitCache-9832889f3ba33ea6127df852fe9b558bb4d30c80-C90BB3B791D3293DB8D5BA1AB0A974D4-0000018E99C16293
java.io.IOException: Stream Closed
at java.base/java.io.RandomAccessFile.read0(Native Method)
at java.base/java.io.RandomAccessFile.read(RandomAccessFile.java:365)
at java.base/java.io.RandomAccessFile.readInt(RandomAccessFile.java:838)
at com.google.gwt.dev.util.DiskCache.transferToStream(DiskCache.java:162)
at com.google.gwt.dev.util.DiskCacheToken.writeObject(DiskCacheToken.java:73)
at jdk.internal.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1201)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1526)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1448)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1191)
at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1582)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1539)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1448)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1191)
at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:354)
at java.base/java.util.ArrayList.writeObject(ArrayList.java:866)
at java.base/jdk.internal.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1201)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1526)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1448)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1191)
at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:354)
at com.google.gwt.dev.javac.CachedCompilationUnit.writeObject(CachedCompilationUnit.java:231)
at jdk.internal.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1201)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1526)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1448)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1191)
at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:354)
at com.google.gwt.dev.javac.PersistentUnitCacheDir$OpenFile.writeUnit(PersistentUnitCacheDir.java:373)
at com.google.gwt.dev.javac.PersistentUnitCacheDir.writeUnit(PersistentUnitCacheDir.java:194)
at com.google.gwt.dev.javac.PersistentUnitCache$BackgroundService$4.run(PersistentUnitCache.java:413)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)

Are any of these causing my issues?

@dgeiselmanMOO It is not clear to me what your current goal is? Do you simply want to upgrade to JDK 17 or are you also trying to move everything to Jakarta? Also is your GWT client code in the same project as your server side code?

The above errors you are seeing usually mean that calls to GWT.create(<some interface or abstract class>) failed. Either because there was no generator / rebind rule defined in a *.gwt.xml file or the generator threw an exception. Usually the log shows the root cause.

Generally you are not required to use Jakarta just to use Java 17. However more and more libraries/projects will use Jakarta in the future. Because you are using GIN, which only supports javax.inject, it would be wise to split your project into a GWT/UI project and a server project. Then both projects can evolve independently and the GWT/UI project can use GIN 2.1.2 + Guice 6.0.0 with javax.inject while the server might use Guice 7 and Jakarta.

Right now the goal is to figure out where the errors are occuring so I can fix them. I'm past the Javax/Jakarta issue and the errors I'm getting with the DOMImpl and CellBasedWidgetImpl are both in strict and when I compile without strict. I'll check for the GWT.create are there any others I need to hunt for?

[ERROR] Errors in 'com/google/gwt/user/client/DOM.java'
[ERROR] Line 65: Rebind result 'com.google.gwt.user.client.impl.DOMImpl' cannot be abstract
[ERROR] Errors in 'com/google/gwt/dom/client/DOMImpl.java'
[ERROR] Line 23: Rebind result 'com.google.gwt.dom.client.DOMImpl' cannot be abstract

This error for example is pure GWT internal. Basically DOM internally calls GWT.create(DOMImpl.classs) because some browsers behave differently with regard to DOM operations GWT uses. I think the root cause might be that your project uses user.agent values that GWT does not support anymore. The only valid values right now are safari (Safari / Chrome based browsers) and gecko1_8 (Firefox / IE 11).

So you should check:

  • in your 3rd party GWT libraries check if they are nasty and provide their own com.google.gwt....DOM/DOMImpl implementation to override the one provided by GWT. That is almost always bad.
  • Check if your app and 3rd party libraries use a user.agent property that is not supported anymore by GWT SDK. GWT 2.10 dropped support for ie8, ie9, ie10 values for user.agent.

Ok, so

<extend-property name="user.agent" values="ie8" />
<extend-property name="user.agent" values="gecko1_8" />
<extend-property name="user.agent" values="safari" />
<extend-property name="user.agent" values="ie9" fallback-value="ie8" />

Should only have Safari and Chrome and get rid of ie and gecko?

No, search for ie8, ie9, ie10 in your *.gwt.xml files and the ones of your 3rd party dependencies.

All I have now is safari, do I need gecko1_8?

If your application should support FireFox and IE 11 then you also need gecko1_8.

Ok, that took care of my issues. Thank you for the help