Microsoft SDK for Java

J0264-J0500

J0264 J0265 J0266
J0267 J0268 J0269
J0270 J0271 J0272
J0273 J0274 J0275
J0276-J0499 J0500  

J0264 - Array cannot have a dimension

The compiler detected an attempt to initialize an array dimension incorrectly. This error usually occurs when an array dimension size is specified before the instance is created. This error can also occur when an array is given a dimension in the proper place but an initialization list is also provided to set the values of the array (you cannot specify an array size for the dimension when using an initialization list). Correct the initialization of the array specified by the error and compile again.

The following example illustrates this error.

public class Simple{
   public void method1(){
      String[3] var1; /* error: cannot specify array size here since
                         array is not instantiated yet */
      String[] var2 = new String[3]; //this is OK!
      
      boolean var3 = new boolean[3]{true,false,true};
      /*error: cannot specify an array size for the dimension when using
               an initialization list */
      boolean var4 = new boolean[]{true, false,true}; //this is OK!
   }
}

J0265 - @dll attribute cannot be placed on method 'identifier' — it must be declared 'native'

The compiler detected an @dll comment tag placed on a method that is not declared with the native modifier. This error usually occurs if an @dll comment tag is defined but the method it was applied to was removed or commented out, and other methods in the class can have the comment tag applied to them. Ensure that the method declared with the @dll comment tag is declared as native or remove the @dll comment tag and compile again.

The following example illustrates this error.

public class Simple{
   /** @dll.import("USER32") */
   //private native static int MessageBox(int hwndOwner, String text,
                                          String title, int fuStyle);
   
   /*error: the @dll comment tag cannot applied to 'method1' which is a
            non-native method instead of the intended native method*/
   public void method1(){
     //do something here
   }
}

J0266 - Compilation canceled by user

The user canceled compilation. This error simply informs the user that the request to cancel compilation was successful.

J0267 - A delegate cannot be 'identifier'

The compiler detected an attempt to declare a delegate with an invalid modifier. Only the public and final modifiers can be applied to a delegate declared outside of a class. A delegate declared within a class can have the public, final, protected, and private modifiers applied. Ensure that your delegate declaration is not using an invalid modifier and compile again.

Note   Although you can use the final modifier in a delegate declaration, it is not needed as delegates are implicitly final.

The following example illustrates this error.

private delegate void Simple(int var1, int var2);
//error: cannot declare a delegate as 'private'

J0268 - A delegate cannot be 'identifier' and 'identifier'

The compiler detected a delegate declaration, within a class, attempted to use a combination of access modifiers that are not allowed. This error usually occurs when a delegate is declared with two access modifiers applied. Remove the additional access modifier applied to the specified delegate declaration and compile again.

The following example illustrates this error.

public class Simple{
   public private delegate void SimpleDelegate();
   //error: cannot declare a delegate to be 'public' and 'private'
}

J0269 - Ambiguous name: inherited 'identifier' and outer scope 'identifier' — an explicit 'this' qualifier is required

The compiler detected reference to a variable or method from within an inner class that is defined in both its outer class and its superclass. The compiler cannot determine which variable or method is to be used. You can reference the outer class variable or method by using class.this.name, where class is the name of the outer class whose variable or method you wish to reference and name is the variable or method name. To reference the superclass variable or method you can use the this super keyword before the reference.

The following example illustrates this error.

class NotSimple{
   int var1 = 20;
}

public class Simple{
   int var1 = 10;
   class InnerClass extends NotSimple{
      int var2 = var1;
      //error: cannot determine which 'var1' to use
   }
}

The following example illustrates how to resolve name ambiguity between the outer class and superclass variables.

class NotSimple{
   int var1 = 20;
}

public class Simple{
   int var1 = 10;
   class InnerClass extends NotSimple{
      int var2 = Simple.this.var1;
      //this is OK and references the outer class variable
      int var3 = super.var1;
      //this is OK and references the superclass variable
   }
}

J0270

