Author: schor Date: Thu Jan 25 18:51:21 2018 New Revision: 1822219 URL: http://svn.apache.org/viewvc?rev=1822219&view=rev Log: [UIMA-5708] better message for alpha02 level of jcas, remove obsolete scaffolding
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSClassRegistry.java uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSClassRegistry.java URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSClassRegistry.java?rev=1822219&r1=1822218&r2=1822219&view=diff ============================================================================== --- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSClassRegistry.java (original) +++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSClassRegistry.java Thu Jan 25 18:51:21 2018 @@ -313,7 +313,6 @@ public abstract class FSClassRegistry { } for (TypeImpl subType : ti.getDirectSubtypes()) { - TypeSystemImpl.typeBeingLoadedThreadLocal.set(subType); loadBuiltins(subType, cl, type2jcci, callSites_toSync); } } @@ -438,11 +437,7 @@ public abstract class FSClassRegistry { JCasClassInfo jcci = getOrCreateJCasClassInfo(ti, cl, type2jcci, lookup); if (null != jcci && tsi.isCommitted()) { - try { - updateOrValidateAllCallSitesForJCasClass(jcci.jcasClass, ti, callSites_toSync); - } finally { - TypeSystemImpl.typeBeingLoadedThreadLocal.set(null); - } + updateOrValidateAllCallSitesForJCasClass(jcci.jcasClass, ti, callSites_toSync); } // String t2jcciKey = Misc.typeName2ClassName(ti.getName()); @@ -530,7 +525,6 @@ public abstract class FSClassRegistry { for (TypeImpl subtype : ti.getDirectSubtypes()) { - TypeSystemImpl.typeBeingLoadedThreadLocal.set(subtype); // not used, but left in for backwards compat. maybeLoadJCasAndSubtypes(tsi, subtype, jcci_or_copyDown, cl, type2jcci, callSites_toSync, lookup); } } @@ -837,13 +831,10 @@ public abstract class FSClassRegistry { String className = ti.getJCasClassName(); try { - TypeSystemImpl.typeBeingLoadedThreadLocal.set(ti); // only for backwards compat with alpha02 release clazz = (Class<? extends TOP>) Class.forName(className, true, cl); } catch (ClassNotFoundException e) { // Class not found is normal, if there is no JCas for this class return clazz; - } finally { - TypeSystemImpl.typeBeingLoadedThreadLocal.set(null); } return clazz; Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java?rev=1822219&r1=1822218&r2=1822219&view=diff ============================================================================== --- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java (original) +++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java Thu Jan 25 18:51:21 2018 @@ -250,11 +250,11 @@ public class TypeSystemImpl implements T final private static Map<TypeSystemImpl, WeakReference<TypeSystemImpl>> committedTypeSystems = Collections.synchronizedMap(new WeakHashMap<>()); - /** - * used to pass the type being loaded reference to the JCas static initializer code, - * referenced from the TypeSystemImpl.getAdjustedFeatureOffset([featurename]) method. - */ - public final static ThreadLocal<TypeImpl> typeBeingLoadedThreadLocal = new ThreadLocal<TypeImpl>(); +// /** OBSOLETE with BETA and later levels +// * used to pass the type being loaded reference to the JCas static initializer code, +// * referenced from the TypeSystemImpl.getAdjustedFeatureOffset([featurename]) method. +// */ +// public final static ThreadLocal<TypeImpl> typeBeingLoadedThreadLocal = new ThreadLocal<TypeImpl>(); /****************************************** * I N S T A N C E V A R I A B L E S * @@ -2830,22 +2830,13 @@ public class TypeSystemImpl implements T */ // ******** OBSOLETE - only left in for supporting some jcas style in alpha level ************* public static synchronized int getAdjustedFeatureOffset(String featName) { - TypeImpl type = typeBeingLoadedThreadLocal.get(); - if (null == type) { - /*A JCas class is being loaded and initialized (by non-framework user code) before - * the type system with the corresponding type has been set up and committed. - * This is not allowed in UIMA v3 because the static class initialization code needs access to - * the type system in order to bridge the JCas class definition to the - * corresponding type system type. - * You can fix this by reordering your code to do the commit for the type system first, or - * if you're using a form like Class.forName("myJCasClass"), you can use the alternative - * API which only loads (but doesn't run the initialization: - * Class.forName("myJCasClass", false, this.getClass().getClassLoader()).*/ - throw new CASRuntimeException(CASRuntimeException.JCAS_CLASS_INITIALIZED_BEFORE_TYPE_SYSTEM_COMMIT); - } - - FeatureImpl fi = type.getFeatureByBaseName(featName); - return (fi == null) ? -1 : fi.getAdjustedOffset(); + /* The JCas class being loaded was generated for the "alpha" level of UIMA v3, + * and is not supported for Beta and later levels. + * + * This can be fixed by regenerating this using the current v3 version of UIMA tooling + * (JCasgen, or the migration tooling to migrate from v2). + */ + throw new CASRuntimeException(CASRuntimeException.JCAS_ALPHA_LEVEL_NOT_SUPPORTED); } static int getAdjustedFeatureOffset(TypeImpl type, String featName) {