Watch, Follow, &
Connect with Us
Public Report
Report From: JBuilder/Designers    [ Add a report in this area ]  
Report #:  14360   Status: Reported
Designer fails when class has an enum field (w/ jdk1.5).
Project:  JBuilder Build #:  11.0.320.0
Version:    11 Submitted By:   Khalid Zubair
Report Type:  Basic functionality failure Date Reported:  7/13/2005 3:25:27 PM
Severity:    Serious / Highly visible problem Last Updated: 7/14/2005 8:13:34 AM
Platform:    All Unix platforms Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (3 Total Ratings)
3.33 out of 5
Total Votes: 14
Description
I switched to Java 5 and started adding new enums where neccessary. The GUI designer stopped working at that point, I was able to trace the problem to classes having enum values as fields.
I was then able to reproduce the same errors in a very simple class.
Steps to Reproduce:
1. Set the language features/jvm to v5.0 under project    
   settings.
2. Create a public enum, like below:

package bug;

public enum Planet {
    MERCURY (3.303e+23, 2.4397e6),
    VENUS   (4.869e+24, 6.0518e6),
    EARTH   (5.976e+24, 6.37814e6),
    MARS    (6.421e+23, 3.3972e6),
    JUPITER (1.9e+27,   7.1492e7),
    SATURN  (5.688e+26, 6.0268e7),
    URANUS  (8.686e+25, 2.5559e7),
    NEPTUNE (1.024e+26, 2.4746e7),
    PLUTO   (1.27e+22,  1.137e6);

    private final double mass;   // in kilograms
    private final double radius; // in meters
    Planet(double mass, double radius) {
        this.mass = mass;
        this.radius = radius;
    }
    public double mass()   { return mass; }
    public double radius() { return radius; }

    // universal gravitational constant  (m3 kg-1 s-2)
    public static final double G = 6.67300E-11;

    public double surfaceGravity() {
        return G * mass / (radius * radius);
    }
    public double surfaceWeight(double otherMass) {
        return otherMass * surfaceGravity();
    }
}

-------

3. Create a new Class that extends from a JPanel or
   JFrame. Switch to Designer and it works fine, try
   adding a few components.

4. Now, add a private field of enum type defined in 2.

5. Switch to designer, you'll get some warnings:

Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Unable to load bug.Planet.  Please check that bug.Planet is compiled.
java.lang.SecurityException: Prohibited package name: java.lang

6. Now add a getter to the field added in 4. Designer
   stops working altogether. Final picture of class:

package bug;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JPanel;


public class SimpleTest extends JPanel {
    BorderLayout borderLayout1 = new BorderLayout();
    JButton jButton1 = new JButton();
    private Planet field1;


    public SimpleTest() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.setLayout(borderLayout1);
        jButton1.setText("BigButton");
        this.add(jButton1, java.awt.BorderLayout.CENTER);
    }

    public Planet getField1(){
        return field1;
    }
}
------

   Errors when switching to designer:

Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Failed to create live visual subcomponent this (BorderLayout) as . Creating a red component in its place
Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Failed to create live visual subcomponent jButton1 as JButton jButton1 = new JButton();. Creating using default constructor javax.swing.JButton
Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  
Problems encountered while processing the source code.  Please check for possible syntax errors or uninitialized fields and variables.  


Workarounds
none yet.
Attachment
enumbug.zip
Comments

Khalid Zubair at 7/14/2005 8:11:52 AM -
Add your comments here.

Martin Tonge at 6/15/2006 5:59:52 AM -
Don't believe that the designer interpreter works with Java 5 language features. The same errors occur where generics are used inconjunction with a widget.

Khalid Zubair at 10/5/2005 7:37:21 AM -
Anyone looked at this yet?

Khalid Zubair at 10/5/2005 7:37:33 AM -
Anyone looked at this yet?

Khalid Zubair at 10/6/2005 9:14:26 AM -
It's not limited to Classes with enum fields, but to all classes that have a method that returns or requires an enum as an arg.

Jeff Saler at 8/25/2006 11:45:43 AM -
In Windows XP, I get the following error messages when switching to design mode for a JDialog which has a variable whose type is an enum from another class:

class java.lang.SecurityException Prohibited package name: java.lang
Unable to design NewECSDialog.java.  Make sure that the file is in the current project, does not contain any syntax errors, and that all resources are compiled.

Server Response from: ETNACODE01