2

It is a Java inner class problem and the code is shown below:

public class Load {
   /*
   static { //load
       System.loadLibrary("lvb");
   }*/

   public class FILTER_T{

      HP05_T hp;
      LP40_T lp;
      NOTCH50_T notch;
      //   Load.FILTER_T.HP05_T hp;
      //  Load.FILTER_T.LP40_T lp;
      //  Load.FILTER_T.NOTCH50_T notch;

      public class HP05_T {
         public int[] buf;
         public long y1;
         public long y2;
         public int ptr;
      }

      public class LP40_T {
          public int[] buf;
          public int ptr;
      }
      public class NOTCH50_T {
          public int[] buf;
          public int ptr;
       }

    }

    public native void func1(FILTER_T filter);

    public native int func2(FILTER_T filter, int in);

    public native int[] func3(int a,int[] in,FILTER_T filter);

    public static void main(String[] args) {
      Load load = new Load();
      load.FILTER_T ff = new load.FILTER_T();
      load.func1(ff);
      load.func2(ff, 120);
    }

}

In line

 load.FILTER_T ff = new load.FILTER_T();

there is a compile error:

error: package load does not exist

I wonder if any one know the problem and the way to fix it.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
Kaiyu Wang
  • 21
  • 1
  • The enclosing instance expression is only needed in the instantiation expression, not in the type declaration for the variable. – Sotirios Delimanolis Jul 01 '16 at 15:32
  • You can use `FILTER_T ff = new FILTER_T();` without prefixing it. – Bruno Toffolo Jul 01 '16 at 15:34
  • Why are they inner classes? They don't seem to need ant reference to their enclosing instances, so they could be static nested classes instead of inner classes. Your naming also doesn't respect Java conventions, and making everything public is a huge code smell. Anyway, the syntax is `FILTER_T ff = load.new FILTER_T();` – JB Nizet Jul 01 '16 at 15:35
  • Java is case sensitive so `load` is not the same as `Load` – Peter Lawrey Jul 01 '16 at 15:39
  • @LeoIzen They're not automatic. Your answer is incorrect. – JB Nizet Jul 01 '16 at 15:40
  • 2
    All those answers are plain wrong! It is an _inner_ class that needs an _instance_ for the instantiation. Correct would be `load.new FILTER_T();` – Seelenvirtuose Jul 01 '16 at 15:40

1 Answers1

7

This is an inner, non-static class. You are correct to us an instance of the outer class to instantiate it. However, the correct syntax is:

FILTER_T ff = load.new FILTER_T();