|
From: <ls...@us...> - 2008-05-29 18:53:09
|
Revision: 4145
http://jnode.svn.sourceforge.net/jnode/?rev=4145&view=rev
Author: lsantha
Date: 2008-05-29 11:53:07 -0700 (Thu, 29 May 2008)
Log Message:
-----------
Checkstyle fixes.
Modified Paths:
--------------
trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/Asm.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/FileSetTask.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/HeaderTask.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/Hotswap.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/Native2AsciiTask.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/NativeCheckTask.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/classpath/BaseDirs.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/classpath/CompareTask.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/classpath/Flags.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/classpath/PackageDirectory.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/classpath/SourceFile.java
trunk/builder/src/builder/org/jnode/ant/taskdefs/classpath/TargetedFileSet.java
trunk/builder/src/builder/org/jnode/build/AbstractAsmConstBuilder.java
trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java
trunk/builder/src/builder/org/jnode/build/AbstractPluginTask.java
trunk/builder/src/builder/org/jnode/build/AbstractPluginsTask.java
trunk/builder/src/builder/org/jnode/build/AddressFinder.java
trunk/builder/src/builder/org/jnode/build/AsmSourceInfo.java
trunk/builder/src/builder/org/jnode/build/BootDiskBuilder.java
trunk/builder/src/builder/org/jnode/build/BootFloppyBuilder.java
trunk/builder/src/builder/org/jnode/build/BuildException.java
trunk/builder/src/builder/org/jnode/build/BuildObjectResolver.java
trunk/builder/src/builder/org/jnode/build/FieldInfo.java
trunk/builder/src/builder/org/jnode/build/InitJarBuilder.java
trunk/builder/src/builder/org/jnode/build/InitJarsBuilder.java
trunk/builder/src/builder/org/jnode/build/JNodeClassNotFoundException.java
trunk/builder/src/builder/org/jnode/build/ObjectEmitter.java
trunk/builder/src/builder/org/jnode/build/PluginList.java
trunk/builder/src/builder/org/jnode/build/PluginTask.java
trunk/builder/src/builder/org/jnode/build/VMwareBuilderTask.java
trunk/builder/src/builder/org/jnode/build/dependencies/BCELDependencyChecker.java
trunk/builder/src/builder/org/jnode/build/documentation/DotBuilder.java
trunk/builder/src/builder/org/jnode/build/documentation/LicenseEntry.java
trunk/builder/src/builder/org/jnode/build/documentation/PackageData.java
trunk/builder/src/builder/org/jnode/build/documentation/PluginData.java
trunk/builder/src/builder/org/jnode/build/documentation/PluginDocumentationTask.java
trunk/builder/src/builder/org/jnode/build/documentation/ToolbarEntry.java
trunk/builder/src/builder/org/jnode/build/natives/NativeStubGenerator.java
trunk/builder/src/builder/org/jnode/build/package.html
trunk/builder/src/builder/org/jnode/build/x86/AsmConstBuilder.java
trunk/builder/src/builder/org/jnode/build/x86/BootImageBuilder.java
trunk/builder/src/builder/org/jnode/build/x86/Disasm.java
trunk/builder/src/builder/org/jnode/build/x86/package.html
trunk/builder/src/builder/org/jnode/jnasm/JNAsm.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/Address.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/Assembler.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/AssemblerModule.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/HardwareSupport.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/Identifier.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/Instruction.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/InstructionUtils.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/PseudoInstructions.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/Register.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/x86/AbstractX86Module.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/x86/MMX.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/x86/X86Core.java
trunk/builder/src/builder/org/jnode/jnasm/assembler/x86/X86Support.java
trunk/builder/src/builder/org/jnode/jnasm/preprocessor/FileResolver.java
trunk/builder/src/builder/org/jnode/jnasm/preprocessor/Macro.java
trunk/builder/src/builder/org/jnode/jnasm/preprocessor/Preprocessor.java
trunk/builder/src/builder/org/jnode/linker/Elf.java
trunk/builder/src/builder/org/jnode/linker/ElfLinker.java
trunk/builder/src/builder/org/jnode/linker/LoadUtil.java
trunk/builder/src/builder/org/jnode/linker/Reloc.java
trunk/builder/src/builder/org/jnode/linker/Reloca.java
trunk/builder/src/builder/org/jnode/linker/Section.java
trunk/builder/src/builder/org/jnode/linker/StoreUtil.java
trunk/builder/src/builder/org/jnode/linker/StrTab.java
trunk/builder/src/builder/org/jnode/linker/Symbol.java
Modified: trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java
===================================================================
--- trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java 2008-05-29 18:52:00 UTC (rev 4144)
+++ trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java 2008-05-29 18:53:07 UTC (rev 4145)
@@ -18,7 +18,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.ant.taskdefs;
import java.io.File;
@@ -31,11 +31,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
-
import org.apache.tools.ant.BuildException;
import org.jnode.vm.annotation.MagicPermission;
import org.jnode.vm.annotation.SharedStatics;
@@ -53,377 +50,337 @@
/**
* That ant task will add some annotations to some compiled classes
* mentioned in a property file.
- * For now, it's only necessary to add annotations to some
+ * For now, it's only necessary to add annotations to some
* openjdk classes to avoid modifying the original source code.
- *
- * @author Fabien DUMINY (fduminy at jnode dot org)
*
+ * @author Fabien DUMINY (fduminy at jnode dot org)
*/
public class AnnotateTask extends FileSetTask {
- private static final String SHAREDSTATICS_TYPE_DESC = Type.getDescriptor(SharedStatics.class);
- private static final String MAGICPERMISSION_TYPE_DESC = Type.getDescriptor(MagicPermission.class);
+ private static final String SHAREDSTATICS_TYPE_DESC = Type.getDescriptor(SharedStatics.class);
+ private static final String MAGICPERMISSION_TYPE_DESC = Type.getDescriptor(MagicPermission.class);
- private File annotationFile;
- private String[] classesFiles;
-
- private String buildStartTime = "";
- private String pattern = "";
- private long startTime = 0;
-
- private Properties annotations = new Properties();
+ private File annotationFile;
+ private String[] classesFiles;
- protected void doExecute() throws BuildException {
- try {
- SimpleDateFormat format = new SimpleDateFormat(pattern);
- startTime = format.parse(buildStartTime).getTime();
- } catch (Exception e) {
- throw new BuildException("invalid buildStartTime or pattern", e);
- }
-
- if(readProperties())
- {
- processFiles();
- }
- }
+ private String buildStartTime = "";
+ private String pattern = "";
+ private long startTime = 0;
- /**
- * Defines the annotation property file where are specified annotations to add
- * @param annotationFile
- */
- public final void setAnnotationFile(File annotationFile) {
- this.annotationFile = annotationFile;
- }
-
- /**
- * Define the time at which build started
- * @param annotationFile
- */
- public final void setBuildStartTime(String buildStartTime) {
- this.buildStartTime = buildStartTime;
- }
+ private Properties annotations = new Properties();
- /**
- * Define the pattern with which buildStartTime is defined
- * @param annotationFile
- */
- public final void setPattern(String pattern) {
- this.pattern = pattern;
- }
+ protected void doExecute() throws BuildException {
+ try {
+ SimpleDateFormat format = new SimpleDateFormat(pattern);
+ startTime = format.parse(buildStartTime).getTime();
+ } catch (Exception e) {
+ throw new BuildException("invalid buildStartTime or pattern", e);
+ }
- /**
- * Read the properties file. For now, it simply contains a list of
- * classes that need the SharedStatics annotation.
- *
- * @return
- * @throws BuildException
- */
- private boolean readProperties() throws BuildException
- {
- readProperties("annotationFile", annotationFile, annotations);
- if(annotations.isEmpty())
- {
- System.err.println("WARNING: annotationFile is empty (or doesn't exist)");
- return false;
- }
+ if (readProperties()) {
+ processFiles();
+ }
+ }
- classesFiles = (String[]) annotations.keySet().toArray(new String[annotations.size()]);
+ /**
+ * Defines the annotation property file where are specified annotations to add
+ *
+ * @param annotationFile
+ */
+ public final void setAnnotationFile(File annotationFile) {
+ this.annotationFile = annotationFile;
+ }
- // we must sort the classes in reverse order so that
- // classes with longest package name will be used first
- // (that is only necessary for classes whose name is the same
- // but package is different ; typical such class name : "Constants")
- Arrays.sort(classesFiles, Collections.reverseOrder());
+ /**
+ * Define the time at which build started
+ *
+ * @param annotationFile
+ */
+ public final void setBuildStartTime(String buildStartTime) {
+ this.buildStartTime = buildStartTime;
+ }
- return true;
- }
-
- /**
- * Generic method that read properties from a given file.
- *
- * @param name
- * @param file
- * @param properties
- * @throws BuildException
- */
- private void readProperties(String name, File file, Properties properties) throws BuildException
- {
- if(file == null)
- {
- throw new BuildException(name + " is mandatory");
- }
-
- if(!file.exists())
- {
- return;
- }
+ /**
+ * Define the pattern with which buildStartTime is defined
+ *
+ * @param annotationFile
+ */
+ public final void setPattern(String pattern) {
+ this.pattern = pattern;
+ }
- FileInputStream fis = null;
- try
- {
- fis = new FileInputStream(file);
- properties.load(fis);
- } catch (IOException e) {
- throw new BuildException(e);
- }
- finally
- {
- if(fis != null)
- {
- try {
- fis.close();
- } catch (IOException e) {
- throw new BuildException(e);
- }
- }
- }
- }
+ /**
+ * Read the properties file. For now, it simply contains a list of
+ * classes that need the SharedStatics annotation.
+ *
+ * @return
+ * @throws BuildException
+ */
+ private boolean readProperties() throws BuildException {
+ readProperties("annotationFile", annotationFile, annotations);
+ if (annotations.isEmpty()) {
+ System.err.println("WARNING: annotationFile is empty (or doesn't exist)");
+ return false;
+ }
- /**
- * Get the list of annotations for the given class file.
- *
- * @param classFile list of annotations with ',' as separator. null if no annotation for that class.
- * @return
- */
- private String getAnnotations(File classFile)
- {
- String annotations = null;
- String classFilePath = classFile.getAbsolutePath();
- for(String f : classesFiles)
- {
- if(classFilePath.endsWith(f))
- {
- annotations = this.annotations.getProperty(f);
- break;
- }
- }
+ classesFiles = (String[]) annotations.keySet().toArray(new String[annotations.size()]);
- return annotations;
- }
+ // we must sort the classes in reverse order so that
+ // classes with longest package name will be used first
+ // (that is only necessary for classes whose name is the same
+ // but package is different ; typical such class name : "Constants")
+ Arrays.sort(classesFiles, Collections.reverseOrder());
- /**
- * Actually process a class file (called from parent class)
- */
- @Override
- protected void processFile(File classFile) throws IOException {
- String annotations = getAnnotations(classFile);
- if(annotations == null)
- {
- return;
- }
-
- if(classFile.lastModified() < startTime)
- {
- System.out.println("Skipping already annotated file "+classFile.getName());
- return;
- }
-
- File tmpFile = new File(classFile.getParentFile(), classFile.getName()+".tmp");
- FileInputStream fis = null;
- boolean classIsModified = false;
+ return true;
+ }
- try
- {
- fis = new FileInputStream(classFile);
- classIsModified = addAnnotation(classFile, fis, tmpFile, annotations);
- }
- finally
- {
- if(fis != null)
- {
- fis.close();
- }
- }
+ /**
+ * Generic method that read properties from a given file.
+ *
+ * @param name
+ * @param file
+ * @param properties
+ * @throws BuildException
+ */
+ private void readProperties(String name, File file, Properties properties) throws BuildException {
+ if (file == null) {
+ throw new BuildException(name + " is mandatory");
+ }
- if(classIsModified)
- {
- if(trace)
- {
- traceClass(classFile, "before");
+ if (!file.exists()) {
+ return;
+ }
- traceClass(tmpFile, "after");
- }
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(file);
+ properties.load(fis);
+ } catch (IOException e) {
+ throw new BuildException(e);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ throw new BuildException(e);
+ }
+ }
+ }
+ }
- if(!classFile.delete())
- {
- throw new IOException("can't delete "+classFile.getAbsolutePath());
- }
+ /**
+ * Get the list of annotations for the given class file.
+ *
+ * @param classFile list of annotations with ',' as separator. null if no annotation for that class.
+ * @return
+ */
+ private String getAnnotations(File classFile) {
+ String annotations = null;
+ String classFilePath = classFile.getAbsolutePath();
+ for (String f : classesFiles) {
+ if (classFilePath.endsWith(f)) {
+ annotations = this.annotations.getProperty(f);
+ break;
+ }
+ }
- if(!tmpFile.renameTo(classFile))
- {
- throw new IOException("can't rename "+tmpFile.getAbsolutePath());
- }
- }
- }
+ return annotations;
+ }
- /**
- * Simple debug method that trace a class file.
- * It can be used to visually check that the annotations has been
- * properly added
- *
- * @param file
- * @throws IOException
- */
- private void traceClass(File file, String message) throws IOException
- {
- System.out.println("===== ("+message+") trace for "+file.getAbsolutePath()+" =====");
- FileInputStream fis = null;
- try
- {
- fis = new FileInputStream(file);
+ /**
+ * Actually process a class file (called from parent class)
+ */
+ @Override
+ protected void processFile(File classFile) throws IOException {
+ String annotations = getAnnotations(classFile);
+ if (annotations == null) {
+ return;
+ }
- ClassReader cr = new ClassReader(fis);
- TraceClassVisitor tcv = new TraceClassVisitor(null, new PrintWriter(System.out));
- cr.accept(tcv, Attributes.getDefaultAttributes(), true);
- }
- finally
- {
- if(fis != null)
- {
- fis.close();
- }
- }
- System.out.println("----- end trace -----");
- }
+ if (classFile.lastModified() < startTime) {
+ System.out.println("Skipping already annotated file " + classFile.getName());
+ return;
+ }
- /**
- * Add an annotation to a class file
- *
- * @param classFile
- * @param inputClass
- * @param tmpFile
- * @param annotations
- * @return
- * @throws BuildException
- */
- private boolean addAnnotation(File classFile, InputStream inputClass, File tmpFile, String annotations) throws BuildException {
- boolean classIsModified = false;
- FileOutputStream outputClass = null;
+ File tmpFile = new File(classFile.getParentFile(), classFile.getName() + ".tmp");
+ FileInputStream fis = null;
+ boolean classIsModified = false;
- ClassWriter cw = new ClassWriter(false);
- try {
- ClassReader cr = new ClassReader(inputClass);
+ try {
+ fis = new FileInputStream(classFile);
+ classIsModified = addAnnotation(classFile, fis, tmpFile, annotations);
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ }
- List<String> annotationTypeDescs = new ArrayList<String>(2);
- if(annotations.contains("SharedStatics"))
- {
- annotationTypeDescs.add(SHAREDSTATICS_TYPE_DESC);
- }
- if(annotations.contains("MagicPermission"))
- {
- annotationTypeDescs.add(MAGICPERMISSION_TYPE_DESC);
- }
+ if (classIsModified) {
+ if (trace) {
+ traceClass(classFile, "before");
- MarkerClassVisitor mcv = new MarkerClassVisitor(cw, annotationTypeDescs);
- cr.accept(mcv, Attributes.getDefaultAttributes(), true);
+ traceClass(tmpFile, "after");
+ }
- if(mcv.classIsModified())
- {
- System.out.println("adding annotations "+annotations+" to file "+classFile.getName());
- classIsModified = true;
+ if (!classFile.delete()) {
+ throw new IOException("can't delete " + classFile.getAbsolutePath());
+ }
- outputClass = new FileOutputStream(tmpFile);
+ if (!tmpFile.renameTo(classFile)) {
+ throw new IOException("can't rename " + tmpFile.getAbsolutePath());
+ }
+ }
+ }
- byte[] b = cw.toByteArray();
- outputClass.write(b);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- throw new BuildException("Unable to add annotations to file "+classFile.getName(), ex);
- }
- finally
- {
- if(outputClass != null)
- {
- try {
- outputClass.close();
- } catch (IOException e) {
- System.err.println("Can't close stream for file "+classFile.getName());
- }
-
- long timestamp = classFile.lastModified();
- tmpFile.setLastModified(timestamp);
- }
- }
+ /**
+ * Simple debug method that trace a class file.
+ * It can be used to visually check that the annotations has been
+ * properly added
+ *
+ * @param file
+ * @throws IOException
+ */
+ private void traceClass(File file, String message) throws IOException {
+ System.out.println("===== (" + message + ") trace for " + file.getAbsolutePath() + " =====");
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(file);
- return classIsModified;
- }
+ ClassReader cr = new ClassReader(fis);
+ TraceClassVisitor tcv = new TraceClassVisitor(null, new PrintWriter(System.out));
+ cr.accept(tcv, Attributes.getDefaultAttributes(), true);
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ }
+ System.out.println("----- end trace -----");
+ }
- /**
- * Visitor for a class file that actually do the job of adding annotations in the class.
- *
- * @author fabien
- *
- */
- private static class MarkerClassVisitor extends ClassAdapter {
- final private List<String> annotationTypeDescs;
+ /**
+ * Add an annotation to a class file
+ *
+ * @param classFile
+ * @param inputClass
+ * @param tmpFile
+ * @param annotations
+ * @return
+ * @throws BuildException
+ */
+ private boolean addAnnotation(File classFile, InputStream inputClass, File tmpFile, String annotations)
+ throws BuildException {
+ boolean classIsModified = false;
+ FileOutputStream outputClass = null;
- private boolean classIsModified = false;
+ ClassWriter cw = new ClassWriter(false);
+ try {
+ ClassReader cr = new ClassReader(inputClass);
- public MarkerClassVisitor(ClassVisitor cv, List<String> annotationTypeDescs) {
- super(cv);
+ List<String> annotationTypeDescs = new ArrayList<String>(2);
+ if (annotations.contains("SharedStatics")) {
+ annotationTypeDescs.add(SHAREDSTATICS_TYPE_DESC);
+ }
+ if (annotations.contains("MagicPermission")) {
+ annotationTypeDescs.add(MAGICPERMISSION_TYPE_DESC);
+ }
- this.annotationTypeDescs = annotationTypeDescs;
- }
+ MarkerClassVisitor mcv = new MarkerClassVisitor(cw, annotationTypeDescs);
+ cr.accept(mcv, Attributes.getDefaultAttributes(), true);
- @Override
- public void visit(int version, int access, String name,
- String superName, String[] interfaces, String sourceFile) {
- super.visit(org.objectweb.asm.Constants.V1_5, access,
- name, superName, interfaces, sourceFile);
- }
+ if (mcv.classIsModified()) {
+ System.out.println("adding annotations " + annotations + " to file " + classFile.getName());
+ classIsModified = true;
- @Override
- public void visitAttribute(Attribute attr) {
- if(attr instanceof RuntimeVisibleAnnotations)
- {
- RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr;
- for(Object annotation : rva.annotations)
- {
- if(annotation instanceof Annotation)
- {
- Annotation ann = (Annotation) annotation;
- for(String annTypeDesc : annotationTypeDescs)
- {
- if(ann.type.equals(annTypeDesc))
- {
- // we have found one of the annotations -> we won't need to add it again !
- annotationTypeDescs.remove(annTypeDesc);
- break;
- }
- }
- }
- }
- }
+ outputClass = new FileOutputStream(tmpFile);
- super.visitAttribute(attr);
- }
+ byte[] b = cw.toByteArray();
+ outputClass.write(b);
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new BuildException("Unable to add annotations to file " + classFile.getName(), ex);
+ } finally {
+ if (outputClass != null) {
+ try {
+ outputClass.close();
+ } catch (IOException e) {
+ System.err.println("Can't close stream for file " + classFile.getName());
+ }
- @SuppressWarnings("unchecked")
- public void visitEnd() {
- if(!annotationTypeDescs.isEmpty())
- {
- // we have not found the annotation -> we will add it and so modify the class
- classIsModified = true;
- RuntimeVisibleAnnotations attr = new RuntimeVisibleAnnotations();
+ long timestamp = classFile.lastModified();
+ tmpFile.setLastModified(timestamp);
+ }
+ }
- for(String annTypeDesc : annotationTypeDescs)
- {
+ return classIsModified;
+ }
- Annotation ann = new Annotation(annTypeDesc);
- ann.add("name", "");
+ /**
+ * Visitor for a class file that actually do the job of adding annotations in the class.
+ *
+ * @author fabien
+ */
+ private static class MarkerClassVisitor extends ClassAdapter {
+ final private List<String> annotationTypeDescs;
- attr.annotations.add(ann);
- }
+ private boolean classIsModified = false;
- cv.visitAttribute(attr);
- }
+ public MarkerClassVisitor(ClassVisitor cv, List<String> annotationTypeDescs) {
+ super(cv);
- super.visitEnd();
- }
+ this.annotationTypeDescs = annotationTypeDescs;
+ }
- public boolean classIsModified()
- {
- return classIsModified;
- }
- }
+ @Override
+ public void visit(int version, int access, String name,
+ String superName, String[] interfaces, String sourceFile) {
+ super.visit(org.objectweb.asm.Constants.V1_5, access,
+ name, superName, interfaces, sourceFile);
+ }
+
+ @Override
+ public void visitAttribute(Attribute attr) {
+ if (attr instanceof RuntimeVisibleAnnotations) {
+ RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr;
+ for (Object annotation : rva.annotations) {
+ if (annotation instanceof Annotation) {
+ Annotation ann = (Annotation) annotation;
+ for (String annTypeDesc : annotationTypeDescs) {
+ if (ann.type.equals(annTypeDesc)) {
+ // we have found one of the annotations -> we won't need to add it again !
+ annotationTypeDescs.remove(annTypeDesc);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ super.visitAttribute(attr);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void visitEnd() {
+ if (!annotationTypeDescs.isEmpty()) {
+ // we have not found the annotation -> we will add it and so modify the class
+ classIsModified = true;
+ RuntimeVisibleAnnotations attr = new RuntimeVisibleAnnotations();
+
+ for (String annTypeDesc : annotationTypeDescs) {
+
+ Annotation ann = new Annotation(annTypeDesc);
+ ann.add("name", "");
+
+ attr.annotations.add(ann);
+ }
+
+ cv.visitAttribute(attr);
+ }
+
+ super.visitEnd();
+ }
+
+ public boolean classIsModified() {
+ return classIsModified;
+ }
+ }
}
Modified: trunk/builder/src/builder/org/jnode/ant/taskdefs/Asm.java
===================================================================
--- trunk/builder/src/builder/org/jnode/ant/taskdefs/Asm.java 2008-05-29 18:52:00 UTC (rev 4144)
+++ trunk/builder/src/builder/org/jnode/ant/taskdefs/Asm.java 2008-05-29 18:53:07 UTC (rev 4145)
@@ -18,12 +18,16 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.ant.taskdefs;
import java.io.File;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
@@ -33,7 +37,7 @@
/**
* Description of the Class
- *
+ *
* @author epr
* @version $Revision$
*/
@@ -51,7 +55,7 @@
/**
* Returns the dir.
- *
+ *
* @return File
*/
public File getDir() {
@@ -60,9 +64,8 @@
/**
* Sets the dir.
- *
- * @param dir
- * The dir to set
+ *
+ * @param dir The dir to set
*/
public void setDir(File dir) {
this.dir = dir;
@@ -92,38 +95,35 @@
private File srcdir;
private boolean enableJNasm;
-
+
private String version;
-
+
private boolean setVbe;
-
+
/**
* Add an includedir
- *
+ *
* @param dir
*/
public void addConfiguredIncludeDir(IncludeDir dir) {
includeDirs.add(dir);
}
-
- public void setVbeMode(String vbeMode)
- {
- System.err.println("setVbeMode");
- this.setVbe = (vbeMode != null) && (vbeMode.trim().length() > 0);
+
+ public void setVbeMode(String vbeMode) {
+ System.err.println("setVbeMode");
+ this.setVbe = (vbeMode != null) && (vbeMode.trim().length() > 0);
}
/**
* Description of the Method
- *
+ *
* @param srcFile
* @param dstFile
- * @throws BuildException
- * Description of Exception
- * @throws IOException
- * Description of the Exception
+ * @throws BuildException Description of Exception
+ * @throws IOException Description of the Exception
*/
private void doNasm(File srcFile, File dstFile) throws BuildException,
- IOException {
+ IOException {
Execute exec = new Execute();
ArrayList<String> cmdLine = new ArrayList<String>();
@@ -136,26 +136,25 @@
}
cmdLine.add("-o");
- cmdLine.add(dstFile.toString());
+ cmdLine.add(dstFile.toString());
if (bits == 64) {
- cmdLine.add("-m");
- cmdLine.add("amd64");
+ cmdLine.add("-m");
+ cmdLine.add("amd64");
// Set preprocessor
cmdLine.add("-r");
cmdLine.add("nasm");
}
-
- if(setVbe)
- {
- System.err.println("setVbeMode : add property");
- cmdLine.add("-D");
- cmdLine.add("SETUP_VBE");
+
+ if (setVbe) {
+ System.err.println("setVbeMode : add property");
+ cmdLine.add("-D");
+ cmdLine.add("SETUP_VBE");
}
-
- cmdLine.add("-D");
- cmdLine.add("BITS" + bits);
-
+
+ cmdLine.add("-D");
+ cmdLine.add("BITS" + bits);
+
if (version != null) {
cmdLine.add("-D");
cmdLine.add("JNODE_VERSION='" + version + "'");
@@ -181,7 +180,7 @@
log("cmdLine=" + cmdLine, Project.MSG_VERBOSE);
exec.setCommandline(cmdLine.toArray(new String[cmdLine
- .size()]));
+ .size()]));
dstFile.getParentFile().mkdirs();
int rc = exec.execute();
@@ -189,32 +188,31 @@
if (rc != 0) {
destdir.delete();
throw new BuildException("Asm failed on "
- + srcFile.getAbsolutePath());
+ + srcFile.getAbsolutePath());
}
}
/**
* Description of the Method
- *
- * @throws BuildException
- * Description of Exception
+ *
+ * @throws BuildException Description of Exception
*/
public void execute() throws BuildException {
if (srcdir == null) {
throw new BuildException("Error: srcdir attribute must be set!",
- getLocation());
+ getLocation());
} else if (!srcdir.isDirectory()) {
throw new BuildException("Error: srcdir directory is not valid!",
- getLocation());
+ getLocation());
}
if (destdir == null) {
throw new BuildException("Error: destdir attribute must be set!",
- getLocation());
+ getLocation());
} else if (!destdir.isDirectory()) {
throw new BuildException("Error: destdir directory is not valid!",
- getLocation());
+ getLocation());
}
try {
@@ -228,11 +226,9 @@
/**
* Description of the Method
- *
- * @throws BuildException
- * Description of Exception
- * @throws IOException
- * Description of the Exception
+ *
+ * @throws BuildException Description of Exception
+ * @throws IOException Description of the Exception
*/
protected void executeAsm() throws BuildException, IOException {
@@ -243,7 +239,7 @@
if (compileMap.size() > 0) {
log("Compiling " + compileMap.size() + " source files to "
- + destdir);
+ + destdir);
for (File srcFile : compileMap.keySet()) {
File dstFile = compileMap.get(srcFile);
@@ -254,7 +250,7 @@
/**
* Gets the number of bits of the target platform.
- *
+ *
* @return 32/64
*/
public final int getBits() {
@@ -263,7 +259,7 @@
/**
* Returns the destdir.
- *
+ *
* @return File
*/
public File getDestdir() {
@@ -272,7 +268,7 @@
/**
* Returns the ext.
- *
+ *
* @return String
*/
public String getExtension() {
@@ -281,7 +277,7 @@
/**
* Returns the listFile.
- *
+ *
* @return File
*/
public File getListFile() {
@@ -290,7 +286,7 @@
/**
* Returns the outputFormat.
- *
+ *
* @return String
*/
public String getOutputFormat() {
@@ -299,7 +295,7 @@
/**
* Returns the srcdir.
- *
+ *
* @return File
*/
public File getSrcdir() {
@@ -309,19 +305,15 @@
/**
* Scans the directory looking for source files to be compiled. The results
* are returned in the class variable compileList
- *
- * @param srcDir
- * Description of Parameter
- * @param destDir
- * Description of Parameter
- * @param files
- * Description of Parameter
+ *
+ * @param srcDir Description of Parameter
+ * @param destDir Description of Parameter
+ * @param files Description of Parameter
* @param compileMap
- * @throws IOException
- * Description of the Exception
+ * @throws IOException Description of the Exception
*/
protected void scanDir(File srcDir, File destDir, String[] files,
- Map<File, File> compileMap) throws IOException {
+ Map<File, File> compileMap) throws IOException {
long now = System.currentTimeMillis();
for (int c = 0; c < files.length; c++) {
@@ -333,33 +325,33 @@
int diff = fileDirString.compareTo(rootDirString);
String destSubDir = fileDirString.substring(
- fileDirString.length() - diff, fileDirString.length())
- .replace('\\', '/');
+ fileDirString.length() - diff, fileDirString.length())
+ .replace('\\', '/');
// log(destSubDir);
File fileDir = new File(destDir.toString() + destSubDir);
String objName = aFile.getName().substring(0,
- aFile.getName().indexOf(".asm"))
- + "." + ext;
+ aFile.getName().indexOf(".asm"))
+ + "." + ext;
File objFile = new File(fileDir, objName);
// check if the file has been modified in the future, error?
if (aFile.lastModified() > now) {
log("Warning: file modified in the future: " + aFile.getName(),
- Project.MSG_WARN);
+ Project.MSG_WARN);
}
if (!objFile.exists()
- || aFile.lastModified() > objFile.lastModified()) {
+ || aFile.lastModified() > objFile.lastModified()) {
if (!objFile.exists()) {
log("Compiling " + aFile.getPath() + " because class file "
- + objFile.getPath() + " does not exist",
- Project.MSG_VERBOSE);
+ + objFile.getPath() + " does not exist",
+ Project.MSG_VERBOSE);
} else {
log("Compiling " + aFile.getPath()
- + " because it is out of date with respect to "
- + objFile.getPath(), Project.MSG_VERBOSE);
+ + " because it is out of date with respect to "
+ + objFile.getPath(), Project.MSG_VERBOSE);
}
compileMap.put(aFile, objFile);
@@ -370,9 +362,8 @@
/**
* Sets the number of bits of the target platform.
- *
- * @param bits
- * 32/64
+ *
+ * @param bits 32/64
*/
public final void setBits(int bits) {
if ((bits != 32) && (bits != 64)) {
@@ -383,9 +374,8 @@
/**
* Sets the Destdir attribute of the JspC object
- *
- * @param destDir
- * The new Destdir value
+ *
+ * @param destDir The new Destdir value
*/
public void setDestdir(File destDir) {
this.destdir = destDir;
@@ -393,9 +383,8 @@
/**
* Sets the ext.
- *
- * @param ext
- * The ext to set
+ *
+ * @param ext The ext to set
*/
public void setExtension(String ext) {
this.ext = ext;
@@ -403,9 +392,8 @@
/**
* Sets the listFile.
- *
- * @param listFile
- * The listFile to set
+ *
+ * @param listFile The listFile to set
*/
public void setListFile(File listFile) {
this.listFile = listFile;
@@ -413,9 +401,8 @@
/**
* Sets the outputFormat.
- *
- * @param outputFormat
- * The outputFormat to set
+ *
+ * @param outputFormat The outputFormat to set
*/
public void setOutputFormat(String outputFormat) {
this.outputFormat = outputFormat;
@@ -423,9 +410,8 @@
/**
* Sets the srcdir.
- *
- * @param srcdir
- * The srcdir to set
+ *
+ * @param srcdir The srcdir to set
*/
public void setSrcdir(File srcdir) {
this.srcdir = srcdir;
Modified: trunk/builder/src/builder/org/jnode/ant/taskdefs/FileSetTask.java
===================================================================
--- trunk/builder/src/builder/org/jnode/ant/taskdefs/FileSetTask.java 2008-05-29 18:52:00 UTC (rev 4144)
+++ trunk/builder/src/builder/org/jnode/ant/taskdefs/FileSetTask.java 2008-05-29 18:53:07 UTC (rev 4145)
@@ -18,10 +18,11 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.ant.taskdefs;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -31,81 +32,66 @@
/**
* Abstract class for ant task that process one or more FileSet
* The concrete classes only have to implement the <i>process</i> method
- * for doing the concrete work on a file.
- *
- * @author Fabien DUMINY (fduminy at jnode.org)
+ * for doing the concrete work on a file.
*
+ * @author Fabien DUMINY (fduminy at jnode.org)
*/
abstract public class FileSetTask extends Task {
- protected boolean trace = false;
- protected boolean failOnError = true;
-
- private final ArrayList<FileSet> fileSets = new ArrayList<FileSet>();
+ protected boolean trace = false;
+ protected boolean failOnError = true;
- public final void setTrace(boolean trace)
- {
- this.trace = trace;
- }
-
- public final void setFailOnError(boolean failOnError)
- {
- this.failOnError = failOnError;
- }
-
- public void addFileSet(FileSet fs) {
- fileSets.add(fs);
- }
+ private final ArrayList<FileSet> fileSets = new ArrayList<FileSet>();
- final public void execute() throws BuildException {
- try
- {
- doExecute();
- }
- catch(BuildException be)
- {
- if(failOnError)
- {
- throw be;
- }
- else
- {
- be.printStackTrace();
- }
- }
- catch(Throwable t)
- {
- if(failOnError)
- {
- throw new BuildException(t);
- }
- else
- {
- t.printStackTrace();
- }
- }
- }
+ public final void setTrace(boolean trace) {
+ this.trace = trace;
+ }
- protected void doExecute() throws BuildException {
- // default implementation : simply iterate on all files
- processFiles();
- }
-
- final protected void processFiles() throws BuildException
- {
- final Project project = getProject();
- try {
- for (FileSet fs : fileSets) {
- final String[] files = fs.getDirectoryScanner(project)
- .getIncludedFiles();
- final File projectDir = fs.getDir(project);
- for (String fname : files) {
- processFile(new File(projectDir, fname));
- }
- }
- } catch (IOException e) {
- throw new BuildException(e);
- }
- }
-
- abstract protected void processFile(File file) throws IOException;
+ public final void setFailOnError(boolean failOnError) {
+ this.failOnError = failOnError;
+ }
+
+ public void addFileSet(FileSet fs) {
+ fileSets.add(fs);
+ }
+
+ final public void execute() throws BuildException {
+ try {
+ doExecute();
+ } catch (BuildException be) {
+ if (failOnError) {
+ throw be;
+ } else {
+ be.printStackTrace();
+ }
+ } catch (Throwable t) {
+ if (failOnError) {
+ throw new BuildException(t);
+ } else {
+ t.printStackTrace();
+ }
+ }
+ }
+
+ protected void doExecute() throws BuildException {
+ // default implementation : simply iterate on all files
+ processFiles();
+ }
+
+ final protected void processFiles() throws BuildException {
+ final Project project = getProject();
+ try {
+ for (FileSet fs : fileSets) {
+ final String[] files = fs.getDirectoryScanner(project)
+ .getIncludedFiles();
+ final File projectDir = fs.getDir(project);
+ for (String fname : files) {
+ processFile(new File(projectDir, fname));
+ }
+ }
+ } catch (IOException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ abstract protected void processFile(File file) throws IOException;
}
Modified: trunk/builder/src/builder/org/jnode/ant/taskdefs/HeaderTask.java
===================================================================
--- trunk/builder/src/builder/org/jnode/ant/taskdefs/HeaderTask.java 2008-05-29 18:52:00 UTC (rev 4144)
+++ trunk/builder/src/builder/org/jnode/ant/taskdefs/HeaderTask.java 2008-05-29 18:53:07 UTC (rev 4145)
@@ -18,134 +18,137 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.ant.taskdefs;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.util.ArrayList;
import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.FileSet;
/**
* @author Ewout Prangsma (ep...@us...)
*/
public class HeaderTask extends FileSetTask {
- private File headerFile;
- private String[] header;
-
- private boolean update = false;
-
- private boolean compareHeader(String[] lines, String[] header) {
- final int linesCnt = lines.length;
- final int hdrCnt = header.length;
-
- for (int i = 0; i < linesCnt; i++) {
- final String line = lines[i];
- if (i < hdrCnt) {
- if (!compareLine(line, header[i])) {
- return false;
- }
- } else {
- String trimmedLine = line.trim();
- if (trimmedLine.startsWith("package")) {
- return true;
- }
- if (trimmedLine.length() > 0) {
- return false;
- }
- }
- }
-
- return false;
- }
-
- private boolean compareLine(String line, String hdrLine) {
- if ((line.indexOf('$') >= 0) && (hdrLine.indexOf('$') >= 0)) {
- return true;
- }
- return line.trim().equals(hdrLine.trim());
- }
+ private File headerFile;
+ private String[] header;
- protected void doExecute() throws BuildException {
- if (headerFile == null) {
- throw new BuildException("HeaderFile must be set");
- }
- try {
- header = readFile(headerFile);
- processFiles();
- } catch (IOException ex) {
- throw new BuildException(ex);
- }
- }
+ private boolean update = false;
- public final File getHeaderFile() {
- return headerFile;
- }
+ private boolean compareHeader(String[] lines, String[] header) {
+ final int linesCnt = lines.length;
+ final int hdrCnt = header.length;
- public final boolean isUpdate() {
- return update;
- }
+ for (int i = 0; i < linesCnt; i++) {
+ final String line = lines[i];
+ if (i < hdrCnt) {
+ if (!compareLine(line, header[i])) {
+ return false;
+ }
+ } else {
+ String trimmedLine = line.trim();
+ if (trimmedLine.startsWith("package")) {
+ return true;
+ }
+ if (trimmedLine.length() > 0) {
+ return false;
+ }
+ }
+ }
- @Override
- protected void processFile(File file) throws IOException {
- final String[] inp = readFile(file);
- if (!compareHeader(inp, header)) {
- if (update) {
- log("Updating " + file);
- writeUpdateFile(file, inp, header);
- } else {
- log("Wrong header in " + file);
- }
- }
- }
+ return false;
+ }
- private void writeUpdateFile(File file, String[] lines, String[] header) throws IOException {
- PrintWriter out = new PrintWriter(new FileWriter(file));
- try {
- final int hdrCnt = header.length;
- for (int i = 0; i < hdrCnt; i++) {
- out.println(header[i]);
- }
-
- final int linesCnt = lines.length;
- boolean write = false;
- for (int i = 0; i < linesCnt; i++) {
- final String line = lines[i];
- String trimmedLine = line.trim();
- if (trimmedLine.startsWith("package")) {
- write = true;
- }
- if (write) {
- out.println(lines[i]);
- }
- }
- } finally {
- out.close();
- }
- }
+ private boolean compareLine(String line, String hdrLine) {
+ if ((line.indexOf('$') >= 0) && (hdrLine.indexOf('$') >= 0)) {
+ return true;
+ }
+ return line.trim().equals(hdrLine.trim());
+ }
-
-
- private String[] readFile(File file) throws IOException {
- final BufferedReader in = new BufferedReader(new FileReader(file));
- try {
- final ArrayList<String> lines = new ArrayList<String>();
- String line;
- while ((line = in.readLine()) != null) {
- lines.add(line);
- }
- return lines.toArray(new String[lines.size()]);
- } finally {
- in.close();
- }
- }
+ protected void doExecute() throws BuildException {
+ if (headerFile == null) {
+ throw new BuildException("HeaderFile must be set");
+ }
+ try {
+ header = readFile(headerFile);
+ processFiles();
+ } catch (IOException ex) {
+ throw new BuildException(ex);
+ }
+ }
- public final void setHeaderFile(File headerFile) {
- this.headerFile = headerFile;
- }
- public final void setUpdate(boolean update) {
- this.update = update;
- }
+ public final File getHeaderFile() {
+ return headerFile;
+ }
+
+ public final boolean isUpdate() {
+ return update;
+ }
+
+ @Override
+ protected void processFile(File file) throws IOException {
+ final String[] inp = readFile(file);
+ if (!compareHeader(inp, header)) {
+ if (update) {
+ log("Updating " + file);
+ writeUpdateFile(file, inp, header);
+ } else {
+ log("Wrong header in " + file);
+ }
+ }
+ }
+
+ private void writeUpdateFile(File file, String[] lines, String[] header) throws IOException {
+ PrintWriter out = new PrintWriter(new FileWriter(file));
+ try {
+ final int hdrCnt = header.length;
+ for (int i = 0; i < hdrCnt; i++) {
+ out.println(header[i]);
+ }
+
+ final int linesCnt = lines.length;
+ boolean write = false;
+ for (int i = 0; i < linesCnt; i++) {
+ final String line = lines[i];
+ String trimmedLine = line.trim();
+ if (trimmedLine.startsWith("package")) {
+ write = true;
+ }
+ if (write) {
+ out.println(lines[i]);
+ }
+ }
+ } finally {
+ out.close();
+ }
+ }
+
+
+ private String[] readFile(File file) throws IOException {
+ final BufferedReader in = new BufferedReader(new FileReader(file));
+ try {
+ final ArrayList<String> lines = new ArrayList<String>();
+ String line;
+ while ((line = in.readLine()) != null) {
+ lines.add(line);
+ }
+ return lines.toArray(new String[lines.size()]);
+ } finally {
+ in.close();
+ }
+ }
+
+ public final void setHeaderFile(File headerFile) {
+ this.headerFile = headerFile;
+ }
+
+ public final void setUpdate(boolean update) {
+ this.update = update;
+ }
}
Modified: trunk/builder/src/builder/org/jnode/ant/taskdefs/Hotswap.java
===================================================================
--- trunk/builder/src/builder/org/jnode/ant/taskdefs/Hotswap.java 2008-05-29 18:52:00 UTC (rev 4144)
+++ trunk/builder/src/builder/org/jnode/ant/taskdefs/Hotswap.java 2008-05-29 18:53:07 UTC (rev 4145)
@@ -1,26 +1,24 @@
package org.jnode.ant.taskdefs;
+import com.sun.jdi.Bootstrap;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.VirtualMachineManager;
+import com.sun.jdi.connect.AttachingConnector;
+import com.sun.jdi.connect.Connector;
+import java.io.DataInputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
-import java.io.DataInputStream;
-import java.io.FileInputStream;
-import java.util.Vector;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.HashMap;
+import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.taskdefs.MatchingTask;
-
-import com.sun.jdi.VirtualMachine;
-import com.sun.jdi.VirtualMachineManager;
-import com.sun.jdi.Bootstrap;
-import com.sun.jdi.ReferenceType;
-import com.sun.jdi.connect.AttachingConnector;
-import com.sun.jdi.connect.Connector;
-
/*
This code is based on http://hotswap.dev.java.net/.
Adapted to JNode by Levente S\xE1ntha.
@@ -45,25 +43,25 @@
* <p/>
* Add this line to your build.xml<br/>
* <code>
- * <taskdef name="hotswap" classname="org.apache.tools.ant.taskdefs.Hotswap"/>
+ * <taskdef name="hotswap" classname="org.apache.tools.ant.taskdefs.Hotswap"/>
* </code>
* <p/>
* This is an example of how to hotswap with a JVM on port 9000 on your local machine
* <br/>
* <code>
* <!-- note, replace the <star> tags below with "*". This kept the example from breaking the javadoc -->
- * <hotswap verbose="true" port="9000">
- * <!-- This line matches 3 classes in the ant build/classes directory -->
- * <fileset dir="build/classes" includes="<star><star>/Hot*.class"/>
- * <!-- This line matches all classes in the taskefs package (and below) -->
- * <fileset dir="build/classes" includes="<star><star>/taskdefs"/>
- * </hotswap>
+ * <hotswap verbose="true" port="9000">
+ * <!-- This line matches 3 classes in the ant build/classes directory -->
+ * <fileset dir="build/classes" includes="<star><star>/Hot*.class"/>
+ * <!-- This line matches all classes in the taskefs package (and below) -->
+ * <fileset dir="build/classes" includes="<star><star>/taskdefs"/>
+ * </hotswap>
* </code>
* <br/>
* The preferred way to build the <fileset> would be based on modification time.
* At present, the tstamp isn't fine grained enough. The <outofdate> task from ant-contrib
* provides absolute paths to all of the class files, which isn't compatible with the
- * way <hotswap> needs the paths.
+ * way <hotswap> needs the paths.
*
* @author David A. Kavanagh <a href="mailto:da...@do...">da...@do...</a>
*/
@@ -76,20 +74,22 @@
private boolean verbose = false;
private boolean failonerror = true;
- protected String host;
- protected String port;
- protected String name;
+ protected String host;
+ protected String port;
+ protected String name;
protected Vector filesets = new Vector();
- private boolean useSocket = true;
+ private boolean useSocket = true;
/**
* Hotswap task for compilation of Java files.
*/
- public Hotswap() { }
+ public Hotswap() {
+ }
/**
* If true, asks the compiler for verbose output.
+ *
* @param verbose if true, asks the compiler for verbose output
*/
public void setVerbose(boolean verbose) {
@@ -98,6 +98,7 @@
/**
* Gets the verbose flag.
+ *
* @return the verbose flag
*/
public boolean getVerbose() {
@@ -106,6 +107,7 @@
/**
* Gets the name of the host with the running VM.
+ *
* @return the hotswap host name
*/
public String getHost() {
@@ -114,6 +116,7 @@
/**
* Sets the name of the host with the running VM.
+ *
* @param host the host to be used when connecting to a running VM
*/
public void setHost(String host) {
@@ -122,6 +125,7 @@
/**
* Gets the socket address of the host with the running VM.
+ *
* @return the hotswap socket address
*/
public String getPort() {
@@ -130,6 +134,7 @@
/**
* Sets the socket address of the host with the running VM.
+ *
* @param port the socket address to be used when connecting to a running VM
*/
public void setPort(String port) {
@@ -138,6 +143,7 @@
/**
* Gets the shared mem name to use when connecting to the running VM.
+ *
* @return the hotswap socket address
*/
public String getName() {
@@ -146,6 +152,7 @@
/**
* Sets the shared mem name to use when connecting to the running VM.
+ *
* @param name the shared memory name
*/
public void setName(String name) {
@@ -157,114 +164,116 @@
*
* @param failonerror true or false
*/
- public void setFailOnError(boolean failonerror) {
- this.failonerror = failonerror;
- }
+ public void setFailOnError(boolean failonerror) {
+ this.failonerror = failonerror;
+ }
- /**
- * Adds a set of files to be deployed.
- * @param set the set of files to be deployed
- */
- public void addFileset(FileSet set) {
- filesets.addElement(set);
- }
+ /**
+ * Adds a set of files to be deployed.
+ *
+ * @param set the set of files to be deployed
+ */
+ public void addFileset(FileSet set) {
+ filesets.addElement(set);
+ }
/**
* Executes the task.
- * @exception BuildException if an error occurs
+ *
+ * @throws BuildException if an error occurs
*/
public void execute() throws BuildException {
checkParameters();
- try {
- HotSwapHelper hsh = new HotSwapHelper();
- // attach
- if (useSocket) {
- hsh.connect(host, port);
- }
- else {
- hsh.connect(name);
- }
+ try {
+ HotSwapHelper hsh = new HotSwapHelper();
+ // attach
+ if (useSocket) {
+ hsh.connect(host, port);
+ } else {
+ hsh.connect(name);
+ }
- // load classes and replace them on target VM
- for (int i = 0; i < filesets.size(); i++) {
- FileSet fs = (FileSet) filesets.elementAt(i);
- try {
- DirectoryScanner ds = fs.getDirectoryScanner(getProject());
- String[] files = ds.getIncludedFiles();
- String[] dirs = ds.getIncludedDirectories();
- hotswapFiles(hsh, fs.getDir(getProject()), files, dirs);
- } catch (BuildException be) {
- // directory doesn't exist or is not readable
- if (failonerror) {
- throw be;
- } else {
- log(FAIL_MSG);
- log(be.getMessage());
- }
- }
- }
+ // load classes and replace them on target VM
+ for (int i = 0; i < filesets.size(); i++) {
+ FileSet fs = (FileSet) filesets.elementAt(i);
+ try {
+ DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+ String[] files = ds.getIncludedFiles();
+ String[] dirs = ds.getIncludedDirectories();
+ hotswapFiles(hsh, fs.getDir(getProject()), files, dirs);
+ } catch (BuildException be) {
+ // directory doesn't exist or is not readable
+ if (failonerror) {
+ throw be;
+ } else {
+ log(FAIL_MSG);
+ log(be.getMessage());
+ }
+ }
+ }
- hsh.disconnect();
- } catch (Exception ex) {
- if (failonerror) {
- throw new BuildException(ex);
- } else {
- log(FAIL_MSG);
- log(ex.getMessage());
- }
- }
+ hsh.disconnect();
+ } catch (Exception ex) {
+ if (failonerror) {
+ throw new BuildException(ex);
+ } else {
+ log(FAIL_MSG);
+ log(ex.getMessage());
+ }
+ }
}
/**
* Check that all required attributes have been set and nothing
* silly has been entered.
*
+ * @throws BuildException if an error occurs
* @since Ant 1.5
- * @exception BuildException if an error occurs
*/
protected void checkParameters() throws BuildException {
if (filesets.size() == 0) {
throw new BuildException("At least one of the file or dir "
- + "attributes, or a fileset element, "
- + "must be set.");
+ + "attributes, or a fileset element, "
+ + "must be set.");
}
if ((port == null) && (name == null)) {
throw new BuildException("port is null or name is null");
}
- if (port != null)
- useSocket = true;
- else
- useSocket = false;
+ if (port != null)
+ useSocket = true;
+ else
+ useSocket = false;
}
/**
* remove an array of files in a directory, and a list of subdirectories
* which will only be deleted if 'includeEmpty' is true
- * @param hsh the hotswap helper class
- * @param d directory to work from
+ *
+ * @param hsh the hotswap helper class
+ * @param d directory to work from
* @param files array of files to delete; can be of zero length
- * @param dirs array of directories to delete; can of zero length
+ * @param dirs array of directories to delete; can of zero length
*/
protected void hotswapFiles(HotSwapHelper hsh, File d, String[] files, String[] dirs) throws Exception {
if (files.length > 0) {
log("hotswapping " + files.length + " files from "
+ d.getAbsolutePath());
for (int j = 0; j < files.length; j++) {
- processHotswap(hsh, d, files[j]);
+ processHotswap(hsh, d, files[j]);
}
}
if (dirs.length > 0) {
int dirCount = 0;
for (int j = dirs.length - 1; j >= 0; j--) {
- log("swapping dir " + d.getAbsolutePath() +", "+ dirs[j]);
- processDirectory(hsh, d, dirs[j]);
+ log("swapping dir " + d.getAbsolutePath() + ", " + dirs[j]);
+ processDirectory(hsh, d, dirs[j]);
// dirCount++;
}
- // TODO: need an accurate count?
+ ...
[truncated message content] |