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


Java ClassFile类代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ClassFile的典型用法代码示例。如果您正苦于以下问题:Java ClassFile类的具体用法?Java ClassFile怎么用?Java ClassFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClassFile类属于org.eclipse.jdt.internal.compiler包,在下文中一共展示了ClassFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: deployCodeSnippetClassIfNeeded

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
private void deployCodeSnippetClassIfNeeded(IRequestor requestor) throws InstallException {
	if (this.codeSnippetBinary == null) {
		// Deploy CodeSnippet class (only once)
		if (!requestor.acceptClassFiles(
			new ClassFile[] {
				new ClassFile() {
					public byte[] getBytes() {
						return getCodeSnippetBytes();
					}
					public char[][] getCompoundName() {
						return EvaluationConstants.ROOT_COMPOUND_NAME;
					}
				}
			},
			null))
				throw new InstallException();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:EvaluationContext.java

示例3: init

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
public void init(ClassFile targetClassFile) {
	super.init(targetClassFile);
	this.stateIndexesCounter = 0;
	if (this.framePositions != null) {
		this.framePositions.clear();
	}
	if (this.exceptionMarkers != null) {
		this.exceptionMarkers.clear();
	}
	if (this.stackDepthMarkers != null) {
		this.stackDepthMarkers.clear();
	}
	if (this.stackMarkers != null) {
		this.stackMarkers.clear();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:StackMapFrameCodeStream.java

示例4: reset

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
public void reset(ClassFile givenClassFile) {
	super.reset(givenClassFile);
	this.stateIndexesCounter = 0;
	if (this.framePositions != null) {
		this.framePositions.clear();
	}
	if (this.exceptionMarkers != null) {
		this.exceptionMarkers.clear();
	}
	if (this.stackDepthMarkers != null) {
		this.stackDepthMarkers.clear();
	}
	if (this.stackMarkers != null) {
		this.stackMarkers.clear();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:StackMapFrameCodeStream.java

示例5: reset

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
public void reset(LambdaExpression lambda, ClassFile targetClassFile) {
	init(targetClassFile);
	this.lambdaExpression = lambda;
	this.methodDeclaration = null;
	int[] lineSeparatorPositions2 = this.lineSeparatorPositions;
	if (lineSeparatorPositions2 != null) {
		int length = lineSeparatorPositions2.length;
		int lineSeparatorPositionsEnd = length - 1;
		int start = Util.getLineNumber(lambda.body().sourceStart, lineSeparatorPositions2, 0, lineSeparatorPositionsEnd);
		this.lineNumberStart = start;
		if (start > lineSeparatorPositionsEnd) {
			this.lineNumberEnd = start;
		} else {
			int end = Util.getLineNumber(lambda.body().sourceEnd, lineSeparatorPositions2, start - 1, lineSeparatorPositionsEnd);
			if (end >= lineSeparatorPositionsEnd) {
				end = length;
			}
			this.lineNumberEnd = end == 0 ? 1 : end;
		}

	}
	this.preserveUnusedLocals = lambda.scope.compilerOptions().preserveAllLocalVariables;
	initializeMaxLocals(lambda.binding);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:CodeStream.java

示例6: 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

示例7: getCachedClass

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
protected Class<?> getCachedClass(String name) {
    Class<?> c = null;
    if (classCache != null) {
        c = classCache.get(name);
    }

    // the class could be compiled but not yet define()d
    if (c == null && resultAccumulator != null) {
        ClassFile cf = resultAccumulator.get(name);
        if (cf != null) {
            c = defineClass(name, cf);
            resultAccumulator.remove(cf);
        }
    }
    return c;
}
 
开发者ID:CoCoViLa,项目名称:CoCoViLa,代码行数:17,代码来源:CCL.java

示例8: outputClassFiles

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
@Override
public void outputClassFiles(CompilationResult result) {
  super.outputClassFiles(result);

  if (result == null || result.hasErrors() && !proceedOnError) {
    return;
  }

  List<String> classFiles = new ArrayList<String>();
  for (ClassFile file : result.getClassFiles()) {
    classFiles.add(new String(file.fileName()) + ".class");
  }
  myOutputs.put(new String(result.getFileName()), classFiles);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GreclipseMain.java

示例9: acceptResult

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
public void acceptResult(CompilationResult result) {
	String className = ((CompilationUnit) result.getCompilationUnit()).className;

	int classIdx;
	for (classIdx = 0; classIdx < units.length; ++classIdx) {
		if (className.equals(units[classIdx].getName())) {
			break;
		}
	}

	if (result.hasErrors()) {
		// IProblem[] problems = result.getErrors();
		IProblem[] problems = getJavaCompilationErrors(result);

		unitResults[classIdx].problems = problems;

		String sourceCode = units[classIdx].getSourceCode();

		for (int i = 0; i < problems.length; i++) {
			IProblem problem = problems[i];

			if (IProblem.UndefinedMethod == problem.getID()) {
				if (problem.getSourceStart() >= 0 && problem.getSourceEnd() >= 0) {
					String methodName = sourceCode.substring(problem.getSourceStart(), problem.getSourceEnd() + 1);

					Method method = FunctionsUtil.getInstance(jasperReportsContext).getMethod4Function(methodName);
					if (method != null) {
						unitResults[classIdx].addMissingMethod(method);
						// continue;
					}
				}
			}
		}
	} else {
		ClassFile[] resultClassFiles = result.getClassFiles();
		for (int i = 0; i < resultClassFiles.length; i++) {
			units[classIdx].setCompileData(resultClassFiles[i].getBytes());
		}
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:41,代码来源:JRJdtCompiler.java

示例10: VariablesInfo

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
/**
 * Creates a new variables info.
 * The name of the global variable class is the simple name of this class.
 * The package name can be null if the variables have been defined in the default package.
 */
public VariablesInfo(char[] packageName, char[] className, ClassFile[] classFiles, GlobalVariable[] variables, int variableCount) {
	this.packageName = packageName;
	this.className = className;
	this.classFiles = classFiles;
	this.variables = variables;
	this.variableCount = variableCount;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:VariablesInfo.java

示例11: evaluateVariables

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
/**
 * @see org.eclipse.jdt.core.eval.IEvaluationContext
 * @exception org.eclipse.jdt.internal.eval.InstallException if the code snippet class files could not be deployed.
 */
public void evaluateVariables(INameEnvironment environment, Map options, IRequestor requestor, IProblemFactory problemFactory) throws InstallException {
	deployCodeSnippetClassIfNeeded(requestor);
	VariablesEvaluator evaluator = new VariablesEvaluator(this, environment, options, requestor, problemFactory);
	ClassFile[] classes = evaluator.getClasses();
	if (classes != null) {
		if (classes.length > 0) {
			// Sort classes so that enclosing types are cached before nested types
			// otherwise an AbortCompilation is thrown in 1.5 mode since the enclosing type
			// is needed to resolve a nested type
			Util.sort(classes, new Util.Comparer() {
				public int compare(Object a, Object b) {
					if (a == b) return 0;
					ClassFile enclosing = ((ClassFile) a).enclosingClassFile;
					while (enclosing != null) {
						if (enclosing == b)
							return 1;
						enclosing = enclosing.enclosingClassFile;
					}
					return -1;
				}
			});

			// Send classes
			if (!requestor.acceptClassFiles(classes, null)) {
				throw new InstallException();
			}

			// Remember that the variables have been installed
			int count = this.variableCount;
			GlobalVariable[] variablesCopy = new GlobalVariable[count];
			System.arraycopy(this.variables, 0, variablesCopy, 0, count);
			this.installedVars = new VariablesInfo(evaluator.getPackageName(), evaluator.getClassName(), classes, variablesCopy, count);
			VAR_CLASS_COUNTER++;
		}
		this.varsChanged = false;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:42,代码来源:EvaluationContext.java

示例12: generateCode

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
public void generateCode(ClassScope classScope, ClassFile classFile) {
	int problemResetPC = 0;
	classFile.codeStream.wideMode = false;
	boolean restart = false;
	do {
		try {
			problemResetPC = classFile.contentsOffset;
			this.generateCode(classFile);
			restart = false;
		} catch (AbortMethod e) {
			// Restart code generation if possible ...
			if (e.compilationResult == CodeStream.RESTART_IN_WIDE_MODE) {
				// a branch target required a goto_w, restart code generation in wide mode.
				classFile.contentsOffset = problemResetPC;
				classFile.methodCount--;
				classFile.codeStream.resetInWideMode(); // request wide mode
				restart = true;
			} else if (e.compilationResult == CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE) {
				classFile.contentsOffset = problemResetPC;
				classFile.methodCount--;
				classFile.codeStream.resetForCodeGenUnusedLocals();
				restart = true;
			} else {
				throw new AbortType(this.compilationResult, e.problem);
			}
		}
	} while (restart);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:LambdaExpression.java

示例13: cleanUp

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
public void cleanUp() {
	if (this.types != null) {
		for (int i = 0, max = this.types.length; i < max; i++) {
			cleanUp(this.types[i]);
		}
		for (int i = 0, max = this.localTypeCount; i < max; i++) {
		    LocalTypeBinding localType = this.localTypes[i];
			// null out the type's scope backpointers
			localType.scope = null; // local members are already in the list
			localType.enclosingCase = null;
		}
	}

	this.compilationResult.recoveryScannerData = null; // recovery is already done

	ClassFile[] classFiles = this.compilationResult.getClassFiles();
	for (int i = 0, max = classFiles.length; i < max; i++) {
		// clear the classFile back pointer to the bindings
		ClassFile classFile = classFiles[i];
		// null out the classfile backpointer to a type binding
		classFile.referenceBinding = null;
		classFile.innerClassesBindings = null;
		classFile.bootstrapMethods = null;
		classFile.missingTypes = null;
		classFile.visitedTypes = null;
	}

	this.suppressWarningAnnotations = null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:CompilationUnitDeclaration.java

示例14: writeToDisk

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
/**
	 * outputPath is formed like:
	 *	   c:\temp\ the last character is a file separator
	 * relativeFileName is formed like:
	 *     java\lang\String.class
	 * @param generatePackagesStructure a flag to know if the packages structure has to be generated.
	 * @param outputPath the given output directory
	 * @param relativeFileName the given relative file name
	 * @param classFile the given classFile to write
	 *
	 */
	public static void writeToDisk(boolean generatePackagesStructure, String outputPath, String relativeFileName, ClassFile classFile) throws IOException {
		FileOutputStream file = getFileOutputStream(generatePackagesStructure, outputPath, relativeFileName);
		/* use java.nio to write
		if (true) {
			FileChannel ch = file.getChannel();
			try {
				ByteBuffer buffer = ByteBuffer.allocate(classFile.headerOffset + classFile.contentsOffset);
				buffer.put(classFile.header, 0, classFile.headerOffset);
				buffer.put(classFile.contents, 0, classFile.contentsOffset);
				buffer.flip();
				while (true) {
					if (ch.write(buffer) == 0) break;
				}
			} finally {
				ch.close();
			}
			return;
		}
		*/
		BufferedOutputStream output = new BufferedOutputStream(file, DEFAULT_WRITING_SIZE);
//		BufferedOutputStream output = new BufferedOutputStream(file);
		try {
			// if no IOException occured, output cannot be null
			output.write(classFile.header, 0, classFile.headerOffset);
			output.write(classFile.contents, 0, classFile.contentsOffset);
			output.flush();
		} catch(IOException e) {
			throw e;
		} finally {
			output.close();
		}
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:44,代码来源:Util.java

示例15: ConstantPool

import org.eclipse.jdt.internal.compiler.ClassFile; //导入依赖的package包/类
/**
 * ConstantPool constructor comment.
 */
public ConstantPool(ClassFile classFile) {
	this.UTF8Cache = new CharArrayCache(UTF8_INITIAL_SIZE);
	this.stringCache = new CharArrayCache(STRING_INITIAL_SIZE);
	this.methodsAndFieldsCache = new HashtableOfObject(METHODS_AND_FIELDS_INITIAL_SIZE);
	this.classCache = new CharArrayCache(CLASS_INITIAL_SIZE);
	this.nameAndTypeCacheForFieldsAndMethods = new HashtableOfObject(NAMEANDTYPE_INITIAL_SIZE);
	this.offsets = new int[5];
	initialize(classFile);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:ConstantPool.java


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