-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
6u25, 9
-
x86
-
windows_7
FULL PRODUCT VERSION :
1.6.0_23-b05
64-bit server build 19.0-b09
ADDITIONAL OS VERSION INFORMATION :
Windows 6.1.7601
A DESCRIPTION OF THE PROBLEM :
When 'Class.getEnumConstants' is run against a class with over two thousand enums, index position 2000 is null.
Said another way:
Class.getEnumConstant()[2000] is always null. Assuming of course that there are at least that many declared.
Reference:
http://lexs.gov/
http://niem.gov/
http://www.schemacentral.com/sc/niem21/t-fbi_MAKCodeSimpleType.html
The Enum class comes from lexs.gov. The LEXS and NIEM specifications declare web services with large Enums that have thousands of constants. This bug is about MAKCodeSimpleType which has over two thousand enums however the largest have seven to eight thousand.
The code below will have null for the index position of two thousand.
Class<?> clazz = MAKCodeSimpleType.class;
Object[] values = clazz.getEnumConstants();
If you examine the source, MAKCodeSimpleType.java you will see that the 2000 constant should be 'VUC' for Vulcain. However null is returned instead of 'VUC'.
This bug may repeat every 2000 indexes so that index 2000, 4000, 6000,... all return null. There is a limit to the size of a static block, 64 bytes I believe, that prevents Enum class from reaching up into 6 or 8 thousand constants. This bug is not related to that constraint. The java source files compile without warning or error using both Oracle and Eclipse compilers.
Unfortunately, this bug gives the impression that java cannot handle large web service projects.
REGRESSION. Last worked in version 6
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
An Enum class with over 2000 constants is required. The LEXS wsdl and XSDs can be downloaded from http://lexs.gov/content/downloads and JAXB used to convert the XSDs. If you do so, you will need a custom binding file to tell JAXB to go higher with the Enum constants.
<jaxb:bindings>
<jaxb:globalBindings typesafeEnumMaxMembers="3250" />
</jaxb:bindings>
When you have a large Enum class, update the test code and run.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Class.getEnumConstants() should return all enums without nulls. In the context of this bug, index 2000 should return 'VUC'.
ACTUAL -
Index position 2000 is null.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package gov.niem.niem.fbi._2;
import java.lang.reflect.Field;
import java.util.EnumSet;
public class Test
{
public static void main(String[] args)
{
tryEnumConstants();
tryFieldsWorkaround();
tryEnumSetWorkaround();
System.out.println("Finished");
}
private static void tryFieldsWorkaround()
{
Class<?> clazz = MAKCodeSimpleType.class;
Field[] fields = clazz.getFields();
Field vuc = fields[2000];
if (vuc == null)
{
System.out.println("Class.getFields() is broken.");
} else
{
System.out.println("vuc = " + vuc.getName() + " isExpectedName = " + ("VUC".equals(vuc.getName())));
}
for (Field field : clazz.getFields())
{
if (field == null || field.getName() == null || !field.isEnumConstant())
{
System.out.println("Class.getFields() is broken");
}
}
}
private static void tryEnumConstants()
{
Class<?> clazz = MAKCodeSimpleType.class;
Object[] values = clazz.getEnumConstants();
Object broken = values[2000];
if (broken == null)
{
System.out.println("Class.getEnumConstants() is broken.");
}
}
private static void tryEnumSetWorkaround()
{
for (MAKCodeSimpleType type : EnumSet.allOf(MAKCodeSimpleType.class))
{
if (type == null)
{
System.out.println("EnumSet.allOf is broken.");
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Class.getFields() can be used to provide a correct array of Enum constants. The code for the workaround is in the test case. tryFieldsWorkaround().
1.6.0_23-b05
64-bit server build 19.0-b09
ADDITIONAL OS VERSION INFORMATION :
Windows 6.1.7601
A DESCRIPTION OF THE PROBLEM :
When 'Class.getEnumConstants' is run against a class with over two thousand enums, index position 2000 is null.
Said another way:
Class.getEnumConstant()[2000] is always null. Assuming of course that there are at least that many declared.
Reference:
http://lexs.gov/
http://niem.gov/
http://www.schemacentral.com/sc/niem21/t-fbi_MAKCodeSimpleType.html
The Enum class comes from lexs.gov. The LEXS and NIEM specifications declare web services with large Enums that have thousands of constants. This bug is about MAKCodeSimpleType which has over two thousand enums however the largest have seven to eight thousand.
The code below will have null for the index position of two thousand.
Class<?> clazz = MAKCodeSimpleType.class;
Object[] values = clazz.getEnumConstants();
If you examine the source, MAKCodeSimpleType.java you will see that the 2000 constant should be 'VUC' for Vulcain. However null is returned instead of 'VUC'.
This bug may repeat every 2000 indexes so that index 2000, 4000, 6000,... all return null. There is a limit to the size of a static block, 64 bytes I believe, that prevents Enum class from reaching up into 6 or 8 thousand constants. This bug is not related to that constraint. The java source files compile without warning or error using both Oracle and Eclipse compilers.
Unfortunately, this bug gives the impression that java cannot handle large web service projects.
REGRESSION. Last worked in version 6
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
An Enum class with over 2000 constants is required. The LEXS wsdl and XSDs can be downloaded from http://lexs.gov/content/downloads and JAXB used to convert the XSDs. If you do so, you will need a custom binding file to tell JAXB to go higher with the Enum constants.
<jaxb:bindings>
<jaxb:globalBindings typesafeEnumMaxMembers="3250" />
</jaxb:bindings>
When you have a large Enum class, update the test code and run.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Class.getEnumConstants() should return all enums without nulls. In the context of this bug, index 2000 should return 'VUC'.
ACTUAL -
Index position 2000 is null.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package gov.niem.niem.fbi._2;
import java.lang.reflect.Field;
import java.util.EnumSet;
public class Test
{
public static void main(String[] args)
{
tryEnumConstants();
tryFieldsWorkaround();
tryEnumSetWorkaround();
System.out.println("Finished");
}
private static void tryFieldsWorkaround()
{
Class<?> clazz = MAKCodeSimpleType.class;
Field[] fields = clazz.getFields();
Field vuc = fields[2000];
if (vuc == null)
{
System.out.println("Class.getFields() is broken.");
} else
{
System.out.println("vuc = " + vuc.getName() + " isExpectedName = " + ("VUC".equals(vuc.getName())));
}
for (Field field : clazz.getFields())
{
if (field == null || field.getName() == null || !field.isEnumConstant())
{
System.out.println("Class.getFields() is broken");
}
}
}
private static void tryEnumConstants()
{
Class<?> clazz = MAKCodeSimpleType.class;
Object[] values = clazz.getEnumConstants();
Object broken = values[2000];
if (broken == null)
{
System.out.println("Class.getEnumConstants() is broken.");
}
}
private static void tryEnumSetWorkaround()
{
for (MAKCodeSimpleType type : EnumSet.allOf(MAKCodeSimpleType.class))
{
if (type == null)
{
System.out.println("EnumSet.allOf is broken.");
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Class.getFields() can be used to provide a correct array of Enum constants. The code for the workaround is in the test case. tryFieldsWorkaround().