remm 2004/02/02 10:18:01
Modified: jasper2/src/share/org/apache/jasper/compiler Generator.java
Log:
- Revert useBean optimization done by Kin-Man, as it seems to violate the
spec wording (which basically says that an error should occur at runtime if the
class
is not a JavaBean).
- Bug 26507.
Revision Changes Path
1.217 +31 -35
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
Index: Generator.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -r1.216 -r1.217
--- Generator.java 31 Jan 2004 01:56:28 -0000 1.216
+++ Generator.java 2 Feb 2004 18:18:00 -0000 1.217
@@ -1261,41 +1261,37 @@
className =
attributeValue(beanName, false, String.class);
}
- out.printil("try {");
- out.pushIndent();
- out.printin(name);
- out.print(" = (");
- out.print(type);
- out.print(") java.beans.Beans.instantiate(");
- out.print("this.getClass().getClassLoader(), ");
- out.print(className);
- out.println(");");
- out.popIndent();
- /*
- * Note: Beans.instantiate throws ClassNotFoundException
- * if the bean class is abstract.
- */
- out.printil("} catch (ClassNotFoundException exc) {");
- out.pushIndent();
- out.printil(
- "throw new InstantiationException(exc.getMessage());");
- out.popIndent();
- out.printil("} catch (Exception exc) {");
- out.pushIndent();
- out.printin("throw new ServletException(");
- out.print("\"Cannot create bean of class \" + ");
- out.print(className);
- out.println(", exc);");
- out.popIndent();
- out.printil("}"); // close of try
} else {
// Implies klass is not null
- // Generate codes to instantiate the bean class
- out.printin(name);
- out.print(" = new ");
- out.print(klass);
- out.println("();");
+ className = quote(klass);
}
+ out.printil("try {");
+ out.pushIndent();
+ out.printin(name);
+ out.print(" = (");
+ out.print(type);
+ out.print(") java.beans.Beans.instantiate(");
+ out.print("this.getClass().getClassLoader(), ");
+ out.print(className);
+ out.println(");");
+ out.popIndent();
+ /*
+ * Note: Beans.instantiate throws ClassNotFoundException
+ * if the bean class is abstract.
+ */
+ out.printil("} catch (ClassNotFoundException exc) {");
+ out.pushIndent();
+ out.printil(
+ "throw new InstantiationException(exc.getMessage());");
+ out.popIndent();
+ out.printil("} catch (Exception exc) {");
+ out.pushIndent();
+ out.printin("throw new ServletException(");
+ out.print("\"Cannot create bean of class \" + ");
+ out.print(className);
+ out.println(", exc);");
+ out.popIndent();
+ out.printil("}"); // close of try
/*
* Set attribute for bean in the specified scope
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]