test/tools/javac/enum/EnumImplicitPrivateConstructor.java

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 5009601 5010455 5005748
  27  * @summary enum constructors can be declared private
  28  * @author Joseph D. Darcy
  29  *
  30  * @compile -source 1.5 EnumImplicitPrivateConstructor.java
  31  * @run main EnumImplicitPrivateConstructor
  32  */
  33 
  34 import java.util.*;
  35 import java.lang.reflect.*;
  36 import java.lang.annotation.*;
  37 
  38 /*
  39  * Arguably, only the final and abstract should be held in
  40  * ExpectedModifiers; whether or not an enum should be static could be
  41  * inferred from getDeclaringClass and working versions of
  42  * getEnclosingMethod and getEnclosingConstructor.  I.e. if
  43  * getDeclaringClass, getEnclosingMethod, and getEnclosingConstructor
  44  * were all null, the enum is a top-level class and should not be
  45  * static; otherwise, it should be static.
  46  */
  47 
  48 @ExpectedModifiers(Modifier.FINAL)
  49 public enum EnumImplicitPrivateConstructor {
  50     RED(255, 0, 0),
  51     GREEN(0, 255, 0),




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 5009601 5010455 5005748
  27  * @summary enum constructors can be declared private
  28  * @author Joseph D. Darcy



  29  */
  30 
  31 import java.util.*;
  32 import java.lang.reflect.*;
  33 import java.lang.annotation.*;
  34 
  35 /*
  36  * Arguably, only the final and abstract should be held in
  37  * ExpectedModifiers; whether or not an enum should be static could be
  38  * inferred from getDeclaringClass and working versions of
  39  * getEnclosingMethod and getEnclosingConstructor.  I.e. if
  40  * getDeclaringClass, getEnclosingMethod, and getEnclosingConstructor
  41  * were all null, the enum is a top-level class and should not be
  42  * static; otherwise, it should be static.
  43  */
  44 
  45 @ExpectedModifiers(Modifier.FINAL)
  46 public enum EnumImplicitPrivateConstructor {
  47     RED(255, 0, 0),
  48     GREEN(0, 255, 0),