Skip to content

Commit 8373566

Browse files
committed
HHH-18976 Remove now-unused helper methods that perform dynamic array instantiation
1 parent 3f05464 commit 8373566

File tree

3 files changed

+3
-34
lines changed

3 files changed

+3
-34
lines changed

hibernate-core/src/main/java/org/hibernate/internal/util/collections/ArrayHelper.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ public static int indexOf(Object[] array, int end, Object object) {
5959
return -1;
6060
}
6161

62-
@SuppressWarnings("unchecked")
63-
@AllowReflection
64-
public static <T> T[] filledArray(T value, Class<T> valueJavaType, int size) {
65-
final T[] array = (T[]) Array.newInstance( valueJavaType, size );
66-
Arrays.fill( array, value );
67-
return array;
68-
}
69-
7062
public static String[] toStringArray(Object[] objects) {
7163
int length = objects.length;
7264
String[] result = new String[length];
@@ -521,15 +513,4 @@ public static <T> void forEach(T[] array, Consumer<T> consumer) {
521513
consumer.accept( array[ i ] );
522514
}
523515
}
524-
525-
/**
526-
* @deprecated Use {@link Array#newInstance(Class, int)} instead.
527-
*/
528-
@Deprecated
529-
@SuppressWarnings("unchecked")
530-
@AllowReflection
531-
public static <T> T[] newInstance(Class<T> elementType, int length) {
532-
return (T[]) Array.newInstance( elementType, length );
533-
}
534-
535516
}

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderHelper.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public static Boolean getReadOnlyFromLoadQueryInfluencers(LoadQueryInfluencers l
169169
*
170170
* @param <K> The key type
171171
*/
172+
@AllowReflection
172173
public static <K> K[] normalizeKeys(
173174
K[] keys,
174175
BasicValuedModelPart keyPart,
@@ -184,7 +185,8 @@ public static <K> K[] normalizeKeys(
184185
return keys;
185186
}
186187

187-
final K[] typedArray = createTypedArray( keyClass, keys.length );
188+
//noinspection unchecked
189+
final K[] typedArray = (K[]) Array.newInstance( keyClass, keys.length );
188190
final boolean coerce = !sessionFactory.getJpaMetamodel().getJpaCompliance().isLoadByIdComplianceEnabled();
189191
if ( !coerce ) {
190192
System.arraycopy( keys, 0, typedArray, 0, keys.length );
@@ -197,18 +199,6 @@ public static <K> K[] normalizeKeys(
197199
return typedArray;
198200
}
199201

200-
/**
201-
* Creates a typed array, as opposed to a generic {@code Object[]} that holds the typed values
202-
*
203-
* @param elementClass The type of the array elements. See {@link Class#getComponentType()}
204-
* @param length The length to which the array should be created. This is usually zero for Hibernate uses
205-
*/
206-
@AllowReflection
207-
public static <X> X[] createTypedArray(Class<X> elementClass, @SuppressWarnings("SameParameterValue") int length) {
208-
//noinspection unchecked
209-
return (X[]) Array.newInstance( elementClass, length );
210-
}
211-
212202
/**
213203
* Load one or more instances of a model part (an entity or collection)
214204
* based on a SQL ARRAY parameter to specify the keys (as opposed to the

rules/forbidden-apis.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
java.lang.reflect.Array#newInstance(java.lang.Class, int)
1313
java.lang.reflect.Array#newInstance(java.lang.Class, int[])
14-
org.hibernate.internal.util.collections.ArrayHelper#newInstance(java.lang.Class, int)
15-
org.hibernate.internal.util.collections.ArrayHelper#filledArray(java.lang.Object, java.lang.Class, int)
1614
org.hibernate.internal.util.collections.ArrayHelper#join(java.lang.Object[], java.lang.Object[])
1715

1816
################################################################################################################

0 commit comments

Comments
 (0)