JsInterop: annotations not found

133 views
Skip to first unread message

Bob Woodbury

unread,
Dec 3, 2017, 2:00:29 AM12/3/17
to GWT Users
I am learning to use jsinterop, and I am stuck at square one -- javac won't recognize the @JsType annotation.

I'm using the jdk1.8.0_102 and apache-ant-1.10.1 and gwt-2.8.2 on Linux (Fedora).

My project compiles without problems until I try to add "MyClass" with the @JsType annotation.

I lifted the following code from the tutorial at: http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJsInterop.html


package com.webshoz.insight.client.iaol;


import jsinterop.annotations.*;  // I have tried compiling with and without this import, without success.


@JsType
public class MyClass {


   
public String name;


   
public MyClass(String name) {
       
this.name = name;
   
}


   
public void sayHello() {
       
return "Hello" + this.name;
   
}
}



The relevant parts of my Ant build file are:


<?xml version="1.0" encoding="utf-8" ?>
<project name="Insight" default="build" basedir=".">


 
<path id="project.class.path">
   
<pathelement location="war/WEB-INF/classes"/>
   
<fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
 
</path>


 
<target name="javac" description="Compile java source">
   
<javac srcdir="src" includes="**" encoding="utf-8"
       
destdir="war/WEB-INF/classes"
       
source="1.8" target="1.8" nowarn="false"
       
includeantruntime="false"
       
debug="true" debuglevel="lines,vars,source">
     
<classpath refid="project.class.path"/>
     
<compilerarg value="-Xlint:deprecation"/>
     
<compilerarg value="-Xlint:unchecked"/>
     
<compilerarg value="-verbose"/>
     
<compilerarg value="-Xlint"/>
     
<compilerarg value="-XprintProcessorInfo"/>
   
</javac>
 
</target>


 
<target name="gwtc" depends="javac" description="GWT compile to JavaScript">
   
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
     
<classpath>
       
<pathelement location="src"/>
       
<path refid="project.class.path"/>
     
</classpath>
     
<jvmarg value="-Xmx512M"/>
     
<arg line="-generateJsInteropExports -strict -XdisableUpdateCheck"/>
     
<arg value="com.webshoz.insight.Application"/>
     
<arg value="com.webshoz.insight.Iaol"/>
   
</java>
 
</target>


</project>


The javac compiler puts out the following:

[javac] Processor com.google.web.bindery.requestfactory.apt.RfValidator matches [java.lang.Override, jsinterop.annotations.JsType] and returns false.
[javac] warning: No processor claimed any of these annotations: jsinterop.annotations.JsType
[javac] [search path for source files: /house/Dev/Insight/branches/IAOL/src]

Can anyone tell me what I'm missing? Thanks!

Thomas Broyer

unread,
Dec 3, 2017, 5:01:08 AM12/3/17
to GWT Users
If you see this message I would believe that it means javac did find the annotation (it's in gwt-user.jar, so how could it not find it?)
This warning is inconsequential, of the kind that you would always silence because it's a false positive 99% of the time.
So, what's missing? Well, I'd say <compilerarg value="-Xlint:-processing"/>

Does compilation fail after that? Or were you only worried by the warning?

Bob Woodbury

unread,
Dec 3, 2017, 3:16:53 PM12/3/17
to GWT Users
In the bright light of morning, I can see the problem. The javac message tells me javac is searching my srcdir for some of the jsinterop sources. They are in the jar files in my class path, but not in my srcdir. I will experiment to find the best way to handle this.

Thanks for your help.
Reply all
Reply to author
Forward
0 new messages