public void uninitializeMultipleModules( IExecutionEnvironment execEnv ) { if (ExecutionMode.isRuntime()) { throw new IllegalStateException( "The typesystem is not in multi-module mode." ); } ((ExecutionEnvironment)execEnv).uninitializeMultipleModules(); } }
protected ClassPath init() { return new ClassPath( _module, ExecutionMode.isRuntime() ? IClassPath.ONLY_API_CLASSES : // FIXME-isd: for performance reasons, only select API classes IClassPath.ALLOW_ALL_WITH_SUN_FILTER); } };
public ClassCache(final IModule module) { _module = module; ignoreTheCache = ExecutionMode.isRuntime(); _classPathCache = new LockingLazyVar<ClassPath>() { protected ClassPath init() { return new ClassPath( _module, ExecutionMode.isRuntime() ? IClassPath.ONLY_API_CLASSES : // FIXME-isd: for performance reasons, only select API classes IClassPath.ALLOW_ALL_WITH_SUN_FILTER); } }; _asmClassLoader = new AsmClassLoader(_module); }
public static ClassLoader create(IModule module) { List<IDirectory> javaClassPath = module.getJavaClassPath(); List<URL> urls = new ArrayList<URL>(javaClassPath.size()); for (IDirectory entry : javaClassPath) { try { urls.add(entry.toURI().toURL()); } catch (MalformedURLException e) { throw new RuntimeException(e); } } IExecutionEnvironment environment = module.getExecutionEnvironment(); if (ExecutionMode.isRuntime()) { // XXX-isd: we need discardable classloader for JRE module, so we can use it for defining throw-away proxy classes. urls = Collections.emptyList(); //return CommonServices.getEntityAccess().getPluginClassLoader(); } // JRE module delegates to plugin classloader, all other modules delegate to JRE module first. ClassLoader parent = (module == environment.getJreModule()) ? CommonServices.getEntityAccess().getPluginClassLoader() : null; //environment.getJreModule().getModuleClassLoader(); return new ModuleClassLoader(urls.toArray(new URL[urls.size()]), parent, module); }
private static boolean shouldReplaceAnyway(IJavaClassInfo cls, JavaClassIRType javaClassIRType) { if( ILanguageLevel.Util.STANDARD_GOSU() ) { return false; } // Barf... return ExecutionMode.isRuntime() && !equal(javaClassIRType.getJavaClassInfo().getBackingClass().getClassLoader(), cls.getBackingClass().getClassLoader()); }
/** * Wraps the actual class with a proxy. */ @Override public ITypeRef create( IType type ) { // already a proxy? return as is then if( type instanceof ITypeRef ) { return (ITypeRef)type; } if( type instanceof INonLoadableType ) { throw new UnsupportedOperationException( "Type references are not supported for nonloadable types: " + type.getName() ); } String strTypeName = TypeLord.getNameWithQualifiedTypeVariables( type, true ); if( strTypeName == null || strTypeName.length() == 0 ) { throw new IllegalStateException( "Type has no name" ); } ITypeRef ref; if (ExecutionMode.isRuntime()) { ref = getRefTheFastWay(type, strTypeName); } else { ref = getRefTheSafeWay(type, strTypeName); } return ref; }
@Override public Class getBackingClass() { if( !ExecutionMode.isRuntime() ) { return null; } try { return Class.forName( getJavaName(), false, TypeSystem.getCurrentModule().getModuleClassLoader() ); } catch( ClassNotFoundException e ) { throw GosuExceptionUtil.forceThrow( e ); } }
private IJavaClassInfo getByClass( String className, IModule lookupModule, IModule actualModule ) { DefaultTypeLoader loader = (DefaultTypeLoader)lookupModule.getTypeLoaders( IDefaultTypeLoader.class ).get( 0 ); if( ExecutionMode.isRuntime() ) { Class theClass = loader.loadClass( className ); if( theClass == null ) { return null; } return getJavaClassInfo( theClass, actualModule ); } else { AsmClass theClass = loader.loadAsmClass( className ); if( theClass == null ) { return null; } return getJavaClassInfo( theClass, actualModule ); } }
private static ExtendedTypeDataFactory getExtendedTypeDataFactory(IJavaType javaType) { boolean extendedType; if( ExecutionMode.isRuntime() ) { Class<?> backingClass = javaType.getBackingClass(); // Server runtime case. We can't go through the IJavaClassInfo for this case, because it leads to a // circularity w.r.t. the JavaType (ClassAnnotationInfo attempts to get the JavaType) extendedType = backingClass.isAnnotationPresent(ExtendedType.class); } else { // Studio case extendedType = javaType.getBackingClassInfo().getAnnotation(ExtendedType.class) != null; } return extendedType ? CommonServices.getEntityAccess().getExtendedTypeDataFactory(javaType.getName()) : null; }
public static IJavaClassInfo getClassInfo(Class aClass, IModule gosuModule) { DefaultTypeLoader loader = (DefaultTypeLoader) gosuModule.getModuleTypeLoader().getDefaultTypeLoader(); if (isProxy(aClass)) { return loader.getJavaClassInfo( aClass, gosuModule ); } else if (aClass.isArray()) { IJavaClassInfo classInfo = getClassInfo(aClass.getComponentType(), gosuModule); IModule module = classInfo.getModule(); return loader.getJavaClassInfo(aClass, module); } else { if( ExecutionMode.isRuntime() ) { // Don't try to load from source unless we have to, this saves a load of time esp. for case // where we're loading an inner java class where replacing the '$' below with '.' we bascially // put the type system through a load of unnecessary work. IJavaClassInfo javaClassInfo = loader.getJavaClassInfo( aClass, gosuModule ); if (javaClassInfo != null) { return javaClassInfo; } } return getClassInfo(aClass.getName().replace('$', '.'), gosuModule); } }
public void refreshedImpl() { JavaType.unloadTypes(); if (ExecutionMode.isRuntime()) { _classCache.clearClasspathInfo(); } else { _classCache.dispose(); _classCache = new ClassCache(getModule()); dumpGosuClassLoader(); } _namespaces = null; _classInfoCache.clear(); _module.getFileRepository().typesRefreshed( null ); JavaTypes.flushCache(); }
public void maybeClearDebugInfo() { if (ExecutionMode.isRuntime()) { TypeSystem.lock(); try { if (!_gosuClass.getTypeLoader().shouldKeepDebugInfo(_gosuClass)) { clearDebugInfoOnFields(_mapStaticFields.values()); clearDebugInfoOnFields(_mapMemberFields.values()); clearDebugInfoOnProperties(_listStaticProperties); clearDebugInfoOnProperties(_mapMemberProperties.values()); clearDebugInfoOnFunctions(_mapMemberFunctions.values()); clearDebugInfoOnFunctions(_listStaticFunctions); clearDebugInfoOnFunctions(_mapConstructorFunctions.values()); clearDebugInfoOnAnnotations(_gosuClass.getModifierInfo().getAnnotations()); getClassStatement().clearParseTreeInformation(); Set<IUsesStatement> usesStatements = _gosuClass.getTypeUsesMap() == null ? null : _gosuClass.getTypeUsesMap().getUsesStatements(); if (usesStatements != null) { for (IUsesStatement usesStatement : usesStatements) { usesStatement.clearParseTreeInformation(); } } } } finally { TypeSystem.unlock(); } } }