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 36433 - ClassElement.forName() is a no-op in prj40_prototype branch
Summary: ClassElement.forName() is a no-op in prj40_prototype branch
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P2 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-04 00:47 UTC by Timothy.n Jones
Modified: 2007-09-26 09:14 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy.n Jones 2003-10-04 00:47:14 UTC
The body of this method was replaced with "return
null;" in the projects branch.  Unfortunately this
breaks classclosure.  Studio requires classclosure
to implement the migration feature, and so we need
this method back.
Comment 1 Svata Dedic 2003-10-04 06:35:11 UTC
I dare to speak for Tomas on this issue an I think this is an
intentional change; please use forName(JavaProject, String) to find
your class. In new project system, there are no assumptions on
libraries or jre used, so you have to parser the JavaProject instance
to supply that information. Because there may be several projects
opened at a time, the environment may change from project to project.

There could be some defaults used, but it seems that it is better to
break a functionality in a defined way for a major version than to
trace strange bugs of type "why feature XXX does not work with
jre-specific classes/libraries added to the project/..." in all code.
Comment 2 Tomas Hurka 2003-10-08 08:48:15 UTC
Yes, Svata is absolutely right. This was an intentional change. Use 
ClassElement.forName(JavaProject, String).
Comment 3 Timothy.n Jones 2003-10-08 16:13:57 UTC
Simply altering the method to return null, trading compile time errors
for runtime errors, is not an acceptable solution.  At the very least
you should have thrown a runtime exception, such as
UnsupportedOperationException.  As it is, callers have no way of
knowing that the data returned (null) is bogus unless they happen to
examine the source or use a debugger.

You also should not be both deprecating APIs and removing their
functionality simultaneously.  The point of deprecation is to issue
compile-time warnings while preserving functionality, so that callers
have a chance for at least one release to switch to a new API.  When
you change the functionality, callers instantly break.

Either remove the method or restore its functionality.
Comment 4 Tomas Zezula 2003-10-08 17:50:15 UTC
A agree that throwing RuntimeException is better than returning null.
But the functionality can not be preserved.
If the source hierarchy hasn't classpath it is unable to do anything,
it is a cost for replacing "mounted filesystem == classpath" approach.
The NetBeans 4.0 is not compatible with NetBeans 3.x and this is one
of the points where the compatibility can not be preserved.

I will change the method to throw RuntimeException.
Comment 5 Jeffrey Norton 2003-10-08 19:33:48 UTC
If the functionality is not going to be preserved then the API should 
be removed.  Throwing a runtime exception only delays the discovery 
process and perhaps masks it.  Better to discover when you compile 
that your code is broken than wait until runtime.  Moreover the 
former is guaranteed, the later is subject to use.  

In either case (removal or throwing an exception) the high-impact 
integration process should be followed.  All developers should be 
warned of this change and have opportunity to modify their code in 
advance of the integration.  We need to keep the code working and not 
introduce regressions -- especially ones that may not be caught until 
long after the integration that introduced them.
Comment 6 Tomas Zezula 2003-10-08 19:43:20 UTC
I agree.
Comment 7 Timothy.n Jones 2003-10-24 21:28:52 UTC
Reopening this until the method is removed.  See Jeff's note about the
process for doing this.
Comment 8 Jan Pokorsky 2003-12-01 17:39:34 UTC
The projects prototype has been canceled so the issue is irrelevant.
For more details see
http://www.netbeans.org/servlets/ReadMsg?msgId=619519&listName=nbdiscuss
Comment 9 Quality Engineering 2007-09-20 12:02:28 UTC
Reorganization of java component