JDK-4450091 : GetClassLoaderClasses does not return primitive arrays
  • Type: Bug
  • Component: vm-legacy
  • Sub-Component: jvmdi
  • Affected Version: 1.3.0,1.4.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 2001-04-24
  • Updated: 2002-08-30
  • Resolved: 2002-08-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 beta2Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
http://java.sun.com/docs/books/vmspec/2nd-edition/html/ConstantPool.doc.html#79473

From the JVM spec section 5.3.3:

   2. The Java virtual machine creates a new array class with the indicated component type and number of dimensions. If the
      component type is a reference type, C is marked as having been defined by the defining class loader of the component type.
      Otherwise, C is marked as having been defined by the bootstrap class loader. In any case, the Java virtual machine then
      records that L is an initiating loader for C (��5.3.4).  ...

The last sentence is clear that, for creation, all arrays have their initiating class loader marked.  The prefacing sentence
indicates that the information is used and that it would be considered a creation since it is not already an initiating loader
of the array:

      If L has already been recorded as an initiating loader of an array class with the same component type as N, that 
      class is C, and no array class creation is necessary Otherwise, the following steps are performed to create C: 

JVMDI function GetClassLoaderClasses is defined:

      Returns an array of all classes for which this class loader has been recorded as the initiating loader.

The related JVMDI function, GetLoadedClasses, is specific that primitive arrays are included:

      Array classes of all types (including arrays of primitive types) are included in the returned list. Primitive 
      classes (for example, java.lang.Integer.TYPE) are not included in this list. 

HotSpot build 1.4.0-beta-b61 does not return primitive arrays such as "int[]".

robert.field@Eng 2001-04-24

Note: this will indirectly cause the JDI methods:

	Field.type()
	Method.returnType()
	Method.argumentTypes()?
	LocalVariable.type()
	others...?

to incorrectly throw ClassNotLoadedException.
robert.field@Eng 2001-04-27

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta2 FIXED IN: merlin-beta2 INTEGRATED IN: merlin-beta2 VERIFIED IN: merlin-beta2
14-06-2004

EVALUATION See description. High level (JDI) functions, e.g: Field.type() Method.returnType() depend on the accuracy of this list. Needs to be fixed for Merlin. HotSpot seems to be special casing primitive arrays. There are two options for fixing this: 1) have HotSpot do the accounting for primitive arrays too, or 2) fake the results to include all primitive arrays. That later option is a hack, since it will include arrays that have never been referenced by this ClassLoader. Another option is to bounce this back at me, and I'll change the spec to specify that primitive arrays aren't or maybe needn't be included, and then we can hack it at another level. robert.field@Eng 2001-04-24 Also, see regression Tim wrote for IBM submitted bug - 4359312 - jdi: LocalVariable.type().signature() on array type: ClassNotLoadedException robert.field@Eng 2001-04-27 mandy.chung@eng 2001-07-30 I can reproduce the failure using Merlin JDK1.4 build 72. I can also reproduce the failure using classic VM. The way I ran it: a) Run debuggee: > /usr/local/java/jdk1.3/solaris.ri/bin/java -classic -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=4571 ClassLoaderClassesTarg b) Run debugger: > /usr/local/java/jdk1.3/solaris.ri/bin/java -classic ClassLoaderClassesTest -connect com.sun.jdi.SocketAttach:hostname=localhost,port=4571 I still got the error "failed - int[] not found" with exception: Exception in thread "main" com.sun.jdi.ClassNotLoadedException: Class int[] not loaded at com.sun.tools.jdi.ClassLoaderReferenceImpl.findType(ClassLoaderReferenceImpl.java:92) at com.sun.tools.jdi.ReferenceTypeImpl.findType(ReferenceTypeImpl.java:711) at com.sun.tools.jdi.FieldImpl.findType(FieldImpl.java:58) at com.sun.tools.jdi.FieldImpl.type(FieldImpl.java:53) at ClassLoaderClassesTest.runTests(ClassLoaderClassesTest.java:121) at TestScaffold.startTests(TestScaffold.java:150) at ClassLoaderClassesTest.main(ClassLoaderClassesTest.java:78) It would be very useful to learn if other VMs (such as IBM) are able to include arrays of primitive types in the returned list from GetClassLoaderClasses. In the current hotspot implementation, initiating loader information is available in the resolution phase and is maintained in the system dictionary. However, only anewarray and multianewarray instructions cause resolution. The newarray instruction, which is used to create single-dimensional array with primitive type do not involve any resolution. I think it would be possible to find out the initiating loader while interpreting the bytecode newarray but it would be rather complicated. I am not sure how to get that information when we support compile-mode. I discussed with Robert F. about one option he proposed to change the spec such that GetClassLoaderClasses not to include arrays of primitive types. I think it sounds reasonable especially when we find out that other VMs may not be able to include arrays of primitive types in the returned list for GetClassLoaderClasses. Instead of implementing a complicated fix to make GetClassLoaderClasses to include a correct list of primitive arrays being initiated loading by a given loader, we choose to implement a simple hack to include single-dimensional arrays of all primitive types, which might not be initiated loading by the specified loader.
11-06-2004

PUBLIC COMMENTS Note: this will indirectly cause the JDI methods: Field.type() Method.returnType() Method.argumentTypes()? LocalVariable.type() others...? to incorrectly throw ClassNotLoadedException. --------------- http://java.sun.com/docs/books/vmspec/2nd-edition/html/ConstantPool.doc.html#79473 From the JVM spec section 5.3.3: 2. The Java virtual machine creates a new array class with the indicated component type and number of dimensions. If the component type is a reference type, C is marked as having been defined by the defining class loader of the component type. Otherwise, C is marked as having been defined by the bootstrap class loader. In any case, the Java virtual machine then records that L is an initiating loader for C (��5.3.4). ... The last sentence is clear that, for creation, all arrays have their initiating class loader marked. The prefacing sentence indicates that the information is used and that it would be considered a creation since it is not already an initiating loader of the array: If L has already been recorded as an initiating loader of an array class with the same component type as N, that class is C, and no array class creation is necessary Otherwise, the following steps are performed to create C: JVMDI function GetClassLoaderClasses is defined: Returns an array of all classes for which this class loader has been recorded as the initiating loader. The related JVMDI function, GetLoadedClasses, is specific that primitive arrays are included: Array classes of all types (including arrays of primitive types) are included in the returned list. Primitive classes (for example, java.lang.Integer.TYPE) are not included in this list. HotSpot build 1.4.0-beta-b61 does not return primitive arrays such as "int[]".
10-06-2004

SUGGESTED FIX mandy.chung@eng 2001-08-02 See attached webrev.tar.
02-08-2001