Author: klape
Date: 2013-01-17 23:30:36 -0500 (Thu, 17 Jan 2013)
New Revision: 17239
Added:
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1-JBPAPP-10590/common/common/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java
Modified:
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1-JBPAPP-10590/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java
Log:
[JBPAPP-10590] StackOverflowError when ASMHelper tries to getClassCode from a parametrized
type <E extends Enum>
Modified:
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1-JBPAPP-10590/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1-JBPAPP-10590/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java 2013-01-18
04:24:58 UTC (rev 17238)
+++
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1-JBPAPP-10590/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java 2013-01-18
04:30:36 UTC (rev 17239)
@@ -113,12 +113,14 @@
} else if (type instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType)type;
StringBuilder a = new StringBuilder(getClassCode(pt.getRawType()));
- a.setLength(a.length() - 1);
- a.append('<');
- for (Type t : pt.getActualTypeArguments()) {
- a.append(getClassCode(t));
+ if (!pt.getRawType().equals(Enum.class)) {
+ a.setLength(a.length() - 1);
+ a.append('<');
+ for (Type t : pt.getActualTypeArguments()) {
+ a.append(getClassCode(t));
+ }
+ a.append(">;");
}
- a.append(">;");
return a.toString();
} else if (type instanceof WildcardType) {
WildcardType wt = (WildcardType)type;
Added:
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1-JBPAPP-10590/common/common/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1-JBPAPP-10590/common/common/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1-JBPAPP-10590/common/common/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java 2013-01-18
04:30:36 UTC (rev 17239)
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.common.util;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ASMHelperTest extends Assert {
+ @Test
+ public void testEnumParamType() throws Exception {
+ Method method = EnumTest.class.getMethod("test", new Class[] {
+ EnumObject.class
+ });
+ Type[] types = method.getGenericParameterTypes();
+ String classCode = ASMHelper.getClassCode(types[0]);
+
assertEquals("Lorg/apache/cxf/common/util/ASMHelperTest$EnumObject<Ljava/lang/Enum;>;",
classCode);
+ }
+
+ public class EnumObject<E extends Enum<E>> {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String param) {
+ this.name = param;
+ }
+ }
+
+ public class EnumTest {
+ public <T extends Enum<T>> EnumObject<T>
test(EnumObject<T> o) {
+ return o;
+ }
+ }
+
+}