Class ArrayClassImpl

    • Method Detail

      • createClassForFD

        public static JClass createClassForFD​(java.lang.String arrayFD,
                                              JamClassLoader loader)
        Creates an array JClass from a field descriptor as described in the JLS. This is the nasty '[[[Lfoo.bar.Baz;'-style notation.
      • normalizeArrayName

        public static java.lang.String normalizeArrayName​(java.lang.String declaration)
        Returns the normal form for a given array name. This is a trimmed, unspaced field descriptor, e.g. '[[[Ljava.lang.String;' for a three dimensional array of strings. This method will also normalize understands declaration-style array names, e.g. 'java.lang.String[][][]'.
      • getSimpleName

        public java.lang.String getSimpleName()
        Description copied from interface: JElement

        Returns a simple name of this abstraction. The exact format of the name depends on the particular abstraction (see javadoc). Please refer to the JAM package documentation for more details on naming conventions.

        Specified by:
        getSimpleName in interface JElement
        Overrides:
        getSimpleName in class ElementImpl
      • getQualifiedName

        public java.lang.String getQualifiedName()
        Description copied from interface: JElement

        Returns a qualified name for this abstraction. The exact format of this name depends on the particular abstraction. Please refer to the documentation for each JElement subclass for a detailed description of the qualified name formats.

        Specified by:
        getQualifiedName in interface JElement
        Overrides:
        getQualifiedName in class BuiltinClassImpl
      • getArrayComponentType

        public JClass getArrayComponentType()
        Description copied from interface: JClass

        Returns the Class representing the component type of an array. If this JClass does not represent an array class this method returns null.

        Note that this method differs substantially from java.lang.Class.getComponentType() in the way it treats multidimensional arrays. Specifically, let fooArrayClass be the class of an n dimensional array of class foo for n > 2. For the java.lang.Class representation of fooArrayClass, getComponentType() will return a java.lang.Class for an (n-1)-dimensional array of foos. By contrast, the JClass representation of fooArrayClass will always simply return a JClass representing foo for any value of n > 1.

        In other words, this method always returns the 'core' type of the array, effectively hiding away all of the intermediary array types. Given that JClass provides the additional getArrayDimensions facility, it is felt that this is a much easier convention for tool authors to work with.

        Specified by:
        getArrayComponentType in interface JClass
        Overrides:
        getArrayComponentType in class BuiltinClassImpl
      • getArrayDimensions

        public int getArrayDimensions()
        Description copied from interface: JClass

        If this JClass represents an array type (isArray() == true), returns the number of dimensions in the array. Otherwise returns zero.

        Specified by:
        getArrayDimensions in interface JClass
        Overrides:
        getArrayDimensions in class BuiltinClassImpl
      • getSuperclass

        public JClass getSuperclass()
        Description copied from interface: JClass

        Returns the Class representing the superclass of the entity (class, interface, primitive type or void) represented by this Class. If this Class represents either the Object class, an interface, a primitive type, or void, then null is returned. If this object represents an array class then the Class object representing the Object class is returned.

        Specified by:
        getSuperclass in interface JClass
        Overrides:
        getSuperclass in class BuiltinClassImpl
      • isAssignableFrom

        public boolean isAssignableFrom​(JClass c)
        Description copied from interface: JClass

        Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter. It returns true if so; otherwise it returns false. If this Class object represents a primitive type, this method returns true if the specified Class parameter is exactly this Class object; otherwise it returns false.

        Specifically, this method tests whether the type represented by the specified Class parameter can be converted to the type represented by this Class object via an identity conversion or via a widening reference conversion. See The Java Language Specification, sections 5.1.1 and 5.1.4 , for details.

      • getFieldDescriptor

        public java.lang.String getFieldDescriptor()
        Description copied from interface: JClass

        Returns the name of this member in the format described in section 4.3.2 of the VM spec, 'Field Descriptors.' This is the same nasty format returned by java.lang.Class.getName(), and is the format you need to use in calls to Class.forName(). For example, the ClassfileName of the class of a two-dimensional array of strings is [[Ljava.lang.String;. For details, see http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html

        Specified by:
        getFieldDescriptor in interface JClass
        Overrides:
        getFieldDescriptor in class BuiltinClassImpl