当前位置: 首页>>代码示例>>Java>>正文


Java ClassFile.getBytes方法代码示例

本文整理汇总了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));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:RequestorWrapper.java

示例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);
		}
	}
}
 
开发者ID:MattiasBuelens,项目名称:junit,代码行数:21,代码来源:EclipseCompiler.java

示例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();
  }
}
 
开发者ID:takari,项目名称:takari-lifecycle,代码行数:30,代码来源:CompilerJdt.java

示例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;
}
 
开发者ID:CoCoViLa,项目名称:CoCoViLa,代码行数:7,代码来源:CCL.java


注:本文中的org.eclipse.jdt.internal.compiler.ClassFile.getBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。