This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 70111 - Unexpected Exception thrown when using enum in a wrong place
Summary: Unexpected Exception thrown when using enum in a wrong place
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 5.x
Hardware: All Windows XP
: P2 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-08 19:20 UTC by pcdinh
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Netbeans error log (56.82 KB, text/plain)
2005-12-08 19:21 UTC, pcdinh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pcdinh 2005-12-08 19:20:38 UTC
This code has forced NetBeans IDE 200512072015, Java 1.6 rc-b62 throw an
unexpected exception.

package net.phpvietnam.java.swing;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.border.Border;
/**
 *
 * @author Admin
 */

    // This class represents a "canvas" that can display colored shapes
public class ShapeCanvas extends JPanel implements ActionListener {
    

    
    public enum shape { Rectangle, Circle, Eclipse, Polygon }
    Color currentLineColor = Color.red;     // default color; when a shape is
created, this is its color
    Color currentFillColor = Color.blue;     // default color; when a shape is
created, this is its color
    
    /** Creates a new instance of ShapeCanvas */
    // Constructor: set background color of the drawing area to white
    /*
    ShapeCanvas() {
        setBackground(Color.red);
    }
     */
    public void paintComponent(Graphics g) {
        
        super.paintComponent(g);
        // Call the paintComponent method from
        // the superclass, JPanel.  This simply
        // fills the entire component with the
        // component's background color.
        
        int width = getSize().width;   // Get this component's width.
        int height = getSize().height; // Get this component's height.
    }
    
    public void actionPerformed(ActionEvent event) {
        // Called to respond to action events.  The 4 shape-adding
        // buttons have been set up to send action events to this canvas.
        // Respond by adding the appropriate shape to the canvas.
        // This method is divided into 2 parts
        // 1: Determine which shape should be drawn: get the order from button event
        // 2: Get the order from JComboBox. If they exist, get the color and
paint them with the shape.
        
        // Check the color first because if I check the button first, I will
want to draw the Shapes
        // before I have any info on the colors ordered.
        // I will use a eventSource object to store information on the source
that generates the events
        // Please be advised that I have set the ActionCommand first. He he.pcdinh
        
        Object eventSource = event.getSource();
        
        System.out.println("Source: "+eventSource);
        
        if (eventSource instanceof JButton) {
            System.out.println("Source: JButton");
            
        }
        
        String command = event.getActionCommand();
        System.out.println("Command: "+command);
        if (command.equals("Rectangle")) {
            System.out.println("Command: "+command);
        } else if (command.equals("Circle")) {
        }
        
        else if (command.equals("Eclipse")) {
        }
        
        else if (command.equals("PolygonShape")) {
        }
    }
    
    private void drawShapes(enum shape) {
// Originally, I use private void drawShapes(String shape) but
// after that I decided to try out enum feature. An exception has been thrown.
        
        switch (shape) {
            case "Rectangle":
                break;
            case "Eclipse":
                break;
            default:
                break;
        }
        
    }

    
}


Log file is attached below
Comment 1 pcdinh 2005-12-08 19:21:23 UTC
Created attachment 27678 [details]
Netbeans error log
Comment 2 pcdinh 2005-12-08 19:25:57 UTC
It should be a warning: modifier enum not allowed here instead of a exception
Comment 3 Jan Becicka 2005-12-09 07:34:56 UTC
Tomasi, can you take a look at it?
Comment 4 pcdinh 2006-05-24 03:15:03 UTC
Hi, 

I tried to reproduce this bug in Netbeans 5.5 and it is still there.

java.lang.RuntimeException: Unexpected type of ASTree: 272
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.getElementProxy(MetadataElement.java:688)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.createElement(MetadataElement.java:554)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.initOrCreate(MetadataElement.java:1312)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.ParameterImpl.initChildren(ParameterImpl.java:347)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.ParameterImpl.getTypeName(ParameterImpl.java:154)
	at org.netbeans.jmi.javamodel.Parameter$Impl.getTypeName(Unknown Source)
	at
org.netbeans.modules.java.navigation.jmi.JUtils.getParameterType(JUtils.java:406)
	at
org.netbeans.modules.java.navigation.jmi.JUtils.extractParameterName(JUtils.java:390)
	at
org.netbeans.modules.java.navigation.jmi.JUtils.extractMethodName(JUtils.java:305)
	at org.netbeans.modules.java.navigation.jmi.JUtils.extractName(JUtils.java:247)
	at
org.netbeans.modules.java.navigation.ClassMemberModel.buildWString(ClassMemberModel.java:397)
	at
org.netbeans.modules.java.navigation.ClassMemberModel.buildMembersForPainting(ClassMemberModel.java:358)
	at
org.netbeans.modules.java.navigation.ClassMemberModel.loadContents(ClassMemberModel.java:331)
	at
org.netbeans.modules.java.navigation.spi.ListModelSupport$Loader.run(ListModelSupport.java:960)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:493)
[catch] at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:926)


This exception has been thrown on and on when the code line  private void
drawShapes(enum shape) { } was not fixed.
Comment 5 Jiri Prox 2006-10-05 11:14:43 UTC
Is this going to be fixed in 5.5? If not please change milestone to proper value.
Comment 6 Jan Becicka 2006-10-26 16:26:50 UTC
Javacore module was replaced by Retouche infrastructure. This bug is not valid
in trunk any more.
Comment 7 Quality Engineering 2007-09-20 09:46:47 UTC
Reorganization of java component