mirror of https://github.com/apache/openjpa.git
OPENJPA-293. More-eager failures.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@567889 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dda1e8ef6f
commit
ede9dcbd61
|
@ -19,24 +19,25 @@
|
||||||
package org.apache.openjpa.enhance;
|
package org.apache.openjpa.enhance;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||||
import org.apache.openjpa.lib.util.JavaVersions;
|
|
||||||
import org.apache.openjpa.lib.util.BytecodeWriter;
|
|
||||||
import org.apache.openjpa.lib.util.Localizer;
|
|
||||||
import org.apache.openjpa.lib.log.Log;
|
import org.apache.openjpa.lib.log.Log;
|
||||||
import org.apache.openjpa.util.GeneratedClasses;
|
import org.apache.openjpa.lib.util.BytecodeWriter;
|
||||||
import org.apache.openjpa.util.InternalException;
|
import org.apache.openjpa.lib.util.JavaVersions;
|
||||||
|
import org.apache.openjpa.lib.util.Localizer;
|
||||||
import org.apache.openjpa.meta.ClassMetaData;
|
import org.apache.openjpa.meta.ClassMetaData;
|
||||||
import org.apache.openjpa.meta.FieldMetaData;
|
import org.apache.openjpa.meta.FieldMetaData;
|
||||||
import org.apache.openjpa.meta.JavaTypes;
|
import org.apache.openjpa.meta.JavaTypes;
|
||||||
|
import org.apache.openjpa.util.GeneratedClasses;
|
||||||
|
import org.apache.openjpa.util.InternalException;
|
||||||
|
import org.apache.openjpa.util.UserException;
|
||||||
import serp.bytecode.BCClass;
|
import serp.bytecode.BCClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,9 +63,10 @@ public class ManagedClassSubclasser {
|
||||||
* will need to do state comparisons to detect changes to newly inserted
|
* will need to do state comparisons to detect changes to newly inserted
|
||||||
* instances after a flush has been called.
|
* instances after a flush has been called.
|
||||||
*
|
*
|
||||||
* @return the new subclasses, or <code>null</code> if subclassing is
|
* @return the new subclasses, or <code>null</code> if <code>classes</code>
|
||||||
* disabled in <code>conf</code> or <code>classes</code> is
|
* is <code>null</code>.
|
||||||
* <code>null</code>.
|
* @throws UserException if <code>conf</code> requires build-time
|
||||||
|
* enhancement and <code>classes</code> includes unenhanced types.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
@ -76,8 +78,16 @@ public class ManagedClassSubclasser {
|
||||||
return null;
|
return null;
|
||||||
if (classes.size() == 0)
|
if (classes.size() == 0)
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
if (!conf.getRuntimeClassOptimization())
|
if (!conf.getRuntimeClassOptimization()) {
|
||||||
|
Collection unenhanced = new ArrayList();
|
||||||
|
for (Class cls : classes)
|
||||||
|
if (!PersistenceCapable.class.isAssignableFrom(cls))
|
||||||
|
unenhanced.add(cls);
|
||||||
|
if (unenhanced.size() > 0)
|
||||||
|
throw new UserException(_loc.get(
|
||||||
|
"runtime-optimization-disabled", unenhanced));
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Log log = conf.getLog(OpenJPAConfiguration.LOG_ENHANCE);
|
Log log = conf.getLog(OpenJPAConfiguration.LOG_ENHANCE);
|
||||||
boolean redefine = ClassRedefiner.canRedefineClasses();
|
boolean redefine = ClassRedefiner.canRedefineClasses();
|
||||||
|
|
|
@ -38,6 +38,9 @@ detach-custom-extern: Type "{0}" is set to detach on serialize, but implements \
|
||||||
a custom readExternal and/or writeExternal method. You cannot use custom \
|
a custom readExternal and/or writeExternal method. You cannot use custom \
|
||||||
serialization with detachment.
|
serialization with detachment.
|
||||||
enhance-start: Enhancing type "{0}".
|
enhance-start: Enhancing type "{0}".
|
||||||
|
runtime-optimization-disabled: This configuration disallows runtime \
|
||||||
|
optimization, but the following listed types were not enhanced at build \
|
||||||
|
time or at class load time with a javaagent: "{0}".
|
||||||
enhance-and-subclass-and-redef-start: Creating subclass and redefining methods \
|
enhance-and-subclass-and-redef-start: Creating subclass and redefining methods \
|
||||||
for "{0}". This means that your application will be less efficient \
|
for "{0}". This means that your application will be less efficient \
|
||||||
than it would if you ran the OpenJPA enhancer.
|
than it would if you ran the OpenJPA enhancer.
|
||||||
|
|
|
@ -33,10 +33,7 @@ public class TestEnhancementConfiguration
|
||||||
UnenhancedFieldAccess.class, CLEAR_TABLES);
|
UnenhancedFieldAccess.class, CLEAR_TABLES);
|
||||||
assertFalse(ImplHelper.isManagedType(emf.getConfiguration(),
|
assertFalse(ImplHelper.isManagedType(emf.getConfiguration(),
|
||||||
UnenhancedFieldAccess.class));
|
UnenhancedFieldAccess.class));
|
||||||
EntityManager em = emf.createEntityManager();
|
emf.createEntityManager().close();
|
||||||
em.getTransaction().begin();
|
|
||||||
em.persist(new UnenhancedFieldAccess());
|
|
||||||
em.getTransaction().rollback();
|
|
||||||
fail("should not be possible to fully-initialize a system " +
|
fail("should not be possible to fully-initialize a system " +
|
||||||
"that depends on unenhanced types but disables runtime" +
|
"that depends on unenhanced types but disables runtime" +
|
||||||
"redefinition.");
|
"redefinition.");
|
||||||
|
|
Loading…
Reference in New Issue