Microsoft SDK for Java

J0221-J0242

J0221 J0222 J0223
J0224 J0225 J0226
J0227 J0228 J0229
J0230 J0231 J0232
J0233 J0234 J0235
J0236 J0237 J0238
J0239 J0240 J0241
J0242    

J0221 - The @com attribute on member 'identifier' cannot be used in this kind of class or interface

The compiler has detected that an @com declaration was placed on a member of a class or method but because of the type of @com declaration used with the class or interface, it is not allowed. This error can occur in the following situations:

The following example illustrates this error.

/**@com.struct()*/
class Simple{
   /**@com.method(dispid=777)*/
   public native void method1();
   /*error: cannot use @com.method inside of
            @com.struct*/
}

J0222 - @com attribute cannot be placed on method 'identifier'-- it must be declared 'native' or be in an interface

The compiler has detected that a method was specified with an @com.method or @com.parameters declaration but the method was not declared with the native modifier or declared in an interface definition. For methods to be exposed through a COM interface, they must be either declared native from within a class declaration or be declared in an interface declaration.

J0223 - The @com.parameters declaration on member 'identifier' has the wrong number of parameters

The compiler has detected that the @com.parameters declaration, specified in the error message, has a different number of parameters than the method it is exposing through COM. Make sure that both the method's declaration and the @com.parameters declaration have the correct number of parameters, and then compile again.

The following example illustrates this error.

/**@com.interface(iid=31415926-5358-9793-2384-612345678910)*/
interface Itest{
   /** @com.method(dispid=306)
       @com.parameters([type=BOOLEAN] var1, var2, var3)
   */
   public void method1(boolean var1, int var2);
   /*error: extra parameter added to com.parameters
            declaration */
}

J0224 - 'return' must be the last item in an @com.parameters declaration

When declaring @com.parameters for a method, the return parameter must be the last parameter in the list. The compiler has detected the return parameter in a different position within the parameter list. Check the location of the return parameter in the @com.paramters declaration specified in the error message, make appropriate changes, and then compile again.

J0225 - An @com.'identifier' declaration is illegal for this kind of item

The compiler detected that an @com declaration was defined for the wrong type of item. This error most likely occurs as a result of a change to your code but not to the syntax or placement of an @com declaration. Make sure the proper @com declaration is used on the specified item in your code.

The following example illustrates this error.

/**@com.interface(iid=31415926-5358-9793-2384-612345678901,dual)*/
interface Itest{
   /**@com.struct()*/
   public int method1();
   //error: wrong type of @com attribute applied
}

J0226 - The @com declared type of 'identifier' is illegal for a dispatch or a dual interface

The compiler detected that an @com interface declaration, declared as either a dual or dispatch interface, has a member that contains an @com.parameters declaration with an incorrect type. Certain @com.parameters types are not allowed when the interface they are defined in is declared as either dual or dispatch interface. The following list shows which values are invalid for type.

J0227 - It is impossible for an expression of type 'identifier' to be an instance of 'identifier'

The compiler has detected that a comparison of two classes using the instanceof operator could never be instances of each other. To use the instanceof operator correctly, you must be comparing classes that have some common class lineage. Either change the expression containing the instanceof operator so that it uses a related class and instance for its comparison, or remove the expression, and then compile again.

The following example illustrates this error.

