Refs #1800 Make method Scripting.loadClass() generic to avoid type cast warnings

This commit is contained in:
Konstantin Krivopustov 2013-01-16 13:27:59 +00:00
parent b30972a371
commit 06cfa265a9
2 changed files with 5 additions and 4 deletions

View File

@ -92,7 +92,7 @@ public interface Scripting {
* @return class or null if not found
*/
@Nullable
Class loadClass(String name);
<T> Class<T> loadClass(String name);
/**
* DEPRECATED - use {@link Resources#getResourceAsStream(String)}

View File

@ -37,9 +37,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* <p>$Id$</p>
*
* @author krivopustov
* @version $Id$
*/
public abstract class AbstractScripting implements Scripting {
@ -227,6 +226,7 @@ public abstract class AbstractScripting implements Scripting {
@Override
public <T> T runGroovyScript(String name, Map<String, Object> context) {
Binding binding = createBinding(context);
//noinspection unchecked
return (T) runGroovyScript(name, binding);
}
@ -236,8 +236,9 @@ public abstract class AbstractScripting implements Scripting {
}
@Override
public Class loadClass(String name) {
public <T> Class<T> loadClass(String name) {
try {
//noinspection unchecked
return getGroovyClassLoader().loadClass(name, true, false);
} catch (ClassNotFoundException e) {
return null;