Microsoft SDK for Java

J0101-J0120

J0101 J0102 J0103
J0104 J0105 J0106
J0107 J0108 J0109
J0110 J0111 J0112
J0113 J0114 J0115
J0116 J0117 J0118
J0119 J0120  

J0101 - The type 'identifier' does not inherit from 'Throwable'

The compiler detected an invalid class argument used as an argument in a catch declaration. When using a catch statement to handle exceptions, you must define it with a class derived from Throwable as a parameter. Make sure the class you defined for the catch statement is derived from Throwable, and then compile again.

The following sample illustrates this error.

public class Simple {
   
   public void method1() {
   
      try {
         // do something meaningful
      } catch (String s) {
         // error: 'String' not a subclass
         // of 'Throwable'
      }
   }
}

J0102 - Handler for 'identifier' hidden by earlier handler for 'identifier'

The compiler detected an exception handler that will never be executed because an earlier handler would have already caught the exception. This error is most likely caused by putting catch statements in the wrong order.

The following sample illustrates this error.

class Simple {
   
   static
   {
      try
      {
      }
      catch (Exception e)
      {
      }
      catch (ArithmeticException e)
      {
      }
      // error: any exceptions this block
      // could have caught are already caught
      // by the first catch statement.
   }
}

J0103 - Cannot override final method 'identifier'

The compiler detected a class method attempting to override one of its base class methods, but the base class method was declared with the keyword final. Methods defined with the final modifier cannot be overridden by a derived class.

The following sample illustrates this error.

public class Simple extends Simple2 {
   
   public void method1() {
      // error: 'method1' final in superclass
   }
}
class Simple2 {
   
   public final void method1() {
      // do something meaningful
   }
}

J0104 - Unreachable statement or declaration

The compiler detected a statement or declaration that cannot be reached under any circumstances. This error most likely occurs when a return statement is called from a method and code is placed below the return statement. This error can also occur if a break statement is used in a loop without any flow control to allow code below it to be run.

The following sample illustrates this error.

class Simple {
   static
   {
      return;
      int x;
      //error: the declaration cannot be reached
   }
}

J0105 - Method 'identifier' must return a value

The compiler detected a method declaration, which included a return type other than void, but the keyword return was not found in the method body. This error most likely occurs when a method that returns a value is missing a valid return statement. This error can also occur if a return statement is called within a flow control block and cannot always accessed due to the logic of the method.

The following sample illustrates this error.

public class Simple {
   
   public int method1(int arg1) {
   
   } // error: expected an integer returned
}

J0106 - Class 'identifier' has a circular dependency

The compiler detected two or more classes directly or indirectly attempting to subclass each other. One class should act as the base class of the other.

The following sample illustrates this error.

public class Simple extends Simple2 {
   
   // error: extending 'Simple2'
}
class Simple2 extends Simple {
   
   // error: also extending 'Simple'
}

J0107 - Missing array dimension

The compiler detected the initialization of an array, but failed to detect a valid array dimension. This error most likely occurs when an array is defined but one of the dimensions of the array is not defined. To use an array, all dimensions must be defined.

The following sample illustrates this error.

public class Simple {
   
   public void method1() {
   
      int [][] i = new int[][12]; 
      // error: missing first array dimension
   }
}

J0108 - Cannot 'new' an instance of type 'identifier'

The compiler detected an attempt to instantiate a data type that does not require use of the keyword new. This error most likely occurs when an attempt is made to use the new keyword with an intrinsic data type and the declaration is not an array. Make sure your member declaration does not use the new keyword unless it is a class object or array declaration.

The following sample illustrates this error.

public class Simple {
   
   public void method1() {
      int i = new int(5); 
      // error: cannot use 'new' on 'int' types
   }
}

J0109 - Cannot 'new' an instance of abstract class 'identifier'

The compiler detected an attempt to instantiate a class object declared as abstract. A class declared as abstract cannot be instantiated and exists only as a base class for other classes to derive from.

