SlickEdit Product Discussion > SlickEdit®
push-tag in Java only finds public members in other files
RobFreundlich:
--- Quote from: RobFreundlich on July 15, 2006, 02:44:09 am ---I'll take a look on Monday when I'm back in the office.
--- End quote ---
I've explored this further. Here's what I've found (see the attached zipfile). Assume Foo as follows:
--- Code: ---package a.b.c;
public class Foo
{
public Foo()
{
}
public Foo(String abc)
{
}
protected Foo(int def)
{
}
}
--- End code ---
In the following table, SubFoo* refers to a subclass of Foo.
classnew Foo(3) legal Java?push-tag shows protected constructor?push-tag on super(3) shows protected constructor?a.b.c.BarYesNoN/Aa.b.c.SubFooSamePackageYesYesYesx.y.z.SubFooDifferentPackageNoYesYes
When Foo isn't in a package, and Bar isn't in a package (see my original example), then push-tag works properly.
So the problem seems to be that for protected members of packaged classes, push-tag cares only about whether the current class is a subclass of the member's class - it is broken for classes that are in the same package but are not subclasses of the member's class.
I suspect the root of this lies in the difference between the meaning of "protected" in C++ and Java. In C++, there's no "package" concept, and so protecteds are only visible to subclasses. However, in Java, protecteds are visible to subclasses and anyone in the same class.
I've found that developers who started in C++ and migrated to Java tend to be unaware of the difference (it makes a great interview question :)). Given SlickEdit's strong C++ focus, I can see why push-tag might work this way (assuming I'm right, of course).
Navigation
[0] Message Index
[*] Previous page
Go to full version