-
Bug
-
Resolution: Fixed
-
P4
-
8
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
"A public class can likewise prevent the creation of instances outside its package by declaring at least one constructor, to prevent creation of a default constructor with public access, and by declaring no constructor that is public."
This is incorrect: a public class with only a protected ctor can be instantiated outside the package.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A public class can likewise prevent the creation of instances outside its package by declaring at least one constructor, to prevent creation of a default constructor with public access, and by declaring no constructor that is public or protected.
ACTUAL -
A public class can likewise prevent the creation of instances outside its package by declaring at least one constructor, to prevent creation of a default constructor with public access, and by declaring no constructor that is public.
URL OF FAULTY DOCUMENTATION :
https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.8.10
"A public class can likewise prevent the creation of instances outside its package by declaring at least one constructor, to prevent creation of a default constructor with public access, and by declaring no constructor that is public."
This is incorrect: a public class with only a protected ctor can be instantiated outside the package.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A public class can likewise prevent the creation of instances outside its package by declaring at least one constructor, to prevent creation of a default constructor with public access, and by declaring no constructor that is public or protected.
ACTUAL -
A public class can likewise prevent the creation of instances outside its package by declaring at least one constructor, to prevent creation of a default constructor with public access, and by declaring no constructor that is public.
URL OF FAULTY DOCUMENTATION :
https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.8.10