The following sample illustrates this error.

public class Simple {
   
   public void method1() {
   
      Simple2 s2Object = new Simple2(); 
      // error: class 'Simple2' declared as abstract
   }
}
abstract class Simple2 {
   // do something meaningful
}

J0110 - Cannot 'new' an interface 'identifier'

The compiler detected an attempt to instantiate an interface object declared as abstract. Note that interfaces are abstract by default, regardless whether the keyword abstract is used in their declaration.

The following sample illustrates this error.

public class Simple {
   
   public void method1() {
   
      Simple2 s2Object = new Simple2(); 
      // error: interface Simple2 is abstract
   }
}
interface Simple2 {
   // do something meaningful
}

J0111 - Invalid use of array initializer

The compiler detected an attempt to initialize an array, but the initialization statement was not syntactically correct. Arrays can be initialized at declaration with an initial set of values. The compiler detected that the syntax of the initialization was incorrect. This error most likely occurs when trying to initialize a multidimension array with the incorrect number or positioning of braces and commas. Check the syntax of your array initialization, and then compile again.

J0112 - Cannot assign final variable 'identifier'

The compiler detected an attempt to change the value of a variable declared as final. A field declared as final cannot be assigned a value once it has been initialized with a value either at declaration or in an initializer block.

The following sample illustrates this error.

public class Simple {
   private final int i = 3;
   public void method1(int arg1) {
      i = arg1; 
      // error: variable 'i' declared final
   }
}

J0113 - Call to constructor must be first in constructor

The compiler detected a constructor called from within the body of a second constructor, but the constructor call was not placed at the beginning of the second constructor body. In a constructor, calls to another constructor must be the first line of code in the constructor's body. Move the constructor call to the top, and then compile again.

The following sample illustrates this error.

public class Simple {
   
   int i, j;
   Simple () {
   
      i = 0;
   }
   
   Simple(int arg1) {
   
      j = arg1;
      this(); // error: call to Simple() must be first
   }
}

J0114 - Cannot reference 'this' in constructor call

The compiler detected a reference to this in a constructor. The this statement can only be used in a constructor to access methods and fields of the constructor's class. Usage of this(this) or super(this) in a constructor will cause this error to occur because the instance of the class has not yet been created, and thus cannot be passed to another constructor.

The following sample illustrates this error.

class SuperSimple {
   
   SuperSimple(Object o) { }
}
public class Simple extends SuperSimple {
   
   Simple()
   {
      super(this);
      //error: cannot refer to this in constructor
   }
}

J0115 - Cannot call constructor recursively

The compiler detected a recursive constructor call. This error most likely occurs when a constructor has a call to the same constructor. This error can also occur if one constructor calls a second constructor and the second constructor has a call back to the first constructor.

The following sample illustrates this error.

public class Simple {
   
   Simple (int arg1) {
   
      this(1);
      // error: constructor calling itself
   }
}

J0116 - Variable 'identifier' may be used before initialization

The compiler detected an attempt to use a variable before it was properly initialized. To use a variable in an assignment or expression, you need to assign a value to it. Initialize the variable in a constructor or field initializer, and then compile again.

The following sample illustrates this error.

public class Simple {
   
   static 
   {
      int i;
      int j = i;
      // error: 'i' not yet initialized
   
   }
}

J0117 - Cannot declare a class to be 'private'

The compiler detected use of the modifier private in an outer class declaration. This modifier may only be used with fields, methods, and inner class declarations.

The following sample illustrates this error.

private class Simple {
   
   // error: a class cannot be 'private'
   
}

J0118 - Not used

This error message is currently not used.

J0119 - Not used

This error message is currently not used.

J0120 - Divide or mod by zero

The compiler detected a division by zero error in code.

The following sample illustrates this error.

public class Simple {
   
   final int x = 0;
   int y = 1 % x;
   //error: x cannot be 0 
   
}

© 1999 Microsoft Corporation. All rights reserved. Terms of use.