本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ClassFile.getBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ClassFile.getBytes方法的具体用法?Java ClassFile.getBytes怎么用?Java ClassFile.getBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.ClassFile
的用法示例。
在下文中一共展示了ClassFile.getBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: acceptClassFiles
import org.eclipse.jdt.internal.compiler.ClassFile; //导入方法依赖的package包/类
/**
* @see ICodeSnippetRequestor
*/
public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) {
int length = classFiles.length;
byte[][] classFileBytes = new byte[length][];
String[][] compoundNames = new String[length][];
for (int i = 0; i < length; i++) {
ClassFile classFile = classFiles[i];
classFileBytes[i] = classFile.getBytes();
char[][] classFileCompundName = classFile.getCompoundName();
int length2 = classFileCompundName.length;
String[] compoundName = new String[length2];
for (int j = 0; j < length2; j++){
compoundName[j] = new String(classFileCompundName[j]);
}
compoundNames[i] = compoundName;
}
return this.requestor.acceptClassFiles(classFileBytes, compoundNames, codeSnippetClassName == null ? null : new String(codeSnippetClassName));
}
示例2: acceptResult
import org.eclipse.jdt.internal.compiler.ClassFile; //导入方法依赖的package包/类
public void acceptResult(final org.eclipse.jdt.internal.compiler.CompilationResult result) {
if (result.hasProblems()) {
// Store compilation problems
for (IProblem iproblem : result.getProblems()) {
problems.add(new EclipseCompilationProblem(iproblem));
}
}
if (!result.hasErrors()) {
final ClassFile[] classFiles = result.getClassFiles();
for (ClassFile classFile : classFiles) {
// Write class file to store
String className = NameUtils.getClassName(classFile.getCompoundName());
String resourceName = NameUtils.toBinaryName(className);
byte[] classBytes = classFile.getBytes();
getBinaryStore().write(resourceName, classBytes);
// Add to compiled resources
compiled.put(className, classBytes);
}
}
}
示例3: writeClassFile
import org.eclipse.jdt.internal.compiler.ClassFile; //导入方法依赖的package包/类
private void writeClassFile(Resource<File> input, String relativeStringName, ClassFile classFile) throws IOException {
final byte[] bytes = classFile.getBytes();
final File outputFile = new File(getOutputDirectory(), relativeStringName);
// context.associatedOutput resets output attributes set during earlier iterations of this incremental compile
// so deal with classfile digest before context.associatedOutput
final byte[] oldHash = context.getAttribute(outputFile, ATTR_CLASS_DIGEST, byte[].class);
final byte[] hash = digestClassFile(outputFile, bytes);
boolean significantChange = oldHash == null || hash == null || !Arrays.equals(hash, oldHash);
final Output<File> output = context.associatedOutput(input, outputFile);
if (hash != null) {
// TODO evaluate if this is useful
// trade-off is between storing digest on disk between builds
// and recomputing the hash each time class files are written
context.setAttribute(outputFile, ATTR_CLASS_DIGEST, hash);
}
if (significantChange) {
// find all sources that reference this type and put them into work queue
strategy.addDependentsOf(CharOperation.toString(classFile.getCompoundName()));
}
try (final BufferedOutputStream os = new BufferedOutputStream(output.newOutputStream())) {
os.write(bytes);
os.flush();
}
}
示例4: defineClass
import org.eclipse.jdt.internal.compiler.ClassFile; //导入方法依赖的package包/类
protected Class<?> defineClass(String name, ClassFile classFile) {
byte bs[] = classFile.getBytes();
Class<?> c = defineClass(name, bs, 0, bs.length);
putCachedClass(name, c);
return c;
}