HHH-16515 - Add the org.hibernate.bytecode.spi package to nullness checking
Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
parent
1fed78d4e5
commit
e12cfdb0b9
|
@ -524,7 +524,7 @@ checkerFramework {
|
||||||
extraJavacArgs = [
|
extraJavacArgs = [
|
||||||
'-AsuppressWarnings=initialization',
|
'-AsuppressWarnings=initialization',
|
||||||
"-Astubs=${project.rootDir}/checkerstubs",
|
"-Astubs=${project.rootDir}/checkerstubs",
|
||||||
'-AonlyDefs=^org\\.hibernate\\.(jpamodelgen|spi|pretty|(action|context)\\.spi)\\.'
|
'-AonlyDefs=^org\\.hibernate\\.(jpamodelgen|spi|pretty|(action|context|bytecode)\\.spi)\\.'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
||||||
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BytecodeEnhancementMetadata implementation for non-POJO models, mainly
|
* BytecodeEnhancementMetadata implementation for non-POJO models, mainly
|
||||||
* {@link org.hibernate.metamodel.RepresentationMode#MAP}
|
* {@link org.hibernate.metamodel.RepresentationMode#MAP}
|
||||||
|
@ -78,12 +80,12 @@ public class BytecodeEnhancementMetadataNonPojoImpl implements BytecodeEnhanceme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LazyAttributeLoadingInterceptor extractInterceptor(Object entity) throws NotInstrumentedException {
|
public @Nullable LazyAttributeLoadingInterceptor extractInterceptor(Object entity) throws NotInstrumentedException {
|
||||||
throw new NotInstrumentedException( errorMsg );
|
throw new NotInstrumentedException( errorMsg );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BytecodeLazyAttributeInterceptor extractLazyInterceptor(Object entity) throws NotInstrumentedException {
|
public @Nullable BytecodeLazyAttributeInterceptor extractLazyInterceptor(Object entity) throws NotInstrumentedException {
|
||||||
throw new NotInstrumentedException( errorMsg );
|
throw new NotInstrumentedException( errorMsg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
|
import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
|
||||||
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptableType;
|
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptableType;
|
||||||
import static org.hibernate.engine.internal.ManagedTypeHelper.processIfSelfDirtinessTracker;
|
import static org.hibernate.engine.internal.ManagedTypeHelper.processIfSelfDirtinessTracker;
|
||||||
|
@ -136,7 +138,7 @@ public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhanc
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LazyAttributeLoadingInterceptor extractInterceptor(Object entity) throws NotInstrumentedException {
|
public @Nullable LazyAttributeLoadingInterceptor extractInterceptor(Object entity) throws NotInstrumentedException {
|
||||||
return (LazyAttributeLoadingInterceptor) extractLazyInterceptor( entity );
|
return (LazyAttributeLoadingInterceptor) extractLazyInterceptor( entity );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +259,7 @@ public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhanc
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BytecodeLazyAttributeInterceptor extractLazyInterceptor(Object entity) throws NotInstrumentedException {
|
public @Nullable BytecodeLazyAttributeInterceptor extractLazyInterceptor(Object entity) throws NotInstrumentedException {
|
||||||
if ( !enhancedForLazyLoading ) {
|
if ( !enhancedForLazyLoading ) {
|
||||||
throw new NotInstrumentedException( "Entity class [" + entityClass.getName() + "] is not enhanced for lazy loading" );
|
throw new NotInstrumentedException( "Entity class [" + entityClass.getName() + "] is not enhanced for lazy loading" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ import net.bytebuddy.jar.asm.Opcodes;
|
||||||
import net.bytebuddy.jar.asm.Type;
|
import net.bytebuddy.jar.asm.Type;
|
||||||
import net.bytebuddy.matcher.ElementMatcher;
|
import net.bytebuddy.matcher.ElementMatcher;
|
||||||
import net.bytebuddy.matcher.ElementMatchers;
|
import net.bytebuddy.matcher.ElementMatchers;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class BytecodeProviderImpl implements BytecodeProvider {
|
public class BytecodeProviderImpl implements BytecodeProvider {
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ public class BytecodeProviderImpl implements BytecodeProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReflectionOptimizer getReflectionOptimizer(Class<?> clazz, Map<String, PropertyAccess> propertyAccessMap) {
|
public @Nullable ReflectionOptimizer getReflectionOptimizer(Class<?> clazz, Map<String, PropertyAccess> propertyAccessMap) {
|
||||||
final Class<?> fastClass;
|
final Class<?> fastClass;
|
||||||
if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {
|
if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {
|
||||||
// we only provide a fast class instantiator if the class can be instantiated
|
// we only provide a fast class instantiator if the class can be instantiated
|
||||||
|
@ -1313,7 +1314,7 @@ public class BytecodeProviderImpl implements BytecodeProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enhancer getEnhancer(EnhancementContext enhancementContext) {
|
public @Nullable Enhancer getEnhancer(EnhancementContext enhancementContext) {
|
||||||
return new EnhancerImpl( enhancementContext, byteBuddyState );
|
return new EnhancerImpl( enhancementContext, byteBuddyState );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ import org.hibernate.bytecode.spi.ReflectionOptimizer;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This BytecodeProvider represents the "no-op" enhancer; mostly useful
|
* This BytecodeProvider represents the "no-op" enhancer; mostly useful
|
||||||
* as an optimisation when not needing any byte code optimisation applied,
|
* as an optimisation when not needing any byte code optimisation applied,
|
||||||
|
@ -44,12 +46,12 @@ public final class BytecodeProviderImpl implements BytecodeProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReflectionOptimizer getReflectionOptimizer(Class<?> clazz, Map<String, PropertyAccess> propertyAccessMap) {
|
public @Nullable ReflectionOptimizer getReflectionOptimizer(Class<?> clazz, Map<String, PropertyAccess> propertyAccessMap) {
|
||||||
throw new HibernateException( "Using the ReflectionOptimizer is not possible when the configured BytecodeProvider is 'none'. Disable " + AvailableSettings.USE_REFLECTION_OPTIMIZER + " or use a different BytecodeProvider");
|
throw new HibernateException( "Using the ReflectionOptimizer is not possible when the configured BytecodeProvider is 'none'. Disable " + AvailableSettings.USE_REFLECTION_OPTIMIZER + " or use a different BytecodeProvider");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enhancer getEnhancer(EnhancementContext enhancementContext) {
|
public @Nullable Enhancer getEnhancer(EnhancementContext enhancementContext) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
||||||
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates bytecode enhancement information about a particular entity.
|
* Encapsulates bytecode enhancement information about a particular entity.
|
||||||
*
|
*
|
||||||
|
@ -80,9 +82,9 @@ public interface BytecodeEnhancementMetadata {
|
||||||
*
|
*
|
||||||
* @throws NotInstrumentedException Thrown if {@link #isEnhancedForLazyLoading()} returns {@code false}
|
* @throws NotInstrumentedException Thrown if {@link #isEnhancedForLazyLoading()} returns {@code false}
|
||||||
*/
|
*/
|
||||||
LazyAttributeLoadingInterceptor extractInterceptor(Object entity) throws NotInstrumentedException;
|
@Nullable LazyAttributeLoadingInterceptor extractInterceptor(Object entity) throws NotInstrumentedException;
|
||||||
|
|
||||||
BytecodeLazyAttributeInterceptor extractLazyInterceptor(Object entity) throws NotInstrumentedException;
|
@Nullable BytecodeLazyAttributeInterceptor extractLazyInterceptor(Object entity) throws NotInstrumentedException;
|
||||||
|
|
||||||
boolean hasUnFetchedAttributes(Object entity);
|
boolean hasUnFetchedAttributes(Object entity);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ import org.hibernate.bytecode.enhance.spi.Enhancer;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
import org.hibernate.service.Service;
|
import org.hibernate.service.Service;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contract for providers of bytecode services to Hibernate.
|
* Contract for providers of bytecode services to Hibernate.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -54,7 +56,7 @@ public interface BytecodeProvider extends Service {
|
||||||
* @param propertyAccessMap The ordered property access map
|
* @param propertyAccessMap The ordered property access map
|
||||||
* @return The reflection optimization delegate.
|
* @return The reflection optimization delegate.
|
||||||
*/
|
*/
|
||||||
ReflectionOptimizer getReflectionOptimizer(Class<?> clazz, Map<String, PropertyAccess> propertyAccessMap);
|
@Nullable ReflectionOptimizer getReflectionOptimizer(Class<?> clazz, Map<String, PropertyAccess> propertyAccessMap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a byte code enhancer that implements the enhancements described in the supplied enhancement context.
|
* Returns a byte code enhancer that implements the enhancements described in the supplied enhancement context.
|
||||||
|
@ -63,7 +65,7 @@ public interface BytecodeProvider extends Service {
|
||||||
*
|
*
|
||||||
* @return An enhancer to perform byte code manipulations.
|
* @return An enhancer to perform byte code manipulations.
|
||||||
*/
|
*/
|
||||||
Enhancer getEnhancer(EnhancementContext enhancementContext);
|
@Nullable Enhancer getEnhancer(EnhancementContext enhancementContext);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some BytecodeProvider implementations will have classloader specific caching.
|
* Some BytecodeProvider implementations will have classloader specific caching.
|
||||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.bytecode.spi;
|
||||||
import java.security.ProtectionDomain;
|
import java.security.ProtectionDomain;
|
||||||
|
|
||||||
import jakarta.persistence.spi.TransformerException;
|
import jakarta.persistence.spi.TransformerException;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A persistence provider provides an instance of this interface to the
|
* A persistence provider provides an instance of this interface to the
|
||||||
|
@ -36,9 +37,9 @@ public interface ClassTransformer extends jakarta.persistence.spi.ClassTransform
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
byte[] transform(
|
byte[] transform(
|
||||||
ClassLoader loader,
|
@Nullable ClassLoader loader,
|
||||||
String className,
|
String className,
|
||||||
Class<?> classBeingRedefined,
|
@Nullable Class<?> classBeingRedefined,
|
||||||
ProtectionDomain protectionDomain,
|
ProtectionDomain protectionDomain,
|
||||||
byte[] classfileBuffer) throws TransformerException;
|
byte[] classfileBuffer) throws TransformerException;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue