Ticket #114 (closed defect: fixed)
Opened 11 years ago
Protected variable access from another package
|Reported by:||Bernhard Haumacher (haui at haumacher dot de)||Owned by:|
It is not possible to access a protected static variable from a non-static method of a subclass in another package. The same problem does occur for a protected non-static variable accessed from a static method of a subclass in another package.
Since class implementation code and instance implementation code end up in two different classes after transformation, the class implementing the instance part has no access privileges to access protected methods of the super class implementing the static part (there is no inheritance relationship between these two classes). Since the access methods in the handle class inherit the access privileges of the original declarations, and these handle methods are used for (remote) variable access, the generated code does not compile, because the generated handle method for variable access is not accessible.
The problem does not occur, if one tries to access a protected static method from within a non static method of the same class or a subclass in the same package, because each class has access to all protected members of a class in the same package.
Since all methods accessible through RMI must be declared public, and since each method of a remote class in JavaParty is remotely accessible in principle, each method of the implementation classes after the transformation must be public. For that reason, JavaParty does not offer any security, while it tries to provide as much safety as possible to the programmer. This is done by access checks in the JavaParty compiler based on the declarations in the original remote class. This prevents a JavaParty user from using protected fields of another class erroneously, even if the resulting declarations in the generated code are public. The only solution to the problem seems to be to declare all handle methods public.
fixed since 1.05f.