class Simple1{
   //do something meaningful here
}
class Simple2{
   //do something meaningful here
}
class CompClasses{
   Simple1 x = new Simple1();
   public static void main(String args[]){
   
   if(smp.x instanceof Simple2){
      /*error: nonrelated classes cannot be instances of each other*/
   }
}

J0228 - Syntax error in @dll declaration

The compiler has detected a syntax error in an @dll statement. This error most likely occurs when an @dll statement has been mistyped. Check the statement for syntactical errors, and then compile again.

J0229 - Expected string constant

The compiler detected a parameter of a comment tag's declaration (for example @com, @dll, or @security) that was expecting a string constant, was either missing it or it was incorrectly entered. This error most often occurs when matching quotes are missing around a value passed to an attribute. Check your comment tag declaration's attributes, and then compile again.

The following example illustrates this error.

/**@com.interface(iid=31415926-5358-9793-2384-612345678901,dual)*/
interface ITest{
   /**@com.method(name=method1);*/
   //error: Missing quotes around 'method1'
   public void method1();
}

J0230 - Class or interface name 'identifier' conflicts with import 'identifier'

The specified class or interface conflicts with a class that has been imported. This could be caused by declaring a class or interface that is already declared in the Java API and you are importing that API class or interface into your source file.

J0231 - Expression statement must be assignment, method call, increment, decrement, or 'new'

The compiler has detected an invalid expression statement. An expression statement is a statement that can reside on its own line of source code. The following are some examples of valid expression statements.

Method calls

m_cars.changeColor();

Assignment statements

int x = y + z;

Increment statement

j++;

m_tempVar1 += 3;

Use of the new keyword

new Simple();

The following are examples of invalid expression statements.

1+2;

Error: No assignment statement

j+k-method1();

A method call but not a valid assignment statement

var1 == var2;

Comparison statements should be contained in flow control statements

J0232 - Expected '{' or ';'

The compiler has detected an error with a method declaration in a class or interface. This error most likely occurs if an interface's method declaration is missing a semicolon at the end of the declaration or a class's declaration is missing its opening brace '{'. Check the specified class or interface method declaration and check for a missing semicolon or opening brace, and then compile again.

J0233 - Catch clause is unreachable; exception 'identifier' is never thrown in the corresponding try block

The compiler detected that the specified catch clause will never be executed because the corresponding try statement never throws the catch statement's exception type. Catch statements are required to catch exceptions or derivations of exceptions that the try statement can throw. This error can be avoided by changing the catch statement so it does not catch a specific exception type but catches the base Exception class. Change the exception class so that your catch statement will trap it, and then compile again.

J0234 - 'identifier' is not a field in class 'identifier'

The compiler detected a field reference but the field does not exist in the specified class. This error most likely occurs when the field reference is mistyped or the field reference was meant to reference a field in a different class. Make sure that the field exists in the specified class and that your reference to the field is syntactically correct, and then compile again.

J0235 - 'identifier' is not a method in class 'identifier'

The compiler detected a method call but the method does not exist in the specified class. This error most likely occurs when the method call is called incorrectly or the method call was meant to reference a method in a different class. Make sure that the method exists in the specified class and that your method call is syntactically correct.

J0236 - 'identifier' is not a nested class or interface in class 'identifier'

The compiler has detected a reference to a nested class or interface but the nested class or interface does not exist in the specified class. This error most likely occurs because of a syntactical error in referencing a nested class or interface. Check the reference to the inner class for syntax errors and make sure that the class or interface exists inside the specified class, and then compile again.

The following example illustrates this error.

class NotSimple{
}
public class Simple{
   void method1(){
      NotSimple nt = new NotSimple();
      Object o = nt.new InnerClass();
      //error: 'InnerClass' is not an inner class of 'NotSimple'
   }
}

J0237 - 'identifier' is not a field or nested class in class 'identifier'

The compiler has detected a reference to a nested class or field but the nested class or field does not exist in the specified class. This error most likely occurs because of a syntactical error in referencing a nested class or field. This error can also occur if a reference to a field in an inner class is made but the field does not exist within the inner class definition. Check to make sure the inner class or field exists, and then compile again.

J0238 - Cannot throw exception 'identifier' from field initializer

The compiler has detected that an exception was thrown within a field initializer. This error most likely occurs when an exception can be thrown from a constructor of a class, and an instance of that class is declared and instantiated as a member of another class. To resolve this problem, have the class object that throws the exception instantiated inside a constructor so it can use a try and catch combination to trap any exceptions from the other class's constructor call.

The following example illustrates this error.

public class Simple{
   public int i;
   public Simple(boolean var1) throws Exception{
      if (var1 = true)
         i = 0;
      else
         throw new Exception();
   }
}
//This is the incorrect way to instantiate this class
class Simple2{
   Simple smp = new Simple(true);
   /* error: cannot call constructor that throws exception in field
            initializer*/
}

J0239 - Static initializer must assign a value to blank final variable 'identifier'

The compiler detected that a static final variable was not initialized to a value using a static or field initializer. To declare a variable as static and final, you must use a static or field initializer to set an initial value. This error can also occur if a field is declared as static and final and assigned a value in a constructor.

The following example illustrates this error.

public class Simple{
   static final int MAX_CONTROL;
} //error: static final variables must have value assigned

J0240 - Syntax error in @security declaration

The compiler detected a syntax error in the specified @security comment tag. This error most likely occurs when the comment tag is missing a closing parenthesis or the tag's attributes are incorrect. Check the syntax of the specified @security comment tag declaration, and then compile again.

The following example illustrates this error.

/**@security()*/   //error: invalid @security syntax
public class Simple{
   //Class members defined here
}

J0241 - '@security' can only be specified on a class or interface

The compiler detected that the @security comment tag was applied to something other than a class or interface declaration. @security comment tags are used to define the security settings for a class or interface definition and cannot be applied to methods or fields of a class or interface.

J0242 - Cannot make static call to nonstatic method 'identifier'

The compiler has detected that a method was called by using the static method call syntax of '<classname>'.'<method>', but the method is not a static method. Change the method call to use an instance of the class that contains the method instead of the class name itself, and then compile again.

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