Skip to content

Commit

Permalink
Polish generics
Browse files Browse the repository at this point in the history
  • Loading branch information
aclement committed Oct 7, 2014
1 parent 34cff60 commit 48eac47
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 53 deletions.
Expand Up @@ -52,7 +52,7 @@ public String getClasspath() {
return classpath.toString();
}

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

Expand Down
Expand Up @@ -33,7 +33,7 @@ public interface ICompilerConfiguration extends CompilerConfigurationChangeFlags
* @see org.aspectj.ajde.core.JavaOptions#getDefaultJavaOptions or
* 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
Expand All @@ -59,7 +59,7 @@ public interface ICompilerConfiguration extends CompilerConfigurationChangeFlags
*
* @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
Expand Down Expand Up @@ -95,7 +95,7 @@ public interface ICompilerConfiguration extends CompilerConfigurationChangeFlags
*
* @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
Expand All @@ -122,7 +122,7 @@ public interface ICompilerConfiguration extends CompilerConfigurationChangeFlags
* @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)
*/
public List getClasspathElementsWithModifiedContents();
public List<String> getClasspathElementsWithModifiedContents();

//
// /**
Expand Down
6 changes: 3 additions & 3 deletions ajde.core/src/org/aspectj/ajde/core/JavaOptions.java
Expand Up @@ -60,15 +60,15 @@ public final class JavaOptions {
public static final String GENERATE = CompilerOptions.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
*/
public static Map getDefaultJavaOptions() {
public static Map<String,String> getDefaultJavaOptions() {
if (defaultOptionsMap != null) return defaultOptionsMap;

defaultOptionsMap = new HashMap();
defaultOptionsMap = new HashMap<String,String>();
defaultOptionsMap.put(COMPLIANCE_LEVEL, VERSION_14);
defaultOptionsMap.put(SOURCE_COMPATIBILITY_LEVEL, VERSION_13);
defaultOptionsMap.put(PRESERVE_ALL_LOCALS, OPTIMIZE);
Expand Down
Expand Up @@ -187,7 +187,7 @@ private String formatCollection(Collection<?> options) {
return formattedOptions.toString();
}

private String formatMap(Map options) {
private String formatMap(Map<String,? extends Object> options) {
if (options == null) {
return "<default>";
}
Expand Down Expand Up @@ -309,7 +309,7 @@ public AjBuildConfig generateAjBuildConfig() {
mergeInto(config.getAspectpath(), compilerConfig.getAspectPath());

// Process the JAVA OPTIONS MAP
Map jom = compilerConfig.getJavaOptionsMap();
Map<String,String> jom = compilerConfig.getJavaOptionsMap();
if (jom != null) {
String version = (String) jom.get(CompilerOptions.OPTION_Compliance);
if (version != null && !version.equals(CompilerOptions.VERSION_1_4)) {
Expand Down
Expand Up @@ -42,7 +42,7 @@ public File getOutputLocationForResource(File resource) {
return this.locationManager.getOutputLocationForResource(resource);
}

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

Expand All @@ -67,7 +67,7 @@ public int discoverChangesSince(File dir, long buildtime) {
*
* @return a map from inpath entries (jars/dirs) to handle components.
*/
public Map getInpathMap() {
public Map<File,String> getInpathMap() {
return this.locationManager.getInpathMap();
}

Expand Down
12 changes: 5 additions & 7 deletions ajde.core/testsrc/org/aspectj/ajde/core/AjdeCoreTestCase.java
Expand Up @@ -13,12 +13,12 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

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

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

/**
Expand Down Expand Up @@ -124,19 +124,17 @@ public AjCompiler getCompiler() {
}

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)
return true;
}
return false;
}

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);
}
}
Expand Down
Expand Up @@ -11,7 +11,6 @@
package org.aspectj.ajde.core;

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

/**
Expand All @@ -29,7 +28,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor {

private String programmableString;
private int count;
private List messagesReceived = new ArrayList();
private List<String> messagesReceived = new ArrayList<String>();
private int currentVal;
private boolean isCancelRequested = false;

Expand Down Expand Up @@ -75,8 +74,7 @@ public void cancelOn(String string,int count) {
}

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) &&
element.indexOf(distinguishingMarks)!=-1) return true;
}
Expand All @@ -85,11 +83,9 @@ public boolean containsMessage(String prefix,String distinguishingMarks) {

public void dumpMessages() {
System.out.println("ProgressMonitorMessages");
for (Iterator iter = messagesReceived.iterator(); iter.hasNext();) {
String element = (String) iter.next();
for (String element: messagesReceived) {
System.out.println(element);
}
}


}
Expand Up @@ -94,7 +94,7 @@ public List<String> getProjectSourceFiles() {
return projectSourceFiles;
}

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

Expand Down Expand Up @@ -139,7 +139,7 @@ public void setOutjar(String outjar) {
this.outjar = outjar;
}

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

Expand All @@ -163,7 +163,7 @@ public int getConfigurationChanges() {
return ICompilerConfiguration.EVERYTHING;
}

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

Expand Down
12 changes: 6 additions & 6 deletions ajde.core/testsrc/org/aspectj/ajde/core/TestMessageHandler.java
Expand Up @@ -25,13 +25,13 @@
public class TestMessageHandler implements IBuildMessageHandler {

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

public TestMessageHandler() {
ignoring = new ArrayList<Kind>();
messages = new ArrayList();
errors = new ArrayList();
messages = new ArrayList<TestMessage>();
errors = new ArrayList<TestMessage>();
ignore(IMessage.INFO);
ignore(IMessage.WEAVEINFO);
}
Expand Down Expand Up @@ -70,11 +70,11 @@ public void ignore(Kind kind) {
}
}

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

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

Expand Down
Expand Up @@ -61,9 +61,9 @@ public void setOutputLocForResource(File f) {
resourceOutputLoc = f;
}

public List getAllOutputLocations() {
public List<File> getAllOutputLocations() {
if (allOutputLocations == null) {
allOutputLocations = new ArrayList();
allOutputLocations = new ArrayList<File>();
initLocations();
allOutputLocations.add(classOutputLoc);
if (!classOutputLoc.equals(resourceOutputLoc)) {
Expand Down
Expand Up @@ -49,7 +49,7 @@ protected void tearDown() throws Exception {
}

public void testJavaOptionsMap() {
Map options = JavaOptions.getDefaultJavaOptions();
Map<String,String> options = JavaOptions.getDefaultJavaOptions();
options.put(JavaOptions.WARN_DEPRECATION, JavaOptions.WARNING);
compilerConfig.setJavaOptions(options);
Map found = genAjBuildConfig().getOptions().getMap();
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.aspectj.ajde.core.AjdeCoreTestCase;
import org.aspectj.ajde.core.TestCompilerConfiguration;
import org.aspectj.ajde.core.TestMessageHandler;
import org.aspectj.ajde.core.TestMessageHandler.TestMessage;
import org.aspectj.bridge.IMessage;

public class CompilerMessagesTests extends AjdeCoreTestCase {
Expand Down Expand Up @@ -47,7 +48,7 @@ public void testMessages() {
// bug 33474
// The build has happened, what messages did the compiler give, and do they
// contain the information we expect?
List msgs = handler.getMessages();
List<TestMessage> msgs = handler.getMessages();
if (2 != msgs.size()) {
assertTrue("not two messages: " + msgs, false);
}
Expand All @@ -69,7 +70,7 @@ public void testMessages() {
}

public void testDeclareMessageContents() {
List msgs = handler.getMessages();
List<TestMessage> msgs = handler.getMessages();
IMessage msg = ((TestMessageHandler.TestMessage)msgs.get(1)).getContainedMessage();
assertEquals( "Please don't call setters" , msg.getMessage());
assertEquals("field-set(int apackage.SomeClass.x)", msg.getDetails());
Expand Down
Expand Up @@ -46,10 +46,10 @@ protected void tearDown() throws Exception {
}

public void testWeave() {
Set injars = new HashSet();
Set<File> injars = new HashSet<File>();
injars.add(openFile(injarName));
compilerConfig.setInpath(injars);
Set aspectpath = new HashSet();
Set<File> aspectpath = new HashSet<File>();
aspectpath.add(openFile(aspectjarName));
compilerConfig.setAspectPath(aspectpath);
File outjar = openFile(outjarName);
Expand Down
Expand Up @@ -97,7 +97,7 @@ public void testInpathToOutjar() {
*
*/
public void testInpathToBin() {
Set inpath = new HashSet();
Set<File> inpath = new HashSet<File>();
File indir1 = openFile(indir1Name);
inpath.add(indir1);
compilerConfig.setInpath(inpath);
Expand All @@ -106,7 +106,7 @@ public void testInpathToBin() {
doBuild(true);
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
// If we don't copy resources, these next three files won't make it
// expectedBindirContents.add("META-INF/MANIFEST.MF");
Expand Down Expand Up @@ -224,7 +224,7 @@ public void testInpathAndInjarToBin() {
/*
* 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 {
assertTrue(
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.aspectj.ajde.core.AjdeCoreTestCase;
import org.aspectj.ajde.core.TestCompilerConfiguration;
import org.aspectj.ajde.core.TestMessageHandler;
import org.aspectj.ajde.core.TestMessageHandler.TestMessage;
import org.aspectj.bridge.Constants;

public class OutxmlTests extends AjdeCoreTestCase {
Expand Down Expand Up @@ -111,7 +112,7 @@ public void testOutxmlToOutjar () {
*/
public void testOutxmlToOutjarWithAop_xml () {
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);
compilerConfig.setInpath(roots);

Expand All @@ -122,7 +123,7 @@ public void testOutxmlToOutjarWithAop_xml () {
assertFalse("Expected compiler errors or warnings but didn't find any "
+ handler.getMessages(), handler.getMessages().isEmpty());

List msgs = handler.getMessages();
List<TestMessage> msgs = handler.getMessages();
String msg = ((TestMessageHandler.TestMessage)msgs.get(0)).getContainedMessage().getMessage();
String exp = "-outxml/-outxmlfile option ignored because resource already exists:";
assertTrue("Expected message to start with : " + exp + " but found message " + msg,msg.startsWith(exp));
Expand Down
Expand Up @@ -108,7 +108,7 @@ public void testSrcToOutjar() {
}

public void testInjarsToBin() {
Set injars = new HashSet();
Set<File> injars = new HashSet<File>();
File injar1 = openFile(injar1Name);
injars.add(injar1);
compilerConfig.setInpath(injars);
Expand Down
9 changes: 5 additions & 4 deletions asm/src/org/aspectj/asm/AsmManager.java
Expand Up @@ -256,6 +256,7 @@ public void readStructureModel(String configFilePath) {
((AspectJElementHierarchy) hierarchy).setAsmManager(this);
hierarchyReadOK = true;
mapper = (RelationshipMap) s.readObject();
s.close();
}
} catch (FileNotFoundException fnfe) {
// That is OK
Expand Down Expand Up @@ -931,13 +932,13 @@ private void repairRelationships(Writer fw) {
Set<String> sourcesToRemove = new HashSet<String>();
Set<String> nonExistingHandles = new HashSet<String>(); // Cache of handles that we
// *know* are invalid
int srchandlecounter = 0;
int tgthandlecounter = 0;
// int srchandlecounter = 0;
// int tgthandlecounter = 0;

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

// Do we already know this handle points to nowhere?
if (nonExistingHandles.contains(hid)) {
Expand Down Expand Up @@ -967,7 +968,7 @@ private void repairRelationships(Writer fw) {
// Iterate through the targets for this relationship
for (Iterator<String> targetIter = targets.iterator(); targetIter.hasNext();) {
String targethid = targetIter.next();
tgthandlecounter++;
// tgthandlecounter++;
// Do we already know it doesn't exist?
if (nonExistingHandles.contains(targethid)) {
if (dumpDeltaProcessing) {
Expand Down

0 comments on commit 48eac47

Please sign in to comment.