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


Java ClassFormatException类代码示例

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


ClassFormatException类属于org.apache.bcel.classfile包,在下文中一共展示了ClassFormatException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNextClass

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
public JavaClass getNextClass() throws IOException, InterruptedException {
	if (url == null)
		return null;
	if (Thread.interrupted())
		throw new InterruptedException();

	URL urlToParse = url;
	url = null; // don't return it next time

	// ClassScreener may veto this class.
	if (!classScreener.matches(urlToParse.toString()))
		return null;

	try {
		return parseClass(urlToParse);
	} catch (ClassFormatException e) {
		throw new ClassFormatException("Invalid class file format for " +
		        url.toString() + ": " + e.getMessage());
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:FindBugs.java

示例2: verify

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
/**
 * Verify the integrity of the jar file.
 * 
 * @throws IOException
 * @throws ClassFormatException
 */
private void verify() throws ClassFormatException, IOException {
	for (JavaClass cls : bcelClasses) {
		Verifier verifier = VerifierFactory.getVerifier(cls.getClassName());
		Method[] methods = cls.getMethods();
		for (int i = 0; i < methods.length; i++) {
			VerificationResult vr;
			// Do a pass 3a for the constructor of java.lang.Object because
			// we are using an uninitialized "this".
			if (cls.getClassName().equals(Names.JAVA_LANG_OBJECT)
					&& methods[i].getName().equals(SootMethod.constructorName)) {
				vr = verifier.doPass3a(i);
			} else {
				vr = verifier.doPass3b(i);
			}

			Assertions.verificationResultOKAssertion(vr, cls.getClassName(), methods[i].getName());
		}
	}
}
 
开发者ID:karimhamdanali,项目名称:averroes,代码行数:26,代码来源:JarFile.java

示例3: verifyPathAdheresToDesign

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
private void verifyPathAdheresToDesign(Design d, Path p) throws ClassFormatException, IOException {
	String files[] = p.list();
	for (int i = 0; i < files.length; i++) {
		File file = new File(files[i]);
		if (file.isDirectory()) {
			FileSet set = new FileSet();
			set.setDir(file);
			set.setProject(task.getProject());
			PatternSet.NameEntry entry1 = set.createInclude();
			PatternSet.NameEntry entry2 = set.createInclude();
			PatternSet.NameEntry entry3 = set.createInclude();
			entry1.setName("**/*.class");
			entry2.setName("**/*.jar");
			entry3.setName("**/*.war");
			DirectoryScanner scanner = set.getDirectoryScanner(task.getProject());
			scanner.setBasedir(file);
			String[] scannerFiles = scanner.getIncludedFiles();
			for (int j = 0; j < scannerFiles.length; j++) {
				verifyPartOfPath(scannerFiles[j], new File(file, scannerFiles[j]), d);
			}
		} else
			verifyPartOfPath(files[i], file, d);
	}
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:25,代码来源:VerifyDesignDelegate.java

示例4: verifyClassAdheresToDesign

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
private void verifyClassAdheresToDesign(Design d, File classFile) throws ClassFormatException, IOException {
	FileInputStream fis = null;
	try {
		fis = new FileInputStream(classFile);
		verifyClassAdheresToDesign(d, fis, classFile.getAbsolutePath(), classFile);
	} finally {
		try {
			if (fis != null) {
				fis.close();
			}
		} catch (IOException e) {
			; // doh!!
		}
	}

}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:17,代码来源:VerifyDesignDelegate.java

示例5: testInitializeWithInvalidClassListShouldThrowClassFormatException

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
@Test
public void testInitializeWithInvalidClassListShouldThrowClassFormatException() throws IOException {
    //GIVEN
    List<String> list = new ArrayList<>();
    list.add(FOLDER_NAME);
    Collection<File> filesInFolder = new ArrayList<>();
    File invalidClass = new File("InvalidClass.class");
    filesInFolder.add(invalidClass);
    given(fileUtils.listFiles(FOLDER)).willReturn(filesInFolder);
    given(javaClassFactory.createJavaClass(invalidClass)).willThrow(new ClassFormatException());
    Whitebox.setInternalState(underTest, "logger", logger);
    //WHEN
    underTest.initialize(list);
    //THEN
    verify(logger).info(Mockito.anyString(), Mockito.any(ClassFormatException.class));
}
 
开发者ID:epam,项目名称:Wilma,代码行数:17,代码来源:ClassNameMapperTest.java

示例6: get

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
static StackFrameType get(int frame_type) {
    if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) {
        return SAME_FRAME;
    } else if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME
            && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
        return SAME_LOCALS_1_STACK_ITEM_FRAME;
    } else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
        return SAME_LOCALS_1_STACK_ITEM_FRAME;
    } else if (frame_type >= Constants.CHOP_FRAME && frame_type <= Constants.CHOP_FRAME_MAX) {
        return CHOP_FRAME;
    } else if (frame_type == Constants.SAME_FRAME_EXTENDED) {
        return SAME_FRAME;
    } else if (frame_type >= Constants.APPEND_FRAME && frame_type <= Constants.APPEND_FRAME_MAX) {
        return APPEND_FRAME;
    } else if (frame_type == Constants.FULL_FRAME) {
        return FULL_FRAME;
    } else {
        /* Can't happen */
        throw new ClassFormatException("Invalid frame type : " + frame_type);
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:22,代码来源:StackMapAnalyzer.java

示例7: getArgumentTypes

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
/**
 * Convert arguments of a method (signature) to an array of Type objects.
 * @param signature signature string such as (Ljava/lang/String;)V
 * @return array of argument types
 */
public static Type[] getArgumentTypes( String signature ) {
    List vec = new ArrayList();
    int index;
    Type[] types;
    try { // Read all declarations between for `(' and `)'
        if (signature.charAt(0) != '(') {
            throw new ClassFormatException("Invalid method signature: " + signature);
        }
        index = 1; // current string position
        while (signature.charAt(index) != ')') {
            vec.add(getType(signature.substring(index)));
            //corrected concurrent private static field acess
            index += unwrap(consumed_chars); // update position
        }
    } catch (StringIndexOutOfBoundsException e) { // Should never occur
        throw new ClassFormatException("Invalid method signature: " + signature);
    }
    types = new Type[vec.size()];
    vec.toArray(types);
    return types;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:27,代码来源:Type.java

示例8: options

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
/**
 * Java options.
 * @return Options
 */
private Collection<String> options() {
    final Collection<String> opts = new LinkedList<>();
    opts.add("-classpath");
    opts.add(
        StringUtils.join(
            Arrays.asList(
                this.jar(Wrap.class),
                this.jar(FindBugs2.class),
                this.jar(ClassFormatException.class),
                this.jar(DocumentException.class),
                this.jar(JaxenException.class),
                this.jar(ClassNode.class),
                this.jar(ClassVisitor.class),
                this.jar(When.class),
                this.jar(FormatterNumberFormatException.class),
                this.jar(StringEscapeUtils.class),
                this.jar(FBContrib.class),
                this.jar(Iterables.class)
            ),
            // @checkstyle MultipleStringLiteralsCheck (1 line)
            System.getProperty("path.separator")
        ).replace("\\", "/")
    );
    return opts;
}
 
开发者ID:teamed,项目名称:qulice,代码行数:30,代码来源:FindBugsValidator.java

示例9: getArgumentTypes

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
/**
 * Convert arguments of a method (signature) to an array of Type objects.
 *
 * @param signature signature string such as (Ljava/lang/String;)V
 * @return array of argument types
 */
public static Type[] getArgumentTypes(String signature) {
    ArrayList<Type> vec = new ArrayList<Type>();
    int index;
    Type[] types;

    try { // Read all declarations between for `(' and `)'
        if (signature.charAt(0) != '(')
            throw new ClassFormatException("Invalid method signature: " + signature);

        index = 1; // current string position

        while (signature.charAt(index) != ')') {
            vec.add(getType(signature.substring(index)));
            index += consumed_chars; // update position
        }
    } catch (StringIndexOutOfBoundsException e) { // Should never occur
        throw new ClassFormatException("Invalid method signature: " + signature);
    }

    types = new Type[vec.size()];
    vec.toArray(types);
    return types;
}
 
开发者ID:miuirussia,项目名称:KJBE,代码行数:30,代码来源:Type.java

示例10: testCreateFilePathShouldRethrowClassFormatExceptionAsCannotUploadExternalResourceException

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
@Test(expectedExceptions = CannotUploadExternalResourceException.class)
public void testCreateFilePathShouldRethrowClassFormatExceptionAsCannotUploadExternalResourceException() throws IOException {
    //GIVEN
    given(fileFactory.createFile(FILE_NAME)).willReturn(file);
    given(file.getParent()).willReturn(PARENT_DIRECTORY);
    given(file.getName()).willReturn(SIMPLE_CLASS_NAME);
    given(javaClassFactory.createJavaClass(classFile, FILE_NAME)).willThrow(new ClassFormatException());
    //WHEN
    underTest.createFilePath(classFile, FILE_NAME, EXCEPTION_MESSAGE);
    //THEN error is thrown
}
 
开发者ID:epam,项目名称:Wilma,代码行数:12,代码来源:ClassFilePathAssemblerTest.java

示例11: getConstantPool

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
public static Set<Object> getConstantPool(InputStream is, String name) throws ClassFormatException, IOException {
	HashSet<Object> constants = new HashSet<Object>();
	ClassParser parser = new ClassParser(is, name);
	ConstantPool pool = parser.parse().getConstantPool();
	for (Constant constant : pool.getConstantPool()) {
		//Strings used in code are stored using String constant, they are just references to Utf8 constant
		//but we can't use Utf8 constants because they are used to store field/method/class names and signatures too
		if (constant instanceof ConstantString) {
			String string = (String) ((ConstantString) constant).getConstantValue(pool);
			//skip empty string
			if (string.isEmpty()) {
				continue;
			}
			constants.add(string);
		}
		if (constant instanceof ConstantInteger || constant instanceof ConstantLong || constant instanceof ConstantFloat || constant instanceof ConstantDouble) {
			constants.add(((ConstantObject) constant).getConstantValue(pool));
		}
	}
	return constants;
}
 
开发者ID:MCCarbon,项目名称:DecompileTools,代码行数:22,代码来源:ClassFinderHelpers.java

示例12: getClass

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
public static Object getClass(File file, FileEnum fileEnum) throws ClassFormatException, IOException {
	switch (fileEnum) {
	case JAVA:
		return loadClass(file, getClassPackage(file));
	case CLASS:
		ClassParser parser = new ClassParser(file.getName());
		JavaClass javaClass = parser.parse();
		return javaClass;
	default:
		return null;
	}
}
 
开发者ID:ralphavalon,项目名称:statement-generator,代码行数:13,代码来源:ClassUtils.java

示例13: getType

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
/**
 * Convert signature to a Type object.
 * @param signature signature string such as Ljava/lang/String;
 * @return type object
 */
public static final Type getType( String signature ) throws StringIndexOutOfBoundsException {
    byte type = Utility.typeOfSignature(signature);
    if (type <= Constants.T_VOID) {
        //corrected concurrent private static field acess
        wrap(consumed_chars, 1);
        return BasicType.getType(type);
    } else if (type == Constants.T_ARRAY) {
        int dim = 0;
        do { // Count dimensions
            dim++;
        } while (signature.charAt(dim) == '[');
        // Recurse, but just once, if the signature is ok
        Type t = getType(signature.substring(dim));
        //corrected concurrent private static field acess
        //  consumed_chars += dim; // update counter - is replaced by
        int _temp = unwrap(consumed_chars) + dim;
        wrap(consumed_chars, _temp);
        return new ArrayType(t, dim);
    } else { // type == T_REFERENCE
        int index = signature.indexOf(';'); // Look for closing `;'
        if (index < 0) {
            throw new ClassFormatException("Invalid signature: " + signature);
        }
        //corrected concurrent private static field acess
        wrap(consumed_chars, index + 1); // "Lblabla;" `L' and `;' are removed
        return new ObjectType(signature.substring(1, index).replace('/', '.'));
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:34,代码来源:Type.java

示例14: getReturnType

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
/**
 * Convert return value of a method (signature) to a Type object.
 *
 * @param signature signature string such as (Ljava/lang/String;)V
 * @return return type
 */
public static Type getReturnType( String signature ) {
    try {
        // Read return type after `)'
        int index = signature.lastIndexOf(')') + 1;
        return getType(signature.substring(index));
    } catch (StringIndexOutOfBoundsException e) { // Should never occur
        throw new ClassFormatException("Invalid method signature: " + signature);
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:16,代码来源:Type.java

示例15: visitConstantFieldref

import org.apache.bcel.classfile.ClassFormatException; //导入依赖的package包/类
public void visitConstantFieldref(ConstantFieldref obj){
	if (obj.getTag() != Constants.CONSTANT_Fieldref){
		throw new ClassConstraintException("ConstantFieldref '"+tostring(obj)+"' has wrong tag!");
	}
	int name_and_type_index = obj.getNameAndTypeIndex();
	ConstantNameAndType cnat = (ConstantNameAndType) (cp.getConstant(name_and_type_index));
	String name = ((ConstantUtf8) (cp.getConstant(cnat.getNameIndex()))).getBytes(); // Field or Method name
	if (!validFieldName(name)){
		throw new ClassConstraintException("Invalid field name '"+name+"' referenced by '"+tostring(obj)+"'.");
	}
	
	int class_index = obj.getClassIndex();
	ConstantClass cc = (ConstantClass) (cp.getConstant(class_index));
	String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getBytes(); // Class Name in internal form
	if (! validClassName(className)){
		throw new ClassConstraintException("Illegal class name '"+className+"' used by '"+tostring(obj)+"'.");
	}

	String sig  = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
				
	try{
		Type.getType(sig); /* Don't need the return value */
	}
	catch (ClassFormatException cfe){
		throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.");
	}
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:28,代码来源:Pass2Verifier.java


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