Uploaded image for project: 'BlueJ'
  1. BlueJ
  2. BLUEJ-620

Enum value with body messes up object bench/codepad

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: CodePad
    • Sprint:
      Wish List

      Description

      Pretty obscure bug. If you use an enum with a body, it is technically given a different type by the Java runtime, I believe. If you try to "Get" this enum value on to the object bench, the codepad will no longer work (returning "<identifier expected>" for "1+2"), I presume because we are generating bad code in the shell class. To reproduce, use this code:

      enum Color
      {
          RED(255,0,0), // Constructor arguments
          GRAY(128,128,128)  // Individual body:
          {  
              public String toString() { return "gray/grey"; }
          },
          BLACK(0,0,0);
      
          // Group body:
          int red, green, blue;
          private Color(int red, int green, int blue)
          {
              this.red=red;this.green=green;this.blue=blue;
          }
      }
      

      Then inspect the Color class, and try to "Get" the middle enum (grey) to the object bench, then use the codepad.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              nccb Neil Brown
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: