Annotation for GWT compiler to ignore method - java

Is it possible to create an annotation (or some other way) to force the GWT compiler to not compile a method? I have a class that I also use on app-engine (in a shared folder) and one method in it requires a server side only function which causes GWT to not compile. I would like GWT to just ignore the method (while appengine does not).
I figured either an annotation, or a pre-compile script that erases the method prior to compilation. Both methods would work for me, it would be best if I could still compile through the eclipse IDE.
Anyone else thought of this or tried it?

Not until now. Very recently such annotation was added #com.google.gwt.core.shared.GwtIncompatible("Description why..."). It is applicable on classes or methods.
But the patched code was not released yet! Official status is FixedNotReleased. And i can personally confirm, it is not in current GWT 2.5.1 version. I am hopeful for upcoming 2.5.2.
See:
http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/core/shared/GwtIncompatible.java?spec=svn11570&r=11570
http://code.google.com/p/google-web-toolkit/issues/detail?id=3769
https://gwt-review.googlesource.com/#/c/2320/
Note, there is already similar annotation com.google.gwt.thirdparty.guava.common.annotations.GwtIncompatible in gwt-dev.jar, however
it does not work, compiler still wants to compile my incompatible method in shared class.

Prior to GWT version 2.6, there is no annotation to make the GWT compiler ignore a method. There is a requests for it in the GWT issue tracker, and apparently it is scheduled for the 2.6 release.
One workaround approach is to have the "offending" method in a class of its own and ignore that class in your .gwt.xml file:
<source path="gwtclient">
<exclude name="AppEngineOnlyClass.java" />
...
</source>
...
Hope that helps a bit.
Cheers,

Related

gwt-dev - Librairies with same package name

This is my first post on stackoverflow, please be indulgent.
Within my project, I use the library commons-digester-1.8.
Following a need, I now use the library gwt-dev-2.3.0.
When launching the application I get this error :
Exception caught while initializing context java.lang.NoSuchMethodError: org/apache/commons/digester/xmlrules/DigesterLoader.createDigester(Lorg/xml/sax/InputSource;)Lorg/apache/commons/digester/Digester;
at fr.cnasea.commons.webfwk.util.config.lecture.XMLDigesterReader.getConfig(XMLDigesterReader.java:157)
at fr.cnasea.commons.webfwk.util.config.CnaseaAppConfigurator.configure(CnaseaAppConfigurator.java:76)
at fr.cnasea.osiris.commons.gwt.server.Config.contextInitialized(Config.java:47)
It turns out that the two libraries have the same class in the same package with the same method:
Same class
Since the use of gwt-dev, it is the method of this library which is called.
I tried to use newer versions of gwt-dev but the environment makes it not possible
How can I fix it?
Thanks for your help :)
(From my answer to your same question on the github project)
The gwt-dev.jar should not be on your server classpath - it is only used to compile your application. The same is true for gwt-user.jar. Only gwt-servlet.jar (and possibly requestfactory-server.jar) should end up on your server classpath, the others are intended only to be present when compiling, either to do the work of compiling, or to provide the compiler the classes you need.

PreparedStatement with list of parameters in a IN [duplicate]

What are the possible causes for ABstractMethodError?
Exception in thread "pool-1-thread-1" java.lang.AbstractMethodError:
org.apache.thrift.ProcessFunction.isOneway()Z
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:51)
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
at com.gemfire.gemstone.thrift.hbase.ThreadPoolServer$ClientConnnection.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
It usually means that you are using an old version of an interface implementation which is missing a new interface method. For example java.sql.Connection interface got a new getSchema method in 1.7. If you have 1.6 JDBC driver and call Connection.getSchema you will get AbstractMethodError.
The simple answer is this: some code is trying to call a method which is declared abstract. Abstract methods have no body and cannot be executed. Since you have provided so little information I can't really elaborate more on how this can happen since the compiler usually catches this problem - as described here, this means the class must have changed at runtime.
From documnentation of AbstractMethodError
Thrown when an application tries to call an abstract method. Normally,
this error is caught by the compiler; this error can only occur at run
time if the definition of some class has incompatibly changed since
the currently executing method was last compiled.
A kind of special case of the above answer.
I had this error, because I was using a spring-boot-starter-parent (e.g. 2.1.0.RELEASE uses spring version: 5.1.2.RELEASE) but I also included a BOM, that also defined some spring dependencies, but in an older version (e.g. 5.0.9.RELEASE).
So one thing to do, is check your dependency tree (in Eclipse e.g. you can use the Dependency Hierarchy) if you are using the same versions.
So one solution could be that you upgrade the spring dependencies in your BOM, another one could be that you exclude them (but depending on the amount, this could be ugly).
If you download any project zip file, after unzipping them and importing into Android Studio, you are unable to run the project because this error happened.
I got out of the problem by deleting my android studio, then download and install the new version.
I truly hope it help.
If you you are getting this error on the implemented methods, make sure you have added your dependencies correctly as mentioned in this thread.
As Damian quoted :
Normally, this error is caught by the compiler; this error can only
occur at run time if [...]
I had the same error that was not caught by the compiler but at runtime. To solve it I only compiled again without giving the code any modification.
if you are getting this error on a minified build using Proguard then check if the class is a POJO class and if so then exclude it from the Proguard using the below rule:
-keep class your.application.package.pojo.** {*;}
I had the same error when I imported an eclipse project into intellij ide.. I tried to import it without .iml file then my problem was solved
I get this problem when I update my kotlin plugin to a new version .... the problem is that my pom file is using the older kotlin version .. I guess it might help someone if he is doing this mistake
I am getting various of these and others infrequently on android.. I have to clean everything change som configuration rebuild change configuration again to normal somehow just the build tools don't rebuild everything they should for whatever reason (Android gradle bug obviously).