The compiler detected an ambiguous reference to a field. This error usually occurs when a class's superclass and an interface the class implements have the same field declared. The compiler cannot determine which instance of the field to use. Ensure that you do not have a superclass and implemented interface that have the same field defined and compile again.

The following example illustrates this error.

public class Simple extends SuperClass implements SuperInterface{
   public static void main (String args[]){
      float x = var1; /*error: cannot determine which instance of 'var1'
                               to use */
   }
}

class SuperClass{
   float var1;
}

interface SuperInterface{
   float var1=6.0f;
}

J0271 - Expected 'delegate'

The compiler detected the multicast modifier but did not detect the delegate keyword. The multicast modifier can only be used in conjunction with the delegate keyword to create multicast delegates. Ensure that you have the delegate keyword in the declaration specified by the error message and compile again.

The following example illustrates this error.

public multicast void SimpleDelegate(String x, int y);
//error: the 'delegate' keyword is missing after the 'multicast' modifier
public class Simple{
   //Do something here
}

J0272 - A multicast delegate cannot return a value

The compiler detected a return type other than void for a multicast delegate declaration. Although delegates can return a value other than void, multicast delegates cannot return a value other than void. Ensure that the multicast delegate declaration specified by the error returns void and compile again.

The following example illustrates this error.

multicast delegate int SimpleDelegate(int x, int y);
//error: cannot declare multicast delegate with non-void return type
public class Simple{
   public int method1(int x, int y){
      //Do something here
   }
   
   public static void main (String args[]){
      Simple smp = new Simple;
      SimpleDelegate sd = new SimpleDelegate(smp.method1);
   }
}

J0273

The compiler detected an attempt to cast the return value of a method call to void. Casting a method call to void is not allowed in the Java language. Remove the void cast for the method call specified by the error and compile again.

The following examples illustrates this error.

public class Simple{
   public void method1(){
      //Do something meaningful here
   }
   public static void main (String args[]){
      Simple smp = new Simple();
      (void) method1();
      //error: cannot cast method's return value to 'void'.
   }
}

J0274 - Expected 'identifier' within single comment preceding class 'identifier'

The compiler detected that the class, specified in the error message, was declared with either the @com.typeinfo or @com.transaction comment tag and a corresponding @com.register comment tag was not found within the same comment. This error can occur when an @com.register comment tag is declared but is within a separate comment. Ensure that an @com.register comment tag is defined within the same comment as the @com.typeinfo or @com.transaction comment tags defined for the class specified in the error message and compile again.

The following example illustrates this error.

/** @com.register ( clsid=AE032C46-E6A0-11d0-8C83-00C04FC2AAE7) */
/** @com.typeinfo(attrid=31415926-5358-9793-2384-612345678901,
value="Help") */
public class Simple{
   /error: the '@com.register' tag is ignored since it is in a separate
           comment */
}

/** @com.register ( clsid=AE032C46-E6A0-11d0-8C83-00C04FC2AAE7)
    @com.typeinfo(attrid=31415926-5358-9793-2384-612345678901,
value="Help")*/
public class Simple2{
   //This comment is OK. It combines both tags in a single comment.
}

J0275 - Class or interface name 'identifier' conflicts with package 'identifier'

The specified class or interface name conflicts with a package name. This error can be caused by declaring a class or interface within a package with the same name as a subpackage. Rename either the subpackage or the class or interface that is causing the ambiguity and compile again.

The following example illustrates this error.

//located in a file called Plastic.java
package Boxes.Dishes;
public class Plastic{
   //do something here
}

//located in a file called Dishes.java
package Boxes;
public class Dishes{
   //error: the name 'Dishes' is also the name of the subpackage
}

J0276 to J0499 – Not used

These error messages are currently not used.

J0500  - #error 'user defined error'

This error message is generated when there is a #error conditional compilation directive in the program.

The following example illustrates this error.

#define DEBUG
public class Simple{
   public void method1(){
      #if DEBUG
         #error You should not be running in debug mode here!
         //error: displayed when 'DEBUG' is defined
      #endif
   }
}

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