Browse Source

Polish generics

tags/V1_8_3
Andy Clement 9 years ago
parent
commit
48eac479f6

+ 1
- 1
ajbrowser/src/org/aspectj/tools/ajbrowser/core/BrowserCompilerConfiguration.java View File

return classpath.toString(); return classpath.toString();
} }


public Map getJavaOptionsMap() {
public Map<String,String> getJavaOptionsMap() {
return BrowserManager.getDefault().getJavaBuildOptions().getJavaBuildOptionsMap(); return BrowserManager.getDefault().getJavaBuildOptions().getJavaBuildOptionsMap();
} }



+ 4
- 4
ajde.core/src/org/aspectj/ajde/core/ICompilerConfiguration.java View File

* @see org.aspectj.ajde.core.JavaOptions#getDefaultJavaOptions or * @see org.aspectj.ajde.core.JavaOptions#getDefaultJavaOptions or
* org.aspectj.org.eclipse.jdt.core.IJavaProject#getOptions(boolean) * org.aspectj.org.eclipse.jdt.core.IJavaProject#getOptions(boolean)
*/ */
public Map /* String --> String */getJavaOptionsMap();
public Map<String,String> getJavaOptionsMap();


/** /**
* The non-standard options, typically prefaced with -X when used with a command line compiler. The default is no non-standard * The non-standard options, typically prefaced with -X when used with a command line compiler. The default is no non-standard
* *
* @return a subset of those files that would be returned on getProjectSourceFiles() that have actually *changed* * @return a subset of those files that would be returned on getProjectSourceFiles() that have actually *changed*
*/ */
public List /* File */getProjectSourceFilesChanged();
public List<File> getProjectSourceFilesChanged();


/** /**
* @return the classpath to use * @return the classpath to use
* *
* @return map from unique resource name to absolute path to source resource (String to File) * @return map from unique resource name to absolute path to source resource (String to File)
*/ */
public Map /* String --> java.io.File */getSourcePathResources();
public Map<String,File> getSourcePathResources();


/** /**
* Returns a set of bit flags indicating what has changed in the configuration since it was previously read. This allows the * Returns a set of bit flags indicating what has changed in the configuration since it was previously read. This allows the
* @return a list of modified elements that should be checked (can be empty) or null if unknown (and in which case every * @return a list of modified elements that should be checked (can be empty) or null if unknown (and in which case every
* classpath element will be checked) * classpath element will be checked)
*/ */
public List getClasspathElementsWithModifiedContents();
public List<String> getClasspathElementsWithModifiedContents();


// //
// /** // /**

+ 3
- 3
ajde.core/src/org/aspectj/ajde/core/JavaOptions.java View File

public static final String GENERATE = CompilerOptions.GENERATE; public static final String GENERATE = CompilerOptions.GENERATE;
public static final String DO_NOT_GENERATE = CompilerOptions.DO_NOT_GENERATE; public static final String DO_NOT_GENERATE = CompilerOptions.DO_NOT_GENERATE;
private static Map defaultOptionsMap;
private static Map<String,String> defaultOptionsMap;
/** /**
* @return the java options map with the default settings * @return the java options map with the default settings
*/ */
public static Map getDefaultJavaOptions() {
public static Map<String,String> getDefaultJavaOptions() {
if (defaultOptionsMap != null) return defaultOptionsMap; if (defaultOptionsMap != null) return defaultOptionsMap;
defaultOptionsMap = new HashMap();
defaultOptionsMap = new HashMap<String,String>();
defaultOptionsMap.put(COMPLIANCE_LEVEL, VERSION_14); defaultOptionsMap.put(COMPLIANCE_LEVEL, VERSION_14);
defaultOptionsMap.put(SOURCE_COMPATIBILITY_LEVEL, VERSION_13); defaultOptionsMap.put(SOURCE_COMPATIBILITY_LEVEL, VERSION_13);
defaultOptionsMap.put(PRESERVE_ALL_LOCALS, OPTIMIZE); defaultOptionsMap.put(PRESERVE_ALL_LOCALS, OPTIMIZE);

+ 2
- 2
ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java View File

return formattedOptions.toString(); return formattedOptions.toString();
} }


