{"action":"created","issue":{"url":"https://api.github.com/repos/mirah/mirah/issues/314","labels_url":"https://api.github.com/repos/mirah/mirah/issues/314/labels{/name}","comments_url":"https://api.github.com/repos/mirah/mirah/issues/314/comments","events_url":"https://api.github.com/repos/mirah/mirah/issues/314/events","html_url":"https://github.com/mirah/mirah/issues/314","id":72500212,"number":314,"title":"java.lang.NoClassDefFoundError when interface within package follows implementation class in file inclusion order","user":{"login":"eherz1","id":1369940,"avatar_url":"https://avatars.githubusercontent.com/u/1369940?v=3","gravatar_id":"","url":"https://api.github.com/users/eherz1","html_url":"https://github.com/eherz1","followers_url":"https://api.github.com/users/eherz1/followers","following_url":"https://api.github.com/users/eherz1/following{/other_user}","gists_url":"https://api.github.com/users/eherz1/gists{/gist_id}","starred_url":"https://api.github.com/users/eherz1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eherz1/subscriptions","organizations_url":"https://api.github.com/users/eherz1/orgs","repos_url":"https://api.github.com/users/eherz1/repos","events_url":"https://api.github.com/users/eherz1/events{/privacy}","received_events_url":"https://api.github.com/users/eherz1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-01T19:14:11Z","updated_at":"2015-08-14T13:10:49Z","closed_at":null,"body":"I first encountered this issue trying to implement an interface in a class in a separate package from the interface. I thought this was the issue, however, I could not reproduce it in a test case.\r\n\r\nAfter looking back at my project, I suspected that perhaps it was something to do with file inclusion order. I build the list of files to pass to the mirah interpreter programmatically with a bash script, and it happened that the interface came after the implementation class in this list. I modified the test case and found that this was indeed the issue!\r\n\r\nHowever, this issue only seems to occur with interfaces in separate packages. With all 3 files in the same directory and with no package declaration, it still works with the interface being listed after the interface in the file list.\r\n\r\nTest Case:\r\n\r\npackage foo\r\ninterface TestInterface\r\n  def testMethod(x: int): void; end\r\nend\r\n\r\npackage bar\r\nimport foo.TestInterface\r\nclass TestImplementation\r\n  implements TestInterface\r\n  def testMethod(x: int): void\r\n    puts x\r\n  end\r\nend\r\n\r\nimport bar.TestImplementation\r\nimpl = TestImplementation.new\r\nimpl.testMethod(5)\r\n\r\n% mirah Main.mirah bar/TestImplementation.mirah foo/TestInterface.mirah\r\n\r\njava/lang/ClassLoader.java:-2:in `defineClass1': java.lang.NoClassDefFoundError: foo/TestInterface\r\n\tfrom java/lang/ClassLoader.java:800:in `defineClass'\r\n\tfrom java/lang/ClassLoader.java:643:in `defineClass'\r\n\tfrom org/mirah/MirahClassLoader.java:29:in `findClass'\r\n\tfrom org/mirah/MirahClassLoader.java:41:in `loadClass'\r\n\tfrom java/lang/ClassLoader.java:358:in `loadClass'\r\n\tfrom run_command.mirah:44:in `run'\r\n\tfrom org/mirah/tool/run_command.mirah:44:in `run'\r\n\tfrom run_command.mirah:87:in `run'\r\n\tfrom org/mirah/tool/run_command.mirah:87:in `run'\r\n\tfrom java/lang/reflect/Method.java:606:in `invoke'\r\n\tfrom /Users/eherz/.rvm/gems/jruby-1.7.11@jruby1711/gems/mirah-0.1.4-java/lib/mirah.rb:35:in `run'\r\n\tfrom /Users/eherz/.rvm/gems/jruby-1.7.11@jruby1711/gems/mirah-0.1.4-java/bin/mirah:27:in `(root)'\r\n\tfrom org/jruby/RubyKernel.java:1101:in `load'\r\n\tfrom /Users/eherz/.rvm/gems/jruby-1.7.11@jruby1711/bin/mirah:1:in `(root)'\r\n\tfrom org/jruby/RubyKernel.java:1121:in `eval'\r\n\tfrom /Users/eherz/.rvm/gems/jruby-1.7.11@jruby1711/bin/jruby_executable_hooks:15:in `(root)'\r\n\tfrom Users/eherz/$_dot_rvm/gems/jruby_minus_1_dot_7_dot_11_at_40_jruby1711/bin//Users/eherz/.rvm/gems/jruby-1.7.11@jruby1711/bin/jruby_executable_hooks:15:in `(root)'\r\nCaused by:\r\nMirahClassLoader.java:34:in `findClass': java.lang.ClassNotFoundException: foo.TestInterface\r\n\tfrom ClassLoader.java:425:in `loadClass'\r\n\tfrom MirahClassLoader.java:43:in `loadClass'\r\n\tfrom ClassLoader.java:358:in `loadClass'\r\n\tfrom ClassLoader.java:-2:in `defineClass1'\r\n\tfrom ClassLoader.java:800:in `defineClass'\r\n\tfrom ClassLoader.java:643:in `defineClass'\r\n\tfrom MirahClassLoader.java:29:in `findClass'\r\n\tfrom MirahClassLoader.java:41:in `loadClass'\r\n\tfrom ClassLoader.java:358:in `loadClass'\r\n\tfrom run_command.mirah:44:in `run'\r\n\tfrom run_command.mirah:87:in `run'\r\n\tfrom NativeMethodAccessorImpl.java:-2:in `invoke0'\r\n\tfrom NativeMethodAccessorImpl.java:57:in `invoke'\r\n\tfrom DelegatingMethodAccessorImpl.java:43:in `invoke'\r\n\tfrom Method.java:606:in `invoke'\r\n\tfrom JavaMethod.java:455:in `invokeDirectWithExceptionHandling'\r\n\tfrom JavaMethod.java:367:in `invokeStaticDirect'\r\n\tfrom StaticMethodInvoker.java:60:in `call'\r\n\tfrom CachingCallSite.java:326:in `cacheAndCall'\r\n\tfrom CachingCallSite.java:170:in `call'\r\n\tfrom CallOneArgNode.java:57:in `interpret'\r\n\tfrom NewlineNode.java:105:in `interpret'\r\n\tfrom ASTInterpreter.java:74:in `INTERPRET_METHOD'\r\n\tfrom InterpretedMethod.java:268:in `call'\r\n\tfrom DefaultMethod.java:230:in `call'\r\n\tfrom CachingCallSite.java:366:in `cacheAndCall'\r\n\tfrom CachingCallSite.java:238:in `call'\r\n\tfrom CallSpecialArgNode.java:71:in `interpret'\r\n\tfrom NewlineNode.java:105:in `interpret'\r\n\tfrom BlockNode.java:71:in `interpret'\r\n\tfrom RootNode.java:129:in `interpret'\r\n\tfrom ASTInterpreter.java:121:in `INTERPRET_ROOT'\r\n\tfrom Ruby.java:838:in `runInterpreter'\r\n\tfrom Ruby.java:2766:in `loadFile'\r\n\tfrom ExternalScript.java:66:in `load'\r\n\tfrom LoadService.java:359:in `load'\r\n\tfrom RubyKernel.java:1109:in `loadCommon'\r\n\tfrom RubyKernel.java:1101:in `load19'\r\n\tfrom RubyKernel$INVOKER$s$0$1$load19.gen:-1:in `call'\r\n\tfrom DynamicMethod.java:210:in `call'\r\n\tfrom DynamicMethod.java:206:in `call'\r\n\tfrom CachingCallSite.java:326:in `cacheAndCall'\r\n\tfrom CachingCallSite.java:170:in `call'\r\n\tfrom FCallOneArgNode.java:36:in `interpret'\r\n\tfrom NewlineNode.java:105:in `interpret'\r\n\tfrom BlockNode.java:71:in `interpret'\r\n\tfrom RootNode.java:129:in `interpret'\r\n\tfrom ASTInterpreter.java:95:in `INTERPRET_EVAL'\r\n\tfrom ASTInterpreter.java:184:in `evalWithBinding'\r\n\tfrom RubyKernel.java:1158:in `evalCommon'\r\n\tfrom RubyKernel.java:1121:in `eval19'\r\n\tfrom RubyKernel$INVOKER$s$0$3$eval19.gen:-1:in `call'\r\n\tfrom DynamicMethod.java:226:in `call'\r\n\tfrom DynamicMethod.java:222:in `call'\r\n\tfrom CachingCallSite.java:366:in `cacheAndCall'\r\n\tfrom CachingCallSite.java:238:in `call'\r\n\tfrom /Users/eherz/.rvm/gems/jruby-1.7.11@jruby1711/bin/jruby_executable_hooks:15:in `__file__'\r\n\tfrom /Users/eherz/.rvm/gems/jruby-1.7.11@jruby1711/bin/jruby_executable_hooks:-1:in `load'\r\n\tfrom Ruby.java:811:in `runScript'\r\n\tfrom Ruby.java:804:in `runScript'\r\n\tfrom Ruby.java:673:in `runNormally'\r\n\tfrom Ruby.java:522:in `runFromMain'\r\n\tfrom Main.java:395:in `doRunFromMain'\r\n\tfrom Main.java:290:in `internalRun'\r\n\tfrom Main.java:217:in `run'\r\n\tfrom Main.java:197:in `main'\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mirah/mirah/issues/comments/131100614","html_url":"https://github.com/mirah/mirah/issues/314#issuecomment-131100614","issue_url":"https://api.github.com/repos/mirah/mirah/issues/314","id":131100614,"user":{"login":"felixvf","id":11700328,"avatar_url":"https://avatars.githubusercontent.com/u/11700328?v=3","gravatar_id":"","url":"https://api.github.com/users/felixvf","html_url":"https://github.com/felixvf","followers_url":"https://api.github.com/users/felixvf/followers","following_url":"https://api.github.com/users/felixvf/following{/other_user}","gists_url":"https://api.github.com/users/felixvf/gists{/gist_id}","starred_url":"https://api.github.com/users/felixvf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixvf/subscriptions","organizations_url":"https://api.github.com/users/felixvf/orgs","repos_url":"https://api.github.com/users/felixvf/repos","events_url":"https://api.github.com/users/felixvf/events{/privacy}","received_events_url":"https://api.github.com/users/felixvf/received_events","type":"User","site_admin":false},"created_at":"2015-08-14T13:10:49Z","updated_at":"2015-08-14T13:10:49Z","body":"@eherz1 I believe this bug is fixed by now. Can you confirm this?"}}