From 32467f0ca122e6e758711388a64b30137433d54b Mon Sep 17 00:00:00 2001 From: Tobias Brohl aka The_Minefighter Date: Mon, 14 Oct 2024 10:57:24 +0200 Subject: [PATCH] Fix issue #1819 incorrect enum value name generation with leading digits The first character of an enum value name is checked whether it complies with isJavaIdentifierStart, if not an underscore prefix will be added to that name. --- .../com/sun/tools/xjc/reader/xmlschema/SimpleTypeBuilder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/SimpleTypeBuilder.java b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/SimpleTypeBuilder.java index 47eb72161..2decb0beb 100644 --- a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/SimpleTypeBuilder.java +++ b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/SimpleTypeBuilder.java @@ -674,6 +674,8 @@ private List buildCEnumConstants(XSRestrictionSimpleType type, bo if(name==null) { StringBuilder sb = new StringBuilder(); + if (factValue.length()>0 && !Character.isJavaIdentifierStart(facetValue.charAt(0))) + sb.append('_'); //Otherwise enum constants starting with digits will be renamed to VALUE_x for( int i=0; i