Microsoft SDK for Java

J0243-J0263

J0243 J0244 J0245
J0246 J0247 J0248
J0249 J0250 J0251
J0252 J0253 J0254
J0255 J0256 J0257
J0258 J0259 J0260
J0261 J0262 J0263

J0243 - 'identifier' is obsolete; use 'identifier' instead

The compiler detected a comment tag (for example @com, @dll, @security) that is using a format that is now considered obsolete. To avoid this error, change the line of code that the error occurred on to the newer format specified in the error message and compile again.

The following example illustrates this error.

public class Simple{
   /**@dllimport("kernel32", ansi)*/
   /* error: 'dllimport' is no longer a supported format for
      @dll.import declarations */
   public static native boolean GetComputerName(StringBuffer s, int[]cb);
}

J0244 - @conditional allowed only on void-returning methods

The compiler detected an @conditional comment tag for a method that has a non-void return value. The @conditional comment tag can only be used for methods without a return value. Change the method declaration to return void or remove the @conditional comment tag and compile again.

The following example illustrates this error.

public class Simple{
   /**@conditional(DEBUG)*/
   public int method1(int x){
      //error: conditional methods cannot return a value
   return x * 2;
   }
}

J0245 - Warning treated as error

The compiler was run using the /wx switch, and a warning was found during compilation. The /wx compiler switch treats all warnings as errors. In order for the /wx compiler switch to display this error, the warning level switch (/w{0-4}) must be set high enough to display the warning. Determine the cause of the warning and compile again. You can also remove this switch from your compiler options and compile again.

J0246 - Invalid token on a # directive

The compiler detected an invalid token for a conditional compilation expression. This error usually occurs when a token is mistyped or the token used is not a legal token. Ensure that the conditional compilation directive specified in the error is correct and compile again.

The following example illustrates this error.

public class Simple{
   public void method1(){
      #iff DEBUG //error: 'iff' is not a valid token
        System.out.println("Do something meaningful here");
      #endif
   }
}

J0247 - #elif without matching #if

The compiler detected a #elif conditional compilation directive, but did not detect a matching #if directive. Ensure that you have a valid #if conditional compilation directive to match your #elif directive and compile again.

The following example illustrates this error.

public class Simple{
   public void method1(){
      //error: need to have '#if' before '#elif'
      #elif DEBUG
         System.out.println("Do something meaningful here");
      #endif
   }
}

J0248 - #endif without matching #if

The compiler detected a #endif conditional compilation directive, but did not detect a matching #if directive. This error usually occurs because an extra #endif directive was supplied. This error can also occur when a #if conditional compilation directive was deleted or commented out but the matching #endif directive was not deleted. Ensure that you have matching directives and compile again.

The following example illustrates this error.

public class Simple{
   public void method1(){
      //#if SIMPLE
      //do something here
      #if DEBUG
          //do something here
          #if WIN95
             //do something here
          #endif
      #endif
      #endif //error: extra '#endif' directive not permitted
   }
}

J0249 - #else without matching #if

The compiler detected a #else conditional compilation directive but, did not detect a matching #if directive. This error usually occurs because an extra #else directive was supplied. This error can also occur when a #if conditional compilation directive was deleted or commented out but a #else directive was not deleted. Ensure that you have matching directives and compile again.

The following example illustrates this error.

public class Simple{
   public void method1(){
      //do something here
      #else /*error: this '#else' directive has no matching '#if'
              directive */
   }
}

J0250 - Already had an #else

The compiler detected a duplicate #else conditional compilation directive in a #if directive block. A #if directive can only have one #else directive. Ensure that you have only one #else conditional compilation directive for the #if directive in which the error occurred and compile again.

The following example illustrates this error.

public class Simple{
   #if A
     #if B
     void method1{
       //do something here
     }
   #else
     void method2{
       //do something here
   #else  //error: extra '#else' directive supplied
   #endif
}

J0251 - Unexpected EOF while looking for #endif

The compiler detected a #if conditional compilation directive but did not find a matching #endif directive, and the symbol used by the #if directive was not defined. This error usually occurs when a #if conditional compilation directive is used but a matching #endif directive was not defined to close the conditional compilation block. Ensure that you have a matching #endif directive for the #if directive specified in the error and compile again.

The following example illustrates this error.

public class Simple{
   void method1(){
      #if DEBUG //debug has not been defined
         System.out.println("Do something here");
   //error: '#endif' not specified for the '#if' directive
   }
}

J0252 - #if nested too deeply

The compiler detected nested #if conditional compilation blocks that were nested too deeply. Nesting of #if conditional compilation blocks is limited to 64 levels. Ensure that your nesting of #if blocks is within the limit and compile again.

J0253 - Cannot have #define/#undef after source

The compiler detected a #define or #undef conditional compilation directive after other Java source code. The #define and #undef directives must be placed before other Java source code (except for other conditional compilation directives and source comments). Move the #define or #undef directive indicated by the error to the front of all Java source code in the file and compile again.

The following example illustrates this error.

package boxes;

#define DEBUG 
//error: '#define' must occur before the 'package' statement

public class Simple{
}

J0254 - Cannot change predefined symbol

The compiler detected an attempt to use the #define or #undef directive on a symbol already defined in Java. This error occurs when a symbol such as true or false, which are already defined for conditional compilation, is redefined using the #define or #undef conditional compilation directives. Remove or change the #define or #undef directives specified in the error and compile again.

The following example illustrates this error.

#undef false //error: cannot undefine the 'false' symbol
#define true //error: cannot define the predefined 'true' symbol

public class Simple{
   //do something here
}

J0255 - Expected #endif

The compiler detected a #if conditional compilation directive but did not find a matching #endif directive; however, the symbol used by the #if directive was defined. This error usually occurs when a #if conditional compilation directive is used but a matching #endif directive in not defined to close the conditional compilation block, and the code is intended to be compiled. Ensure that you have a matching #endif directive for the #if directive specified in the error and compile again.

The following example illustrates this error.

#define DEBUG

public class Simple{
   void method1(){
      #if DEBUG 
         System.out.println("Do something here");
   //error: '#endif' has not been specified for the '#if' directive
   }
}

J0256 - Expected 'class', 'interface', or 'delegate'

The compiler expected to find the class, interface, or delegate keywords used within the corresponding declaration. This error usually occurs when the keywords are accidentally omitted from a class, interface, or delegate declaration. Another possible cause of this error is unbalanced scoping braces.

Note   This error will only occur if the Microsoft Extensions are enabled in your project. Otherwise, compiler error J0020 will be displayed.

The following example illustrates this error.

public Simple{ //error: missing the 'class' keyword
   //Do something here
}

This example illustrates this error caused by unbalanced scoping braces.

public class Simple {
   
