diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/AccessOptimizerAdapter.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/AccessOptimizerAdapter.java index 9cba73ae3d..35246424bc 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/AccessOptimizerAdapter.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/AccessOptimizerAdapter.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BulkAccessor.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BulkAccessor.java index 47fcdcb97c..1c286eadea 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BulkAccessor.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BulkAccessor.java @@ -29,6 +29,10 @@ * A JavaBean bulk accessor, which provides methods capable of getting/setting multiple properties * of a JavaBean at once. * + * IMPORTANT NOTE!!! Apparently the order of the methods here is important as I think BulkAccessorFactory + * makes use of that information in terms of accessing the constructor. Anyway, when I tried to re-arrange them + * the BulkAccessor creation failed and tests started to fail. + * * @author Muga Nishizawa * @author Shigeru Chiba */ @@ -38,24 +42,9 @@ public abstract class BulkAccessor implements Serializable { protected Class[] types; /** - * Creates a new instance of BulkAccessor. The created instance provides methods for setting/getting - * specified properties at once. - * - * @param beanClass the class of the JavaBeans accessed - * through the created object. - * @param getters the names of setter methods for specified properties. - * @param setters the names of getter methods for specified properties. - * @param types the types of specified properties. - * - * @return The created bulk accessor + * Protected access constructor so the generated class has access to it. */ - public static BulkAccessor create( - Class beanClass, - String[] getters, - String[] setters, - Class[] types) { - final BulkAccessorFactory factory = new BulkAccessorFactory( beanClass, getters, setters, types ); - return factory.create(); + protected BulkAccessor() { } /** @@ -114,6 +103,24 @@ public String[] getSetters() { return setters.clone(); } - private BulkAccessor() { + /** + * Creates a new instance of BulkAccessor. + * The created instance provides methods for setting/getting + * specified properties at once. + * + * @param beanClass the class of the JavaBeans accessed + * through the created object. + * @param getters the names of setter methods for specified properties. + * @param setters the names of getter methods for specified properties. + * @param types the types of specified properties. + * + * @return The created BulkAccessor + */ + public static BulkAccessor create( + Class beanClass, + String[] getters, + String[] setters, + Class[] types) { + return new BulkAccessorFactory( beanClass, getters, setters, types ).create(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BulkAccessorException.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BulkAccessorException.java index 2ec4559a98..9ebece457d 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BulkAccessorException.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BulkAccessorException.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BytecodeProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BytecodeProviderImpl.java index a529a5ef7a..343b732c82 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BytecodeProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/BytecodeProviderImpl.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FastClass.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FastClass.java index e629dfeec3..5fb441798c 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FastClass.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FastClass.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldFilter.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldFilter.java index c1241c4e85..6e08f81c76 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldFilter.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldFilter.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldHandler.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldHandler.java index 98225bd1a0..abcc4949aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldHandler.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java index 6e3b43b6e5..612a70e48d 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/InstantiationOptimizerAdapter.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/InstantiationOptimizerAdapter.java index c064b82e66..26bdfa1e60 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/InstantiationOptimizerAdapter.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/InstantiationOptimizerAdapter.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/JavassistClassTransformer.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/JavassistClassTransformer.java index d8d725b678..0e9005e6ce 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/JavassistClassTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/JavassistClassTransformer.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ProxyFactoryFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ProxyFactoryFactoryImpl.java index abb5cbb04d..7dffeedd2c 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ProxyFactoryFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ProxyFactoryFactoryImpl.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ReflectionOptimizerImpl.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ReflectionOptimizerImpl.java index ce754dc798..13086f5cac 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ReflectionOptimizerImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ReflectionOptimizerImpl.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/TransformingClassLoader.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/TransformingClassLoader.java index 0e96020a59..96661cb461 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/TransformingClassLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/TransformingClassLoader.java @@ -1,7 +1,7 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as + * Copyright (c) 2008-2013, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Inc. diff --git a/hibernate-core/src/test/java/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java b/hibernate-core/src/test/java/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java index 97e8e154b4..913be87887 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/bytecode/javassist/ReflectionOptimizerTest.java @@ -25,6 +25,7 @@ import org.junit.Test; +import org.hibernate.bytecode.internal.javassist.BulkAccessor; import org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl; import org.hibernate.bytecode.spi.ReflectionOptimizer; import org.hibernate.test.bytecode.Bean; @@ -38,6 +39,16 @@ * @author Steve Ebersole */ public class ReflectionOptimizerTest extends BaseUnitTestCase { + @Test + public void testBulkAccessorDirectly() { + BulkAccessor bulkAccessor = BulkAccessor.create( + Bean.class, + BeanReflectionHelper.getGetterNames(), + BeanReflectionHelper.getSetterNames(), + BeanReflectionHelper.getTypes() + ); + } + @Test public void testReflectionOptimization() { BytecodeProviderImpl provider = new BytecodeProviderImpl();