private void maybeAssignGosuType(String strType) {
    if (strType.contains(IGosuProgram.NAME_PREFIX + "eval_")) {
      // Never load an eval class here, they should always load in a single-serving loader
      return;
    }
    ClassLoader loader = TypeSystem.getGosuClassLoader().getActualLoader();
    TypeSystemLockHelper.getTypeSystemLockWithMonitor(loader);
    try {

      IModule global = TypeSystem.getGlobalModule();
      IType type;
      TypeSystem.pushModule(global);
      try {
        type = TypeSystem.getByFullNameIfValidNoJava(strType);
      } finally {
        TypeSystem.popModule(global);
      }
      if (type instanceof ICompilableType) {
        if (!isInSingleServingLoader(type.getEnclosingType())) {
          _type = (ICompilableType) type;
        }
      }
    } finally {
      TypeSystem.unlock();
    }
  }
Пример #2
0
 @Override
 public Class loadClass(String strName) throws ClassNotFoundException {
   TypeSystemLockHelper.getTypeSystemLockWithMonitor(_loader);
   try {
     String strGsName = strName.replace('$', '.');
     // ## hack:
     if (strGsName.startsWith("com.guidewire.commons.metadata.proxy._generated.iface.")) {
       strGsName = "entity." + strGsName.substring(strName.lastIndexOf('.') + 1);
     }
     IType type = TypeSystem.getByFullNameIfValid(strGsName);
     if (type instanceof IGosuClassInternal) {
       return ((IGosuClassInternal) type).getBackingClass();
     } else if (type instanceof IJavaBackedType) {
       return ((IJavaBackedType) type).getBackingClass();
     }
     return _loader.loadClass(strName);
   } finally {
     TypeSystem.unlock();
   }
 }
 private void init() {
   if (_buf == null) {
     ClassLoader loader = TypeSystem.getGosuClassLoader().getActualLoader();
     TypeSystemLockHelper.getTypeSystemLockWithMonitor(loader);
     try {
       if (_bInterfaceAnnotationMethods) {
         _buf =
             TransformingCompiler.compileInterfaceMethodsClass(
                 (IGosuClassInternal) _type, false);
       } else {
         // System.out.println( "Compiling: " + _type.getName() );
         _buf = GosuClassLoader.instance().getBytes(_type);
       }
       _pos = 0;
       _count = _buf.length;
     } catch (Throwable e) {
       // log the exception, it tends to get swollowed esp. if it's the class doesn't parse
       e.printStackTrace();
       throw GosuExceptionUtil.forceThrow(e);
     } finally {
       TypeSystem.unlock();
     }
   }
 }