Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Eclipse's Refactoring Tools Violate The Java Language Specification?

Tags:

java

eclipse

In Eclipse 3.5, say I have a package structure like this:

 tom.package1
 tom.package1.packageA
 tom.package1.packageB

if I right click on an the tom.package1 package and go to Refactor->Rename, an option "Rename subpackages" appears as a checkbox. If I select it, and then rename tom.package1 to tom.red my package structure ends up like this:

tom.red
tom.red.packageA
tom.red.packageB

Yet I hear that Java's packages are not hierarchical. The Java Tutorials back that up (see the section on Apparent Hierarchies of Packages). It certainly seems like Eclipse is treating packages as hierarchical in this case.

I was curious why access specifiers couldn't allow/restrict access to "sub-packages" in a previous question because I KNEW I had seen "sub-packages" referenced somewhere before.

So are Eclipse's refactoring tools intentionally misleading impressionable young minds by furthering the "sub-package" myth? Or am I misinterpreting something here?

like image 384
Tom Tresansky Avatar asked Sep 14 '26 05:09

Tom Tresansky


1 Answers

Eclipse can't possibly violate the JLS in this case, because it has nothing to do with compiling or running Java source or bytecode.

The refactoring tools behave as they do because that behaviour is useful to developers. The behaviour is useful to developers because, for many intents and purposes, we do treat packages as hierarchal (a.b.c has some kind of relationship with a.b, even if that relationship is not consistent from project to project). That doesn't mean Java treats them as hierarchal intrinsically.

One example where people treat packages as very hierarchal is in configuring a logging framework such as log4j. Again, it's not intrinsic to log4j, but that's how people use it in practice.

like image 76
Mark Peters Avatar answered Sep 17 '26 09:09

Mark Peters



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!