List of usage examples for java.lang ClassFormatError ClassFormatError
public ClassFormatError(String s)
ClassFormatError
with the specified detail message. From source file:ZipClassLoader.java
public Class findClass(String className) throws ClassNotFoundException { boolean found = false; Object result = null;/*from w w w . ja va2 s.com*/ // check whether we have loaded this class before synchronized (classes) { found = classes.containsKey(className); if (found) result = classes.get(className); } // try loading it from the ZIP file if we haven't if (!found) { String resourceName = className.replace('.', '/') + ".class"; result = request(REQUEST_LOAD, resourceName); if (result instanceof byte[]) { if (DEBUG >= 3) System.err.println(" define class"); //OK byte[] data = (byte[]) result; result = defineClass(className, data, 0, data.length); if (result != null) { if (DEBUG >= 3) System.err.println(" class defined"); //OK } else { if (DEBUG >= 3) System.err.println(" format error"); //OK result = new ClassFormatError(className); } } synchronized (classes) { classes.put(className, result); } } if (result instanceof Class) { return (Class) result; } else if (result instanceof ClassNotFoundException) { throw (ClassNotFoundException) result; } else if (result instanceof Error) { throw (Error) result; } else { return super.findClass(className); } }
From source file:org.spongepowered.asm.mixin.transformer.MixinTransformer.java
/** * Check whether this method was already merged into the target, returns * false if the method was <b>not</b> already merged or if the incoming * method has a higher priority than the already merged method. * //from w w w . j ava 2 s . c om * @param targetClass Target classnode * @param mixin Mixin context * @param method Method being merged * @param isOverwrite True if the incoming method is tagged with Override * @param target target method being checked * @return true if the target was already merged and should be skipped */ private boolean alreadyMerged(ClassNode targetClass, MixinTargetContext mixin, MethodNode method, boolean isOverwrite, MethodNode target) { AnnotationNode merged = ASMHelper.getVisibleAnnotation(target, MixinMerged.class); if (merged == null) { return false; } String sessionId = ASMHelper.<String>getAnnotationValue(merged, "sessionId"); if (!this.sessionId.equals(sessionId)) { throw new ClassFormatError("Invalid @MixinMerged annotation found in" + mixin + " at " + method.name + " in " + targetClass.name); } String owner = ASMHelper.<String>getAnnotationValue(merged, "mixin"); int priority = ASMHelper.<Integer>getAnnotationValue(merged, "priority"); if (priority >= mixin.getPriority() && !owner.equals(mixin.getClassName())) { this.logger.warn("Method overwrite conflict for {}, previously written by {}. Skipping method.", method.name, owner); return true; } return false; }