Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException when calling super of Java class #2923

Closed
yamam opened this Issue May 9, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@yamam
Copy link

commented May 9, 2015

I made subclass of VBox(javafx class). In constructor, I call super, and ArrayIndexOutOfBoundsException occurs rarely.

java_import 'javafx.scene.layout.VBox'

class MyVBox < VBox
    def initialize(a)
        super
    end
end

p VBox.new.getClass.getDeclaredConstructors
MyVBox.new(3)

Run above script many times.

for i in {1..100} 
do
  echo $i
  jruby-9.0.0.0.pre2/bin/jruby test.rb
done
1
java.lang.reflect.Constructor[public javafx.scene.layout.VBox(double), public javafx.scene.layout.VBox(javafx.scene.Node[]), public javafx.scene.layout.VBox(double,javafx.scene.Node[]), public javafx.scene.layout.VBox()]@87761d
2
java.lang.reflect.Constructor[public javafx.scene.layout.VBox(double), public javafx.scene.layout.VBox(javafx.scene.Node[]), public javafx.scene.layout.VBox(double,javafx.scene.Node[]), public javafx.scene.layout.VBox()]@87761d
3
java.lang.reflect.Constructor[public javafx.scene.layout.VBox(double), public javafx.scene.layout.VBox(javafx.scene.Node[]), public javafx.scene.layout.VBox(double,javafx.scene.Node[]), public javafx.scene.layout.VBox()]@87761d
4
java.lang.reflect.Constructor[public javafx.scene.layout.VBox(), public javafx.scene.layout.VBox(double), public javafx.scene.layout.VBox(javafx.scene.Node[]), public javafx.scene.layout.VBox(double,javafx.scene.Node[])]@87761d
CallableSelector.java:171:in `findMatchingCallableForArgs': java.lang.ArrayIndexOutOfBoundsException: 1
        from CallableSelector.java:104:in `matchingCallableArityN'
        from Java.java:781:in `call'
        from JavaMethod.java:692:in `call'
        from CachingCallSite.java:273:in `cacheAndCall'
        from CachingCallSite.java:79:in `callBlock'
        from CachingCallSite.java:83:in `call'
        from ConcreteJavaProxy.java:48:in `call'
        from IRRuntimeHelpers.java:891:in `instanceSuper'
        from IRRuntimeHelpers.java:884:in `instanceSuperSplatArgs'
        from test.rb:-1:in `invokeSuper3:initialize'
        from test.rb:5:in `RUBY$method$initialize$1'
        from CompiledIRMethod.java:134:in `call'
        from CachingCallSite.java:323:in `cacheAndCall'
        from CachingCallSite.java:173:in `callBlock'
        from CachingCallSite.java:177:in `call'
        from RubyClass.java:849:in `newInstance'
        from RubyClass$INVOKER$i$newInstance.gen:-1:in `call'
        from JavaMethod.java:312:in `call'
        from ConcreteJavaProxy.java:155:in `call'
        from CachingCallSite.java:313:in `cacheAndCall'
        from CachingCallSite.java:163:in `call'
        from test.rb:-1:in `invokeOther10:new'
        from test.rb:10:in `RUBY$script'
        from null:-1:in `invokeWithArguments'
        from Compiler.java:111:in `load'
        from Ruby.java:830:in `runScript'
        from Ruby.java:823:in `runScript'
        from Ruby.java:753:in `runNormally'
        from Ruby.java:575:in `runFromMain'
        from Main.java:404:in `doRunFromMain'
        from Main.java:299:in `internalRun'
        from Main.java:226:in `run'
        from Main.java:198:in `main'
@yamam

This comment has been minimized.

Copy link
Author

commented Jun 11, 2015

I analaysed the bug with jdb.

When exceotion raise at findMatchingCallableForArgs
local variables are the following values.

candidates = "[#<[Proxy:javafx.scene.layout.VBox](double,[Ljavafx.scene.Node;)>, #Proxy:javafx.scene.layout.VBox](double)>]"
mostSpecific = "#<[Proxy:javafx.scene.layout.VBox](double,[Ljavafx.scene.Node;)>"
candidate = "#<[Proxy:javafx.scene.layout.VBox](double)>"
msTypes = instance of java.lang.Class[2] ( double, class [Ljavafx.scene.Node; )
cTypes = instance of java.lang.Class[1] ( double )

msTypes is bigger than cTypes. So, an ArrayIndexOutOfBoundsException raise when you access to cTypes[1].

for ( int i = 0; i < msTypes.length; i++ ) {
   final Class<?> msType = msTypes[i], cType = cTypes[i];

@kares kares self-assigned this Aug 14, 2015

@kares

This comment has been minimized.

Copy link
Member

commented Aug 14, 2015

thanks @yaman little harder to reproduce (only on Java 8) but confirmed on 1.7.21 as well as 9.0.0.0

@CeesZ

This comment has been minimized.

Copy link

commented Sep 13, 2015

@kares I noticed that this issue was resolved for 1.7.22, but that it is not listed as a separate milestone for 9.0.0.0
Should it be listed as a separate action, or will resolving it for 1.7.22 also resolve it for future releases of 9.0.0.0 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.