这几天碰到一个诡异的问题,在IBM JDK上二位数组中使用表达式时,出现http 500的错误。500是个外部错误,更web container有关,拿了客户的日志文件,发现异常如下,
2009-7-23 上午05时01分47秒 CDT [weblogic.servlet.internal.WebAppServletContext@1aec462 - appName: 'test', name: 'test', context-path: '/test', spec-version: '2.5'] Root cause of ServletException.
javax.servlet.ServletException: [HTTP:101249][weblogic.servlet.internal.WebAppServletContext@1aec462 - appName: 'test', name: 'test', context-path: '/test', spec-version: '2.5']: Servlet class jsp_servlet.__test for servlet /test.jsp could not be loaded because the requested class was not found in the classpath .
java.lang.ClassFormatError: Illegal class name "[L[Ljava/lang/String;;" in class file jsp_servlet/__test.
......
从具体的异常堆栈来看,应该是class加载时出现了问题,说是类名有问题,但同一context root下类名格式相同的其他page则可以拜访。假设去掉二位数组中的表达式,
.则可以处置这个问题。下面我们通过一个最简单的例子来复现这个问题。
1:IBM JDK version
E:\workspace\eclipse322\src1030\binjava -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pwi3260sr2-20080818_01(SR2))
IBM J9 VM (build 2.4, J2RE 1.6.0 IBM J9 2.4 Windows XP x86-32 jvmwi3260-20080816
_22093 (JIT enabled, AOT enabled)
J9VM - 20080816_022093_lHdSMr
JIT - r9_20080721_1330ifx2
GC - 20080724_AA)
JCL - 20080808_02
2: __MatrixTest.java
1packagetest.classload; 2 3publicclass__MatrixTest{ 4publicvoidinitialize(){ 5StringsResourcesPath=""; 6StringsCustomerScale="123"; 7StringsCustomerType="123"; 8Stringteststr=((!sCustomerScale.equals("")sCustomerScale.substring(0,2).equals("02"))?"false":"true"); 9StringsButtons[][]={ 10{((!sCustomerScale.equals("")sCustomerScale.substring(0,2).equals("02"))?"false":"true"), 11"","Button","新增","新增一条记录","newRecord()",sResourcesPath}, 12//Ifaboveexpressionisreplacedwith'teststr'likebelow,thisissuecouldbesolved. 13//{teststr,"","Button","新增","新增一条记录","newRecord()",sResourcesPath} 14}; 15} 16}