<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
</parent>
<artifactId>aspectjrt</artifactId>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
</parent>
<artifactId>aspectjtools</artifactId>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
</parent>
<artifactId>aspectjweaver</artifactId>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
public class ConstantsInitializer {
+ @SuppressWarnings("unchecked")
public static Object initialize() {
Constants.types[Constants.ILOAD] = Type.INT;
Constants.types[Constants.ISTORE] = Type.INT;
/**
* Exception constants.
- *
+ *
* @version $Id: ExceptionConstants.java,v 1.5 2009/09/14 20:29:10 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase">E. Haase</A>
*/
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
/* *******************************************************************
- * Copyright (c) 2000-2001 Xerox Corporation,
+ * Copyright (c) 2000-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package $installer$.org.aspectj;
* <li>"-text".equals(arg[0])</li>
* <li>arg[1] is the path to a properties file which defines name="output.dir" value="{path to output dir}" name="context.javaPath"
* value="{path to JDKDIR}", i.e,.
- *
+ *
* <pre>
* output.dir=c:/latest
* "context.javaPath=c:/apps/jdk1.3.1
* </pre>
- *
+ *
* </li>
* <li>outputDir must be created and empty (i.e., no overwriting</li>
* <li>the VM being invoked should be the target vm</li>
Main.exit(-1);
}
properties.load(istream);
- // when running outside GUI, load values into properties
+ // when running outside GUI, load values into properties
// so that property-value resolution works
// (otherwise, could just set values below).
// XXX not sure if this indirection is actually needed.
* (files == null) return; for (int i=0; i<files.length; i++) { if (files[i] == null) continue; if (!files[i].isDirectory())
* continue; if (files[i].getName().startsWith(prefix)) { System.out.println("found: " + files[i]); } else { findPaths(prefix,
* files[i], currentDepth + 1); } } }
- *
+ *
* public static void findPaths(String prefix) { File [] files = File.listRoots(); for (int i=1; i<files.length; i++) { if
* (!files[i].isDirectory()) continue; if (files[i].getName().toLowerCase().startsWith(prefix)) { System.out.println("found: " +
* files[i]); } else { findPaths(prefix, files[i], 1); } } }
public Installer installer;
- private Map properties;
+ private Map<String,String> properties;
public boolean hasGui() {
return hasGui;
return overwriteState == OVERWRITE_YES || overwriteState == OVERWRITE_ALL;
}
- public Map getProperties() {
+ public Map<String,String> getProperties() {
return properties;
}
}
/*
* //XXX check that the returned file is valid public String getDefaultJavaLocation() { String name = "java"; if
* (context.onWindows()) name += ".exe";
- *
+ *
* if (Options.verbose) { System.out.println("java.home: " + System.getProperty("java.home")); System.out.println(" java: " +
* new File(new File(System.getProperty("java.home"), "bin"), name)); System.out.println(" java: " + new File(new
* File(System.getProperty("java.home"), "bin"), name).getPath()); }
- *
+ *
* return new File(new File(System.getProperty("java.home"), "bin"), name).getPath(); }
*/
public void unpack(String contentsName, File outputDir) throws IOException {
URL url = getClass().getResource(contentsName);
-
+
// Process everything under 'files/**' copying to the target
// install directory with 'files/' removed
JarURLConnection juc = (JarURLConnection) url.openConnection();
writeResource(jf, je, outputDir);
}
}
-
+
// InputStream stream = url.openStream();
// BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "US-ASCII"));
// String line = reader.readLine();
}
/**
- *
+ *
*/
public void writeAJLaunchScript(String name, boolean isJava5) throws IOException {
if (!context.onUnix()) {
/*
* final static String OVERWRITE_MESSAGE = "Overwrite launch script "; final static String OVERWRITE_TITLE = "Overwrite?";
- *
+ *
* final static String[] OVERWRITE_OPTIONS = { "Yes", "No", "Yes to all", "No to all" };
- *
+ *
* final static int OVERWRITE_YES = 0; final static int OVERWRITE_NO = 1; final static int OVERWRITE_ALL = 2; final static int
* OVERWRITE_NONE = 3;
- *
+ *
* int overwriteState = OVERWRITE_NO; boolean shouldOverwrite(final File file) { if (overwriteState == OVERWRITE_ALL) return
* true; if (overwriteState == OVERWRITE_NONE) return false;
- *
+ *
* try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { int ret =
* JOptionPane.showOptionDialog(context.installer.frame, OVERWRITE_MESSAGE+file.getPath(), OVERWRITE_TITLE,
* JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, OVERWRITE_OPTIONS, OVERWRITE_OPTIONS[OVERWRITE_YES]);
- *
+ *
* overwriteState = ret; } }); } catch (InvocationTargetException ite) { context.handleException(ite.getTargetException()); }
* catch (InterruptedException ie) { }
- *
+ *
* return overwriteState == OVERWRITE_YES || overwriteState == OVERWRITE_ALL; }
*/
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
//XXX INCLUDES CODE FROM ANT -- UNDER APACHE LICENSE
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet;
+@SuppressWarnings("deprecation")
public class AJInstaller extends MatchingTask {
static final String INCLUDE_CLASSES = "$installer$/org/aspectj/*.class";
static final String MAIN_CLASS = "$installer$.org.aspectj.Main";
static final String CONTENTS_FILE = "$installer$/org/aspectj/resources/contents.txt";
private String htmlSrc;
-
+
public void setHtmlSrc(String v) { htmlSrc = v; }
private String resourcesSrc;
private File installerClassJar;
- public void setInstallerclassjar(String v) {
+ public void setInstallerclassjar(String v) {
installerClassJar = project.resolveFile(v);
}
- protected List contentsNames = new ArrayList();
+ protected List<String> contentsNames = new ArrayList<>();
protected long contentsBytes = 0;
PatternSet patterns = new PatternSet();
patterns.setIncludes(INCLUDE_CLASSES);
expand.addPatternset(patterns);
- expand.execute();
+ expand.execute();
// move the correct resource files into the jar
Copy cd = getCopyTask();
StringBuffer buf = new StringBuffer();
buf.append(contentsBytes);
buf.append(NEWLINE);
- for (Iterator i = contentsNames.iterator(); i.hasNext(); ) {
- String name = (String)i.next();
+ for (Iterator<String> i = contentsNames.iterator(); i.hasNext(); ) {
+ String name = i.next();
buf.append(name);
buf.append(NEWLINE);
}
* This is the name/location of where to
* create the .zip file.
*/
- public void setZipfile(String zipFilename) {
+ public void setZipfile(String zipFilename) {
zipFile = project.resolveFile(zipFilename);
}
}
return tmpDir;
}
-
+
public void execute() throws BuildException {
if (installerClassJar == null) {
throw new BuildException("installerClassJar attribute must be set!");
}
- if (!installerClassJar.canRead()
+ if (!installerClassJar.canRead()
|| !installerClassJar.getPath().endsWith(".jar")) {
throw new BuildException("not readable jar:" + installerClassJar);
}
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.ant.taskdefs;
import org.apache.tools.ant.taskdefs.Mkdir;
+@SuppressWarnings("deprecation")
public class AJPush extends ConditionalTask {
private File src;
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.ant.taskdefs;
/**
* Factory for a Builder.
- *
+ *
* @param config the String configuration, where only substrings "verbose" and "useEclipseCompiles" are significant
* @param project the owning Project for all tasks (not null)
* @param tempDir the File path to a temporary dir for side effects (may be null)
/**
* Initialize task with project and "ajbuild-" + name as name. (Using bm- prefix distinguishes these tasks from tasks found in
* the build script.)
- *
+ *
* @param task the Task to initialize - not null
* @param name the String name suffix for the task
* @return true unless some error
/**
* Copy file, optionally filtering. (Filters set in project.)
- *
+ *
* @param fromFile the readable File source to copy
* @param toFile the writable File destination file
* @param boolean filter if true, enable filtering
/**
* (Filters set in project.)
- *
+ *
* @see org.aspectj.internal.tools.ant.taskdefs.Builder#copyFiles(File, File, String, String, boolean)
*/
@Override
for (File file: result.getSrcDirs()) {
path.createPathElement().setLocation(file);
if (!isJava5Compile
- && (Util.Constants.JAVA5_SRC.equals(file.getName()) ||
+ && (Util.Constants.JAVA5_SRC.equals(file.getName()) ||
Util.Constants.JAVA5_TESTSRC.equals(file.getName()) ||
new File(file.getParent(), ".isJava5").exists())) {
isJava5Compile = true;
javac.setDebug(true);
if (isJava8Compile) {
javac.setSource("1.8");
- javac.setTarget("1.8");
+ javac.setTarget("1.8");
} else if (isJava5Compile) {
// *cough*
javac.setSource("1.6");
- javac.setTarget("1.6");
+ javac.setTarget("1.6");
} else {
javac.setTarget("1.1"); // 1.1 class files - Javac in 1.4 uses 1.4
javac.setSource("1.3");
public boolean setupClasspath(Result result, Path classpath) { // XXX fix test access
boolean hasLibraries = false;
// required libraries
- for (Iterator iter = result.getLibJars().iterator(); iter.hasNext();) {
- File file = (File) iter.next();
+ for (Iterator<File> iter = result.getLibJars().iterator(); iter.hasNext();) {
+ File file = iter.next();
classpath.createPathElement().setLocation(file);
if (!hasLibraries) {
hasLibraries = true;
}
// also put on classpath libraries exported from required module
// XXX exported modules not supported
- for (Iterator iterator = requiredResult.getExportedLibJars().iterator(); iterator.hasNext();) {
- classpath.createPathElement().setLocation((File) iterator.next());
+ for (Iterator<File> iterator = requiredResult.getExportedLibJars().iterator(); iterator.hasNext();) {
+ classpath.createPathElement().setLocation(iterator.next());
}
}
return hasLibraries;
ZipFileSet zipfileset = null;
// -- merge any resources in any of the src directories
- for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) {
- File srcDir = (File) iter.next();
+ //for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) {
+ // File srcDir = (File) iter.next();
+ for (File srcDir: result.getSrcDirs()) {
zipfileset = new ZipFileSet();
zipfileset.setProject(project);
zipfileset.setDir(srcDir);
/**
* If this module should be compiled with AspectJ, return a task to do so.
- *
+ *
* @param module the Module to compile
* @param javac the Javac compile commands
* @return javac or a Task to compile with AspectJ if needed
/**
* Wrap AspectJ compiler as Task. Only works for javac-like source compilation of everything under srcDir. Written
* reflectively to compile in the build module, which can't depend on the whole tree.
- *
+ *
* @param javac the Javac specification
* @param toolsJar the Path to the aspectjtools.jar
* @param runtimeJar the Path to the aspectjrt.jar
// loadAntProperties(ant, buildSpec);
// ant.execute();
// }
-//
+//
// /** override definitions */
// private void loadAntProperties(Ant ant, BuildSpec buildSpec) {
// Property property = ant.createProperty();
/**
* Segregate product-building API's from module-building APIs for clarity. These are called by the superclass if the BuildSpec
* warrants. XXX extremely brittle/arbitrary assumptions.
- *
+ *
* @see BuildModule for assumptions
*/
class ProductBuilder extends AntBuilder {
/**
* Calculate name of main, typically InitialCap, and hence installer class.
- *
+ *
* @return $$installer$$.org.aspectj." + ProductName + "Installer"
*/
// String name = (!assembleAll ? jarName : jarName.substring(0, jarName.length()-4));
// return modules.getModule(name);
// }
- //
+ //
}
class ProjectMessager extends Messager {
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.ant.taskdefs;
* Check that included .java files contain license and copyright strings for MPL 1.0 (default), Apache, or CPL. Use list="true" to
* get a list of known license variants {license}-{copyrightHolder} todo reimplement with regexp and jdiff FileLine utilities
*/
+@SuppressWarnings("deprecation")
public class Checklics extends MatchingTask {
/*
* This does not enforce that copyrights are correct/current, only that they exist. E.g., the default behavior requires MPL but
/**
* Run the license check directly
- *
+ *
* @param sourcepaths String[] of paths to source directories
* @param license the String tag for the license, if any
* @param failonerror boolean flag to pass to Checklics
/**
* When failOnError is true, if any file failed, throw BuildException listing number of files that file failed to pass license
* check
- *
+ *
* @param fail if true, report errors by throwing BuildException
*/
public void setFailOnError(boolean fail) {
public static class License {
/** acceptable years for copyright prefix to company - append " " */
static final String[] YEARS = // remove older after license xfer?
- new String[] { "2002 ", "2003 ", "2004 ", "2005", "2006", "2007", "2008",
+ new String[] { "2002 ", "2003 ", "2004 ", "2005", "2006", "2007", "2008",
"2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2001 ", "2000 ",
"1999 " };
public final String tag;
* Alto Research Center, Incorporated (PARC). All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which accompanies this distribution and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors: Xerox/PARC initial implementation ******************************************************************
*/
}
/**
* Add any years found (as String) to years, and return true at the first end-of-comment
- *
+ *
* @return true if this line has end-of-comment
*/
private static boolean checkLine(String line, ArrayList<String> years) {
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.ant.taskdefs;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
+@SuppressWarnings("deprecation")
public abstract class ConditionalTask extends Task {
public final static String TRUE = "true";
Iterator<If> iter = ifs().iterator();
List<String> result = new Vector<String>();
while (iter.hasNext()) {
- If next = (If) iter.next();
+ If next = iter.next();
String name = next.getName();
String prop = project.getProperty(name);
if (prop == null) {
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC),
* 2003 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.build;
/**
* This has only weak forms for build instructions needed: - resource
* pattern - compiler selection and control
- *
+ *
* Both assumed and generated paths are scattered; see XXXNameLiteral and
* XXXFileLiteral.
- *
+ *
* Builder is supposed to be thread-safe, but currently caches build
* properties to tunnel for filters. hmm.
*/
/**
* Splits strings into an unmodifable <code>List</code> of String using
* comma as the delimiter and trimming whitespace from the result.
- *
+ *
* @param text
* <code>String</code> to split.
* @return unmodifiable List (String) of String delimited by comma in text
*/
- public static List commaStrings(String text) {
+ public static List<String> commaStrings(String text) {
if ((null == text) || (0 == text.length())) {
return Collections.EMPTY_LIST;
}
/**
* Map delivered-jar name to created-module name
- *
+ *
* @param jarName
* the String (lowercased) of the jar/zip to map
*/
}
return noErr;
}
-
+
protected final boolean isLogging() {
- return (verbose && (null != this.handler));
+ return (verbose && (null != this.handler));
}
protected Result[] skipUptodate(Result[] results) {
/**
* Build a result with all antecedants.
- *
+ *
* @param result
* the Result to build
* @param errors
* the List sink for errors, if any
* @return false after successful build, when module jar should exist
*/
- protected final boolean buildAll(Result result, List errors) {
+ protected final boolean buildAll(Result result, List<String> errors) {
Result[] buildList = skipUptodate(getAntecedantResults(result));
ArrayList<String> doneList = new ArrayList<String>();
if ((null != buildList) && (0 < buildList.length)) {
/**
* Build a module but no antecedants.
- *
+ *
* @param module
* the Module to build
* @param errors
* Build product by discovering any modules to build, building those,
* assembling the product distribution, and optionally creating an installer
* for it.
- *
+ *
* @return true on success
*/
protected final boolean buildProduct(BuildSpec buildSpec)
}
protected final boolean buildProductModule(ProductModule module) {
- ArrayList errors = new ArrayList();
+ ArrayList<String> errors = new ArrayList<>();
try {
Kind productKind = Result.kind(Result.NORMAL, Result.ASSEMBLE);
Result result = module.module.getResult(productKind);
return buildAll(result, errors);
} finally {
- for (Iterator iter = errors.iterator(); iter.hasNext();) {
+ for (Iterator<String> iter = errors.iterator(); iter.hasNext();) {
handler.error("error building " + module + ": " + iter.next());
}
}
assembleAll));
}
}
- return (ProductModule[]) results.toArray(new ProductModule[0]);
+ return results.toArray(new ProductModule[0]);
}
/**
* Subclasses should query whether to include library files in the assembly.
- *
+ *
* @param module
* the Module being built
* @param libraries
* the List of File path to the jar to consider assembling
* @return true if the jar should be included, false otherwise.
*/
- protected void removeLibraryFilesToSkip(Module module, List libraries) {
- for (ListIterator liter = libraries.listIterator(); liter.hasNext();) {
- File library = (File) liter.next();
+ protected void removeLibraryFilesToSkip(Module module, List<File> libraries) {
+ for (ListIterator<File> liter = libraries.listIterator(); liter.hasNext();) {
+ File library = liter.next();
final String fname = library.getName();
if (null != fname) {
- for (Iterator iter = SKIP_LIBRARIES.iterator(); iter.hasNext();) {
- String name = (String) iter.next();
+ for (Iterator<String> iter = SKIP_LIBRARIES.iterator(); iter.hasNext();) {
+ String name = iter.next();
if (fname.equals(name)) {
liter.remove();
break;
/**
* Compile module classes to classesDir, saving String errors.
- *
+ *
* @param module
* the Module to compile
* @param classesDir
/**
* Assemble the module distribution from the classesDir, saving String
* errors.
- *
+ *
* @see #removeLibraryFilesToSkip(Module, File)
*/
abstract protected boolean assemble(Result result, File classesDir,
/**
* Assemble the module distribution from the classesDir and all
* antecendants, saving String errors.
- *
+ *
* @see #removeLibraryFilesToSkip(Module, File)
*/
abstract protected boolean assembleAll(Result result, Messager handler);
/**
* Copy toDir any fromDir included files without any exluded files,
* optionally filtering contents.
- *
+ *
* @param fromDir
* File dir to read from - error if not readable
* @param toDir
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.build;
* <li>a file <code>{moduleName}.mf.txt</code> is taken as the manifest of
* any .jar file produced, after filtering. </li>
* </ul>
- *
+ *
* @see Builder
* @see Modules#getModule(String)
*/
/**
* Recursively find antecedant jars.
- *
+ *
* @see findKnownJarAntecedants()
*/
static void doFindJarRequirements(Result result, List<File> known) {
// }
// return result;
// }
-
+
public final boolean valid;
public final File moduleDir;
return false;
}
-
+
public String toString() {
return name;
return kind.assemble ? (kind.normal ? releaseAll : testAll)
: (kind.normal ? release : test);
}
-
+
List<File> srcDirs(Result result) {
myResult(result);
return srcDirs;
}
-
+
List<File> libJars(Result result) {
myResult(result);
return libJars;
}
-
+
List<String> classpathVariables(Result result) {
myResult(result);
return classpathVariables;
}
-
+
List<File> exportedLibJars(Result result) {
myResult(result);
return exportedLibJars;
}
-
+
List<Module> requiredModules(Result result) {
myResult(result);
return requiredModules;
}
-
+
private void myResult(Result result) {
if ((null == result) || this != result.getModule()) {
throw new IllegalArgumentException("not my result: " + result + ": " + this);
/** read OSGI manifest.mf file XXX hacked */
private boolean initManifest() {
- File metaInf = new File(moduleDir, "META-INF");
+ File metaInf = new File(moduleDir, "META-INF");
if (!metaInf.canRead() || !metaInf.isDirectory()) {
return false;
}
update("lib", libs[i], libs[i], false);
}
- return true;
+ return true;
}
-
+
/** read eclipse .classpath file XXX line-oriented hack */
private boolean initClasspath() {
// meaning testsrc directory, junit library, etc.
*/
protected boolean reviewInit() {
try {
- for (ListIterator iter = srcDirs.listIterator(); iter.hasNext();) {
- File srcDir = (File) iter.next();
+ for (ListIterator<File> iter = srcDirs.listIterator(); iter.hasNext();) {
+ File srcDir = iter.next();
String lcname = srcDir.getName().toLowerCase();
if (!Util.JAVA5_VM
&& (Util.Constants.JAVA5_SRC.equals(lcname) || Util.Constants.JAVA5_TESTSRC
}
}
}
- return (String[]) result.toArray(new String[0]);
+ return result.toArray(new String[0]);
}
public void acceptLine(String line) {
/* *******************************************************************
* Copyright (c) 2003 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wes Isberg initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
* ******************************************************************/
/*
* A quickie hack to extract sample code from testable sources.
- * This could reuse a lot of code from elsewhere,
- * but currently doesn't,
+ * This could reuse a lot of code from elsewhere,
+ * but currently doesn't,
* to keep it in the build module which avoids dependencies.
* (Too bad we can't use scripting languages...)
*/
package org.aspectj.internal.tools.build;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.io.Reader;
import java.text.DateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
/**
* This gathers sample code delimited with [START..END]-SAMPLE
* ... sample code ...
* // END-SAMPLE {anchorName}
* </pre>
- * where {anchorName} need not be unique and might be
+ * where {anchorName} need not be unique and might be
* hierarchical wrt "-", e.g., "genus-species-individual".
*/
public class SampleGatherer {
-
+
/** EOL String for gathered lines */
public static final String EOL = "\n"; // XXX
-
+
static final String START = "START-SAMPLE";
static final String END = "END-SAMPLE";
static final String AUTHOR = "@author";
// source = "in this <pre> day and </pre> age";
// System.err.println("from " + source);
// System.err.println(" to " + SampleUtil.replace(source, from, to));
-//
+//
// }
/**
* Emit samples gathered from any input args.
fos.close();
System.out.println("see file:///" + out);
}
-
+
/**
* Gather samples from a source file or directory
* @param source the File file or directory to start with
* @return sink or a new Samples collection with any samples found
* @throws IOException if unable to read a source file
*/
- public static Samples gather(File source, Samples sink)
+ public static Samples gather(File source, Samples sink)
throws IOException {
if (null == sink) {
sink = new Samples();
}
return line;
}
-
- private static void doGather(File source, Samples sink)
+
+ private static void doGather(File source, Samples sink)
throws IOException {
if (source.isFile()) {
if (isSource(source)) {
}
return false;
}
-
- private static void gatherFromFile(final File source, final Samples sink)
+
+ private static void gatherFromFile(final File source, final Samples sink)
throws IOException {
Reader reader = null;
try {
anchorName = anchorName.substring(0, loc);
}
continue;
- }
+ }
// found end?
loc = line.indexOf(END);
endLine = lineNumber;
Sample sample = new Sample(anchorName,
anchorTitle,
- author,
- sampleCode.toString(),
- source,
- startLine,
+ author,
+ sampleCode.toString(),
+ source,
+ startLine,
endLine,
(String[]) flags.toArray(new String[flags.size()]));
sink.addSample(sample);
startLine = -1;
endLine = Integer.MAX_VALUE;
continue;
- }
+ }
// found author?
loc = line.indexOf(AUTHOR);
if (-1 != loc) {
flags.add(trimCommentEnd(line, loc + FLAG.length()));
}
-
+
// reading?
if ((-1 != startLine) && (-1 == endLine)) {
sampleCode.append(line);
public int compare(Sample left, Sample right) {
if (null == left) {
return (null == right ? 0 : -1);
- }
+ }
if (null == right) {
return 1;
- }
+ }
int result = left.anchorName.compareTo(right.anchorName);
if (0 != result) {
- return result;
+ return result;
}
result = left.sourcePath.compareTo(right.sourcePath);
if (0 != result) {
- return result;
+ return result;
}
result = right.startLine - left.startLine;
if (0 != result) {
- return result;
+ return result;
}
return right.endLine - left.endLine;
}
public int compare(Sample left, Sample right) {
if (null == left) {
return (null == right ? 0 : -1);
- }
+ }
if (null == right) {
return 1;
- }
+ }
int result = left.author.compareTo(right.author);
if (0 != result) {
- return result;
+ return result;
}
return NAME_SOURCE_COMPARER.compare(left,right);
}
};
-
+
final String anchorName;
final String anchorTitle;
final String author;
}
public static class Kind {
-
+
/** lowercase source suffixes identify files to gather samples from */
public static final String[] SOURCE_SUFFIXES = new String[]
- { ".java", ".aj", ".sh", ".ksh",
+ { ".java", ".aj", ".sh", ".ksh",
".txt", ".text", ".html", ".htm", ".xml" };
static final Kind XML = new Kind();
static final Kind HTML = new Kind();
List<Sample> getSortedSamples() {
return getSortedSamples(Sample.NAME_SOURCE_COMPARER);
}
-
+
List<Sample> getSortedSamples(Comparator<Sample> comparer) {
ArrayList<Sample> result = new ArrayList<Sample>();
result.addAll(samples);
*/
class SamplesRenderer {
public static SamplesRenderer ME = new SamplesRenderer();
- protected SamplesRenderer() {
+ protected SamplesRenderer() {
}
public static final String EOL = "\n"; // XXX
- public static final String INFO =
+ public static final String INFO =
"<p>This contains contributions from the AspectJ community of "
+ "<ul><li>sample code for AspectJ programs,</li>"
+ "<li>sample code for extensions to AspectJ tools using the public API's,</li>"
+ "see the <a href=\"doc/faq.html#q:buildingsource\">FAQ entry "
+ "\"buildingsource\"</a>.</p>";
- public static final String COPYRIGHT =
+ public static final String COPYRIGHT =
"<p><small>Copyright 2003 Contributors. All Rights Reserved. "
+ "This sample code is made available under the Common Public "\r + "License version 1.0 available at "
+ "<a href=\"http://www.eclipse.org/legal/epl-v10.html\">"
+ "the source by reference to the AspectJ project home page "
+ " at http://eclipse.org/aspectj.</small></p>"
+ EOL;
-
+
/** template algorithm to render */
public final StringBuffer render(Samples samples, StringBuffer sink) {
if (null == sink) {
return sink;
}
startList(samples, sink);
- List list = samples.getSortedSamples();
+ List<Sample> list = samples.getSortedSamples();
String anchorName = null;
- for (ListIterator iter = list.listIterator();
+ for (ListIterator<Sample> iter = list.listIterator();
iter.hasNext();) {
- Sample sample = (Sample) iter.next();
+ Sample sample = iter.next();
String newAnchorName = sample.anchorName;
- if ((null == anchorName)
+ if ((null == anchorName)
|| (!anchorName.equals(newAnchorName))) {
- endAnchorName(anchorName, sink);
+ endAnchorName(anchorName, sink);
startAnchorName(newAnchorName, sample.anchorTitle, sink);
anchorName = newAnchorName;
}
class HTMLSamplesRenderer extends SamplesRenderer {
public static SamplesRenderer ME = new HTMLSamplesRenderer();
// XXX move these
- public static boolean doHierarchical = true;
- public static boolean doFlags = false;
+ public static boolean doHierarchical = true;
+ public static boolean doFlags = false;
+
-
final StringBuffer tableOfContents;
final StringBuffer sampleSection;
String[] lastAnchor = new String[0];
String currentAnchor;
String currentAuthor;
- protected HTMLSamplesRenderer() {
+ protected HTMLSamplesRenderer() {
sampleSection = new StringBuffer();
tableOfContents = new StringBuffer();
}
-
+
protected void startAnchorName(String name, String title, StringBuffer sink) {
if (doHierarchical) {
doContentTree(name);
- }
+ }
// ---- now do anchor
tableOfContents.append(" <li><a href=\"#" + name);
if ((null == title) || (0 == title.length())) {
}
currentAnchor = null;
}
-
+
// do heading then code
- renderHeading(sample.anchorName, sample.anchorTitle, sampleSection);
+ renderHeading(sample.anchorName, sample.anchorTitle, sampleSection);
if (sample.kind == Sample.Kind.HTML) {
renderHTML(sample);
} else if (sample.kind == Sample.Kind.XML) {
sampleSection.append(" <p>| " + currentAuthor);
sampleSection.append(EOL);
}
- sampleSection.append(" | ");
+ sampleSection.append(" | ");
sampleSection.append(SampleUtil.renderCodePath(sample.sourcePath));
sampleSection.append(":" + sample.startLine);
- sampleSection.append(" |");
+ sampleSection.append(" |");
sampleSection.append(EOL);
- sampleSection.append("<p>");
+ sampleSection.append("<p>");
sampleSection.append(EOL);
if (doFlags) {
boolean flagHeaderDone = false;
}
}
}
-
+
protected void renderXML(Sample sample) {
renderStandardHeader(sample);
sampleSection.append(" <pre>");
tableOfContents.append(EOL);
tableOfContents.append(" <ul>");
tableOfContents.append(EOL);
-
+
renderHeading(prefixName, prefixName, sampleSection);
}
- lastAnchor = parts;
+ lastAnchor = parts;
}
protected void renderAuthorIndex(Samples samples, StringBuffer sink) {
iter.hasNext();) {
Sample sample = (Sample) iter.next();
sink.append(i++ + ": " + sample);
- }
+ }
}
-
+
/** result struct for getPackagePath */
static class JavaFile {
/** input File possibly signifying a java file */
final File path;
-
- /** String java path suffix in form "com/company/Bar.java"
+
+ /** String java path suffix in form "com/company/Bar.java"
* null if this is not a java file
*/
final String javaPath;
-
+
/** any prefix before java path suffix in the original path */
final String prefix;
-
+
/** error handling */
final Throwable thrown;
JavaFile(File path, String javaPath, String prefix, Throwable thrown) {
if (null != reader) {
try {
reader.close();
- } catch (IOException e1) {
+ } catch (IOException e1) {
// ignore
}
}
}
return new JavaFile(path, javaPath, prefix, thrown);
}
-
+
/**
* Extract file path relative to base of package directory
* and directory in SAMPLE_BASE_DIR_NAME for this file.
public static String renderCodePath(File path) {
JavaFile javaFile = getJavaFile(path);
if (javaFile.thrown != null) {
- throw new Error(javaFile.thrown.getClass()
+ throw new Error(javaFile.thrown.getClass()
+ ": " + javaFile.thrown.getMessage());
}
-
+
String file = javaFile.javaPath; // can be null...
String prefix = javaFile.prefix;
if (prefix == null) {
throw new IllegalArgumentException(m + "?: " + path);
}
prefix = prefix.substring(loc + 1 + SAMPLE_BASE_DIR_NAME.length());
-
+
if (file == null) {
int slash = prefix.lastIndexOf('/');
if (-1 == slash) {
}
return (one.length > two.length ? two.length : one.length);
}
-
+
public static String[] splitAnchorName(Sample sample) {
return splitAnchorName(sample.anchorName);
}
-
+
public static String[] splitAnchorName(String anchorName) {
ArrayList<String> result = new ArrayList<String>();
int start = 0;
}
next = anchorName.substring(start);
result.add(next);
- return (String[]) result.toArray(new String[result.size()]);
+ return result.toArray(new String[result.size()]);
}
/**
* Replace literals with literals in source string
public static void render(
Sample sample,
- String fieldDelim,
- String valueDelim,
+ String fieldDelim,
+ String valueDelim,
StringBuffer sink) {
if ((null == sink) || (null == sample)) {
return;
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
-
+
package org.aspectj.internal.tools.build;
-import java.io.*;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import java.util.jar.Attributes;
-import java.util.jar.Manifest;
import java.util.jar.Attributes.Name;
+import java.util.jar.Manifest;
-/**
+/**
* Build-only utilities.
* Many mirror utils module APIs.
*/
JAVA5_VM = java5VM;
}
- /**
- * Map version in long form to short,
+ /**
+ * Map version in long form to short,
* e.g., replacing "alpha" with "a"
*/
public static String shortVersion(String version) {
version = Util.replace(version, "dev", "d");
return version;
}
-
+
/**
* Replace any instances of {replace} in {input} with {with}.
* @param input the String to search/replace
}
return passed;
}
-
+
/** @throws IllegalArgumentException if cannot read dir */
public static void iaxIfNotCanReadDir(File dir, String name) {
if (!canReadDir(dir)) {
throw new IllegalArgumentException(name + " dir not readable: " + dir);
}
}
-
+
/** @throws IllegalArgumentException if cannot read file */
public static void iaxIfNotCanReadFile(File file, String name) {
if (!canReadFile(file)) {
throw new IllegalArgumentException(name + " file not readable: " + file);
}
}
-
+
/** @throws IllegalArgumentException if cannot write dir */
public static void iaxIfNotCanWriteDir(File dir, String name) {
if (!canWriteDir(dir)) {
throw new IllegalArgumentException(name + " dir not writeable: " + dir);
}
}
-
+
/** @throws IllegalArgumentException if input is null */
public static void iaxIfNull(Object input, String name) {
if (null == input) {
throw new IllegalArgumentException("null " + name);
}
}
-
+
/** render exception to String */
public static String renderException(Throwable thrown) {
if (null == thrown) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
pw.println(thrown.getMessage());
- thrown.printStackTrace(pw);
+ thrown.printStackTrace(pw);
pw.flush();
- return sw.getBuffer().toString();
+ return sw.getBuffer().toString();
}
-
+
/** @return true if dir is a writable directory */
public static boolean canWriteDir(File dir) {
return (null != dir) && dir.canWrite() && dir.isDirectory();
}
-
+
public static String path(String first, String second) {
return first + File.separator + second;
}
}
return sb.toString();
}
-
+
/** @return true if dir is a readable directory */
public static boolean canReadDir(File dir) {
return (null != dir) && dir.canRead() && dir.isDirectory();
}
-
+
/** @return true if dir is a readable file */
public static boolean canReadFile(File file) {
return (null != file) && file.canRead() && file.isFile();
}
-
- /**
+
+ /**
* Delete file or directory.
* @param dir the File file or directory to delete.
- * @return true if all contents of dir were deleted
+ * @return true if all contents of dir were deleted
*/
public static boolean delete(File dir) {
return deleteContents(dir) && dir.delete();
}
-
- /**
+
+ /**
* Delete contents of directory.
* The directory itself is not deleted.
* @param dir the File directory whose contents should be deleted.
- * @return true if all contents of dir were deleted
+ * @return true if all contents of dir were deleted
*/
public static boolean deleteContents(File dir) {
if ((null == dir) || !dir.canWrite()) {
}
return true;
}
-
+
/** @return File temporary directory with the given prefix */
public static File makeTempDir(String prefix) {
if (null == prefix) {
File tempFile = null;
for (int i = 0; i < 10; i++) {
try {
- tempFile = File.createTempFile(prefix,"tmp");
+ tempFile = File.createTempFile(prefix,"tmp");
tempFile.delete();
if (tempFile.mkdirs()) {
break;
} catch (IOException e) {
}
}
- return tempFile;
+ return tempFile;
}
/**
* Close stream with the usual checks.
- * @param stream the InputStream to close - ignored if null
- * @return null if closed without IOException, message otherwise
+ * @param stream the InputStream to close - ignored if null
+ * @return null if closed without IOException, message otherwise
*/
public static String close(Writer stream) {
String result = null;
/**
* Support for OSGI bundles read from manifest files.
- * Currently very limited, and will only support the subset of
+ * Currently very limited, and will only support the subset of
* features that we use.
* sources:
* http://www-128.ibm.com/developerworks/library/os-ecl-osgi/index.html
* http://help.eclipse.org/help30/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/osgi/org/osgi/framework/Constants.html
- */
+ */
public static class OSGIBundle {
public static final Name BUNDLE_NAME = new Name("Bundle-Name");
public static final Name BUNDLE_CLASSPATH = new Name("Bundle-ClassPath");
/** unmodifiable list of all valid OSGIBundle Name's */
- public static final List NAMES;
+ public static final List<Name> NAMES;
static {
- ArrayList names = new ArrayList();
+ ArrayList<Name> names = new ArrayList<>();
names.add(BUNDLE_NAME);
names.add(BUNDLE_SYMBOLIC_NAME);
names.add(BUNDLE_VERSION);
private final Attributes attributes;
/**
- *
+ *
* @param manifestInputStream
* the InputStream of the manifest.mf - will be closed.
* @throws IOException
int skips = 0;
while (st.hasMoreTokens()) {
String token = st.nextToken();
- int first = token.indexOf("\"");
+ int first = token.indexOf("\"");
if (-1 != first) {
if (!st.hasMoreTokens()) {
throw new IllegalArgumentException(token);
}
/**
- * Wrap each dependency on another bundle
+ * Wrap each dependency on another bundle
*/
public static class RequiredBundle {
-
+
/** unparsed entry text, for debugging */
final String text;
-
+
/** Symbolic name of the required bundle */
final String name;
/** if not null, then start/end versions of required bundle
- * in the format of the corresponding manifest entry
+ * in the format of the corresponding manifest entry
*/
final String versions;
int start = RESOLUTION.length();
int end = token.length();
opt = token.substring(start, end);
- }
+ }
}
versions = vers;
optional = "optional".equals(opt);
/* *******************************************************************
* Copyright (c) 2005 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wes Isberg initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
* ******************************************************************/
-
package org.aspectj.internal.build;
-import java.io.File;
-
-import junit.framework.TestCase;
-
-import org.aspectj.internal.tools.build.Messager;
-import org.aspectj.internal.tools.build.Module;
-import org.aspectj.internal.tools.build.Modules;
import org.aspectj.internal.tools.build.Result;
import org.aspectj.internal.tools.build.Result.Kind;
+import junit.framework.TestCase;
+
public class BuildClasspathTest extends TestCase {
public void testKindsGet() {
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
</parent>
<artifactId>installer</artifactId>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<configuration>
<groupId>org.aspectj</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>
<file>${basedir}/jdtcore-for-aspectj.jar</file>
<createChecksum>true</createChecksum>
<configuration>
<groupId>org.aspectj</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>
<file>${basedir}/jdtcore-for-aspectj-src.zip</file>
<createChecksum>true</createChecksum>
<modelVersion>4.0.0</modelVersion>
<properties>
- <revision>1.9.4</revision>
+ <revision>1.9.6.BUILD-SNAPSHOT</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
<packaging>pom</packaging>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<name>AspectJ Parent Project</name>
<modules>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
/* *******************************************************************
- * Copyright (c) 1999-2000 Xerox Corporation.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * Copyright (c) 1999-2000 Xerox Corporation.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
-
package org.aspectj.testing;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.Message;
import org.aspectj.util.LangUtil;
-import java.util.*;
-import java.io.*;
-
/**
* Testing client interface for checking results and reporting
* to a delegate IMessageHandler.
- * Harnesses providing this interface for test clients must
+ * Harnesses providing this interface for test clients must
* set it up by calling
* {@link #setBASEDIR(File)}
- * {@link #setMessageHandler(IMessageHandler)} and
+ * {@link #setMessageHandler(IMessageHandler)} and
* {@link #clear()} for each test, as appropriate.
* (That means that IMessageHandler must be loaded from a class
* loader common to the harness and Tester.)
* If clients submit a failing check, this registers the message
- * and throws an AbortException holding the message; this
+ * and throws an AbortException holding the message; this
* AbortException <b>will not</b> have the correct stack trace;
* all the information should be encoded in the message.
* Find any original exception thrown in the message itself.
*/
- // XXX consider creating exception for new API throwFailure(String m)
+ // XXX consider creating exception for new API throwFailure(String m)
public class Tester {
/** delegate for reporting results */
private static IMessageHandler messageHandler;
-
+
/** base directory for calculating relative paths to event files */
private static File BASEDIR;
-
- /**
+
+ /**
* collection of notes submitted
*/
- private static Set notes;
-
+ private static Set<String> notes;
+
/** <code>List</code> to hold events submitted. */
private static List<String> actualEvents = new ArrayList<>();
-
+
/** <code>List</code> to hold events we expect. */
private static List<String> expectedEvents = new ArrayList<>();
public static File getBASEDIR() {
return BASEDIR;
}
-
-
+
+
/**
* Set the message handler used for this Tester.
- * When given a message of kind FAIL, this handler
+ * When given a message of kind FAIL, this handler
* must complete abruptly or return false (i.e., not handled completely)
- * so the Tester throws an AbortException.
+ * so the Tester throws an AbortException.
* @see checkFailed(..).
*/
- public static void setMessageHandler(IMessageHandler handler) {
+ public static void setMessageHandler(IMessageHandler handler) {
if (null == handler) throw new IllegalArgumentException("null handler");
if (messageHandler != handler) messageHandler = handler;
}
-
+
public static void clear() {
clearNotes();
clearEvents();
/** XXX deprecated #clear() */
public static void clearNotes() {
- notes = new HashSet();
+ notes = new HashSet<>();
}
/** XXX deprecated #clear() */
- public static void clearEvents() {
- actualEvents = new ArrayList<>();
- expectedEvents = new ArrayList<>();
+ public static void clearEvents() {
+ actualEvents = new ArrayList<>();
+ expectedEvents = new ArrayList<>();
}
-
+
/** Add an actual event */
- public static void event(String s) {
- actualEvents.add(s);
+ public static void event(String s) {
+ actualEvents.add(s);
}
-
+
/**
* Add a note to {@link #notes}.
* @param note Message to add.
- * XXX deprecated event(String)
+ * XXX deprecated event(String)
*/
- public static void note(Object note) {
+ public static void note(String note) {
notes.add(note);
}
* and fails using <code>note.toString()</code> is it wasn't found.
*
* @param note Message that should've been added using {@link #note}.
- * XXX deprecated checkEvent(String)
+ * XXX deprecated checkEvent(String)
*/
- public static void check(Object note) {
+ public static void check(String note) {
check(note, "expected note \"" + note.toString() + "\"");
}
* @param message Message with which to fail if <code>node</code>
* wasn't added.
*/
- public static void check(Object note, String message) {
+ public static void check(String note, String message) {
check(notes.contains(note), message);
}
throwable(t, null);
}
-
+
/**
* Reports that <code>t</code> shouldn't have been thrown.
* using <code>msg</code> as the message.
*/
public static void checkEqual(long value, long expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compared <code>value</code> and <code>expectedValue</code>
*/
public static void checkEqual(double value, double expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compared <code>value</code> and <code>expectedValue</code>
*/
public static void checkEqual(short value, short expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compared <code>value</code> and <code>expectedValue</code>
*/
public static void checkEqual(byte value, byte expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compares <code>value</code> and <code>expectedValue</code>
*/
public static void checkEqual(char value, char expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compares <code>value</code> and <code>expectedValue</code>
*/
public static void checkEqual(boolean value, boolean expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compares <code>value</code> and <code>expectedValue</code>
* @param expectedSet Expected <code>String</code> of values.
* @param msg Message with which to fail.
*/
- public static void checkEqual(Collection set, String expectedSet, String msg) {
+ public static void checkEqual(Collection<String> set, String expectedSet, String msg) {
checkEqual(set, LangUtil.split(expectedSet), msg);
}
-
+
/**
* Checks whether the entries of <code>set</code> are equal
* using <code>equals</code> to the corresponding entry in
* <code>expectedSet</code> and fails with message <code>msg</code>,
* except that duplicate actual entries are ignored.
- * This issues fail messages for each failure; when
+ * This issues fail messages for each failure; when
* aborting on failure, only the first will be reported.
*
* @param set Unkown set of values.
* @param expectedSet Expected <code>String</code> of values.
* @param msg Message with which to fail.
*/
- public static void checkEqualIgnoreDups(Collection set, String[] expected, String msg,
+ public static void checkEqualIgnoreDups(Collection<String> set, String[] expected, String msg,
boolean ignoreDups) {
String[] diffs = diffIgnoreDups(set, expected, msg, ignoreDups);
if (0 < diffs.length) {
}
// for (int i = 0; i < diffs.length; i++) {
// check(false, diffs[i]);
-// }
+// }
}
-
+
/** @return String[] of differences '{un}expected msg "..." {not} found' */
- private static String[] diffIgnoreDups(Collection<String> set, String[] expected, String msg,
+ private static String[] diffIgnoreDups(Collection<String> set, String[] expected, String msg,
boolean ignoreDups) {
ArrayList<String> result = new ArrayList<>();
ArrayList<String> actual = new ArrayList<>(set);
}
}
for (String act: actual) {
- result.add(" unexpected " + msg + " \"" + act + "\" found");
+ result.add(" unexpected " + msg + " \"" + act + "\" found");
}
- return (String[]) result.toArray(new String[0]);
+ return result.toArray(new String[0]);
}
/**
* @param expectedSet Expected <code>String</code> of values.
* @param msg Message with which to fail.
*/
- public static void checkEqual(Collection set, String[] expected, String msg) {
+ public static void checkEqual(Collection<String> set, String[] expected, String msg) {
checkEqualIgnoreDups(set, expected, msg, false);
}
*/
public static void checkEqual(Object value, Object expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Checks whether the entries of <code>set</code> are equal
expectedEvents.add(s);
}
}
-
+
/** add expected events */
public static void expectEvent(Object s) {
if (null != s) {
expectEvent(s.toString());
}
}
-
+
/**
* add expected events, parse out ; from string
* Expect those messages in <code>s</code> separated by
if (null != events[i]) {
expectEvent(events[i].toString());
}
- }
+ }
}
}
-
+
/** check actual and expected have same members */
public static void checkAllEvents() {
- checkAndClearEvents((String[]) expectedEvents.toArray(new String[0]));
+ checkAndClearEvents(expectedEvents.toArray(new String[0]));
}
-
+
/** also ignore duplicate actual entries for expected */
public static void checkAllEventsIgnoreDups() {
final boolean ignoreDups = true;
- final String[] exp = (String[]) expectedEvents.toArray(new String[0]);
+ final String[] exp = expectedEvents.toArray(new String[0]);
checkEqualIgnoreDups(actualEvents, exp, "event", ignoreDups);
clearEvents();
}
-
+
/** Check events, file is line-delimited. If there is a non-match, signalls
- * a single error for the first event that does not match the next event in
- * the file. The equivalence is {@link #checkEqualLists}. Blank lines are
+ * a single error for the first event that does not match the next event in
+ * the file. The equivalence is {@link #checkEqualLists}. Blank lines are
* ignored. lines that start with '//' are ignored. */
public static void checkEventsFromFile(String eventsFile) {
// XXX bug reads into current expected and checks all - separate read and check
BufferedReader in = new BufferedReader(new FileReader(file));
//final File parentDir = (null == file? null : file.getParentFile());
String line;
- List expEvents = new ArrayList();
+ List<String> expEvents = new ArrayList<>();
while ((line = in.readLine()) != null) {
line = line.trim();
if ((line.length() < 1) || (line.startsWith("//"))) continue;
expEvents.add(line);
}
+ in.close();
checkEqualLists(actualEvents, expEvents, " from " + eventsFile);
} catch (IOException ioe) {
throwable(ioe);
}
}
-
-
+
+
/** Check to see that two lists of strings are the same. Order is important.
* Trimmable whitespace is not important. Case is important.
*
* @param expected another list
* @param message a context string for the resulting error message if the test fails.
*/
- public static void checkEqualLists(List/*String*/ actual, List/*String*/ expected,
+ public static void checkEqualLists(List<String> actual, List<String> expected,
String message) {
- Iterator a = actual.iterator();
- Iterator e = expected.iterator();
+ Iterator<String> a = actual.iterator();
+ Iterator<String> e = expected.iterator();
int ai = 0;
int ei = 0;
for (; a.hasNext(); ) {
checkFailed("unexpected [" + ai + "] \"" + a.next() + "\" " + message);
return;
}
- String a0 = ((String) a.next()).trim();
- String e0 = ((String) e.next()).trim();
+ String a0 = a.next().trim();
+ String e0 = e.next().trim();
if (! a0.equals(e0)) {
- checkFailed("expected [" + ei + "] \"" + e0
+ checkFailed("expected [" + ei + "] \"" + e0
+ "\"\n but found [" + ai + "] \"" + a0 + "\"\n " + message);
return;
}
checkFailed("expected [" + ei + "] \"" + e.next() + "\" " + message);
ei++;
}
- }
-
+ }
+
/** Check events, expEvents is space delimited */
public static void checkEvents(String expEvents) {
checkEqual(actualEvents, expEvents, "event");
public static void checkEvents(String[] expEvents) {
checkEqual(actualEvents, expEvents, "event");
}
-
+
/** Check events and clear after check*/
public static void checkAndClearEvents(String expEvents) {
checkEvents(expEvents);
clearEvents();
- }
-
+ }
+
/** Check events and clear after check*/
public static void checkAndClearEvents(String[] expEvents) {
checkEvents(expEvents);
/** XXX deprecated */
public static void printEvents() { // XXX no clients?
- for (Iterator i = actualEvents.iterator(); i.hasNext(); ) {
+ for (Iterator<String> i = actualEvents.iterator(); i.hasNext(); ) {
System.out.println(i.next()); // XXX System.out
}
}
* @param thrown <code>Throwable</code> to print.
* @see #maxStackTrace
*/
- public void unexpectedExceptionFailure(Throwable thrown) {
+ public void unexpectedExceptionFailure(Throwable thrown) {
handle("unexpectedExceptionFailure", thrown, true);
}
-
+
/**
* Handle message by delegation to message handler, doing
- * IMessage.FAIL if (fail || (thrown != null) and IMessage.INFO
+ * IMessage.FAIL if (fail || (thrown != null) and IMessage.INFO
* otherwise.
*/
// private static void resofhandle(String message, Throwable thrown, boolean fail) {
// /* If FAIL and the message handler returns false (normally),
// * Then this preserves "abort" semantics by throwing an
-// * abort exception.
+// * abort exception.
// */
// if (failed) {
// if (handled) {
/*******************************************************************************
* Copyright (c) 2006,2017 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
private String mainClass = "UnknownClass";
private String mainLoader = "UnknownLoader";
-
+
public void initialize () throws IOException {
createRootLoader();
loadConfiguration();
}
-
+
private void loadConfiguration () throws IOException {
File file = new File(workingDirectory,"server.properties");
Properties props = new Properties();
FileInputStream in = new FileInputStream(file);
props.load(in);
in.close();
-
+
Enumeration<?> enu = props.propertyNames();
while (enu.hasMoreElements()) {
String key = (String)enu.nextElement();
}
}
}
-
+
private void createLoader (String property) throws IOException {
ClassLoader parent = rootLoader;
if (debug) System.err.println("Creating loader "+name+" with classpath "+classpath);
if (st.hasMoreTokens()) {
String parentName = st.nextToken();
- parent = (ClassLoader)loaders.get(parentName);
+ parent = loaders.get(parentName);
if (parent == null) error("No such loader: " + parentName);
}
-
+
List<URL> urlList = new ArrayList<>();
st = new StringTokenizer(classpath,";");
while (st.hasMoreTokens()) {
loaders.put(name,loader);
}
-
+
private void createRootLoader() throws IOException {
List<URL> urlList = new ArrayList<>();
-
+
// Sandbox
URL url = workingDirectory.getCanonicalFile().toURI().toURL();
urlList.add(url);
urlList.add(new File(aspectjBase,"runtime/target/classes").toURI().toURL());
// urlList.add(new File(aspectjBase,"aspectjrt/target/classes").toURI().toURL());
// urlList.add(new File(aspectjBase,"aspectj5rt/target/classes").toURI().toURL());
-
+
URL[] urls = new URL[urlList.size()];
urlList.toArray(urls);
ClassLoader parent = getClass().getClassLoader().getParent();
rootLoader = new URLClassLoader(urls,parent);
if (debug) System.err.println("? TestServer.createRootLoader() loader=" + rootLoader + ", urlList=" + urlList + ", parent=" + parent);
}
-
+
public void setExitOntError (boolean b) {
exitOnError = b;
}
-
+
public void setWorkingDirectory (String name) {
workingDirectory = new File(name);
if (!workingDirectory.exists()) error("Missing or invalid working directory: " + workingDirectory.getPath());
}
-
+
public static void main(String[] args) throws Exception {
System.out.println("Starting ...");
-
+
TestServer server = new TestServer();
server.setWorkingDirectory(args[0]);
server.initialize();
-
+
Thread thread = new Thread(server,"application");
thread.start();
thread.join();
-
+
System.out.println("Stopping ...");
}
public void run() {
System.out.println("Running " + mainClass);
- runClass(mainClass,(ClassLoader)loaders.get(mainLoader));
+ runClass(mainClass,loaders.get(mainLoader));
}
private void runClass (String className, ClassLoader classLoader) {
try {
- Class clazz = Class.forName(className,false,classLoader);
+ Class<?> clazz = Class.forName(className,false,classLoader);
invokeMain(clazz,new String[] {});
}
catch (ClassNotFoundException ex) {
error(ex.toString());
}
}
-
+
public void invokeMain (Class<?> clazz, String[] args)
{
Class<?>[] paramTypes = new Class[1];
paramTypes[0] = args.getClass();
-
+
try {
Method method = clazz.getDeclaredMethod("main",paramTypes);
Object[] params = new Object[1];
error(th.toString());
}
}
-
+
private void error (String message) {
System.out.println(message);
if (exitOnError) System.exit(0);
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.testing;
-import org.aspectj.bridge.IMessage;
-import org.aspectj.bridge.IMessageHandler;
-
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessageHandler;
+
import junit.framework.TestCase;
import junit.textui.TestRunner;
public class TesterTest extends TestCase {
- private static final String ME
+ private static final String ME
= "org.aspectj.testing.TesterTest";
/** @param args ignored */
public TesterTest(String arg0) {
super(arg0);
}
-
+
/**
* Test the usage pattern
* <pre>Tester.event("foo");
public void testEventArrayPattern() {
MyTestReporter reporter = new MyTestReporter();
Tester.setMessageHandler(reporter);
-
+
//--------- positive test - got expected events
reporter.clear();
- Tester.clear();
+ Tester.clear();
Tester.event("one");
Tester.event("two");
Tester.checkEvents(new String[] { "one", "two"});
//--------- got and didn't get expected events
reporter.clear();
- Tester.clear();
+ Tester.clear();
Tester.event("one");
Tester.event("two");
Tester.checkEvents(new String[] { "one", "two", "three"});
reporter.assertSize(1);
assertTrue(reporter.gotFail("three"));
}
-
+
/**
* Test the usage pattern
* <pre>Tester.event("foo");
public void testEventStringPattern() {
MyTestReporter reporter = new MyTestReporter();
Tester.setMessageHandler(reporter);
-
+
//--------- positive test - got expected events
reporter.clear();
- Tester.clear();
+ Tester.clear();
Tester.event("one");
Tester.event("two");
Tester.expectEvent("one");
//--------- got and didn't get expected events
reporter.clear();
- Tester.clear();
+ Tester.clear();
Tester.expectEvent("one");
Tester.expectEvent("two");
Tester.expectEvent("three");
assertTrue(reporter.gotFail("three"));
reporter.assertSize(1);
}
-
+
/**
* Test the usage pattern
* <pre>Tester.note("foo");
public void testNotePattern() {
MyTestReporter reporter = new MyTestReporter();
Tester.setMessageHandler(reporter);
-
+
//--------- positive test - got expected events
reporter.clear();
- Tester.clear();
+ Tester.clear();
Tester.note("one");
Tester.note("two");
Tester.check("one");
//--------- got and didn't get expected events
reporter.clear();
- Tester.clear();
+ Tester.clear();
Tester.note("one");
Tester.check("one");
Tester.note("two");
assertTrue(reporter.gotFail("three"));
reporter.assertSize(1);
}
-
+
/**
* Stub to record failures emitted by Tester.
* @author isberg
assertTrue(-1 < size);
assertTrue("failures: " + failures, size == failures.size());
}
-
+
boolean gotPass(String substring) {
return gotItem(passes, substring);
}
-
+
boolean gotFail(String substring) {
return gotItem(failures, substring);
}
-
+
boolean gotItem(List<IMessage> list, String substring) {
for (IMessage element: list) {
String s = element.getMessage();
}
return false;
}
-
+
public boolean isIgnoring(IMessage.Kind kind) {
return false;
}
public void dontIgnore(IMessage.Kind kind) {
- ;
+
}
public void ignore(IMessage.Kind kind) {
return true;
}
}
-}
+}
// /**
// * @see ReporterI#abortWithFailure(String, Throwable)
// */
// public void abortWithFailure(String message, Throwable exception) {
// if (null == exception) {
-// check(message, true);
+// check(message, true);
// } else {
// String s = message + Util.unqualifiedClassName(exception)
// + ": " + exception.getMessage();
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.testing.util;
import java.util.Properties;
import java.util.Set;
+import org.aspectj.bridge.IMessageHandler;
+import org.aspectj.bridge.MessageUtil;
+import org.aspectj.util.FileUtil;
+import org.aspectj.util.LangUtil;
+import org.aspectj.util.Reflection;
+
import jdiff.text.FileLine;
import jdiff.util.Diff;
import jdiff.util.DiffNormalOutput;
import junit.framework.TestSuite;
import junit.runner.TestCaseClassLoader;
-import org.aspectj.bridge.IMessageHandler;
-import org.aspectj.bridge.MessageUtil;
-import org.aspectj.util.FileUtil;
-import org.aspectj.util.LangUtil;
-import org.aspectj.util.Reflection;
-
/**
* Things that junit should perhaps have, but doesn't. Note the file-comparison methods require JDiff to run, but JDiff types are
* not required to resolve this class. Also, the bytecode weaver is required to compare class files, but not to compare other files.
LIB_RPATHS.setProperty(TESTING_CLIENT_KEY, "tests/testing-client.jar");
// TODO support others loaded dynamically
- Map map = new HashMap();
- for (Iterator iter = LIB_RPATHS.keySet().iterator(); iter.hasNext();) {
+ Map<String,Object> map = new HashMap<>();
+ for (Iterator<Object> iter = LIB_RPATHS.keySet().iterator(); iter.hasNext();) {
String key = (String) iter.next();
String path = LIB_RPATHS.getProperty(key);
File file = null;
/**
* This relies on these being File (where toString() == getPath()) or URL (where toString() == toExternalForm()).
- *
+ *
* @param entries the Object[] of File or URL elements
* @return the String with entries dlimited by the File.pathSeparator
*/
}
public static String aspectjrtClasspath() {
- return TestUtil.aspectjrtPath().getPath();
+ return TestUtil.aspectjrtPath().getPath();
}
-
+
/**
* @param input the String to parse for [on|off|true|false]
* @throws IllegalArgumentException if input is bad
}
/**
- *
+ *
* @param rpath the String relative path from the library directory to a resource that must exist (may be a directory), using
* forward slashes as a file separator
* @return the File path
/**
* Like libPath, only it returns a URL.
- *
+ *
* @return URL or null if it does not exist
* @throws IllegalArgumentException if no such directory or file
*/
// ---- unordered
- public static void assertSetEquals(Collection expected, Collection found) {
+ public static void assertSetEquals(Collection<?> expected, Collection<?> found) {
assertSetEquals(null, expected, found);
}
assertSetEquals(msg, Arrays.asList(expected), Arrays.asList(found));
}
- public static void assertSetEquals(String msg, Collection expected, Collection found) {
+ public static void assertSetEquals(String msg, Collection<?> expected, Collection<?> found) {
msg = (msg == null) ? "" : msg + ": ";
- Set results1 = new HashSet(found);
+ Set<Object> results1 = new HashSet<>(found);
results1.removeAll(expected);
- Set results2 = new HashSet(expected);
+ Set<Object> results2 = new HashSet<>(expected);
results2.removeAll(found);
if (results1.isEmpty()) {
BufferedReader r1 = new BufferedReader(new StringReader(s1));
BufferedReader r2 = new BufferedReader(new StringReader(s2));
- List lines = new ArrayList();
+ List<String> lines = new ArrayList<>();
String l1, l2;
int index = 1;
/**
* If there is an expected dir, expect each file in its subtree to match a corresponding actual file in the base directory. This
* does NOT check that all actual files have corresponding expected files. This ignores directory paths containing "CVS".
- *
+ *
* @param handler the IMessageHandler sink for error messages
* @param expectedBaseDir the File path to the directory containing expected files, all of which are compared with any
* corresponding actual files
/**
* Test interface to compare two files, line by line, and report differences as one FAIL message if a handler is supplied. This
* preprocesses .class files by disassembling.
- *
+ *
* @param handler the IMessageHandler for any FAIL messages (null to ignore)
* @param expectedFile the File path to the canonical file
* @param actualFile the File path to the actual file, if any
* Test interface to compare two files, line by line, and report differences as one FAIL message if a handler is supplied. This
* preprocesses .class files by disassembling. This method assumes that the files are at the same offset from two respective
* base directories.
- *
+ *
* @param handler the IMessageHandler for any FAIL messages (null to ignore)
* @param expectedBaseDir the File path to the canonical file base directory
* @param actualBaseDir the File path to the actual file base directory
/**
* Reduce file to CanonicalLine[].
- *
+ *
* @param handler the IMessageHandler for errors (may be null)
* @param file the File to render
* @param basedir the File for the base directory (may be null)
private abstract static class Lineator implements ILineator {
/**
* Reduce file to CanonicalLine[].
- *
+ *
* @param handler the IMessageHandler for errors (may be null)
* @param file the File to render
* @param basedir the File for the base directory (may be null)
}
}
}
-
+
public static File createEmptySandbox() {
File sandbox;
ByteArrayOutputStream missed;
- ArrayList sink;
+ ArrayList<String> sink;
public LineStream() {
super(new ByteArrayOutputStream());
- this.sink = new ArrayList();
+ this.sink = new ArrayList<>();
missed = (ByteArrayOutputStream) out;
}
/**
* Get String[] of lines printed, delimited by println(..) calls.
- *
+ *
* @return lines printed, exclusive of any not yet terminated by newline
*/
public String[] getLines() {
- return (String[]) sink.toArray(new String[0]);
+ return sink.toArray(new String[0]);
}
// ---------- PrintStream overrides
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.testingutil;
-import org.aspectj.util.LangUtil;
-
import java.lang.reflect.Array;
-import java.util.ArrayList;
import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedSet;
import java.util.StringTokenizer;
-import java.util.TreeSet;
+
+import org.aspectj.util.LangUtil;
/**
* This is source for a sample .class file.
}
protected static void protectedRunStatic() {
}
-
+
private long privateLong;
private final Object privateFinalObject;
-
+
private TestCompareClassFile() {
super();
privateLong = System.currentTimeMillis();
}
protected void protectedRun() {
}
-
+
// ------- misc stolen utility code
// Collections Util
- public static List getListInMap(Map map, Object key) {
- List list = (List)map.get(key);
+ /*
+ public static List getListInMap(Map<Object,List> map, Object key) {
+ List list = map.get(key);
if (list == null) {
list = new ArrayList();
map.put(key, list);
return list;
}
- public static SortedSet getSortedSetInMap(Map map, Object key) {
- SortedSet list = (SortedSet)map.get(key);
+ public static SortedSet getSortedSetInMap(Map<Object,SortedSet> map, Object key) {
+ SortedSet list = map.get(key);
if (list == null) {
list = new TreeSet();
map.put(key, list);
}
return list;
}
-
+ */
+
// LangUtil
/**
* Make a copy of the array.
lines.add(st.nextToken());
}
st = null;
-
+
String line;
int elided = 0;
- while (!lines.isEmpty()) {
+ while (!lines.isEmpty()) {
line = (String) lines.getLast();
if (null == line) {
break;
lines.removeLast();
}
}
- if ((elided > 0) || (maxLines < 1)) {
- final int EOL_LEN = LangUtil.EOL.length();
+ if ((elided > 0) || (maxLines < 1)) {
+ final int EOL_LEN = LangUtil.EOL.length();
int totalLength = 0;
- while (!lines.isEmpty()) {
+ while (!lines.isEmpty()) {
totalLength += EOL_LEN + ((String) lines.getFirst()).length();
lines.removeFirst();
}
}
}
}
-
+
}
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
</parent>
<artifactId>util</artifactId>
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.util;
import java.util.List;
import java.util.ListIterator;
-import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import junit.textui.TestRunner;
/**
- *
+ *
*/
+@SuppressWarnings("deprecation")
public class FileUtilTest extends TestCase {
public static final String[] NONE = new String[0];
public static boolean log = false;
/**
* Verify that dir contains files with names, and return the names of other files in dir.
- *
+ *
* @return the contents of dir after excluding files or NONE if none
* @throws AssertionFailedError if any names are not in dir
*/
/**
* Get a sorted String[] of all paths to all files/dirs under dir. Files with names starting with "." are ignored, as are
* directory paths containing "CVS". The directory prefix of the path is stripped. Thus, given directory:
- *
+ *
* <pre>
* path/to
* .cvsignore
* aspectj/
* Version.java
* </pre>
- *
+ *
* a call
- *
+ *
* <pre>
* dirPaths(new File("path/to"), new String[0]);
* </pre>
- *
+ *
* returns
- *
+ *
* <pre>
* { "Base.java", "com/parc/messages.properties", "org/aspectj/Version.java" }
* </pre>
- *
+ *
* while the call
- *
+ *
* <pre>
* dirPaths(new File("path/to"), new String[] { ".java" });
* </pre>
- *
+ *
* returns
- *
+ *
* <pre>
* { "Base.java", "org/aspectj/Version.java" }
* </pre>
- *
+ *
* @param dir the File path to the directory to inspect
* @param suffixes if not empty, require files returned to have this suffix
* @return sorted String[] of all paths to all files under dir ending with one of the listed suffixes but not starting with "."
// trim prefix
final String prefix = dir.getPath();
final int len = prefix.length() + 1; // plus directory separator
- String[] ra = (String[]) result.toArray(new String[0]);
+ String[] ra = result.toArray(new String[0]);
for (int i = 0; i < ra.length; i++) {
// assertTrue(ra[i].startsWith(prefix));
assertTrue(ra[i], ra[i].length() > len);
public void tearDown() {
for (ListIterator<File> iter = tempFiles.listIterator(); iter.hasNext();) {
- File dir = (File) iter.next();
+ File dir = iter.next();
log("removing " + dir);
FileUtil.deleteContents(dir);
dir.delete();
/**
* Method checkGetURL.
- *
+ *
* @param string
* @param uRL
*/
/* *******************************************************************
* Copyright (c) 2005-2008 Contributors
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
*
* ******************************************************************/
package org.aspectj.util;
-import junit.framework.TestCase;
-
import org.aspectj.util.GenericSignature.ClassSignature;
import org.aspectj.util.GenericSignature.ClassTypeSignature;
import org.aspectj.util.GenericSignature.FieldTypeSignature;
import org.aspectj.util.GenericSignature.SimpleClassTypeSignature;
+import junit.framework.TestCase;
+
/**
* @author Adrian Colyer
* @author Andy Clement
assertEquals("Ljava/lang/Exception;", mSig.throwsSignatures[0].toString());
assertEquals("Ljava/lang/RuntimeException;", mSig.throwsSignatures[1].toString());
}
-
+
public void testMethodSignaturePrimitiveParams() {
GenericSignature.MethodTypeSignature mSig = parser.parseAsMethodSignature("(ILjava/lang/Object;)V");
assertEquals("2 parameters", 2, mSig.parameters.length);
}
public void testPr107784() {
- parser
- .parseAsMethodSignature("(Lcom/cibc/responders/mapping/CommonDataBeanScenario;Ljava/lang/Object;)Lcom/cibc/responders/response/Formatter<[BLjava/lang/Object;>;");
+ parser.parseAsMethodSignature("(Lcom/cibc/responders/mapping/CommonDataBeanScenario;Ljava/lang/Object;)Lcom/cibc/responders/response/Formatter<[BLjava/lang/Object;>;");
parser.parseAsClassSignature("<Parent:Ljava/lang/Object;Child:Ljava/lang/Object;>Ljava/lang/Object;");
}
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>