This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Tidy up class/type naming?


Doing this back-to-back string substitution of '.' <-> '/' is kind of ugly.

How about changing ArrayType's use of getName to be the Java class name ("[elementClassName") instead of the Kawa's "display name" ("elementClassName[]")? That way the meaning of the name is consistent between Kawa and Java and getReflectClass could just use getName. If anyone really wants to "prettify" the name of array classes for display they can do it there.

Jim

~/Projects/kawa/gnu/bytecode/ObjectType.java:

  public String getInternalName()
  {
    return getName().replace('.', '/');
  }

  /** Get the java.lang.Class object for the representation type. */
  public Class getReflectClass()
  {
    try
      {
	if (reflectClass == null)
	  {
	    /* #ifdef JAVA2 */
	    /* Specifies optional 'initialize' argument. */
	    reflectClass = Class.forName(getInternalName().replace('/', '.'),
					 false, getClass().getClassLoader());
	    /* #endif */
	    /* #ifndef JAVA2 */
	    // reflectClass = Class.forName(getInternalName().replace('/', '.'));
	    /* #endif */
	  }
        flags |= EXISTING_CLASS;
      }
    catch (java.lang.ClassNotFoundException ex)
      {
        if ((flags & EXISTING_CLASS) != 0)
          throw new RuntimeException("no such class: "+getName());
      }
    return reflectClass;
  }

Jim


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]