Skip to content
Permalink
Browse files

[JENKINS-26535] tiger-types to the rescue

  • Loading branch information
kohsuke committed Mar 6, 2016
1 parent 6fe58e6 commit f467a821c1139b55cc74f4b8a11e81393bb71cef
Showing with 11 additions and 11 deletions.
  1. +11 −11 plugin/src/main/java/org/jenkinsci/plugins/symbol/describable/DescribableModel.java
@@ -15,6 +15,7 @@
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.codehaus.groovy.reflection.ReflectionCache;
import org.jvnet.tiger_types.Types;
import org.kohsuke.stapler.ClassDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
@@ -302,19 +303,20 @@ private Object coerce(String context, Type type, Object o) throws Exception {
* Signature of the type that the resolved class should be assignable to.
*/
private Class<?> resolveClass(Type type, String name) throws ClassNotFoundException {
Class<?> clazz;
Class base = Types.erasure(type);

if (name == null) {
if (Modifier.isAbstract(((Class) type).getModifiers())) {
if (Modifier.isAbstract(base.getModifiers())) {
throw new UnsupportedOperationException("must specify " + CLAZZ + " with an implementation of " + type);
}
clazz = (Class) type;
} else if (name.contains(".")) {
return base;
} else if (name.contains(".")) {// a fully qualified name
Jenkins j = Jenkins.getInstance();
ClassLoader loader = j != null ? j.getPluginManager().uberClassLoader : Thread.currentThread().getContextClassLoader();
clazz = Class.forName(name,true,loader);
} else if (type instanceof Class) {
clazz = null;
for (Class<?> c : findSubtypes((Class<?>) type)) {
return Class.forName(name,true,loader);
} else {
Class<?> clazz = null;
for (Class<?> c : findSubtypes(base)) {
if (c.getSimpleName().equals(name)) {
if (clazz != null) {
throw new UnsupportedOperationException(name + " as a " + type + " could mean either " + clazz.getName() + " or " + c.getName());
@@ -325,10 +327,8 @@ private Object coerce(String context, Type type, Object o) throws Exception {
if (clazz == null) {
throw new UnsupportedOperationException("no known implementation of " + type + " is named " + name);
}
} else {
throw new UnsupportedOperationException("JENKINS-26535: do not know how to handle " + type);
return clazz;
}
return clazz;
}

private List<Object> mapList(String context, Type type, List<?> list) throws Exception {

2 comments on commit f467a82

@lrodrigueza

This comment has been minimized.

Copy link

lrodrigueza replied Mar 11, 2016

Does this fix the wilcard issue when trying to publish JUnit reports with the pipeline plugin?

@kohsuke

This comment has been minimized.

Copy link
Member Author

kohsuke replied Mar 12, 2016

@lrodrigueza I don't know. Do you have a stack trace?

Please sign in to comment.
You can’t perform that action at this time.