本文整理汇总了Java中org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read方法的典型用法代码示例。如果您正苦于以下问题:Java ClassFileReader.read方法的具体用法?Java ClassFileReader.read怎么用?Java ClassFileReader.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader
的用法示例。
在下文中一共展示了ClassFileReader.read方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findType
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
@Override
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
try {
final Function1<char[], String> _function = (char[] it) -> {
return String.valueOf(it);
};
String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/");
final String fileName = (_join + ".class");
boolean _containsKey = this.cache.containsKey(fileName);
if (_containsKey) {
return this.cache.get(fileName);
}
final URL url = this.classLoader.getResource(fileName);
if ((url == null)) {
this.cache.put(fileName, null);
return null;
}
final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
this.cache.put(fileName, result);
return result;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例2: findClass
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
public NameEnvironmentAnswer findClass(
String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
if (!isPackage(qualifiedPackageName)) return null; // most common case
try {
ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName);
if (reader != null) {
if (this.accessRuleSet == null) return new NameEnvironmentAnswer(reader, null);
String fileNameWithoutExtension =
qualifiedBinaryFileName.substring(
0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
return new NameEnvironmentAnswer(
reader,
this.accessRuleSet.getViolatedRestriction(fileNameWithoutExtension.toCharArray()));
}
} catch (IOException | ClassFormatException e) { // treat as if class file is missing
}
return null;
}
示例3: gleanNamedType
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
Map<String, String> gleanNamedType(File classfile) throws IOException {
// use jdt class reader to avoid extra runtime dependency, otherwise could use asm
try {
ClassFileReader type = ClassFileReader.read(classfile);
IBinaryAnnotation[] annotations = type.getAnnotations();
if (annotations != null) {
for (IBinaryAnnotation annotation : annotations) {
if ("Ljavax/inject/Named;".equals(new String(annotation.getTypeName()))) {
return Collections.singletonMap(new String(type.getName()).replace('/', '.'), null);
}
}
}
} catch (ClassFormatException e) {
// silently ignore classes we can't read/parse
}
return null;
}
示例4: newClassFileReader
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
public static ClassFileReader newClassFileReader(IResource resource)
throws CoreException, ClassFormatException, IOException {
InputStream in = null;
try {
in = ((IFile) resource).getContents(true);
return ClassFileReader.read(in, resource.getFullPath().toString());
} finally {
if (in != null) in.close();
}
}
示例5: newClassFileReader
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
public static ClassFileReader newClassFileReader(IResource resource) throws CoreException, ClassFormatException, IOException {
InputStream in = null;
try {
in = ((IFile) resource).getContents(true);
return ClassFileReader.read(in, resource.getFullPath().toString());
} finally {
if (in != null)
in.close();
}
}
示例6: findType
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
@Override
public NameEnvironmentAnswer findType(String packageName, String typeName, AccessRestriction accessRestriction) {
try {
String qualifiedFileName = packageName + "/" + typeName + SUFFIX_STRING_class;
ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedFileName);
if (reader != null) {
return new NameEnvironmentAnswer(reader, accessRestriction);
}
} catch (ClassFormatException | IOException e) {
// treat as if class file is missing
}
return null;
}
示例7: findType
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
@Override
public NameEnvironmentAnswer findType(String packageName, String typeName, AccessRestriction accessRestriction) {
try {
Path classFile = getFile(packageName, typeName);
if (classFile != null) {
try (InputStream is = Files.newInputStream(classFile)) {
return new NameEnvironmentAnswer(ClassFileReader.read(is, classFile.getFileName().toString(), false), accessRestriction);
}
}
} catch (ClassFormatException | IOException e) {
// treat as if type is missing
}
return null;
}
示例8: findType
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
public NameEnvironmentAnswer findType(final QualifiedName className) {
try {
boolean _containsKey = this.cache.containsKey(className);
if (_containsKey) {
return this.cache.get(className);
}
final IEObjectDescription candidate = IterableExtensions.<IEObjectDescription>head(this.resourceDescriptions.getExportedObjects(TypesPackage.Literals.JVM_DECLARED_TYPE, className, false));
NameEnvironmentAnswer result = null;
if ((candidate != null)) {
final IResourceDescription resourceDescription = this.resourceDescriptions.getResourceDescription(candidate.getEObjectURI().trimFragment());
final Resource res = this.resource.getResourceSet().getResource(resourceDescription.getURI(), false);
String _xifexpression = null;
if ((res instanceof JavaResource)) {
_xifexpression = ((JavaResource) res).getOriginalSource();
} else {
_xifexpression = this.stubGenerator.getJavaStubSource(candidate, resourceDescription);
}
final String source = _xifexpression;
char[] _charArray = source.toCharArray();
String _string = className.toString("/");
String _plus = (_string + ".java");
CompilationUnit _compilationUnit = new CompilationUnit(_charArray, _plus, null);
NameEnvironmentAnswer _nameEnvironmentAnswer = new NameEnvironmentAnswer(_compilationUnit, null);
result = _nameEnvironmentAnswer;
} else {
String _string_1 = className.toString("/");
final String fileName = (_string_1 + ".class");
final URL url = this.classLoader.getResource(fileName);
if ((url == null)) {
this.cache.put(className, null);
return null;
}
final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
NameEnvironmentAnswer _nameEnvironmentAnswer_1 = new NameEnvironmentAnswer(reader, null);
result = _nameEnvironmentAnswer_1;
}
this.cache.put(className, result);
return result;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}