本文整理汇总了Java中com.google.gwt.dev.javac.CompiledClass类的典型用法代码示例。如果您正苦于以下问题:Java CompiledClass类的具体用法?Java CompiledClass怎么用?Java CompiledClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompiledClass类属于com.google.gwt.dev.javac包,在下文中一共展示了CompiledClass类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findClass
import com.google.gwt.dev.javac.CompiledClass; //导入依赖的package包/类
/**
* Looks up classes in GWT's compilation state.
*/
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
if (!loadedClassFiles) {
classFileMap = extractClassFileMap();
loadedClassFiles = true;
}
if (classFileMap == null) {
throw new ClassNotFoundException(name);
}
String internalName = name.replace('.', '/');
CompiledClass compiledClass = classFileMap.get(internalName);
if (compiledClass == null) {
throw new ClassNotFoundException(name);
}
// Make sure the class's package is present.
String pkg = compiledClass.getPackageName();
if (getPackage(pkg) == null) {
definePackage(pkg, null, null, null, null, null, null, null);
}
byte[] bytes = compiledClass.getBytes();
return defineClass(name, bytes, 0, bytes.length);
}
示例2: extractClassFileMap
import com.google.gwt.dev.javac.CompiledClass; //导入依赖的package包/类
/**
* Retrieves class definitions from a {@link GeneratorContext} by downcasting.
*/
private Map<String, CompiledClass> extractClassFileMap() {
if (context instanceof StandardGeneratorContext) {
StandardGeneratorContext standardContext = (StandardGeneratorContext) context;
return standardContext.getCompilationState().getClassFileMap();
} else {
logger.log(TreeLogger.Type.WARN,
String.format("Could not load generated classes from GWT context, "
+ "encountered unexpected generator type %s.", context.getClass()));
return null;
}
}