Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4143052

sun.tools.java.CompilerError reported in collectInheritedMethods()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • tools
    • sparc
    • solaris_2.5.1



      Name: tb29552 Date: 05/27/98


      The problem seems to be with the import statement
      at the top of the "BadCompileClass.java" file. If
      I remove the import statement and move all of the
      classes from the ./com/amtec/util/assertions
      directory to the same level as the "BadCompileClass.java"
      file the error goes away.

      To reproduce the problem set up the following
      directory structure:
      ./com
      ./com/amtec
      ./com/amtec/util
      ./com/amtec/util/assertions

      with the following command:
      mkdir -p com/amtec/util/assertions

      Add the following files (see source below):
      ./BadCompileClass.java
      ./com/amtec/util/assertions/Assert.java
      ./com/amtec/util/assertions/Check.java
      ./com/amtec/util/assertions/Ensure.java
      ./com/amtec/util/assertions/Invariant.java
      ./com/amtec/util/assertions/Require.java

      Compile the assertion classes with the following
      commands:
      cd ./com/amtec/util/assertions
      javac *.java

      Back up the directory tree and compile the
      BadCompileClass.java file with the following
      commands:
      cd ../../../..
      javac BadCompileClass.java

      The following error is produced:
          sun.tools.java.CompilerError: collectInheritedMethods()
              at sun.tools.java.ClassDefinition.collectInheritedMethods(ClassDefinition.java:1290)
              at sun.tools.java.BinaryClass.basicCheck(BinaryClass.java:60)
              at sun.tools.java.ClassDeclaration.getClassDefinition(ClassDeclaration.java:122)
              at sun.tools.java.MemberDefinition.exceptionsFit(MemberDefinition.java:692)
              at sun.tools.java.MemberDefinition.checkOverride(MemberDefinition.java:550)
              at sun.tools.java.MemberDefinition.checkOverride(MemberDefinition.java:456)
              at sun.tools.java.ClassDefinition.collectOneClass(ClassDefinition.java:1160)
              at sun.tools.java.ClassDefinition.collectInheritedMethods(ClassDefinition.java:1328)
              at sun.tools.java.BinaryClass.basicCheck(BinaryClass.java:60)
              at sun.tools.java.ClassDeclaration.getClassDefinition(ClassDeclaration.java:122)
              at sun.tools.java.Environment.getQualifiedClassDefinition(Environment.java:401)
              at sun.tools.java.Environment.resolve(Environment.java:228)
              at sun.tools.tree.IdentifierExpression.toResolvedType(IdentifierExpression.java:314)
              at sun.tools.tree.IdentifierExpression.checkAmbigName(IdentifierExpression.java:293)
              at sun.tools.tree.MethodExpression.checkValue(MethodExpression.java:135)
              at sun.tools.tree.MethodExpression.check(MethodExpression.java:389)
              at sun.tools.tree.ExpressionStatement.check(ExpressionStatement.java:41)
              at sun.tools.tree.Statement.checkBlockStatement(Statement.java:148)
              at sun.tools.tree.CompoundStatement.check(CompoundStatement.java:67)
              at sun.tools.tree.Statement.checkMethod(Statement.java:94)
              at sun.tools.javac.SourceMember.check(SourceMember.java:529)
              at sun.tools.javac.SourceClass.checkMembers(SourceClass.java:965)
              at sun.tools.javac.SourceClass.checkInternal(SourceClass.java:581)
              at sun.tools.javac.SourceClass.check(SourceClass.java:480)
              at sun.tools.javac.Main.compile(Main.java:391)
              at sun.tools.javac.Main.main(Main.java:571)
          error: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
          1 error


      Following is the source code:


      ./BadCompileClass.java
      ======================

      import com.amtec.util.assertions.*;


      public class BadCompileClass
          {
          public BadCompileClass(
              int option)
              {
              Require.condition(option >= 0);
              }
          }


      ./com/amtec/util/assertions/Assert.java
      =======================================

      package com.amtec.util.assertions;


      /**
       * Assertions provide a mechanism to enforce a client/server contract.
       * @see Invariant
       * @see Require
       * @see Ensure
       * @see Check
       **/
      public class Assert
          extends RuntimeException
          {
          /**
           * Assert the following condition.
           * @param assertion stated condition that must be true
           * @exception Assert thrown whenever the assertion fails
           **/
          public static void condition(
              final boolean assertion)
              throws Assert
              {
              if (!assertion)
                  throw new Assert();
              }


          /**
           * Assert the following condition. The assertion is not enforced it
           * is mearly a documented statement of the desired condition. It should
           * be used only for assertions that for one reason or another are
           * non-testable.
           * @param assertion stated condition that must be true
           **/
          public static void condition(
              final String assertion)
              {
              // serves only as a documentation tool for non-testable conditions
              }
          }


      ./com/amtec/util/assertions/Check.java
      ======================================

      package com.amtec.util.assertions;


      /**
       * Check assertion class.
       * This class is a place holder for catching general violations.
       * @see Assert
       **/
      public class Check
          extends Assert
          {
          /**
           * Check the following condition.
           * @param assertion stated condition that must be true
           * @exception Check thrown whenever the check condition fails
           **/
          public static void condition(
              final boolean assertion)
              throws Check
              {
              if (!assertion)
                  throw new Check();
              }
          }


      ./com/amtec/util/assertions/Ensure.java
      =======================================

      package com.amtec.util.assertions;


      /**
       * Ensure assertion class.
       * This class is a place holder for catching postcondition violations.
       * @see Assert
       **/
      public class Ensure
          extends Assert
          {
          /**
           * Ensure the following condition.
           * @param assertion stated condition that must be true
           * @exception Ensure thrown whenever the postcondition fails
           **/
          public static void condition(
              final boolean assertion)
              throws Ensure
              {
              if (!assertion)
                  throw new Ensure();
              }
          }


      ./com/amtec/util/assertions/Invariant.java
      ==========================================

      package com.amtec.util.assertions;


      /**
       * Invariant assertion class.
       * This class is a place holder for catching invariant violations.
       * @see Assert
       **/
      public class Invariant
          extends Assert
          {
          /**
           * Invariant check of the following condition.
           * @param assertion stated condition that must be true
           * @exception Invariant thrown whenever the invariant check conditon fails
           **/
          public static void condition(
              final boolean assertion)
              throws Invariant
              {
              if (!assertion)
                  throw new Invariant();
              }
          }


      ./com/amtec/util/assertions/Require.java
      ========================================

      package com.amtec.util.assertions;


      /**
       * Require assertion class.
       * This class is a place holder for catching precondition violations.
       * @see Assert
       **/
      public class Require
          extends Assert
          {
          /**
           * Require the following condition.
           * @param assertion stated condition that must be true
           * @exception Require thrown whenever the precondition fails
           **/
          public static void condition(
              final boolean assertion)
              throws Require
              {
              if (!assertion)
                  throw new Require();
              }
          }
      (Review ID: 30800)
      ======================================================================

            tturnidgsunw Todd Turnidge (Inactive)
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: