| @@ -27,8 +27,8 @@ import java.lang.reflect.Field; | |||||
| * This lets you extract values off the classpath and use them elsewhere | * This lets you extract values off the classpath and use them elsewhere | ||||
| * @since Ant 1.7 | * @since Ant 1.7 | ||||
| */ | */ | ||||
| public class JavaConstantResource extends AbstractClasspathResource { | public class JavaConstantResource extends AbstractClasspathResource { | ||||
| /** | /** | ||||
| * open the input stream from a specific classloader | * open the input stream from a specific classloader | ||||
| * | * | ||||
| @@ -37,20 +37,18 @@ public class JavaConstantResource extends AbstractClasspathResource { | |||||
| * @throws IOException if an error occurs. | * @throws IOException if an error occurs. | ||||
| */ | */ | ||||
| protected InputStream openInputStream(ClassLoader cl) throws IOException { | protected InputStream openInputStream(ClassLoader cl) throws IOException { | ||||
| Class<?> clazz; | |||||
| String constant = getName(); | String constant = getName(); | ||||
| if (constant == null) { | if (constant == null) { | ||||
| throw new IOException("Attribute 'name' must be set."); | throw new IOException("Attribute 'name' must be set."); | ||||
| } | } | ||||
| int index1 = constant.lastIndexOf('.'); | |||||
| if (index1 < 0) { | |||||
| int index = constant.lastIndexOf('.'); | |||||
| if (index < 0) { | |||||
| throw new IOException("No class name in " + constant); | throw new IOException("No class name in " + constant); | ||||
| } | } | ||||
| int index = index1; | |||||
| String classname = constant.substring(0, index); | String classname = constant.substring(0, index); | ||||
| String fieldname = constant.substring(index + 1, constant.length()); | String fieldname = constant.substring(index + 1, constant.length()); | ||||
| try { | try { | ||||
| clazz = | |||||
| Class<?> clazz = | |||||
| cl != null | cl != null | ||||
| ? Class.forName(classname, true, cl) | ? Class.forName(classname, true, cl) | ||||
| : Class.forName(classname); | : Class.forName(classname); | ||||