Microsoft SDK for Java

J0021-J0040

J0021 J0022 J0023
J0024 J0025 J0026
J0027 J0028 J0029
J0030 J0031 J0032
J0033 J0034 J0035
J0036 J0037 J0038
J0039 J0040  

J0021 - Expected type specifier

The compiler expected to find a type specifier in the position indicated by the error message. Other errors may accompany this error due to the missing type specifier.

The following example illustrates this error.

public class Simple {
   
   public Object o =new; //error: missing 'Object' type specifier
}

J0022 - Expected end of file

The compiler expected to encounter an end-of-file character, but did not. This error most likely occurs when the source file has been damaged in some way. Try visually checking the source file for obvious corruption, save any changes, and then compile again.

J0023 - Expected 'catch' or 'finally'

The compiler expected to find a catch or finally block immediately following a corresponding try block.

The following sample illustrates this error.

public class Simple {
   
   public void method1( ) {
   
      try {
         // do something meaningful
      }
   
   } // error: 'catch' or 'finally' not found
}

J0024 - Expected method body

The compiler expected to find a method body immediately following a method declaration. This error most likely occurs when the braces surrounding the method body are not properly balanced. This error may also occur when the method was intended to be abstract or native, but the abstract or native keyword was mistakenly omitted from the method declaration.

The following sample illustrates this error.

public abstract class Simple {
   
   public void method1( ); 
   // error: 'abstract' omitted
   
}

J0025 - Expected statement

The compiler expected to find a statement before the end of the current scope. This error most likely occurs when the right brace designating the end of the current scope is misplaced.

The following sample illustrates this error.

abstract class Simple {
   
   void method1() { 
   
      if (1)
      // error: a statement is required 
      // after the if statement
   }
}

J0026 - Expected Unicode escape sequence

The compiler expected to find a valid Unicode escape sequence. This error most likely occurs when a syntactical error is found in a Unicode escape sequence.

The following sample illustrates this error.

public class Simple {
   
   int i = \\u0032; 
   // error: '\\' not invalid 
   
}

J0027 - Identifier too long

The compiler detected an identifier name with a length greater than 1024 characters. Shorten the identifier name, and then compile again.

J0028 - Invalid number

The compiler detected a numeric value that the Java language is not capable of supporting. This error most likely occurs when the number specified is an amount greater than any of the Java language's primitive types can accept.

The following sample illustrates this error.

public class Simple {
   
   long i = 12345678901234567890; 
   // error: value out of range
   
}

J0029 - Invalid character

The compiler detected an ASCII character that could not be used in an identifier. This error most likely occurs when a class, interface, method, or variable identifier includes an invalid character.

The following sample illustrates this error.

public class Simple {
   
   private int c#; 
   // error: '#' not supported
   
}

This error may also occur when you compile code that uses conditional directives (such as #if, #else, #endif, #define, and so on) without enabling the Microsoft language extensions. The Microsoft compiler for Java (jvc.exe) now disables Microsoft language extensions by default. To enable Microsoft extensions, use the /x- option with jvc. To define conditional compilation symbols, you should also use the /D <symbol> option:

jvc /x- /D <symbol>  Test.java

Compiling with the /x- option generates a message warning that the use of Microsoft extensions results in compiled code that will run only on Windows systems with the Microsoft virtual machine installed and may not run on other virtual machines. You can disable this message by using the /nomessage option with jvc. For example:

jvc /x- /D <symbol> /nomessage Test.java

J0030 - Invalid character constant

The compiler detected an attempt to assign an invalid character or character escape sequence to a variable of type char.

The following sample illustrates this error.

public class Simple {
   
   char c = '\'; 
   // error: invalid escape character
   
}

J0031- Invalid escape character

The compiler detected the use of an invalid escape character. This error most likely occurs when a syntactical error is found in a Unicode escape sequence.

The following sample illustrates this error.

public class Simple {
   
   int i = \u032; 
   // error: Unicode uses 4 hex digits
   int x = \u0032;
    //correct assignment of a unicode escape sequence
   
}

J0032 - Unterminated string constant

The compiler did not detect a terminating double-quote character at the end of a string constant. This error most likely occurs when the string terminator is accidentally omitted, or when the string constant is mistakenly divided onto multiple lines.

The following sample illustrates this error.

public class Simple {
   
   String str = "Hello
   // error: '"' and ';' omitted
   
}

J0033 - Unterminated comment

The compiler detected the beginning of a block comment, but did not detect a valid ending for it. This error most likely occurs when the comment terminator is accidentally omitted.

The following sample illustrates this error.

public class Simple {
   
   /* This comment block
    * does not have a valid
    * terminator
   
}

J0034 - Not used

This error message is currently not used.

J0035 - Initializer block must be declared 'static'

The compiler detected a modifier other than static associated with an initializer. Initializers can only use the static keyword to specify the initializer as a static initializer or no modifier to signify that the initializer is a field initializer. Remove the modifier from the initializer specified in the error message or add the static modifier to the initializer, and then compile again.

The following sample illustrates this error.

public class Simple {
   
   static private int i;
   
   {   // error: 'static' omitted
      i = 1;
   }
}

J0036 - A data member cannot be 'native', 'abstract' or 'synchronized'

The compiler detected one of the modifiers previously shown used in the declaration of a variable. The modifiers synchronized and native can only be applied to method declarations. The abstract modifier can be applied to methods, classes, and interfaces.

J0037 - A method cannot be 'transient' or 'volatile'

The compiler detected one of the modifiers shown above used in the declaration of a method. The modifiers transient and volatile can only be applied to field declarations.

J0038 - 'final' members must be initialized

The compiler detected an uninitialized final variable in an interface definition. Variables declared as final in an interface definition must have their value set at declaration. Once set, the value cannot be programmatically changed.

The following sample illustrates this error.

public class Simple {
   
   private final int COOL_RAD; 
   // error: must have value set
   
}

Note that variables declared within interfaces are implicitly defined as final or static. As such, this error also occurs when their initial values are not set at declaration.

J0039 - Not used

This error message is currently not used.

J0040 - Cannot define body for abstract/native methods

The compiler detected a method body defined immediately following the corresponding declaration of an abstract or native method. An abstract method must have its implementation code defined in a subclass. Native methods are implemented using code of a native language, such as C++.

The following sample illustrates this error.

public interface Simple {
   
   public void method1() {
      // error: must define this method body
      // in a class that implements the 
      // 'Simple' interface
   }
}

Note that methods declared within an interface are implicitly abstract. As such, this error will also occur when you attempt to define a method body in an interface.

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