@Test public void testSubArray() { try { AgentRuleUtil.subArray(null, 0); fail("Expected NullPointerException"); } catch (final NullPointerException e) { } try { AgentRuleUtil.subArray(new String[] {""}, 0, -1); fail("Expected IllegalArgumentException"); } catch (final IllegalArgumentException e) { } final Integer[] array = {0, 1, 2, 3, 4, 5, 6, 7, 8}; assertArrayEquals(new Integer[] {2, 3}, AgentRuleUtil.subArray(array, 2, 4)); assertArrayEquals(new Integer[] {6, 7, 8}, AgentRuleUtil.subArray(array, 6)); }
@SuppressWarnings("unchecked") public static <T>T[] subArray(final T[] array, final int beginIndex, final int endIndex) { if (endIndex < beginIndex) throw new IllegalArgumentException("endIndex (" + endIndex + ") < beginIndex (" + beginIndex + ")"); final Class<?> componentType = array.getClass().getComponentType(); final T[] subArray = (T[])Array.newInstance(componentType, endIndex - beginIndex); if (beginIndex == endIndex) return subArray; System.arraycopy(array, beginIndex, subArray, 0, endIndex - beginIndex); return subArray; }
AgentRuleUtil { @SuppressWarnings("unchecked") public static <T>T[] subArray(final T[] array, final int beginIndex, final int endIndex) { if (endIndex < beginIndex) throw new IllegalArgumentException("endIndex (" + endIndex + ") < beginIndex (" + beginIndex + ")"); final Class<?> componentType = array.getClass().getComponentType(); final T[] subArray = (T[])Array.newInstance(componentType, endIndex - beginIndex); if (beginIndex == endIndex) return subArray; System.arraycopy(array, beginIndex, subArray, 0, endIndex - beginIndex); return subArray; } }
AgentRuleUtil { @SuppressWarnings("unchecked") public static <T>T[] subArray(final T[] array, final int beginIndex, final int endIndex) { if (endIndex < beginIndex) throw new IllegalArgumentException("endIndex (" + endIndex + ") < beginIndex (" + beginIndex + ")"); final Class<?> componentType = array.getClass().getComponentType(); final T[] subArray = (T[])Array.newInstance(componentType, endIndex - beginIndex); if (beginIndex == endIndex) return subArray; System.arraycopy(array, beginIndex, subArray, 0, endIndex - beginIndex); return subArray; } private  AgentRuleUtil(); }
AgentRuleUtil { @SuppressWarnings("unchecked") public static <T>T[] subArray(final T[] array, final int beginIndex, final int endIndex) { if (endIndex < beginIndex) throw new IllegalArgumentException("endIndex (" + endIndex + ") < beginIndex (" + beginIndex + ")"); final Class<?> componentType = array.getClass().getComponentType(); final T[] subArray = (T[])Array.newInstance(componentType, endIndex - beginIndex); if (beginIndex == endIndex) return subArray; System.arraycopy(array, beginIndex, subArray, 0, endIndex - beginIndex); return subArray; } private  AgentRuleUtil(); static String getNameId(final Object obj); static String getSimpleNameId(final Object obj); @SuppressWarnings("unchecked") static T[] subArray(final T[] array, final int beginIndex, final int endIndex); static T[] subArray(final T[] array, final int beginIndex); static Class<?>[] getExecutionStack(); static StackTraceElement[] getCallStack(); static boolean callerEquals(int frameIndex, final String name); static boolean callerEquals(int startFrame, int endFrame, final String name); static boolean callerEquals(int frameIndex, final String ... names); static boolean callerEquals(int startFrame, int endFrame, final String ...  names); static boolean hasMethodNamed(TypeDefinition typeDefinition, final String methodName); @SuppressWarnings("unchecked") static T getFieldInBootstrapClass(final Class<?> cls, final String fieldName); static boolean isFromClassLoader(final Class<?>[] callStack, final ClassLoader classLoader); static URL[] classPathToURLs(final String classpath); }
AgentRuleUtil { @SuppressWarnings("unchecked") public static <T>T[] subArray(final T[] array, final int beginIndex, final int endIndex) { if (endIndex < beginIndex) throw new IllegalArgumentException("endIndex (" + endIndex + ") < beginIndex (" + beginIndex + ")"); final Class<?> componentType = array.getClass().getComponentType(); final T[] subArray = (T[])Array.newInstance(componentType, endIndex - beginIndex); if (beginIndex == endIndex) return subArray; System.arraycopy(array, beginIndex, subArray, 0, endIndex - beginIndex); return subArray; } private  AgentRuleUtil(); static String getNameId(final Object obj); static String getSimpleNameId(final Object obj); @SuppressWarnings("unchecked") static T[] subArray(final T[] array, final int beginIndex, final int endIndex); static T[] subArray(final T[] array, final int beginIndex); static Class<?>[] getExecutionStack(); static StackTraceElement[] getCallStack(); static boolean callerEquals(int frameIndex, final String name); static boolean callerEquals(int startFrame, int endFrame, final String name); static boolean callerEquals(int frameIndex, final String ... names); static boolean callerEquals(int startFrame, int endFrame, final String ...  names); static boolean hasMethodNamed(TypeDefinition typeDefinition, final String methodName); @SuppressWarnings("unchecked") static T getFieldInBootstrapClass(final Class<?> cls, final String fieldName); static boolean isFromClassLoader(final Class<?>[] callStack, final ClassLoader classLoader); static URL[] classPathToURLs(final String classpath);  }