Introduce conditional activation of Hibernate substitutions
Closes gh-31452
This commit is contained in:
parent
9af239c8be
commit
a9d67878c5
39
spring-orm/src/main/java/org/springframework/orm/jpa/vendor/SubstituteOnlyIfPresent.java
vendored
Normal file
39
spring-orm/src/main/java/org/springframework/orm/jpa/vendor/SubstituteOnlyIfPresent.java
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.orm.jpa.vendor;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Predicate intended to enabled the related GraalVM substitution only when the class is present in the classpath.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 6.1
|
||||
*/
|
||||
class SubstituteOnlyIfPresent implements Predicate<String> {
|
||||
|
||||
@Override
|
||||
public boolean test(String type) {
|
||||
try {
|
||||
Class.forName(type, false, getClass().getClassLoader());
|
||||
return true;
|
||||
}
|
||||
catch (ClassNotFoundException | NoClassDefFoundError ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ import org.hibernate.property.access.spi.PropertyAccess;
|
|||
* @author Sebastien Deleuze
|
||||
* @since 6.1
|
||||
*/
|
||||
@TargetClass(className = "org.hibernate.bytecode.internal.none.BytecodeProviderImpl")
|
||||
@TargetClass(className = "org.hibernate.bytecode.internal.none.BytecodeProviderImpl", onlyWith = SubstituteOnlyIfPresent.class)
|
||||
final class Target_BytecodeProvider {
|
||||
|
||||
@Substitute
|
||||
|
|
|
@ -32,7 +32,7 @@ import static com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
|
|||
* @author Sebastien Deleuze
|
||||
* @since 6.1
|
||||
*/
|
||||
@TargetClass(className = "org.hibernate.bytecode.internal.BytecodeProviderInitiator")
|
||||
@TargetClass(className = "org.hibernate.bytecode.internal.BytecodeProviderInitiator", onlyWith = SubstituteOnlyIfPresent.class)
|
||||
final class Target_BytecodeProviderInitiator {
|
||||
|
||||
@Alias
|
||||
|
|
Loading…
Reference in New Issue