   // do something meaningful
   
}}   // error: additional '}' is not permitted

J0257 - Delegate cannot be initialized with static method 'identifier'

The compiler detected a delegate instantiation but the method reference, passed as a parameter, was a static method. When instantiating a delegate, you must pass a non-static method as a parameter. Ensure that the method you are defining the delegate to use is a non-static method and compile again.

The following example illustrates this error.

delegate int MyDelegate (int var1, String var2)throws Exception;

public class Simple{

   public static int method1(int var1, String var2) throws Exception{
      //do something here
      return var1;
   }
   
   public static void main (String args[]){
      Simple smp = new Simple();
      MyDelegate md = new MyDelegate(smp.method1);
      /*error: the method passed as a parameter to the delegate is a
               static method */
   }
}

J0258 - Cannot declare delegate in inner class 'identifier'

The compiler detected an attempt to declare a delegate inside an inner class. Inner class definitions do not support delegates declared within them. Remove the delegate declaration from within the inner class declaration and compile again.

The following example illustrates this error.

public class Simple{
   //Do something meaningful here
   class InnerClass{
   //Do something meaninful here
      delegate int MyDelegate (int var1, String var2);
         /*error: delegates cannot be declared
                  inside inner classes */
   }
}

J0259 - Exception 'identifier' from method 'identifier' is not a subclass of       any exceptions declared thrown by delegate 'identifier'

The compiler detected a delegate that was initialized with a method that throws an exception that is incompatible with the delegate's declared set of exceptions. Each exception thrown by the method must be the same class or a subclass of an exception that the delegate throws. Change the set of exceptions thrown by either the delegate or the method and compile again.

The following example illustrates this error.

delegate void SimpleDelegate(String var1) throws Exception;

public class Simple{
   public void method1(String var1) throws Throwable{
      //do something here
   }
   public static void main (String args[]){
      
      Simple smp = new Simple();
      SimpleDelegate del1 = new SimpleDelegate(smp.method1);
      /* error: the method reference argument throws an exception that is
             not the same or a subclass of the exception declared by the
             delegate */
   }
}

J0260 - Cannot declare an interface method to be 'protected' or 'private'

The compiler detected an interface with a method declared as protected or private. Interface methods must be declared as either public or with no access modifier (default). Change the interface method declaration specified in the error so that it is not declared protected or private and compile again.

The following example illustrates this error.

interface ISimple{
   public void method1(); //this is OK!
   void method2(); //this is OK! Declared as "default" access
   protected void method3(); /*error: cannot declare interface method as
                                      protected */
   private void method4(); /*error: cannot declare interface method as
                                    private */
}

J0261 - An explicit enclosing instance of class 'identifier' is needed to instantiate inner class 'identifier'

The compiler detected an attempt to create an instance of an inner class without specifying an instance of its enclosing class. This error usually occurs when an attempt is made, within a static method, to instantiate an inner class as you would an outer class. To create an instance of an inner class, you must use an existing instance of its outer class. Create an instance of the enclosing class and use it to instantiate the inner class and compile again.

The following example illustrates this error.

public class Simple{
   class InnerClass{
      //do something here
   }
   
   public static void main(String args[]){
      InnerClass inc = new InnerClass();
      /*error: an instance of the outer class is required to instantiate
               its inner class */
   }
}

The following example illustrates how to create an instance of an inner class using an instance of its outer class.

public class Simple{
   class InnerClass{
      //Do something here
   }
   public static void main(String args[]){
      Simple smp = new Simple();
      /*use the instance of 'Simple' to create an instance of its inner
        class*/
      InnerClass inc = smp.new InnerClass();
   }
}

J0262 - An explicit enclosing instance of class 'identifier' is needed to call constructor of superclass 'identifier'

The compiler detected an attempt by a derived class to call its superclass constructor without an instance of the superclass. This error usually occurs because the superclass is also an inner class. When a derived class is instantiated, an instance of its superclass is also created (and the superclass constructor is invoked). In order to create an instance of an inner class you must instantiate the inner class using an instance of its outer class.

The following example illustrates this error.

class OuterClass{
   class InnerClass{
   //do something here
   }
}

public class Simple extends OuterClass.InnerClass{
   //do something here
}
/*error: superclass 'InnerClass' cannot be instantiated without its outer class 'OuterClass' being instantiated */

The following example illustrates how to instantiate a class that is derived from an inner class.

class OuterClass{
   class InnerClass{
   //do something here
   }
}

public class Simple extends OuterClass.InnerClass{
   Simple(){
      /*this line creates an instance of the outer class and calls
        the superclass (the inner class) constructor */
      new OuterClass().super();
   }
}

J0263 – Not used

This error message is currently not used.

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