You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2017/09/14 14:48:42 UTC

svn commit: r1808348 - in /uima/uv3/uimaj-v3/trunk/uimaj-core/src/main: java/org/apache/uima/cas/CASRuntimeException.java java/org/apache/uima/cas/impl/TypeSystemImpl.java resources/org/apache/uima/UIMAException_Messages.properties

Author: schor
Date: Thu Sep 14 14:48:42 2017
New Revision: 1808348

URL: http://svn.apache.org/viewvc?rev=1808348&view=rev
Log:
[UIMA-5554] improve error message

Modified:
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java?rev=1808348&r1=1808347&r2=1808348&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java Thu Sep 14 14:48:42 2017
@@ -124,9 +124,15 @@ public class CASRuntimeException extends
    */
 	public static final String JCAS_UNKNOWN_TYPE_NOT_IN_CAS = "JCAS_UNKNOWN_TYPE_NOT_IN_CAS";
 
-	/*A JCas class field "{0}" is being initialized by non-framework (user) code before Type System Commit 
-	 * for a type system with a corresponding type. 
-	 * Either change the user load code to not do initialize, or to defer it until after the type system commit.*/
+  /*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()).*/
 	public static final String JCAS_CLASS_INITIALIZED_BEFORE_TYPE_SYSTEM_COMMIT = "JCAS_CLASS_INITIALIZED_BEFORE_TYPE_SYSTEM_COMMIT";
 	/**
    * JCas getNthElement method called via invalid object - an empty list: {0}.

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=1808348&r1=1808347&r2=1808348&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 Sep 14 14:48:42 2017
@@ -2569,10 +2569,16 @@ public class TypeSystemImpl implements T
   public static synchronized int getAdjustedFeatureOffset(String featName) {
     TypeImpl type = typeBeingLoadedThreadLocal.get();
     if (null == type) {
-      /*A JCas class field "{0}" is being initialized by non-framework (user) code before Type System Commit 
-       * for a type system with a corresponding type. 
-       * Either change the user load code to not do initialize, or to defer it until after the type system commit.*/
-      throw new CASRuntimeException(CASRuntimeException.JCAS_CLASS_INITIALIZED_BEFORE_TYPE_SYSTEM_COMMIT, featName);
+      /*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();

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties?rev=1808348&r1=1808347&r2=1808348&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties Thu Sep 14 14:48:42 2017
@@ -565,7 +565,7 @@ JCAS_GET_NTH_PAST_END = JCas getNthEleme
 JCAS_OLDSTYLE_REF_TO_NONJCAS_TYPE = JCas is referencing via a JFSIterator or get method, a type, "{0}", which has no JCAS class model.  You must use FSIterator instead of JFSIterator.
 JCAS_MAKING_ABSTRACT_INSTANCE = A CAS iterator or createFS call is trying to make an instance of type "{0}", but that type has been declared "abstract" in JCas, and no instances are allowed to be made.
 JCAS_UNSUPPORTED_OP_NOT_TCAS = The method "{0}" is not supported by this JCAS because it is not associated with a TCAS view of a CAS, but rather just with a base CAS.
-JCAS_CLASS_INITIALIZED_BEFORE_TYPE_SYSTEM_COMMIT = A JCas class field "{0}" is being initialized by non-framework (user) code before Type System Commit for a type system with a corresponding type. Either change the user load code to not do initialize, or to defer it until after the type system commit.
+JCAS_CLASS_INITIALIZED_BEFORE_TYPE_SYSTEM_COMMIT = 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.\nThis 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.\nYou can fix this by reordering your code to do the commit for the type system first,\nor 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()).
 SOFANAME_ALREADY_EXISTS = A sofaFS with name {0} has already been created.
 SOFADATA_ALREADY_SET = Data for Sofa feature {0} has already been set.
 SOFANAME_NOT_FOUND = No sofaFS with name {0} found.