{"action":"created","issue":{"url":"https://api.github.com/repos/konsoletyper/teavm/issues/219","repository_url":"https://api.github.com/repos/konsoletyper/teavm","labels_url":"https://api.github.com/repos/konsoletyper/teavm/issues/219/labels{/name}","comments_url":"https://api.github.com/repos/konsoletyper/teavm/issues/219/comments","events_url":"https://api.github.com/repos/konsoletyper/teavm/issues/219/events","html_url":"https://github.com/konsoletyper/teavm/issues/219","id":173048735,"number":219,"title":"Build error when synchronous code inside override of equals()","user":{"login":"shannah","id":2677562,"avatar_url":"https://avatars.githubusercontent.com/u/2677562?v=3","gravatar_id":"","url":"https://api.github.com/users/shannah","html_url":"https://github.com/shannah","followers_url":"https://api.github.com/users/shannah/followers","following_url":"https://api.github.com/users/shannah/following{/other_user}","gists_url":"https://api.github.com/users/shannah/gists{/gist_id}","starred_url":"https://api.github.com/users/shannah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shannah/subscriptions","organizations_url":"https://api.github.com/users/shannah/orgs","repos_url":"https://api.github.com/users/shannah/repos","events_url":"https://api.github.com/users/shannah/events{/privacy}","received_events_url":"https://api.github.com/users/shannah/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-08-24T20:22:31Z","updated_at":"2016-11-07T17:35:11Z","closed_at":null,"body":"I ran into a problem with a project when we accidentally added synchronous code to a class's `equals()` method.  This broke the TeaVM build because this effectively causes `Object.equals()` to be marked as synchronous which, in turn, causes `Hashtable.put()` to be marked synchronous, and this is used inside quite a few class initializers - even inside the core TeaVM class library.\n\nThis limitation seems logical, and probably difficult to overcome.  The main problem is that the error readout is misleading and would be very hard to debug without knowing exactly what changes we had made, and walked our steps back.\n\nThe error message/stack trace was:\n\n```\n     [java] [INFO] Building JavaScript file\n     [java] [INFO] ------------------------------------------------------------------------\n     [java] [INFO] BUILD FAILURE\n     [java] [INFO] ------------------------------------------------------------------------\n     [java] [INFO] Total time: 30.441 s\n     [java] [INFO] Finished at: 2016-08-24T13:04:03-07:00\n     [java] [INFO] Final Memory: 22M/805M\n     [java] [INFO] ------------------------------------------------------------------------\n     [java] [ERROR] Failed to execute goal org.teavm:teavm-maven-plugin:1.0.0-cn1-004:compile (web-client) on project KitchenSink: Unexpected error occured: -1 -> [Help 1]\n     [java] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.teavm:teavm-maven-plugin:1.0.0-cn1-004:compile (web-client) on project KitchenSink: Unexpected error occured\n     [java]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)\n     [java]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)\n     [java]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)\n     [java]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)\n     [java]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)\n     [java]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)\n     [java]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)\n     [java]     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)\n     [java]     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)\n     [java]     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)\n     [java]     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)\n     [java]     at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)\n     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n     [java]     at java.lang.reflect.Method.invoke(Method.java:483)\n     [java]     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)\n     [java]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)\n     [java]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)\n     [java]     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)\n     [java] Caused by: org.apache.maven.plugin.MojoExecutionException: Unexpected error occured\n     [java]     at org.teavm.maven.BuildJavascriptMojo.execute(BuildJavascriptMojo.java:106)\n     [java]     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)\n     [java]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)\n     [java]     ... 19 more\n     [java] Caused by: java.lang.ArrayIndexOutOfBoundsException: -1\n     [java]     at org.teavm.common.LCATree.lcaOf(LCATree.java:72)\n     [java]     at org.teavm.common.DJGraph.isSpanningBack(DJGraph.java:161)\n     [java]     at org.teavm.common.IrreducibleGraphConverter.handleLoops(IrreducibleGraphConverter.java:53)\n     [java]     at org.teavm.common.IrreducibleGraphConverter.splitStronglyConnectedComponent(IrreducibleGraphConverter.java:230)\n     [java]     at org.teavm.common.IrreducibleGraphConverter.handleStronglyConnectedComponent(IrreducibleGraphConverter.java:133)\n     [java]     at org.teavm.common.IrreducibleGraphConverter.handleLoops(IrreducibleGraphConverter.java:65)\n     [java]     at org.teavm.common.IrreducibleGraphConverter.convertToReducible(IrreducibleGraphConverter.java:43)\n     [java]     at org.teavm.common.GraphUtils.splitIrreducibleGraph(GraphUtils.java:169)\n     [java]     at org.teavm.model.util.AsyncProgramSplitter.split(AsyncProgramSplitter.java:159)\n     [java]     at org.teavm.javascript.Decompiler.decompileAsyncCacheMiss(Decompiler.java:320)\n     [java]     at org.teavm.javascript.Decompiler.decompileAsync(Decompiler.java:288)\n     [java]     at org.teavm.javascript.Decompiler.decompile(Decompiler.java:219)\n     [java]     at org.teavm.javascript.Decompiler.decompile(Decompiler.java:209)\n     [java]     at org.teavm.vm.TeaVM.modelToAst(TeaVM.java:578)\n     [java]     at org.teavm.vm.TeaVM.build(TeaVM.java:411)\n     [java]     at org.teavm.tooling.TeaVMTool.generate(TeaVMTool.java:344)\n     [java]     at org.teavm.maven.BuildJavascriptMojo.execute(BuildJavascriptMojo.java:101)\n     [java]     ... 21 more\n     [java] [ERROR] \n     [java] [ERROR] Re-run Maven using the -X switch to enable full debug logging.\n     [java] [ERROR] \n     [java] [ERROR] For more information about the errors and possible solutions, please read the following articles:\n     [java] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException\n     [java] Process return code is 1\n```\n\nI added some debugging code to AsyncProgramSplitter to catch this exception and report which class/method it was choking on.  Unfortunately, this method was also completely unrelated to where the problem originated.  (It pointed at a different class in a different package - and I'm not sure how it relates to the actual problem).  I was able to find the actual problem, though, by commenting this method's contents out.  Then it produced the actual errors about synchronous method calls inside class initializers -- And that allowed me to track down the issue.\n\nI have pushed a project that demonstrates the problem at https://github.com/shannah/teavm_bug_test_equals\n\nThe change the ultimately worked around the problem can be seen here:\nhttps://github.com/codenameone/CodenameOne/commit/9169acd9404af0876522c46275e55eb770c69f23\n\n(This is part of the CodenameOne.jar)\n\nOne possible solution I can see for this problem would be to throw an error (or loud warning) if Object.equals() or Object.hashCode() are overridden with implementations that include synchronous code.  \n"},"comment":{"url":"https://api.github.com/repos/konsoletyper/teavm/issues/comments/258904520","html_url":"https://github.com/konsoletyper/teavm/issues/219#issuecomment-258904520","issue_url":"https://api.github.com/repos/konsoletyper/teavm/issues/219","id":258904520,"user":{"login":"konsoletyper","id":5521903,"avatar_url":"https://avatars.githubusercontent.com/u/5521903?v=3","gravatar_id":"","url":"https://api.github.com/users/konsoletyper","html_url":"https://github.com/konsoletyper","followers_url":"https://api.github.com/users/konsoletyper/followers","following_url":"https://api.github.com/users/konsoletyper/following{/other_user}","gists_url":"https://api.github.com/users/konsoletyper/gists{/gist_id}","starred_url":"https://api.github.com/users/konsoletyper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/konsoletyper/subscriptions","organizations_url":"https://api.github.com/users/konsoletyper/orgs","repos_url":"https://api.github.com/users/konsoletyper/repos","events_url":"https://api.github.com/users/konsoletyper/events{/privacy}","received_events_url":"https://api.github.com/users/konsoletyper/received_events","type":"User","site_admin":false},"created_at":"2016-11-07T17:35:11Z","updated_at":"2016-11-07T17:35:11Z","body":"So what's the error in TeaVM? I see that TeaVM compiles your project and does not crash. It fairly reports errors in your code and exits."}}
{"actor":{"display_login":"konsoletyper"}}