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 46451 - [gjast] exception after 'Fix Imports'
Summary: [gjast] exception after 'Fix Imports'
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: _ tball
URL:
Keywords:
: 46267 48821 (view as bug list)
Depends on:
Blocks: 48914
  Show dependency tree
 
Reported: 2004-07-22 16:04 UTC by Lukas Hasik
Modified: 2007-09-26 09:14 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
org.netbeans.modules.javacore.jmiimpl.javamodel.TransientElement.init(TransientElement.java:50) (21.27 KB, text/plain)
2004-07-22 16:04 UTC, Lukas Hasik
Details
class for reproduction (8.84 KB, text/plain)
2004-07-23 13:46 UTC, Lukas Hasik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Hasik 2004-07-22 16:04:06 UTC
[200407220815], jdk1.4.2_04

-appeared after Alt+Shift+F on java file

getASTContext() returned null for: Type 356 :1
java.lang.Exception: Stack trace
	at java.lang.Thread.dumpStack(Thread.java:1064)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.TransientElement.init(TransientElement.java:50)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.initOrCreate(MetadataElement.java:928)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.PrefixExpressionImpl.initChildren(PrefixExpressionImpl.java:74)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.TransientElement.init(TransientElement.java:62)
Comment 1 Lukas Hasik 2004-07-22 16:04:37 UTC
Created attachment 16392 [details]
org.netbeans.modules.javacore.jmiimpl.javamodel.TransientElement.init(TransientElement.java:50)
Comment 2 Pavel Flaska 2004-07-23 09:33:15 UTC
*** Issue 46267 has been marked as a duplicate of this issue. ***
Comment 3 Pavel Flaska 2004-07-23 09:35:31 UTC
Lukasi, do you have the class where fix all imports were invoked?
Comment 4 Lukas Hasik 2004-07-23 13:46:29 UTC
Created attachment 16416 [details]
class for reproduction
Comment 5 Lukas Hasik 2004-07-23 13:49:51 UTC
i was able to reproduce with attached class.
the testForImports.java was in 'Functional Test Packages' in relevant
package. Open it in Editor and Alt+Shift+F
Comment 6 Pavel Flaska 2004-07-23 17:16:38 UTC
Thanks Lukas, it is what we were looking for. Reassigning to Tom to
evaluate. ASTree.getASTContext() returns null for ParserTokens.INT_LIT.
Comment 7 _ tball 2004-08-03 21:14:32 UTC
Why is this code working on a ScannerToken instead of an actual tree?
 If you look at org.netbeans.lib.java.parser.ScannerToken, its
constructors pass a null ASTContext, which is what is then returned. 
If you were working on a literal tree element from gjast, the toString
output would look different.  

I think the bug is much higher, where somewhere a token is fetched
(using ASTContext.getToken()) and then passed as an ASTree. 
Regardless of how the team likes to treat tokens and trees as the
same, they really are very different.
Comment 8 Pavel Flaska 2004-09-02 16:07:01 UTC
No, it is not true that we fetch it by calling ASTContext.getToken().
If you look at stacktrace, the parameter tree is obtained at
PrefixExpressionImpl:74 by calling tree.getSubTrees()[1].
Comment 9 Pavel Flaska 2004-09-10 09:09:02 UTC
Cc'ing ME developers, they have other scenarios how to reproduce.
Comment 10 _ tball 2004-09-10 16:57:35 UTC
That's cool, maybe these ME engineers will share with me how to
reproduce the error, as I cannot.  I need to know where to find any
additional ME modules that might be needed, and a source file where
this happens.  Please reopen this issue when that information is
available.
Comment 11 Pavel Flaska 2004-09-10 17:08:01 UTC
Tom, use prefix expression in your source code and use negative
integer value, e.g. if (something == -1) {...
Comment 12 _ tball 2004-09-11 03:17:29 UTC
Okay, I see the problem:  if you look at
org.netbeans.lib.java.parser.ScannerToken's constructors, you'll see
that tokens can only be created with "null" for the ASTContext. 
Later, the old parser sets the ASTContext, but does so using a
package-private method I don't have access to.  So I'll add a
constructor which accepts an ASTContext from my scanner.  
Comment 13 _ tball 2004-09-11 05:15:38 UTC
ASTContext now set in tokens.
Comment 14 psuk 2004-09-13 14:35:32 UTC
Reopening, it looks like the fix caused a problem. See Issue 48914
Comment 15 Marek Grummich 2004-09-14 13:01:40 UTC
I've tried to reproduce a described behaviour for continuous build
20040914-0837 and I wasn't successfull. I've tried three cases, press
Alt_Shift_F on an attached file, source with negative integer value
and on the
projects/projectui/src/org/netbeans/modules/project/ui/ProjectChooserAccessory.java
file (from #46267 issue). I would mark this issue as verified, but
I'll wait for resolved status by a developer.
Comment 16 Martin Matula 2004-09-19 14:11:40 UTC
*** Issue 48821 has been marked as a duplicate of this issue. ***
Comment 17 Lukas Hasik 2006-09-14 10:32:44 UTC
v
Comment 18 Quality Engineering 2007-09-20 12:32:53 UTC
Reorganization of java component