Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HHH-16572 - Incorrect enhancement for PROPERTY attributes with mismatched field and method names #6558

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hibernate-core/hibernate-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
implementation libs.jandex
implementation libs.classmate
implementation libs.byteBuddy
implementation libs.asmAnalysis

implementation jakartaLibs.jaxbApi
implementation jakartaLibs.jaxb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ public SessionFactoryBuilderImpl(MetadataImplementor metadata, SessionFactoryOpt
}
}

final BytecodeProvider bytecodeProvider =
metadata.getMetadataBuildingOptions().getServiceRegistry()
.getService( BytecodeProvider.class );
addSessionFactoryObservers( new SessionFactoryObserverForBytecodeEnhancer( bytecodeProvider ) );
addSessionFactoryObservers( new SessionFactoryObserverForBytecodeEnhancer( metadata ) );
addSessionFactoryObservers( new SessionFactoryObserverForNamedQueryValidation( metadata ) );
addSessionFactoryObservers( new SessionFactoryObserverForSchemaExport( metadata ) );
addSessionFactoryObservers( new SessionFactoryObserverForRegistration() );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.bytecode.enhance.internal.bytebuddy;

import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.function.Consumer;

import net.bytebuddy.dynamic.ClassFileLocator;

import static org.hibernate.bytecode.enhance.internal.bytebuddy.model.ModelSourceLogging.MODEL_SOURCE_LOGGER;
import static org.hibernate.bytecode.enhance.internal.bytebuddy.model.ModelSourceLogging.MODEL_SOURCE_TRACE_ENABLED;

/**
* @author Steve Ebersole
*/
public class ClassFileLocatorImpl extends ClassFileLocator.ForClassLoader {
// The name of the class to (possibly be) transformed.
private String className;
// The explicitly resolved Resolution for the class to (possibly be) transformed.
private Resolution resolution;

/**
* Creates a new class file locator for the given class loader.
*
* @param classLoader The class loader to query which must not be the bootstrap class loader, i.e. {@code null}.
*/
public ClassFileLocatorImpl(ClassLoader classLoader) {
super( classLoader );
}

@Override
public Resolution locate(String className) throws IOException {
if ( MODEL_SOURCE_TRACE_ENABLED ) {
MODEL_SOURCE_LOGGER.tracef( "ClassFileLocatorImpl#locate%s)", className );
}
if ( className.equals( this.className ) ) {
return resolution;
}
else {
return super.locate( className );
}
}

void setClassNameAndBytes(String className, byte[] bytes) {
if ( MODEL_SOURCE_TRACE_ENABLED ) {
MODEL_SOURCE_LOGGER.tracef( "ClassFileLocatorImpl#setClassNameAndBytes%s)", className );
}
assert className != null;
assert bytes != null;
this.className = className;
this.resolution = new Resolution.Explicit( bytes );
}

void setClassNameAndBytes(String className, Resolution resolution) {
if ( MODEL_SOURCE_TRACE_ENABLED ) {
MODEL_SOURCE_LOGGER.tracef( "ClassFileLocatorImpl#setClassNameAndBytes%s)", className );
}
assert className != null;
assert resolution != null;
this.className = className;
this.resolution = resolution;
}
}
Loading