unexpected bahaviour with enum class

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Not an Issue
    • Priority: P2
    • None
    • Affects Version/s: 5.0
    • Component/s: tools
    • sparc
    • solaris_2.1

      The following enum when it was compiled it will generate a class file.
      The class file was executable with java.
      Which does n't look good,
      it starts executing and comes out with no main method exception.

      The following are the code and console for verification.
      vishalb:/home/vv145429/tiger/bugs/jan302k+4 82 % javac -source 1.5 Suit.java
      vishalb:/home/vv145429/tiger/bugs/jan302k+4 83 % java Suit
      no thing
      no thing
      thing = red
      thing = black
      Exception in thread "main" java.lang.NoSuchMethodError: main
      vishalb:/home/vv145429/tiger/bugs/jan302k+4 84 % cat Suit.java
      public enum Suit {
          clubs, diamonds,
          hearts("red") {
              public boolean comingUpDiamonds() { return true; }
          }
          ,
          spades("black");
          

          // constructors
          private Suit(String thing) {
              System.out.println("thing = " + thing);
          }
          private Suit() {
              System.out.println("no thing");
          }

          public boolean comingUpDiamonds() {
              return false;
          }
      }

      vishalb:/home/vv145429/tiger/bugs/jan302k+4 85 %

            Assignee:
            Joe Darcy
            Reporter:
            Viswadeep Veguru (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: