Controlling access of packages [message #1130228] |
Wed, 09 October 2013 10:37 |
Pierrick MARIE Messages: 1 Registered: October 2013 |
Junior Member |
|
|
Hi,
With the Eclipse Java editor it is possible to change the visibility of declared packages like this :
private package com.mypackage
class Foo {
// say hello
}
With Eclipse, this piece of code is executed normally with no problem. Whatever the keyword before the package declaration (private, protected or public) the compilation and the execution produce the same result.
But, as it is specified by Java, it is impossible to change the visibility of packages, see : docs.oracle.com/javase/specs/jls/se7/html/jls-7.html#jls-7.4
If I compile manually this code I have an error :
$ javac com.mypackage.Foo
Foo.java:1: error: class, interface, or enum expected
private package com.monsuperpackage;
^
1 error
I don't understand why it is possible to change the visibility of packages with the Eclipse Java editor (and only with it). What is the feature ?
ps : I use the version 1.7.0_25 of javac.
Thank you.
|
|
|
Powered by
FUDForum. Page generated in 0.01697 seconds