Package org.spongepowered.asm.mixin.injection.points

## Class BeforeNew

- java.lang.Object
- - org.spongepowered.asm.mixin.injection.InjectionPoint
  - - org.spongepowered.asm.mixin.injection.points.BeforeNew

    public class BeforeNew
    extends InjectionPoint

This injection point searches for NEW opcodes matching its arguments and returns a list of insns immediately prior to matching instructions. It accepts the following parameters from `At`:

named argument: class (or specify using `target`
  The value of the NEW node to look for, the fully-qualified class name
ordinal
  The ordinal position of the NEW opcode to match. For example if the NEW opcode appears 3 times in the method and you want to match the 3rd then you can specify an ordinal of 2 (ordinals are zero-indexed). The default value is -1 which supresses ordinal matching
target
  Target class can also be specified in `target` which also supports specifying the exact signature of the constructor to target. In this case the target type is specified as the return type of the constructor (in place of the usual `V` (void)) and no owner or name should be specified (they are ignored).

Examples:

>        // Find all NEW opcodes for String
>        @At(value = "NEW", args = "class=java/lang/String")

>        // Find all NEW opcodes for String
>        @At(value = "NEW", target = "java/lang/String"

>        // Find all NEW opcodes for String which are constructed
>        // using the ctor which takes an array of char
>        @At(value = "NEW", target = "([C)Ljava/lang/String;"

Note that like all standard injection points, this class matches the insn itself, putting the injection point immediately before the access in question. Use `shift` specifier to adjust the matched opcode as necessary.

### Nested Class Summary

### Nested classes/interfaces inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint

`InjectionPoint.AtCode, InjectionPoint.Flags, InjectionPoint.RestrictTargetLevel, InjectionPoint.Specifier`

### Field Summary

### Fields inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint

`DEFAULT_ALLOWED_SHIFT_BY, MAX_ALLOWED_SHIFT_BY`

### Constructor Summary

Constructors
`BeforeNew​(InjectionPointData data)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `find​(java.lang.String desc, org.objectweb.asm.tree.InsnList insns, java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes)` Find injection points in the supplied insn list
`static org.objectweb.asm.tree.MethodInsnNode` `findInitNodeFor​(org.objectweb.asm.tree.InsnList insns, org.objectweb.asm.tree.TypeInsnNode newNode, java.lang.String desc)`
`java.lang.String` `getDescriptor()` Gets the descriptor from the injection point, can return null
`boolean` `hasDescriptor()` Returns whether this injection point has a constructor descriptor defined

### Methods inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint

`addMessage, after, and, before, checkPriority, getAtCode, getId, getSlice, getSpecifier, getTargetRestriction, nextNode, or, parse, parse, parse, parse, parse, parse, parse, parse, register, register, setTargetRestriction, shift, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### BeforeNew

    public BeforeNew​(InjectionPointData data)

### Method Detail

#### hasDescriptor

    public boolean hasDescriptor()

Returns whether this injection point has a constructor descriptor defined

#### getDescriptor

    public java.lang.String getDescriptor()

Gets the descriptor from the injection point, can return null

#### find

    public boolean find​(java.lang.String desc,
                        org.objectweb.asm.tree.InsnList insns,
                        java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes)

Description copied from class: `InjectionPoint`
Find injection points in the supplied insn list

Specified by:
  `find` in class `InjectionPoint`
Parameters:
  `desc` - Method descriptor, supplied to allow return types and arguments etc. to be determined
  `insns` - Insn list to search in, the strategy MUST ONLY add nodes from this list to the `nodes` collection
  `nodes` - Collection of nodes to populate. Injectors should NOT make any assumptions about the state of this collection and should only call the add() method
Returns:
  true if one or more injection points were found

#### findInitNodeFor

    public static org.objectweb.asm.tree.MethodInsnNode findInitNodeFor​(org.objectweb.asm.tree.InsnList insns,
                                                                        org.objectweb.asm.tree.TypeInsnNode newNode,
                                                                        java.lang.String desc)