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

On Mon, Jul 25, 2016 at 5:35 PM, Gareth Murfin <[email protected]>
wrote:

> Thanks, how do I identify synchronous code? Surely no use of synchronized
> means it has all gone ?
>
> On 26 July 2016 at 05:51, Steve Hannah <[email protected]>
> wrote:
>
>> 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
>>
>> On Monday, 25 July 2016, Gareth Murfin <[email protected]> wrote:
>>
>>> 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.
>>>
>>> --
>>> 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 [email protected].
>>> 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
>>> <https://groups.google.com/d/msgid/codenameone-discussions/eee3aba0-51a7-4535-a663-7245ac04a928%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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
>> [email protected].
>> 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/CAGOYrKUAxjJ9iGfhu4PLdkA0-eNb2kJ2DeN4XqL2WpRA4QomjQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/codenameone-discussions/CAGOYrKUAxjJ9iGfhu4PLdkA0-eNb2kJ2DeN4XqL2WpRA4QomjQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> 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 [email protected].
> 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/CANOaY6m37Q_QsBz3048fZP5T-cjUVi9AY%3D3xv23H7%3DvgaEW0tQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/codenameone-discussions/CANOaY6m37Q_QsBz3048fZP5T-cjUVi9AY%3D3xv23H7%3DvgaEW0tQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Steve Hannah
Software Developer
Codename One
http://www.codenameone.com

-- 
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 [email protected].
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/CAGOYrKUXMgEYfDaidbGR3NFMs_U%2Bwca299pR3LrKO%3DWfPGR99g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to