[kaffe] CVS kaffe-extras (guilhem): Nested class loading fix.

Kaffe CVS cvs-commits at kaffe.org
Tue Sep 23 11:30:02 PDT 2003


PatchSet 13 
Date: 2003/09/23 18:29:52
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Nested class loading fix.

When imported classes are specified using "import class;" KJC was not looking
for nested classes in the "class". Accessibility of nested classes fixed
btw.

Members: 
	build.xml:1.7->1.8 
	patches/kjc-nested-class-loading.diff:INITIAL->1.1 

Index: kaffe-extras/build.xml
diff -u kaffe-extras/build.xml:1.7 kaffe-extras/build.xml:1.8
--- kaffe-extras/build.xml:1.7	Thu Aug 14 07:15:04 2003
+++ kaffe-extras/build.xml	Tue Sep 23 18:29:52 2003
@@ -242,6 +242,9 @@
 	<patch patchfile="${patches_dir}/kjc-class-file-dir.diff"
 		strip="1"
 		dir="${kjcsuite_dir}"/>
+	<patch patchfile="${patches_dir}/kjc-nested-class-loading.diff"
+		strip="1"
+		dir="${kjcsuite_dir}"/>
 	<touch file="${kjcsuite_unpacked_stamp}"/>
   </target>
 
===================================================================
Checking out kaffe-extras/patches/kjc-nested-class-loading.diff
RCS:  /home/cvs/kaffe/kaffe-extras/patches/kjc-nested-class-loading.diff,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe-extras/patches/kjc-nested-class-loading.diff	Tue Sep 23 18:29:54 2003
@@ -0,0 +1,49 @@
+--- kjc-suite-2.1B/src/kjc/CCompilationUnit.java	2002-07-15 20:53:32.000000000 +0200
++++ kjc-suite-2.1B.new/src/kjc/CCompilationUnit.java	2003-09-23 19:15:25.000000000 +0200
+@@ -79,6 +79,26 @@
+ 	return cl;
+       }
+ 
++      // Now we must check whether the specified class is an inner class
++      // of the imported classes.
++      for (int i = 0; i < importedClasses.length; i++) {
++	String qualifiedName = importedClasses[i].getQualifiedName() + '$' + name;
++
++	if (classReader.hasClassFile(qualifiedName)) {
++	  CClass	lastClass = (CClass)loadedClasses.get(name);
++	  
++          if (lastClass!= null && !lastClass.isAccessible(caller)) {
++             lastClass = null; // not accessible -> not imported
++	  }
++	  if (lastClass != null && !lastClass.getQualifiedName().equals(qualifiedName)) {
++	      // Oops, the name is ambiguous (declared by more than one import-on-demand declaration)
++	      throw new UnpositionedError(KjcMessages.CUNIT_RENAME2, name);
++	  }
++	  loadedClasses.put(name, classReader.loadClass(typeFactory, qualifiedName));
++	  importedClasses[i].setUsed();
++	}
++      }
++
+       // Otherwise, look for a type declared in another compilation unit of this package
+       if (packageName.length() == 0) {
+ 	cl = classReader.hasClassFile(name) ? classReader.loadClass(typeFactory, name) : null;
+@@ -94,7 +114,7 @@
+ 	// Otherwise, look for a type declared by EXACTLY ONE import-on-demand declaration
+ 	for (int i = 0; i < importedPackages.length; i++) {
+ 	  String	qualifiedName;
+-          
++
+           if (classReader.hasClassFile(importedPackages[i].getName())) {
+             // import on demand of enclosed classes!
+             qualifiedName = (importedPackages[i].getName() + '$' + name).intern();
+--- kjc-suite-2.1B/src/kjc/CMember.java	2002-07-15 20:53:32.000000000 +0200
++++ kjc-suite-2.1B.new/src/kjc/CMember.java	2003-09-23 19:27:38.000000000 +0200
+@@ -207,7 +207,7 @@
+       return true;
+     } else if (!isPrivate() && owner.getPackage() == from.getPackage()) {
+       return true;
+-    } else if (isProtected() && from.descendsFrom(owner)) {
++    } else if (!isPrivate() && from.descendsFrom(owner)) {
+       return true;
+     } else {
+       return false;




More information about the kaffe mailing list