private String formatMap(Map options) {
private String formatMap(Map<String,? extends Object> options) {
if (options == null) { if (options == null) {
return "<default>"; return "<default>";
} }
mergeInto(config.getAspectpath(), compilerConfig.getAspectPath()); mergeInto(config.getAspectpath(), compilerConfig.getAspectPath());


// Process the JAVA OPTIONS MAP // Process the JAVA OPTIONS MAP
Map jom = compilerConfig.getJavaOptionsMap();
Map<String,String> jom = compilerConfig.getJavaOptionsMap();
if (jom != null) { if (jom != null) {
String version = (String) jom.get(CompilerOptions.OPTION_Compliance); String version = (String) jom.get(CompilerOptions.OPTION_Compliance);
if (version != null && !version.equals(CompilerOptions.VERSION_1_4)) { if (version != null && !version.equals(CompilerOptions.VERSION_1_4)) {

+ 2
- 2
ajde.core/src/org/aspectj/ajde/core/internal/OutputLocationAdapter.java View File

return this.locationManager.getOutputLocationForResource(resource); return this.locationManager.getOutputLocationForResource(resource);
} }


public List getAllOutputLocations() {
public List<File> getAllOutputLocations() {
return this.locationManager.getAllOutputLocations(); return this.locationManager.getAllOutputLocations();
} }


* *
* @return a map from inpath entries (jars/dirs) to handle components. * @return a map from inpath entries (jars/dirs) to handle components.
*/ */
public Map getInpathMap() {
public Map<File,String> getInpathMap() {
return this.locationManager.getInpathMap(); return this.locationManager.getInpathMap();
} }



+ 5
- 7
ajde.core/testsrc/org/aspectj/ajde/core/AjdeCoreTestCase.java View File

import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;


import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;
import junit.framework.TestCase; import junit.framework.TestCase;


import org.aspectj.ajde.core.TestMessageHandler.TestMessage;
import org.aspectj.tools.ajc.Ajc; import org.aspectj.tools.ajc.Ajc;


/** /**
} }


public boolean checkFor(String what) { public boolean checkFor(String what) {
List ll = ((TestMessageHandler) compiler.getMessageHandler()).getMessages();
for (Iterator iter = ll.iterator(); iter.hasNext();) {
Object element = iter.next();
List<TestMessage> ll = ((TestMessageHandler) compiler.getMessageHandler()).getMessages();
for (TestMessage element: ll) {
if (element.toString().indexOf(what) != -1) if (element.toString().indexOf(what) != -1)
return true; return true;
} }
} }


public void dumpTaskData() { public void dumpTaskData() {
List ll = ((TestMessageHandler) compiler.getMessageHandler()).getMessages();
for (Iterator iter = ll.iterator(); iter.hasNext();) {
Object element = iter.next();
List<TestMessage> ll = ((TestMessageHandler) compiler.getMessageHandler()).getMessages();
for (TestMessage element: ll) {
System.out.println("RecordedMessage>" + element); System.out.println("RecordedMessage>" + element);
} }
} }

+ 3
- 7
ajde.core/testsrc/org/aspectj/ajde/core/TestBuildProgressMonitor.java View File

package org.aspectj.ajde.core; package org.aspectj.ajde.core;


import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;


/** /**
private String programmableString; private String programmableString;
private int count; private int count;
private List messagesReceived = new ArrayList();
private List<String> messagesReceived = new ArrayList<String>();
private int currentVal; private int currentVal;
private boolean isCancelRequested = false; private boolean isCancelRequested = false;
} }
public boolean containsMessage(String prefix,String distinguishingMarks) { public boolean containsMessage(String prefix,String distinguishingMarks) {
for (Iterator iter = messagesReceived.iterator(); iter.hasNext();) {
String element = (String) iter.next();
for (String element: messagesReceived) {
if (element.startsWith(prefix) && if (element.startsWith(prefix) &&
element.indexOf(distinguishingMarks)!=-1) return true; element.indexOf(distinguishingMarks)!=-1) return true;
} }
public void dumpMessages() { public void dumpMessages() {
System.out.println("ProgressMonitorMessages"); System.out.println("ProgressMonitorMessages");
for (Iterator iter = messagesReceived.iterator(); iter.hasNext();) {
String element = (String) iter.next();
for (String element: messagesReceived) {
System.out.println(element); System.out.println(element);
} }
} }

} }

+ 3
- 3
ajde.core/testsrc/org/aspectj/ajde/core/TestCompilerConfiguration.java View File

return projectSourceFiles; return projectSourceFiles;
} }


public List getProjectSourceFilesChanged() {
public List<File> getProjectSourceFilesChanged() {
return null; return null;
} }


this.outjar = outjar; this.outjar = outjar;
} }


public void setJavaOptions(Map javaOptions) {
public void setJavaOptions(Map<String,String> javaOptions) {
this.javaOptions = javaOptions; this.javaOptions = javaOptions;
} }


return ICompilerConfiguration.EVERYTHING; return ICompilerConfiguration.EVERYTHING;
} }


public List getClasspathElementsWithModifiedContents() {
public List<String> getClasspathElementsWithModifiedContents() {
return null; return null;
} }



+ 6
- 6
ajde.core/testsrc/org/aspectj/ajde/core/TestMessageHandler.java View File

public class TestMessageHandler implements IBuildMessageHandler { public class TestMessageHandler implements IBuildMessageHandler {


private List<Kind> ignoring; private List<Kind> ignoring;
private List messages;
private List errors;
private List<TestMessage> messages;
private List<TestMessage> errors;


public TestMessageHandler() { public TestMessageHandler() {
ignoring = new ArrayList<Kind>(); ignoring = new ArrayList<Kind>();
messages = new ArrayList();
errors = new ArrayList();
messages = new ArrayList<TestMessage>();
errors = new ArrayList<TestMessage>();
ignore(IMessage.INFO); ignore(IMessage.INFO);
ignore(IMessage.WEAVEINFO); ignore(IMessage.WEAVEINFO);
} }
} }
} }


public List getMessages() {
public List<TestMessage> getMessages() {
return messages; return messages;
} }


public List getErrors() {
public List<TestMessage> getErrors() {
return errors; return errors;
} }



+ 2
- 2
ajde.core/testsrc/org/aspectj/ajde/core/TestOutputLocationManager.java View File

resourceOutputLoc = f; resourceOutputLoc = f;
} }


public List getAllOutputLocations() {
public List<File> getAllOutputLocations() {
if (allOutputLocations == null) { if (allOutputLocations == null) {
allOutputLocations = new ArrayList();
allOutputLocations = new ArrayList<File>();
initLocations(); initLocations();
allOutputLocations.add(classOutputLoc); allOutputLocations.add(classOutputLoc);
if (!classOutputLoc.equals(resourceOutputLoc)) { if (!classOutputLoc.equals(resourceOutputLoc)) {

+ 1
- 1
ajde.core/testsrc/org/aspectj/ajde/core/tests/AjConfigTests.java View File

} }


public void testJavaOptionsMap() { public void testJavaOptionsMap() {
Map options = JavaOptions.getDefaultJavaOptions();
Map<String,String> options = JavaOptions.getDefaultJavaOptions();
options.put(JavaOptions.WARN_DEPRECATION, JavaOptions.WARNING); options.put(JavaOptions.WARN_DEPRECATION, JavaOptions.WARNING);
compilerConfig.setJavaOptions(options); compilerConfig.setJavaOptions(options);
Map found = genAjBuildConfig().getOptions().getMap(); Map found = genAjBuildConfig().getOptions().getMap();

+ 3
- 2
ajde.core/testsrc/org/aspectj/ajde/core/tests/CompilerMessagesTests.java View File

import org.aspectj.ajde.core.AjdeCoreTestCase; import org.aspectj.ajde.core.AjdeCoreTestCase;
import org.aspectj.ajde.core.TestCompilerConfiguration; import org.aspectj.ajde.core.TestCompilerConfiguration;
import org.aspectj.ajde.core.TestMessageHandler; import org.aspectj.ajde.core.TestMessageHandler;
import org.aspectj.ajde.core.TestMessageHandler.TestMessage;
import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessage;


public class CompilerMessagesTests extends AjdeCoreTestCase { public class CompilerMessagesTests extends AjdeCoreTestCase {
// bug 33474 // bug 33474
// The build has happened, what messages did the compiler give, and do they // The build has happened, what messages did the compiler give, and do they
// contain the information we expect? // contain the information we expect?
List msgs = handler.getMessages();
List<TestMessage> msgs = handler.getMessages();
if (2 != msgs.size()) { if (2 != msgs.size()) {
assertTrue("not two messages: " + msgs, false); assertTrue("not two messages: " + msgs, false);
} }
} }
public void testDeclareMessageContents() { public void testDeclareMessageContents() {
List msgs = handler.getMessages();
List<TestMessage> msgs = handler.getMessages();
IMessage msg = ((TestMessageHandler.TestMessage)msgs.get(1)).getContainedMessage(); IMessage msg = ((TestMessageHandler.TestMessage)msgs.get(1)).getContainedMessage();
assertEquals( "Please don't call setters" , msg.getMessage()); assertEquals( "Please don't call setters" , msg.getMessage());
assertEquals("field-set(int apackage.SomeClass.x)", msg.getDetails()); assertEquals("field-set(int apackage.SomeClass.x)", msg.getDetails());

+ 2
- 2
ajde.core/testsrc/org/aspectj/ajde/core/tests/DuplicateManifestTests.java View File

} }


public void testWeave() { public void testWeave() {
Set injars = new HashSet();
Set<File> injars = new HashSet<File>();
injars.add(openFile(injarName)); injars.add(openFile(injarName));
compilerConfig.setInpath(injars); compilerConfig.setInpath(injars);
Set aspectpath = new HashSet();
Set<File> aspectpath = new HashSet<File>();
aspectpath.add(openFile(aspectjarName)); aspectpath.add(openFile(aspectjarName));
compilerConfig.setAspectPath(aspectpath); compilerConfig.setAspectPath(aspectpath);
File outjar = openFile(outjarName); File outjar = openFile(outjarName);

+ 3
- 3
ajde.core/testsrc/org/aspectj/ajde/core/tests/InpathTests.java View File

* *
*/ */
public void testInpathToBin() { public void testInpathToBin() {
Set inpath = new HashSet();
Set<File> inpath = new HashSet<File>();
File indir1 = openFile(indir1Name); File indir1 = openFile(indir1Name);
inpath.add(indir1); inpath.add(indir1);
compilerConfig.setInpath(inpath); compilerConfig.setInpath(inpath);
doBuild(true); doBuild(true);
assertTrue("Expected no compiler errors or warnings but found " + handler.getMessages(), handler.getMessages().isEmpty()); assertTrue("Expected no compiler errors or warnings but found " + handler.getMessages(), handler.getMessages().isEmpty());


Set expectedBindirContents = new HashSet();
Set<String> expectedBindirContents = new HashSet<String>();
// From indir1 // From indir1
// If we don't copy resources, these next three files won't make it // If we don't copy resources, these next three files won't make it
// expectedBindirContents.add("META-INF/MANIFEST.MF"); // expectedBindirContents.add("META-INF/MANIFEST.MF");
/* /*
* Ensure -outjar contains all non-Java resouces from injars * Ensure -outjar contains all non-Java resouces from injars
*/ */
public void compareJars(File dirFile, String sourceDir, File outjarFile, Set expectedOutputJarContents) {
public void compareJars(File dirFile, String sourceDir, File outjarFile, Set<String> expectedOutputJarContents) {


try { try {
assertTrue( assertTrue(

+ 3
- 2
ajde.core/testsrc/org/aspectj/ajde/core/tests/OutxmlTests.java View File

import org.aspectj.ajde.core.AjdeCoreTestCase; import org.aspectj.ajde.core.AjdeCoreTestCase;
import org.aspectj.ajde.core.TestCompilerConfiguration; import org.aspectj.ajde.core.TestCompilerConfiguration;
import org.aspectj.ajde.core.TestMessageHandler; import org.aspectj.ajde.core.TestMessageHandler;
import org.aspectj.ajde.core.TestMessageHandler.TestMessage;
import org.aspectj.bridge.Constants; import org.aspectj.bridge.Constants;


public class OutxmlTests extends AjdeCoreTestCase { public class OutxmlTests extends AjdeCoreTestCase {
*/ */
public void testOutxmlToOutjarWithAop_xml () { public void testOutxmlToOutjarWithAop_xml () {
File f = new File( getAbsoluteProjectDir() + File.separator + "src-resources" + File.separator + "testjar.jar"); File f = new File( getAbsoluteProjectDir() + File.separator + "src-resources" + File.separator + "testjar.jar");
Set roots = new HashSet();
Set<File> roots = new HashSet<File>();
roots.add(f); roots.add(f);
compilerConfig.setInpath(roots); compilerConfig.setInpath(roots);
assertFalse("Expected compiler errors or warnings but didn't find any " assertFalse("Expected compiler errors or warnings but didn't find any "
+ handler.getMessages(), handler.getMessages().isEmpty()); + handler.getMessages(), handler.getMessages().isEmpty());
List msgs = handler.getMessages();
List<TestMessage> msgs = handler.getMessages();
String msg = ((TestMessageHandler.TestMessage)msgs.get(0)).getContainedMessage().getMessage(); String msg = ((TestMessageHandler.TestMessage)msgs.get(0)).getContainedMessage().getMessage();
String exp = "-outxml/-outxmlfile option ignored because resource already exists:"; String exp = "-outxml/-outxmlfile option ignored because resource already exists:";
assertTrue("Expected message to start with : " + exp + " but found message " + msg,msg.startsWith(exp)); assertTrue("Expected message to start with : " + exp + " but found message " + msg,msg.startsWith(exp));

+ 1
- 1
ajde.core/testsrc/org/aspectj/ajde/core/tests/ResourceCopyTests.java View File

} }


public void testInjarsToBin() { public void testInjarsToBin() {
Set injars = new HashSet();
Set<File> injars = new HashSet<File>();
File injar1 = openFile(injar1Name); File injar1 = openFile(injar1Name);
injars.add(injar1); injars.add(injar1);
compilerConfig.setInpath(injars); compilerConfig.setInpath(injars);

+ 5
- 4
asm/src/org/aspectj/asm/AsmManager.java View File

((AspectJElementHierarchy) hierarchy).setAsmManager(this); ((AspectJElementHierarchy) hierarchy).setAsmManager(this);
hierarchyReadOK = true; hierarchyReadOK = true;
mapper = (RelationshipMap) s.readObject(); mapper = (RelationshipMap) s.readObject();
s.close();
} }
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
// That is OK // That is OK
Set<String> sourcesToRemove = new HashSet<String>(); Set<String> sourcesToRemove = new HashSet<String>();
Set<String> nonExistingHandles = new HashSet<String>(); // Cache of handles that we Set<String> nonExistingHandles = new HashSet<String>(); // Cache of handles that we
// *know* are invalid // *know* are invalid
int srchandlecounter = 0;
int tgthandlecounter = 0;
// int srchandlecounter = 0;
// int tgthandlecounter = 0;


// Iterate over the source handles in the relationships map // Iterate over the source handles in the relationships map
Set<String> keyset = mapper.getEntries(); // These are source handles Set<String> keyset = mapper.getEntries(); // These are source handles
for (String hid : keyset) { for (String hid : keyset) {
srchandlecounter++;
// srchandlecounter++;


// Do we already know this handle points to nowhere? // Do we already know this handle points to nowhere?
if (nonExistingHandles.contains(hid)) { if (nonExistingHandles.contains(hid)) {
// Iterate through the targets for this relationship // Iterate through the targets for this relationship
for (Iterator<String> targetIter = targets.iterator(); targetIter.hasNext();) { for (Iterator<String> targetIter = targets.iterator(); targetIter.hasNext();) {
String targethid = targetIter.next(); String targethid = targetIter.next();
tgthandlecounter++;
// tgthandlecounter++;
// Do we already know it doesn't exist? // Do we already know it doesn't exist?
if (nonExistingHandles.contains(targethid)) { if (nonExistingHandles.contains(targethid)) {
if (dumpDeltaProcessing) { if (dumpDeltaProcessing) {

+ 1
- 0
asm/src/org/aspectj/asm/internal/ProgramElement.java View File

} }
} }


@SuppressWarnings("unchecked")
public Map<String, List<String>> getDeclareParentsMap() { public Map<String, List<String>> getDeclareParentsMap() {
Map<String, List<String>> s = (Map<String, List<String>>) kvpairs.get("declareparentsmap"); Map<String, List<String>> s = (Map<String, List<String>>) kvpairs.get("declareparentsmap");
return s; return s;

+ 1
- 1
runtime/testsrc/org/aspectj/runtime/reflect/RuntimePerformanceTest.java View File

private static final long TIMEOUT = 10000; private static final long TIMEOUT = 10000;
private static final long ITERATIONS = 1000000; private static final long ITERATIONS = 1000000;
private static final long WARMUP_ITERATIONS = 10000; private static final long WARMUP_ITERATIONS = 10000;
private static final long EXPECTED_RATIO = 10;
private static final long EXPECTED_RATIO = 8;
private static final Factory factory = new Factory("RutimePerformanceTest.java",RuntimePerformanceTest.class); private static final Factory factory = new Factory("RutimePerformanceTest.java",RuntimePerformanceTest.class);


private boolean savedUseCaches; private boolean savedUseCaches;

Loading…
Cancel
Save