org.spongepowered.asm.mixin.Final Java Examples
The following examples show how to use
org.spongepowered.asm.mixin.Final.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedirectInjector.java From Mixin with MIT License | 5 votes |
protected RedirectInjector(InjectionInfo info, String annotationType) { super(info, annotationType); int priority = info.getContext().getPriority(); boolean isFinal = Annotations.getVisible(this.methodNode, Final.class) != null; this.meta = new Meta(priority, isFinal, this.info.toString(), this.methodNode.desc); }
Example #2
Source File: InjectionInfo.java From Mixin with MIT License | 5 votes |
private void checkTarget(MethodNode target) { AnnotationNode merged = Annotations.getVisible(target, MixinMerged.class); if (merged == null) { return; } if (Annotations.getVisible(target, Final.class) != null) { throw new InvalidInjectionException(this, String.format("%s cannot inject into @Final method %s::%s%s merged by %s", this, this.classNode.name, target.name, target.desc, Annotations.<String>getValue(merged, "mixin"))); } }
Example #3
Source File: ClassInfo.java From Mixin with MIT License | 5 votes |
@SuppressWarnings("unchecked") public Method(MethodNode method, boolean injected) { super(Type.METHOD, method.name, method.desc, method.access, injected); this.frames = this.gatherFrames(method); this.setUnique(Annotations.getVisible(method, Unique.class) != null); this.isAccessor = Annotations.getSingleVisible(method, Accessor.class, Invoker.class) != null; boolean decoratedFinal = Annotations.getVisible(method, Final.class) != null; boolean decoratedMutable = Annotations.getVisible(method, Mutable.class) != null; this.setDecoratedFinal(decoratedFinal, decoratedMutable); }
Example #4
Source File: ClassInfo.java From Mixin with MIT License | 5 votes |
public Field(FieldNode field, boolean injected) { super(Type.FIELD, field.name, field.desc, field.access, injected); this.setUnique(Annotations.getVisible(field, Unique.class) != null); if (Annotations.getVisible(field, Shadow.class) != null) { boolean decoratedFinal = Annotations.getVisible(field, Final.class) != null; boolean decoratedMutable = Annotations.getVisible(field, Mutable.class) != null; this.setDecoratedFinal(decoratedFinal, decoratedMutable); } }
Example #5
Source File: MixinApplicatorStandard.java From Mixin with MIT License | 4 votes |
/** * 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. * * @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 */ @SuppressWarnings("unchecked") protected boolean isAlreadyMerged(MixinTargetContext mixin, MethodNode method, boolean isOverwrite, MethodNode target) { AnnotationNode merged = Annotations.getVisible(target, MixinMerged.class); if (merged == null) { if (Annotations.getVisible(target, Final.class) != null) { this.logger.warn("Overwrite prohibited for @Final method {} in {}. Skipping method.", method.name, mixin); return true; } return false; } String sessionId = Annotations.<String>getValue(merged, "sessionId"); if (!this.context.getSessionId().equals(sessionId)) { throw new ClassFormatError("Invalid @MixinMerged annotation found in" + mixin + " at " + method.name + " in " + this.targetClass.name); } if (Bytecode.hasFlag(target, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE) && Bytecode.hasFlag(method, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)) { if (mixin.getEnvironment().getOption(Option.DEBUG_VERBOSE)) { this.logger.warn("Synthetic bridge method clash for {} in {}", method.name, mixin); } return true; } String owner = Annotations.<String>getValue(merged, "mixin"); int priority = Annotations.<Integer>getValue(merged, "priority"); AnnotationNode accMethod = Annotations.getSingleVisible(method, Accessor.class, Invoker.class); if (accMethod != null) { AnnotationNode accTarget = Annotations.getSingleVisible(target, Accessor.class, Invoker.class); if (accTarget != null) { String myTarget = Annotations.<String>getValue(accMethod, "target"); String trTarget = Annotations.<String>getValue(accTarget, "target"); if (myTarget == null) { throw new MixinError("Encountered undecorated Accessor method in " + mixin + " applying to " + this.targetName); } if (myTarget.equals(trTarget)) { // This is fine, the accessors overlap return true; } throw new InvalidMixinException(mixin, String.format("Incompatible @%s %s (for %s) in %s previously written by %s (for %s)", Bytecode.getSimpleName(accMethod), method.name, myTarget, mixin, owner, trTarget)); } } if (priority >= mixin.getPriority() && !owner.equals(mixin.getClassName())) { this.logger.warn("Method overwrite conflict for {} in {}, previously written by {}. Skipping method.", method.name, mixin, owner); return true; } if (Annotations.getVisible(target, Final.class) != null) { this.logger.warn("Method overwrite conflict for @Final method {} in {} declared by {}. Skipping method.", method.name, mixin, owner); return true; } return false; }