|
| 1 | +/* |
| 2 | + * Copyright 2002-2023 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.orm.jpa.vendor; |
| 18 | + |
| 19 | +import com.oracle.svm.core.annotate.Alias; |
| 20 | +import com.oracle.svm.core.annotate.RecomputeFieldValue; |
| 21 | +import com.oracle.svm.core.annotate.Substitute; |
| 22 | +import com.oracle.svm.core.annotate.TargetClass; |
| 23 | +import org.hibernate.bytecode.spi.BytecodeProvider; |
| 24 | + |
| 25 | +import static com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; |
| 26 | + |
| 27 | +/** |
| 28 | + * Hibernate substitution designed to prevent ByteBuddy reachability on native, and to enforce the |
| 29 | + * usage of {@code org.hibernate.bytecode.internal.none.BytecodeProviderImpl} with Hibernate 6.3+. |
| 30 | + * TODO Collaborate with Hibernate team on a substitution-less alternative that does not require a custom list of StandardServiceInitiator |
| 31 | + * |
| 32 | + * @author Sebastien Deleuze |
| 33 | + * @since 6.1 |
| 34 | + */ |
| 35 | +@TargetClass(className = "org.hibernate.bytecode.internal.BytecodeProviderInitiator") |
| 36 | +final class Target_BytecodeProviderInitiator { |
| 37 | + |
| 38 | + @Alias |
| 39 | + public static String BYTECODE_PROVIDER_NAME_NONE; |
| 40 | + |
| 41 | + @Alias |
| 42 | + @RecomputeFieldValue(kind = Kind.FromAlias) |
| 43 | + public static String BYTECODE_PROVIDER_NAME_DEFAULT = BYTECODE_PROVIDER_NAME_NONE; |
| 44 | + |
| 45 | + @Substitute |
| 46 | + public static BytecodeProvider buildBytecodeProvider(String providerName) { |
| 47 | + return new org.hibernate.bytecode.internal.none.BytecodeProviderImpl(); |
| 48 | + } |
| 49 | +} |
0 commit comments