Bug 363602 - Provide warning if a package default member is not used inside the package
Summary: Provide warning if a package default member is not used inside the package
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 3.8 M5   Edit
Assignee: Srikanth Sankaran CLA
QA Contact: Ayushman Jain CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-11 11:52 EST by Peter Kriens CLA
Modified: 2012-01-23 05:25 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Kriens CLA 2011-11-11 11:52:43 EST
The Eclipse compiler generates very useful warnings when a variable is not used when it is private. However, no such warnings when the member is package private and nobody in the package uses it. However, a package is a module and the compiler should have full visibility to the package.

It would be very useful if the compiler would also generate these package private warnings.
Comment 1 Ayushman Jain CLA 2011-11-12 06:03:18 EST
Will consider, time permitting. Not very likely for 3.8 though.
Comment 2 Sebastian Zarnekow CLA 2011-11-12 06:55:32 EST
Even though it's not best practice, other project may contribute classes to the very same package thus the compiler cannot know about all classes that possibly exist in the very same namespace.
Comment 3 Srikanth Sankaran CLA 2011-11-13 21:07:54 EST
(In reply to comment #2)
> Even though it's not best practice, other project may contribute classes to the
> very same package thus the compiler cannot know about all classes that possibly
> exist in the very same namespace.

Yes.

I also don't see how this can be ever work with incremental builds.

As an implementation note, JDT/Core has NO infrastructure in place to
do such cross translation unit analysis. There are no plans to create
such infrastructure either.
Comment 4 Peter Kriens CLA 2011-11-14 09:42:37 EST
(In reply to comment #2)
> Even though it's not best practice, other project may contribute classes to the
> very same package thus the compiler cannot know about all classes that possibly
> exist in the very same namespace.
This only happens when you screw around with the classpath. A package is a java module like a class. In the same vein, private fields are then also accessible outside the class when you use reflection.

With this argument the whole concept of default package access is utterly useless. Which is kind of sad since it is actually the default ... :-(
Comment 5 Peter Kriens CLA 2011-11-14 09:44:46 EST
> I also don't see how this can be ever work with incremental builds.
> 
> As an implementation note, JDT/Core has NO infrastructure in place to
> do such cross translation unit analysis. There are no plans to create
> such infrastructure either.
Sorry to hear that. Since packages are so important in OSGi and are necessary to decouple modules it would be nice if this important functionality could be supported in some way.
Comment 6 Srikanth Sankaran CLA 2012-01-11 03:51:08 EST
As mentioned in comment#3, this cannot be made to work well with
incremental builds, which triggers rebuild of client code when
definition change. The current scenario would call for inverting
this picture and won't sit well. 

Also as mentioned in comment#2 unsealed packages could be augmented.
Closing as WONTFIX.
Comment 7 Jay Arthanareeswaran CLA 2012-01-23 05:25:14 EST
Verified for 3.8M5