Microsoft SDK for Java

J0121-J0140

J0121 J0122 J0123
J0124 J0125 J0126
J0127 J0128 J0129
J0130 J0131 J0132
J0133 J0134 J0135
J0136 J0137 J0138
J0139 J0140  

J0121 - Unable to recover from previous error(s)

The compiler encountered a serious error and could not continue processing the file reliably. Try fixing whatever errors are already flagged, and then compile again.

J0122 - Exception 'identifier' not caught or declared by 'identifier'

The compiler detected an exception that was thrown but never caught within the exception class. This error most likely occurs when a method calls another method with a declaration to throw an exception. For a method to call another method that throws an exception, the method must either be declared to throw the exception or handle the error using a try catch combination.

The following sample illustrates this error.

class SimpleException extends Exception {
   // do something meaningful
}
class Simple {
   
   void method1() throws SimpleException { }
   void method2() { method1(); } 
   // error: exception not declared for method2
}

J0123 - Multiple inheritance of classes is not supported

The compiler detected a class attempting to apply the keyword extends to more than one base class. This is defined as multiple inheritance in other languages and is not supported in Java.

The following sample illustrates this error.

public class Simple extends BaseClass1, BaseClass2 {
   // error: Multiple inheritance not supported in Java
}
class BaseClass1 {
   
   // do something meaningful
}
class BaseClass2 {
   
   // do something meaningful
}

J0124 - Operator cannot be applied to 'identifier' values

The compiler detected an operator being applied to a type it cannot be used with. Make sure the operation you are attempting is valid for the type of variable or object, and then compile again.

The following sample illustrates this error.

public class Simple {
   
   void method1(boolean b) {
   
      b++;
      // error: post increment operator cannot
      // be applied to boolean variables
   }
}

J0125 - 'finally' without 'try'

The compiler detected a finally block but did not find a corresponding try statement. A finally block is used to execute code after a try statement and regardless of the results of the try statement.

The following sample illustrates this error.

public class Simple {
   
   public void method1() {
   
      finally {
         // error: missing corresponding 'try'
      }
   }
}

J0126 - 'catch' without 'try'

The compiler detected a catch block but did not find a corresponding try statement. To use a catch block you must have a try statement preceding it. Make sure you have a valid try statement, and then compile again.

The following sample illustrates this error.

public class Simple {
   
   public void method1() {
   
      catch {
         // error: missing corresponding 'try'
      }
   }
}

J0127 - 'else' without 'if'

The compiler detected the keyword else, but did not find a corresponding if statement. This error most likely occurs when there are scoping issues with regards to the placement of an else statement. This error can also occur if an else statement's corresponding if statement is missing.

The following sample illustrates this error.

public class Simple {
   
   public void method1() {
   
      else // error: no corresponding 'if'
         ;
   }
}

J0128 - Cannot declare an interface to be 'final'

The compiler detected an interface declared with the keyword final. Interfaces cannot be defined as final and thus cannot use the final modifier. Remove the final keyword from the interface's declaration, and then compile again.

The following sample illustrates this error.

final interface Simple {
   
   // error: 'final' only applies to
   // classes, methods or variables
   
}

J0129 - Cannot declare a class to be 'identifier' and 'identifier'

The compiler detected a class declared with modifiers that cannot be combined. Make sure that the modifiers you have applied to the class do not conflict with each other, and then make appropriate changes.

The following sample illustrates this error.

public abstract final class Simple {
   
   // error: 'abstract' and 'final' cannot
   // be used together in a class declaration
   
}

J0130 - Cannot declare an interface method to be 'native', 'static', 'synchronized' or 'final'

The compiler detected one of the keywords previously shown used in the declaration of an interface method. Because an interface method does not have implementation code, it cannot be declared as native, static, synchronized, or final.

The following sample illustrates this error.

interface Simple {
   
   public final void method1();
   // error: 'method1' cannot be declared 
   // as final in an interface
}

J0131 - Cannot declare a method to be 'identifier' and 'identifier'

The compiler detected the use of two or more incompatible modifiers in the declaration of a method. This error most likely occurs when a method has been defined with two access modifiers such as public and private. Make sure the modifiers for the method do not conflict with each other, and then make appropriate changes.

The following sample illustrates this error.

public class Simple {
   
   public private void method1() {
   
      // error: modifiers 'public' and 'private'
      // cannot be combined in a declaration
   }
}

J0132 - Cannot declare a field to be 'identifier' and 'identifier'

The compiler detected the use of two or more incompatible modifiers in the declaration of a variable. This error most likely occurs when a field has been defined with two access modifiers, such as public and private. Make sure the modifiers for the field do not conflict with each other, and then make appropriate changes.

The following sample illustrates this error.

public class Simple {
   
   public private int i;
   // error: modifiers 'public' and 'private' 
   // cannot be combined in a declaration
}

J0133 - Constructors cannot be declared 'native', 'abstract', 'static', 'synchronized', or 'final'

The compiler detected the use of one of the modifiers previously shown in the declaration of a constructor. Make sure that the constructor is not defined with any of the modifiers mentioned in the error message, and then compile again.

The following sample illustrates this error.

public class Simple {
   
   final Simple() {}
   // error: constructors cannot be 'final'
   
}

J0134 - Interfaces cannot have constructors

The compiler detected an interface containing a constructor declaration. Because an interface cannot be instantiated, constructors are not allowed to be defined for an interface. If you are defining a method with the same name as the method, make sure that it has appropriate modifiers to differentiate it from a constructor declaration.

The following sample illustrates this error.

interface Simple {
   
   Simple();
   // error: interfaces cannot 
   // declare constructors
   
}

J0135 - Interface data members cannot be declared 'transient', 'volatile', 'private', or 'protected'

The compiler detected one of the modifiers previously shown used in the declaration of an interface member variable.

The following sample illustrates this error.

interface Simple {
   
   volatile int i = 1;
   // error: 'volatile'cannot be used.
   
}

J0136 - Public class 'identifier' should not be defined in 'identifier'

The compiler detected more than one class declared with the modifier public in a source file. Remove the public access modifier from the other classes, and make sure that the class that will be exposed through the class file is declared as public. You can also move classes that need to remain declared as public to their own source file. This error can also occur if the source file does not have the same name as the public class.

The following sample illustrates this error.

public class Simple {
   
   // do something meaningful
   
}
public class Errorclass {
   
   // error: only one class may be defined as 
   // 'public' within the same source file
   
}

J0137 - Not used

This error message is currently not used.

J0138 - Interface cannot have static initializer

The compiler detected a static initializer within an interface. Because an interface does not get instantiated, initializers cannot be defined in an interface. To set the values of interface fields, initialize them at the time of declaration.

The following sample illustrates this error.

interface Simple {
   
   static {
      // error: static initializers cannot 
      // be used in interfaces
   }
   
}

J0139 - Invalid label

The compiler detected an invalid label. Labels must start with an alphanumeric character. Change the label, and then compile again.

The following sample illustrates this error.

public class Simple {

   public void method1() {
   
   123:
   // error: label cannot 
   // begin with alphanumeric
   
   return;
   
   }
}

J0140 - Cannot override static method 'identifier'

The compiler detected an attempt to override a static method from within a subclass. A method that has been declared as static cannot be overridden.

The following sample illustrates this error.

public class Simple {
   
   static void method1() {}
}
class SimpleSubclass extends Simple {
   
   void method1() {}
   // error: cannot override 
   // static method
}

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