Search code examples
javacjava-native-interfacenative-methods

Java field descriptor for Object[][]


Whats field descriptor for an Object[][] within a method descriptor? Say there exists a class foo.bar.Class and a method takes a Class[][], according to

http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#14152

or the JNI specification my understanding is that it should be

[[Lfoo/bar/Class;

but that is evaluated to an array of "[foo.bar.Class" which of course triggers a java.lang.NoClassDefFoundError.

Should the "inner" array probably be considered a java.lang.Object, resulting in

[Ljava/lang/Object;

?


Solution

  • You are doing something wrong I guess. This works for me:

    package ro.redeul.test;
    
    public class Test {
    
        public static void main(String[] args) throws NoSuchMethodException {
            System.out.println("x: " + Test.class.getMethod("method").getReturnType().toString());
        }
    
        public Test[][] method() {
            return null;
        }
    }
    

    it prints x: class [[Lro.redeul.test.Test;

    Can you provide more context ?