Here you can find the source of arrayClass(Class
Parameter | Description |
---|---|
compClass | a parameter |
@SuppressWarnings("unchecked") public static <T> Class<T[]> arrayClass(Class<T> compClass)
//package com.java2s; // This package is part of the Spiralcraft project and is licensed under public class Main { /**//from w w w. j a v a2 s. co m * Return the array class that holds the specific component type. * * @param compClass * @return */ @SuppressWarnings("unchecked") public static <T> Class<T[]> arrayClass(Class<T> compClass) { ClassLoader loader = compClass.getClassLoader(); if (loader == null) { loader = Thread.currentThread().getContextClassLoader(); } if (loader == null) { loader = ClassLoader.getSystemClassLoader(); } if (loader == null) { throw new IllegalStateException("No classloader available"); } try { return (Class<T[]>) Class.forName("[L" + compClass.getName() + ";", true, loader); } catch (ClassNotFoundException x) { throw new IllegalArgumentException(x); } } }