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 46580 - ClassCastException when trying to edit Annotations source file with enum in it
Summary: ClassCastException when trying to edit Annotations source file with enum in it
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: PC All
: P2 blocker (vote)
Assignee: Martin Matula
URL:
Keywords:
: 49385 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-07-26 17:14 UTC by dkkopp
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Source file that cannot be opened (1.22 KB, text/plain)
2004-07-26 17:15 UTC, dkkopp
Details
stack trace (10.65 KB, text/plain)
2004-07-26 17:15 UTC, dkkopp
Details
Java code that is causing exception (1.25 KB, patch)
2004-08-18 15:10 UTC, dkkopp
Details | Diff
stack trace (2.09 KB, text/plain)
2004-08-18 15:11 UTC, dkkopp
Details
DTD that validates tree dumps (32.50 KB, text/plain)
2004-08-18 15:59 UTC, Martin Matula
Details
ant script that validates AST dumps (196 bytes, text/plain)
2004-08-18 16:00 UTC, Martin Matula
Details
Project displaying problem (10.49 KB, application/octet-stream)
2004-08-25 12:40 UTC, dkkopp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dkkopp 2004-07-26 17:14:44 UTC
Issue 46107 has been fixed, but now this has come
up. I will be attaching the source file that
cannot be opened as well as the stack trace.
Comment 1 dkkopp 2004-07-26 17:15:22 UTC
Created attachment 16459 [details]
Source file that cannot be opened
Comment 2 dkkopp 2004-07-26 17:15:41 UTC
Created attachment 16460 [details]
stack trace
Comment 3 dkkopp 2004-08-02 23:11:48 UTC
I did a little more investigation and found that the problem is the
attributes with a default value set to an enum. The parser is not
handling this case.
Comment 4 Tomas Hurka 2004-08-03 10:43:50 UTC
Yes, problematic part is annotation attribute with default value like this one:

SessionBeanType beanType() default SessionBeanType.STATELESS;

This is correctly recognized as AStreeTypes.ANNOTATION_ATTRIBUTE_DECLARATION, 
but getText() for that ASTree returns "SessionBeanType beanType() default", so the last 
token is wrong and subtree at index 3 should have type AStreeTypes.DEFAULT_VALUE 
but now it returns MULTI_PART_ID.
Comment 5 _ tball 2004-08-06 22:16:42 UTC
Fixed incorrect token range for annotation attributes with default values.
Comment 6 dkkopp 2004-08-18 15:10:48 UTC
Created attachment 16922 [details]
Java code that is causing exception
Comment 7 dkkopp 2004-08-18 15:11:19 UTC
Created attachment 16923 [details]
stack trace
Comment 8 dkkopp 2004-08-18 15:12:09 UTC
This is still not working correctly. I have tried the latest Q build
(15 August I think) and the 17 August daily build. I have attached the
problem file and the stack trace again.
Comment 9 Martin Matula 2004-08-18 15:58:06 UTC
I tried to dump the attached source code with DumpXMLTree and it seems
that the description provided by Tomas still applies (the default
value is not represented using DEFAULT_VALUE tree type).
To make the testing easier, attached is a simple ant script and dtd
that validates the dumped XML documents. Just place it into the same
dir as the dumped XML files and run ant. Currently it fails for the
file provided by David.
Comment 10 Martin Matula 2004-08-18 15:59:37 UTC
Created attachment 16925 [details]
DTD that validates tree dumps
Comment 11 Martin Matula 2004-08-18 16:00:11 UTC
Created attachment 16926 [details]
ant script that validates AST dumps
Comment 12 _ tball 2004-08-20 01:37:25 UTC
Finally nailed this:  I was storing the default tree directly in the
annotation tree, but needed to wrap it first in a DEFAULT_VALUE tree.
 Martin's validation test now passes.
Comment 13 dkkopp 2004-08-24 13:56:08 UTC
Well, this is still not fixed for me either by 4.0 beta 1 or the
August 23 daily build.
Comment 14 _ tball 2004-08-24 23:56:57 UTC
Please attach the other sources in
mil.army.logsa.elfs.annotations.ejb, at least those so that the
example can compile outside of your system, as I cannot verify the
attached example without them.  When you do so, please also reassign
this issue back to me.

Thanks for your help.
Comment 15 dkkopp 2004-08-25 12:40:25 UTC
Created attachment 17127 [details]
Project displaying problem
Comment 16 dkkopp 2004-08-25 12:41:30 UTC
Thomas,

I have attached the NB 4 project. I get the ClassCastException when I
open up EjbSessionBean.java for editing.

Thanks for taking a look at this again.
Comment 17 Martin Matula 2004-08-25 14:40:52 UTC
This is no longer caused by a bug in gjast. These exceptions are
caused by a bug in MDRParser - a switch branch for handling
DEFAULT_VALUE tree types is missing.
Comment 18 Martin Matula 2004-08-25 15:35:37 UTC
The bug is now fixed. However, I found out that finding usages in
default values does not work currently due to another bug in nodes. I
will file a separate issue for that.

Checking in src/org/netbeans/modules/javacore/parser/MDRParser.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/parser/MDRParser.java,v
 <--  MDRParser.java
new revision: 1.45; previous revision: 1.44
done
Comment 19 Martin Matula 2004-08-25 15:38:59 UTC
The bug causing find usages to not work in annotation attribute
default value has been filed as issue 47923.
Comment 20 Tomas Hurka 2004-09-22 09:43:16 UTC
*** Issue 49385 has been marked as a duplicate of this issue. ***
Comment 21 Jiri Prox 2005-07-11 15:24:53 UTC
Verified in 4.2 (200507110943)
Comment 22 Quality Engineering 2007-09-20 10:55:55 UTC
Reorganization of java component