warning: No processor claimed any of these annotations: javax.annotation.Generated

I'm working on a module project in NetBeans 8.2, with a GUI and everything. I'm using lots of the IDE functionality to auto-generate code for the GUI.
Every time I do a clean build of my project, I get a warning from the compiler:
warning: No processor claimed any of these annotations:javax.annotation.Generated
Browsing the build directory, I see that the IDE generates a class for me, Bundle.java, and it slaps the given annotation on top of it:
#javax.annotation.Generated(value="org.netbeans.modules.openide.util.NbBundleProcessor")
I need this warning to go away. I tried searching the web for an annotation processor that processes this specific annotation but I had no luck. Does an annotation processor for this specific annotation exist?
If this is a "harmless warning," I need to understand why it is harmless to justify its existence in my build output.
If needed I can include in this question the argument to the -processorpath option that is passed to javac from the IDE; I didn't include it on purpose because it is very long but I can add it if necessary
EDIT #1:
I did a "hacky" modification to the common.xml file under the NetBeans installation directory to make the invocation to javac not include the -processorpath option, and doing so makes the warning dissapear. I still do not understand why that is the case
A simple fix for this is to remove the #Messages annotation from the TopComponent class that is generated by the NetBeans code generator. It is that annotation that is responsible for generating the Bundle class, as per the NbBundle.Messages API Documentation.
As soon as you remove that annotation, you might get warnings from other annotations that rely on the contents of the #Messages annotation (i.e. TopComponent.OpenActionRegistration), so make sure to modify the contents of those annotation as well until nothing in your code depends on that Bundle anymore.
Hopefully nothing else in your code relies on your Bundle.

Codename One: Annotation Processing

I have a Codename One project on Netbeans using their plugin.
Is there a way to make it work? I enabled it in project's settings and still doesn't show in final jar.
The annotations are in the libraries of the project. and I can see it being done in the output:
warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.ServiceProviderProcessor' less than -source '1.8'
I used instructions here: https://netbeans.org/kb/docs/java/annotations-lombok.html
Update:
I thought it was clear but seems it's not. All this is using Netbean's Lookup. Let's say I have one jar as project dependency with one interface in it, let's say ITest. Also a class implementing the interface, for example:
#ServiceProvider(service=ITest.class)
public class Test implements ITest{
..
}
So in the Codenamone Project I call it like this:
Lookup.getDefault().lookupAll(ITest.class);
But it come up empty. I know the system works as it does in other projects, just porting it to Codename one. Seems like it is not seeing the annotations in the dependencies.
I don't know if that will work and I'm pretty curious about it myself. Make sure you created a Java 8 version of the project and you are running on top of Java 8 to get started.
In the past things like this were done using bytecode manipulation e.g. see this code from the work done by Steve.

Getting Guava to work on GWT

I can't get Guava to work with GWT. I'm using Eclipse, I've added both guava-11.0.2.jar and guava-gwt-11.0.2.jar to my class path, inherited the module com.google.common.collect.Collect in my gwt.xml file but still can't get it working.
It compiles but when I run it a lot of error appear. Many of them refering to unresolvable annotation javax.annotation.Nullable
I tried adding jsr305.jar to my class path but nothing chanded.
Also some errors appear depending on which version of Guava I include (tried with 11.0.2, 11.0.1, 10.0.1) and if I include or not the jsr305.jar
Some examples of these error are:
The type PersonActivity.PersonFilterPredicate must implement the inherited abstract method Predicate<PersonRoleProxy>.apply(Object)
The method compare(T, T) in the type Ordering<T> is not applicable for the arguments (Object, Object)
Which is quite strange because the code compiles and these kind of error should appear at compile time.
We have been embarrassingly unable to figure out the solution to the #Nullable problem, which we believe to be a GWT problem. You can follow along at http://code.google.com/p/guava-libraries/issues/detail?id=776 We're trying to get help from the GWT team, but things have been kind of crazy lately for the people who work on the part of the compiler we're interested in. It does look like you can work around the problem by removing -strict from your GWT compilation arguments, but of course that's a terrible workaround.
Other users' experiences suggest that the weird other errors you're seeing are related to the #Nullable problem, though I haven't seen definitive confirmation. You might also confirm that all your imports are com.google.common.* and not com.google.gwt.thirdparty.guava.common.*
Sorry for all the trouble. This is one of a few major thorns in our side at the moment.
The following workaround works for GWT 2.4.0 with
Guava 14.0 RC1 and
jsr305-1.3.9.jar
Create a file named Annotation.gwt.xml with the following content:
<module>
<source path=""/>
</module>
Within the archive jsr305-1.3.9.jar copy this file into sub-directory javax/annotation.
Add the following line to your applications .gwt.xml file:
<inherits name='javax.annotation.Annotation'/>

Categories

Resources