Search code examples
javac++java-native-interfaceinner-classesnosuchmethoderror

jni doesn't find method in inner class , java.lang.NoSuchMethodError


I have a question for getting access to methods in nested classes with JNI.

public class AccountUI {
    public native ExtrasWageUI[] getExtrasWages();

      public class ExtrasWageUI {
        public ExtrasWageUI() {
          mCppHandle = callConstructorN();
        }

        public ExtrasWageUI(long cppHandle) {
          mCppHandle = cppHandle;
        }

      private native long callConstructorN();
   }
  }

I will get the Error at accountUI.getExtrasWages():

java.lang.NoSuchMethodError: no method with name='' signature='(J)V' in class Lde/projects/customer/.../myProject/domain/AccountUI$ExtrasWageUI;

JNI won´t find the method. Has anyone an idea how I can access the method in the inner class?


Solution

  • you have to add the outer class in the signature:

    environment->GetMethodID(resultClassAssistantUI, "<init>", "(L.../domain/AccountUI;J)V");