title: The Type of <class> is erroneous error in netbeans
body: <p>I have defined two classes for a java program I am writing, call them Class1 and Class2. In the body of the constructor for Class1, I call the constructor for class 2. However, I am getting the compile error </p>
  
  <pre><code> "The type of Class1(JSONObject) is erroneous". 
  </code></pre>
  
  <p>I tried googling this error but could not find any discussion of this exact error anywhere, so I thought I would post it to stack exchange.</p>
  
  <p>Could someone please explain what type of error this is? Both class1 and class2 are very simple: both have only a constructor method, which takes a JSONObject as an argument in both cases. The only imports are for JSON. Any advice?</p>
  
  <pre><code>//class1 definition
  public class Class1 {
         public Class1(JSONObject jObject){
             try{
             //parsing json and saving class variables
             } catch(Exception e)
             {
                 System.out.println("Class1 JSON Exception: " + e.getMessage());
             }
         }
  }
  
  
  //constructor of Class2
  Class1 user;
  
  public Class2(JSONObject jObject){
      try{
      JSONObject userJSON = jObject.getJSONObject("user");
      user = new Class1(userJSON); //error occurrs here
      }
      catch(Exception e){
     System.out.println("Class2 JSON Exception: " + e.getMessage());
  
      }
  }
  
  }
  </code></pre>
  
  <p>EDIT: when I try to run the code even with this compile error, I get the following runtime error:</p>
  
  <pre><code>Exception in thread "main" java.lang.ExceptionInInitializerError
  at bitcoin.thesis.Client.main(BTCJamClient.java:18)
  Caused by: java.lang.RuntimeException: Uncompilable source code - Erroneous tree type:        
  thesis.JSONArray
  at thesis.Class3.&lt;clinit&gt;(Class3.java)
  ... 1 more
  Java Result: 1
  </code></pre>
  
  <p>Class3 here is another class that has a default constructor. Client is the main class which takes the http request and passes the JSON object to Class2 constructor. Basically this is the part of the code execution before Class1 and Class2 constructors are even called. So it is not caused directly by the compile error, but I suspect they are related to the same problem that has do do more generally with my coding environment.</p>
  
  <p>Thanks,
  Paul</p>