Skip to content

Commit 491d734

Browse files
committed
HHH-11377 - ReflectHelper#getConstantValue should consider digits as well
1 parent 2b59aad commit 491d734

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ subprojects { subProject ->
188188

189189
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190190
// compilation
191+
compileJava.options.encoding = 'UTF-8'
192+
193+
tasks.withType(JavaCompile) {
194+
options.encoding = 'UTF-8'
195+
}
196+
191197
task compile
192198
compile.dependsOn compileJava, processResources, compileTestJava, processTestResources
193199

hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public final class ReflectHelper {
3737

3838
private static final Pattern JAVA_CONSTANT_PATTERN = Pattern.compile(
39-
"[a-z]+\\.([A-Z]{1}[a-z]+)+\\$?([A-Z]{1}[a-z]+)*\\.[A-Z_\\$]+" );
39+
"[a-z\\d]+\\.([A-Z]{1}[a-z\\d]+)+\\$?([A-Z]{1}[a-z\\d]+)*\\.[A-Z_\\$]+", Pattern.UNICODE_CHARACTER_CLASS);
4040

4141
public static final Class[] NO_PARAM_SIGNATURE = new Class[0];
4242
public static final Object[] NO_PARAMS = new Object[0];

hibernate-core/src/test/java/org/hibernate/internal/util/ReflectHelperTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
1212
import org.hibernate.boot.spi.SessionFactoryOptions;
1313
import org.hibernate.engine.spi.SessionFactoryImplementor;
14+
import org.hibernate.internal.util.hib3rnat3.C0nst4nts३;
1415
import org.hibernate.service.spi.ServiceRegistryImplementor;
1516

1617
import org.junit.Before;
@@ -123,4 +124,14 @@ public void test_getConstantValue_nestedEnum() {
123124
assertEquals( Status.ON, value );
124125
verify(classLoaderServiceMock, times(1)).classForName( eq("org.hibernate.internal.util.ReflectHelperTest$Status") );
125126
}
127+
128+
@Test
129+
public void test_getConstantValue_constant_digits() {
130+
131+
when( sessionFactoryOptionsMock.isConventionalJavaConstants() ).thenReturn( true );
132+
when( classLoaderServiceMock.classForName( "org.hibernate.internal.util.hib3rnat3.C0nst4nts३" ) ).thenReturn( (Class) C0nst4nts३.class );
133+
Object value = ReflectHelper.getConstantValue( "org.hibernate.internal.util.hib3rnat3.C0nst4nts३.ABC_DEF", sessionFactoryImplementorMock);
134+
assertEquals( C0nst4nts३.ABC_DEF, value );
135+
verify(classLoaderServiceMock, times(1)).classForName( eq("org.hibernate.internal.util.hib3rnat3.C0nst4nts३") );
136+
}
126137
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.internal.util.hib3rnat3;
8+
9+
/**
10+
* @author Vlad Mihalcea
11+
*/
12+
public class C0nst4nts३ {
13+
14+
public static final String ABC_DEF = "xyz";
15+
}

0 commit comments

Comments
 (0)