JS V is claimed to be synchronous, but it is has invocations of asynchronous methods

29 views
Skip to first unread message

Gareth Murfin

unread,
Jul 25, 2016, 3:00:44 PM7/25/16
to CodenameOne Discussions
I have removed all references to synchronized, but I am still getting this error with a Javascript build: 

[INFO] 
[INFO] --- teavm-maven-plugin:1.0.0-cn1-004:compile (web-client) @ MyApplication ---
[INFO] Preparing classpath for JavaScript generation
[INFO] Using the following classpath for JavaScript generation: /tmp/build7232626002789411357xxx/lib/CodenameOne.jar:/tmp/build7232626002789411357xxx/lib/Factory.jar:/tmp/build7232626002789411357xxx/lib/app.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-classlib/1.0.0-cn1-004/teavm-classlib-1.0.0-cn1-004.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-platform/1.0.0-cn1-004/teavm-platform-1.0.0-cn1-004.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-core/1.0.0-cn1-004/teavm-core-1.0.0-cn1-004.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-metaprogramming-api/1.0.0-cn1-004/teavm-metaprogramming-api-1.0.0-cn1-004.jar:/home/ec2-user/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/home/ec2-user/.m2/repository/com/carrotsearch/hppc/0.6.1/hppc-0.6.1.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-jso-apis/1.0.0-cn1-004/teavm-jso-apis-1.0.0-cn1-004.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-jso-impl/1.0.0-cn1-004/teavm-jso-impl-1.0.0-cn1-004.jar:/home/ec2-user/.m2/repository/org/mozilla/rhino/1.7.7/rhino-1.7.7.jar:/home/ec2-user/.m2/repository/org/ow2/asm/asm-debug-all/5.0.4/asm-debug-all-5.0.4.jar:/home/ec2-user/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar:/home/ec2-user/.m2/repository/com/jcraft/jzlib/1.1.3/jzlib-1.1.3.jar:/home/ec2-user/.m2/repository/joda-time/joda-time/2.7/joda-time-2.7.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-jso/1.0.0-cn1-004/teavm-jso-1.0.0-cn1-004.jar:/home/ec2-user/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/home/ec2-user/.m2/repository/org/mitre/dsmiley/httpproxy/smiley-http-proxy-servlet/1.6/smiley-http-proxy-servlet-1.6.jar:/home/ec2-user/.m2/repository/org/apache/httpcomponents/httpclient/4.3.4/httpclient-4.3.4.jar:/home/ec2-user/.m2/repository/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar:/home/ec2-user/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/home/ec2-user/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar:/tmp/build7232626002789411357xxx/target/classes
[INFO] Building JavaScript file
[INFO] JavaScript file built with errors
[ERROR] Method userclasses.DDragon.<clinit>()V is claimed to be synchronous, but it is has invocations of asynchronous methods
    at userclasses.DDragon.<clinit>
    at com.elite.dd.MyApplication.start(MyApplication.java:47)
    at com.codename1.impl.html5.Stub.run(Stub.java:80)
    at com.codename1.ui.Display.callSerially(Display.java:771)
    at com.codename1.impl.html5.Stub.main(Stub.java:68)
[INFO] Debug information successfully written
[INFO] Source maps successfully written
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.337 s
[INFO] Finished at: 2016-07-25T14:58:48-04:00
[INFO] Final Memory: 26M/875M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.teavm:teavm-maven-plugin:1.0.0-cn1-004:compile (web-client) on project MyApplication: Build error -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.teavm:teavm-maven-plugin:1.0.0-cn1-004:compile (web-client) on project MyApplication: Build error
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Build error
	at org.teavm.maven.BuildJavascriptMojo.execute(BuildJavascriptMojo.java:103)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	... 19 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Currently 'stopOnErrors' is on.  With this enabled, even build warnings will cause the build to fail. 
Try adding the 'javascript.stopOnErrors=false' build hint and see if it builds.  
WARNING: switching stopOnErrors off may result in runtime errors, if the warnings actually fall in the execution path of the app. 

Steve Hannah

unread,
Jul 25, 2016, 5:51:23 PM7/25/16
to codenameone...@googlegroups.com
Check your static initializer for the Ddragon class. If you have something like

private static void myvar = new SomeObject();

And the SomeObject constructor includes synchronous code somewhere down the line, then this would also trigger it.

Steve
--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/eee3aba0-51a7-4535-a663-7245ac04a928%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gareth Murfin

unread,
Jul 25, 2016, 8:35:33 PM7/25/16
to CodenameOne Discussions
Thanks, how do I identify synchronous code? Surely no use of synchronized means it has all gone ?

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/SvAR87Pz7ns/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gareth Murfin
(Android Freelancer - www.garethmurfin.co.uk)

Steve Hannah

unread,
Jul 25, 2016, 8:46:49 PM7/25/16
to codenameone...@googlegroups.com
The best thing to do is just no use the static initializer to initialize objects that you aren't sure about.  Instead instantiate them lazily.

E.g. 

don't do anything like

static MyClass c = new MyClass();

Steve


For more options, visit https://groups.google.com/d/optout.



--
Steve Hannah
Software Developer
Codename One

Gareth Murfin

unread,
Jul 26, 2016, 7:26:39 AM7/26/16
to CodenameOne Discussions
Thanks, I cant see anything like that al;though I do have stuff like

static private byte[]           rgRS = new byte[NV_SIZE*4];    
static GeneralTask[]                   pActObj = new GeneralTask[TASK_MAX];   

etc, will they trigger it?



For more options, visit https://groups.google.com/d/optout.

Gareth Murfin

unread,
Jul 26, 2016, 7:56:13 AM7/26/16
to CodenameOne Discussions
I used the build hints to skip errors, now it stops on this line
is = Display.getInstance().getResourceAsStream( Class.forName("java.lang.Object"),"/stmaps" );

I am presuming I need to do something else to load up files in the browser?
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/SvAR87Pz7ns/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsub...@googlegroups.com.



--
Gareth Murfin
(Android Freelancer - www.garethmurfin.co.uk)

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.



--
Steve Hannah
Software Developer
Codename One

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/SvAR87Pz7ns/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsub...@googlegroups.com.

Steve Hannah

unread,
Jul 26, 2016, 11:34:36 AM7/26/16
to codenameone...@googlegroups.com
In my experience, it is more productive to focus on those synchronization warnings, as they will pop out in weird ways at runtime if you just ignore them.  This error is likely a case of that.

There is something in your Ddragon static initializer that calls synchronous code at some point.  If you post the class source, I can probably point it out right away.

Steve

To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/SvAR87Pz7ns/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.



--
Gareth Murfin
(Android Freelancer - www.garethmurfin.co.uk)

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.



--
Steve Hannah
Software Developer
Codename One

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/SvAR87Pz7ns/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.



--
Gareth Murfin
(Android Freelancer - www.garethmurfin.co.uk)

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages