issue_id
int64
2.04k
425k
title
stringlengths
9
251
body
stringlengths
4
32.8k
status
stringclasses
6 values
after_fix_sha
stringlengths
7
7
project_name
stringclasses
6 values
repo_url
stringclasses
6 values
repo_name
stringclasses
6 values
language
stringclasses
1 value
issue_url
null
before_fix_sha
null
pull_url
null
commit_datetime
unknown
report_datetime
unknown
updated_file
stringlengths
23
187
chunk_content
stringlengths
1
22k
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
*/ public static String[][] copyStrings(String[][] in) { String[][] out = new String[in.length][]; for (int i = 0; i < out.length; i++) { out[i] = new String[in[i].length]; System.arraycopy(in[i], 0, out[i], 0, out[i].length); } return out; } /** * Extract options and arguments to input option list, returning remainder. The input options will be nullified if not found. * e.g., * * <pre> * String[] options = new String[][] { new String[] { &quot;-verbose&quot; }, new String[] { &quot;-classpath&quot;, null } }; * String[] args = extractOptions(args, options); * boolean verbose = null != options[0][0]; * boolean classpath = options[1][1]; * </pre> * * @param args the String[] input options * @param options the String[][]options to find in the input args - not null for each String[] component the first subcomponent * is the option itself, and there is one String subcomponent for each additional argument. * @return String[] of args remaining after extracting options to extracted */ public static String[] extractOptions(String[] args, String[][] options) { if (LangUtil.isEmpty(args) || LangUtil.isEmpty(options)) { return args; } BitSet foundSet = new BitSet();
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
String[] result = new String[args.length]; int resultIndex = 0; for (int j = 0; j < args.length; j++) { boolean found = false; for (int i = 0; !found && (i < options.length); i++) { String[] option = options[i]; LangUtil.throwIaxIfFalse(!LangUtil.isEmpty(option), "options"); String sought = option[0]; found = sought.equals(args[j]); if (found) { foundSet.set(i); int doMore = option.length - 1; if (0 < doMore) { final int MAX = j + doMore; if (MAX >= args.length) { String s = "expecting " + doMore + " args after "; throw new IllegalArgumentException(s + args[j]); } for (int k = 1; k < option.length; k++) { option[k] = args[++j]; } } } } if (!found) { result[resultIndex++] = args[j]; } } for (int i = 0; i < options.length; i++) {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
if (!foundSet.get(i)) { options[i][0] = null; } } if (resultIndex < args.length) { String[] temp = new String[resultIndex]; System.arraycopy(result, 0, temp, 0, resultIndex); args = temp; } return args; } /** */
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
} } } } } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
} } } break; } } } } } } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
} break; } } } } } } break; } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
} } /** */ } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
} } } } } } } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
} /** */ } /** * Convert arrays safely. The number of elements in the result will be 1 smaller for each element that is null or not * assignable. This will use sink if it has exactly the right size. The result will always have the same component type as sink. * * @return an array with the same component type as sink containing any assignable elements in source (in the same order). * @throws IllegalArgumentException if either is null */ public static Object[] safeCopy(Object[] source, Object[] sink) { final Class<?> sinkType = (null == sink ? Object.class : sink.getClass().getComponentType()); final int sourceLength = (null == source ? 0 : source.length); final int sinkLength = (null == sink ? 0 : sink.length); final int resultSize; ArrayList<Object> result = null; if (0 == sourceLength) { resultSize = 0; } else {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
result = new ArrayList<Object>(sourceLength); for (int i = 0; i < sourceLength; i++) { if ((null != source[i]) && (sinkType.isAssignableFrom(source[i].getClass()))) { result.add(source[i]); } } resultSize = result.size(); } if (resultSize != sinkLength) { sink = (Object[]) Array.newInstance(sinkType, result.size()); } if (0 < resultSize) { sink = result.toArray(sink); } return sink; } /** * @return a String with the unqualified class name of the class (or "null") */ public static String unqualifiedClassName(Class<?> c) { if (null == c) { return "null"; } String name = c.getName(); int loc = name.lastIndexOf("."); if (-1 != loc) { name = name.substring(1 + loc); } return name; }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
/** * @return a String with the unqualified class name of the object (or "null") */ public static String unqualifiedClassName(Object o) { return LangUtil.unqualifiedClassName(null == o ? null : o.getClass()); } public static String replace(String in, String sought, String replace) { if (LangUtil.isEmpty(in) || LangUtil.isEmpty(sought)) { return in; } StringBuffer result = new StringBuffer(); final int len = sought.length(); int start = 0; int loc; while (-1 != (loc = in.indexOf(sought, start))) { result.append(in.substring(start, loc)); if (!LangUtil.isEmpty(replace)) { result.append(replace); } start = loc + len; } result.append(in.substring(start)); return result.toString(); } public static String toSizedString(long i, int width) { String result = "" + i; int size = result.length(); if (width > size) {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
final String pad = " "; final int padLength = pad.length(); if (width > padLength) { width = padLength; } int topad = width - size; result = pad.substring(0, topad) + result; } return result; } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
i++; j++; break; } } } } /** * @return "({UnqualifiedExceptionClass}) {message}" */ public static String renderExceptionShort(Throwable e) { if (null == e) { return "(Throwable) null"; } return "(" + LangUtil.unqualifiedClassName(e) + ") " + e.getMessage(); } /** * Renders exception <code>t</code> after unwrapping and eliding any test packages. * * @param t <code>Throwable</code> to print. * @see #maxStackTrace */ public static String renderException(Throwable t) { return renderException(t, true); } /** * Renders exception <code>t</code>, unwrapping, optionally eliding and limiting total number of lines.
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
* * @param t <code>Throwable</code> to print. * @param elide true to limit to 100 lines and elide test packages * @see StringChecker#TEST_PACKAGES */ public static String renderException(Throwable t, boolean elide) { if (null == t) { return "null throwable"; } t = unwrapException(t); StringBuffer stack = stackToString(t, false); if (elide) { elideEndingLines(StringChecker.TEST_PACKAGES, stack, 100); } return stack.toString(); } /** * Trim ending lines from a StringBuffer, clipping to maxLines and further removing any number of trailing lines accepted by * checker. * * @param checker returns true if trailing line should be elided. * @param stack StringBuffer with lines to elide * @param maxLines int for maximum number of resulting lines */ static void elideEndingLines(StringChecker checker, StringBuffer stack, int maxLines) { if (null == checker || (null == stack) || (0 == stack.length())) { return; } final LinkedList<String> lines = new LinkedList<String>(); StringTokenizer st = new StringTokenizer(stack.toString(), "\n\r");
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
while (st.hasMoreTokens() && (0 < --maxLines)) { lines.add(st.nextToken()); } st = null; String line; int elided = 0; while (!lines.isEmpty()) { line = (String) lines.getLast(); if (!checker.acceptString(line)) { break; } else { elided++; lines.removeLast(); } } if ((elided > 0) || (maxLines < 1)) { final int EOL_LEN = EOL.length(); int totalLength = 0; while (!lines.isEmpty()) { totalLength += EOL_LEN + ((String) lines.getFirst()).length(); lines.removeFirst(); } if (stack.length() > totalLength) { stack.setLength(totalLength); if (elided > 0) { stack.append(" (... " + elided + " lines...)"); } } } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
public static StringBuffer stackToString(Throwable throwable, boolean skipMessage) { if (null == throwable) { return new StringBuffer(); } StringWriter buf = new StringWriter(); PrintWriter writer = new PrintWriter(buf); if (!skipMessage) { writer.println(throwable.getMessage()); } throwable.printStackTrace(writer); try { buf.close(); } catch (IOException ioe) { } ignored return buf.getBuffer(); } public static Throwable unwrapException(Throwable t) { Throwable current = t; Throwable next = null; while (current != null) { if (current instanceof InvocationTargetException) { next = ((InvocationTargetException) current).getTargetException(); } else if (current instanceof ClassNotFoundException) { next = ((ClassNotFoundException) current).getException(); } else if (current instanceof ExceptionInInitializerError) { next = ((ExceptionInInitializerError) current).getException(); } else if (current instanceof PrivilegedActionException) {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
next = ((PrivilegedActionException) current).getException(); } else if (current instanceof SQLException) { next = ((SQLException) current).getNextException(); } if (null == next) { break; } else { current = next; next = null; } } return current; } /** * Replacement for Arrays.asList(..) which gacks on null and returns a List in which remove is an unsupported operation. * * @param array the Object[] to convert (may be null) * @return the List corresponding to array (never null) */ public static List<Object> arrayAsList(Object[] array) { if ((null == array) || (1 > array.length)) {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
return Collections.emptyList(); } ArrayList<Object> list = new ArrayList<Object>(); list.addAll(Arrays.asList(array)); return list; } public static class StringChecker { static StringChecker TEST_PACKAGES = new StringChecker(new String[] { "org.aspectj.testing", "org.eclipse.jdt.internal.junit", "junit.framework.", "org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" }); String[] infixes; StringChecker(String[] infixes) { this.infixes = infixes; } public boolean acceptString(String input) { boolean result = false; if (!LangUtil.isEmpty(input)) { for (int i = 0; !result && (i < infixes.length); i++) { result = (-1 != input.indexOf(infixes[i])); } } return result; } } /** * Gen classpath. *
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
* @param bootclasspath * @param classpath * @param classesDir * @param outputJar * @return String combining classpath elements */ public static String makeClasspath( String bootclasspath, String classpath, String classesDir, String outputJar) { StringBuffer sb = new StringBuffer(); addIfNotEmpty(bootclasspath, sb, File.pathSeparator); addIfNotEmpty(classpath, sb, File.pathSeparator); if (!addIfNotEmpty(classesDir, sb, File.pathSeparator)) { addIfNotEmpty(outputJar, sb, File.pathSeparator); } return sb.toString(); } /** * @param input ignored if null * @param sink the StringBuffer to add input to - return false if null * @param delimiter the String to append to input when added - ignored if empty * @return true if input + delimiter added to sink */ private static boolean addIfNotEmpty(String input, StringBuffer sink, String delimiter) { if (LangUtil.isEmpty(input) || (null == sink)) { return false; } sink.append(input); if (!LangUtil.isEmpty(delimiter)) { sink.append(delimiter); }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
return true; } /** * Create or initialize a process controller to run a process in another VM asynchronously. * * @param controller the ProcessController to initialize, if not null * @param classpath * @param mainClass * @param args * @return initialized ProcessController */ public static ProcessController makeProcess(ProcessController controller, String classpath, String mainClass, String[] args) { File java = LangUtil.getJavaExecutable(); ArrayList<String> cmd = new ArrayList<String>(); cmd.add(java.getAbsolutePath()); cmd.add("-classpath"); cmd.add(classpath); cmd.add(mainClass); if (!LangUtil.isEmpty(args)) { cmd.addAll(Arrays.asList(args)); } String[] command = (String[]) cmd.toArray(new String[0]); if (null == controller) { controller = new ProcessController(); } controller.init(command, mainClass); return controller; } /**
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
*/ } } /** * Find java executable File path from java.home system property. * * @return File associated with the java command, or null if not found. */ public static File getJavaExecutable() { String javaHome = null; File result = null; try { javaHome = System.getProperty("java.home"); } catch (Throwable t) { ignore }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
if (null != javaHome) { File binDir = new File(javaHome, "bin"); if (binDir.isDirectory() && binDir.canRead()) { String[] execs = new String[] { "java", "java.exe" }; for (int i = 0; i < execs.length; i++) { result = new File(binDir, execs[i]); if (result.canRead()) { break; } } } } return result; } /** * */ } } /** * Sleep until a particular time.
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
* * @param time the long time in milliseconds to sleep until * @return true if delay succeeded, false if interrupted 100 times */ public static boolean sleepUntil(long time) { if (time == 0) { return true; } else if (time < 0) { throw new IllegalArgumentException("negative: " + time); } long curTime = System.currentTimeMillis(); for (int i = 0; (i < 100) && (curTime < time); i++) { try { Thread.sleep(time - curTime); } catch (InterruptedException e) { ignore } curTime = System.currentTimeMillis(); } return (curTime >= time); } /** * Handle an external process asynchrously. <code>start()</code> launches a main thread to wait for the process and pipes * streams (in child threads) through to the corresponding streams (e.g., the process System.err to this System.err). This can * complete normally, by exception, or on demand by a client. Clients can implement <code>doCompleting(..)</code> to get notice * when the process completes. * <p> * The following sample code creates a process with a completion callback starts it, and some time later retries the process. *
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
* <pre> * LangUtil.ProcessController controller = new LangUtil.ProcessController() { * protected void doCompleting(LangUtil.ProcessController.Thrown thrown, int result) { * signal result * } * }; * controller.init(new String[] { &quot;java&quot;, &quot;-version&quot; }, &quot;java version&quot;); * controller.start(); * some time later... * retry... * if (!controller.completed()) { * controller.stop(); * controller.reinit(); * controller.start(); * } * </pre> * * <u>warning</u>: Currently this does not close the input or output streams, since doing so prevents their use later. */ public static class ProcessController { /* * XXX not verified thread-safe, but should be. Known problems: - user stops (completed = true) then exception thrown from * destroying process (stop() expects !completed) ... */ private String[] command; private String[] envp; private String label; private boolean init; private boolean started; private boolean completed;
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
private boolean userStopped; private Process process; private FileUtil.Pipe errStream; private FileUtil.Pipe outStream; private FileUtil.Pipe inStream; private ByteArrayOutputStream errSnoop; private ByteArrayOutputStream outSnoop; private int result; private Thrown thrown; public ProcessController() { } /** * Permit re-running using the same command if this is not started or if completed. Can also call this when done with * results to release references associated with results (e.g., stack traces). */ public final void reinit() { if (!init) { throw new IllegalStateException("must init(..) before reinit()"); } if (started && !completed) { throw new IllegalStateException("not completed - do stop()"); } started = false; completed = false; result = Integer.MIN_VALUE; thrown = null; process = null; errStream = null;
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
outStream = null; inStream = null; } public final void init(String classpath, String mainClass, String[] args) { init(LangUtil.getJavaExecutable(), classpath, mainClass, args); } public final void init(File java, String classpath, String mainClass, String[] args) { LangUtil.throwIaxIfNull(java, "java"); LangUtil.throwIaxIfNull(mainClass, "mainClass"); LangUtil.throwIaxIfNull(args, "args"); ArrayList<String> cmd = new ArrayList<String>(); cmd.add(java.getAbsolutePath()); cmd.add("-classpath"); cmd.add(classpath); cmd.add(mainClass); if (!LangUtil.isEmpty(args)) { cmd.addAll(Arrays.asList(args)); } init((String[]) cmd.toArray(new String[0]), mainClass); } public final void init(String[] command, String label) { this.command = (String[]) LangUtil.safeCopy(command, new String[0]); if (1 > this.command.length) { throw new IllegalArgumentException("empty command"); } this.label = LangUtil.isEmpty(label) ? command[0] : label; init = true; reinit(); } public final void setEnvp(String[] envp) {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
this.envp = (String[]) LangUtil.safeCopy(envp, new String[0]); if (1 > this.envp.length) { throw new IllegalArgumentException("empty envp"); } } public final void setErrSnoop(ByteArrayOutputStream snoop) { errSnoop = snoop; if (null != errStream) { errStream.setSnoop(errSnoop); } } public final void setOutSnoop(ByteArrayOutputStream snoop) { outSnoop = snoop; if (null != outStream) { outStream.setSnoop(outSnoop); } } /** * Start running the process and pipes asynchronously. * * @return Thread started or null if unable to start thread (results available via <code>getThrown()</code>, etc.) */ public final Thread start() { if (!init) { throw new IllegalStateException("not initialized"); } synchronized (this) { if (started) { throw new IllegalStateException("already started"); }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
started = true; } try { process = Runtime.getRuntime().exec(command); } catch (IOException e) { stop(e, Integer.MIN_VALUE); return null; } errStream = new FileUtil.Pipe(process.getErrorStream(), System.err); if (null != errSnoop) { errStream.setSnoop(errSnoop); } outStream = new FileUtil.Pipe(process.getInputStream(), System.out); if (null != outSnoop) { outStream.setSnoop(outSnoop); } inStream = new FileUtil.Pipe(System.in, process.getOutputStream()); Runnable processRunner = new Runnable() { public void run() { Throwable thrown = null; int result = Integer.MIN_VALUE; try { new Thread(errStream).start(); new Thread(outStream).start(); new Thread(inStream).start(); process.waitFor(); result = process.exitValue(); } catch (Throwable e) {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
thrown = e; } finally { stop(thrown, result); } } }; Thread result = new Thread(processRunner, label); result.start(); return result; } /** * Destroy any process, stop any pipes. This waits for the pipes to clear (reading until no more input is available), but * does not wait for the input stream for the pipe to close (i.e., not waiting for end-of-file on input stream). */ public final synchronized void stop() { if (completed) { return; } userStopped = true; stop(null, Integer.MIN_VALUE); } public final String[] getCommand() { String[] toCopy = command; if (LangUtil.isEmpty(toCopy)) { return new String[0]; } String[] result = new String[toCopy.length]; System.arraycopy(toCopy, 0, result, 0, result.length); return result; }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
public final boolean completed() { return completed; } public final boolean started() { return started; } public final boolean userStopped() { return userStopped; } /** * Get any Throwable thrown. Note that the process can complete normally (with a valid return value), at the same time the * pipes throw exceptions, and that this may return some exceptions even if the process is not complete. * * @return null if not complete or Thrown containing exceptions thrown by the process and streams. */ public final Thrown getThrown() { return makeThrown(null); } public final int getResult() { return result; } /** * Subclasses implement this to get synchronous notice of completion. All pipes and processes should be complete at this * time. To get the exceptions thrown for the pipes, use <code>getThrown()</code>. If there is an exception, the process * completed abruptly (including side-effects of the user halting the process). If <code>userStopped()</code> is true, then * some client asked that the process be destroyed using <code>stop()</code>. Otherwise, the result code should be the * result value returned by the process. * * @param thrown same as <code>getThrown().fromProcess</code>. * @param result same as <code>getResult()</code>
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
* @see getThrown() * @see getResult() * @see stop() */ protected void doCompleting(Thrown thrown, int result) { } /** * Handle termination (on-demand, abrupt, or normal) by destroying and/or halting process and pipes. * * @param thrown ignored if null * @param result ignored if Integer.MIN_VALUE */ private final synchronized void stop(Throwable thrown, int result) { if (completed) { throw new IllegalStateException("already completed"); } else if (null != this.thrown) { throw new IllegalStateException("already set thrown: " + thrown); } this.thrown = makeThrown(thrown); if (null != process) { process.destroy(); } if (null != inStream) { inStream.halt(false, true); inStream = null; } if (null != outStream) { outStream.halt(true, true); outStream = null;
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
} if (null != errStream) { errStream.halt(true, true); errStream = null; } if (Integer.MIN_VALUE != result) { this.result = result; } completed = true; doCompleting(this.thrown, result); } /** * Create snapshot of Throwable's thrown. * * @param thrown ignored if null or if this.thrown is not null */ private final synchronized Thrown makeThrown(Throwable processThrown) { if (null != thrown) { return thrown; } return new Thrown(processThrown, (null == outStream ? null : outStream.getThrown()), (null == errStream ? null : errStream.getThrown()), (null == inStream ? null : inStream.getThrown())); } public static class Thrown { public final Throwable fromProcess; public final Throwable fromErrPipe; public final Throwable fromOutPipe; public final Throwable fromInPipe; public final boolean thrown;
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
util/src/org/aspectj/util/LangUtil.java
private Thrown(Throwable fromProcess, Throwable fromOutPipe, Throwable fromErrPipe, Throwable fromInPipe) { this.fromProcess = fromProcess; this.fromErrPipe = fromErrPipe; this.fromOutPipe = fromOutPipe; this.fromInPipe = fromInPipe; thrown = ((null != fromProcess) || (null != fromInPipe) || (null != fromOutPipe) || (null != fromErrPipe)); } public String toString() { StringBuffer sb = new StringBuffer(); append(sb, fromProcess, "process"); append(sb, fromOutPipe, " stdout"); append(sb, fromErrPipe, " stderr"); append(sb, fromInPipe, " stdin"); if (0 == sb.length()) { return "Thrown (none)"; } else { return sb.toString(); } } private void append(StringBuffer sb, Throwable thrown, String label) { if (null != thrown) { sb.append("from " + label + ": "); sb.append(LangUtil.renderExceptionShort(thrown)); sb.append(LangUtil.EOL); } } } } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java
/******************************************************************************* * Copyright (c) 2012 Contributors. * All rights reserved.
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java
* 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: * John Kew (vmware) initial implementation * Lyor Goldstein (vmware) add support for weaved class being re-defined *******************************************************************************/ package org.aspectj.weaver.tools.cache; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.io.StreamCorruptedException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.Map; import java.util.TreeMap; import org.aspectj.util.LangUtil; /** * Uses an <code>index</code> file to keep track of the cached entries */ public abstract class AbstractIndexedFileCacheBacking extends AbstractFileCacheBacking {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java
/** * Default name of cache index file - assumed to contain {@link IndexEntry}-s */ public static final String INDEX_FILE = "cache.idx"; protected static final IndexEntry[] EMPTY_INDEX=new IndexEntry[0]; protected static final String[] EMPTY_KEYS=new String[0]; private final File indexFile; protected AbstractIndexedFileCacheBacking(File cacheDir) { super(cacheDir); indexFile = new File(cacheDir, INDEX_FILE); } public File getIndexFile () { return indexFile; } public String[] getKeys(String regex) { Map<String, IndexEntry> index=getIndex(); if ((index == null) || index.isEmpty()) { return EMPTY_KEYS; } Collection<String> matches=new LinkedList<String>(); synchronized(index) { for (String key : index.keySet()) { if (key.matches(regex)) { matches.add(key); } } } if (matches.isEmpty()) {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java
return EMPTY_KEYS; } else { return matches.toArray(new String[matches.size()]); } } protected Map<String, IndexEntry> readIndex () { return readIndex(getCacheDirectory(), getIndexFile()); } protected void writeIndex () { writeIndex(getIndexFile()); } protected void writeIndex (File file) { try { writeIndex(file, getIndex()); } catch(Exception e) { if ((logger != null) && logger.isTraceEnabled()) { logger.warn("writeIndex(" + file + ") " + e.getClass().getSimpleName() + ": " + e.getMessage(), e); } } } protected abstract Map<String, IndexEntry> getIndex (); protected Map<String, IndexEntry> readIndex (File cacheDir, File cacheFile) { Map<String, IndexEntry> indexMap=new TreeMap<String, IndexEntry>(); IndexEntry[] idxValues=readIndex(cacheFile); if (LangUtil.isEmpty(idxValues)) { if ((logger != null) && logger.isTraceEnabled()) { logger.debug("readIndex(" + cacheFile + ") no index entries"); } return indexMap; }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java
for (IndexEntry ie : idxValues) { IndexEntry resEntry=resolveIndexMapEntry(cacheDir, ie); if (resEntry != null) { indexMap.put(resEntry.key, resEntry); } else if ((logger != null) && logger.isTraceEnabled()) { logger.debug("readIndex(" + cacheFile + ") skip " + ie.key); } } return indexMap; } protected IndexEntry resolveIndexMapEntry (File cacheDir, IndexEntry ie) { return ie; } public IndexEntry[] readIndex(File indexFile) { if (!indexFile.canRead()) { return EMPTY_INDEX; } ObjectInputStream ois = null; try { ois = new ObjectInputStream(new FileInputStream(indexFile)); return (IndexEntry[]) ois.readObject(); } catch (Exception e) { if ((logger != null) && logger.isTraceEnabled()) { logger.error("Failed (" + e.getClass().getSimpleName() + ")" + " to read index from " + indexFile.getAbsolutePath() + " : " + e.getMessage(), e); } delete(indexFile); } finally { close(ois, indexFile);
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java
} return EMPTY_INDEX; } protected void writeIndex (File indexFile, Map<String,? extends IndexEntry> index) throws IOException { writeIndex(indexFile, LangUtil.isEmpty(index) ? Collections.<IndexEntry>emptyList() : index.values()); } protected void writeIndex (File indexFile, IndexEntry ... entries) throws IOException { writeIndex(indexFile, LangUtil.isEmpty(entries) ? Collections.<IndexEntry>emptyList() : Arrays.asList(entries)); } protected void writeIndex (File indexFile, Collection<? extends IndexEntry> entries) throws IOException { File indexDir=indexFile.getParentFile(); if ((!indexDir.exists()) && (!indexDir.mkdirs())) { throw new IOException("Failed to create path to " + indexFile.getAbsolutePath()); } int numEntries=LangUtil.isEmpty(entries) ? 0 : entries.size(); IndexEntry[] entryValues=(numEntries <= 0) ? null : entries.toArray(new IndexEntry[numEntries]); if (LangUtil.isEmpty(entryValues)) { if (indexFile.exists() && (!indexFile.delete())) { throw new StreamCorruptedException("Failed to clean up index file at " + indexFile.getAbsolutePath()); } return; } ObjectOutputStream oos=new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(indexFile), 4096)); try { oos.writeObject(entryValues); } finally { close(oos, indexFile); } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java
/** * The default index entry in the index file */ public static class IndexEntry implements Serializable, Cloneable { private static final long serialVersionUID = 756391290557029363L; public String key; public boolean generated; public boolean ignored; public long crcClass; public long crcWeaved; public IndexEntry () { super(); } @Override public IndexEntry clone () { try { return getClass().cast(super.clone()); } catch(CloneNotSupportedException e) { throw new RuntimeException("Failed to clone: " + toString() + ": " + e.getMessage(), e); } } @Override public int hashCode() { return (int) (key.hashCode() + (generated ? 1 : 0) + (ignored ? 1 : 0) + crcClass + crcWeaved); }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java
@Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; if (getClass() != obj.getClass()) return false; IndexEntry other=(IndexEntry) obj; if (this.key.equals(other.key) && (this.ignored == other.ignored) && (this.generated == other.generated) && (this.crcClass == other.crcClass) && (this.crcWeaved == other.crcWeaved)) { return true; } else { return false; } } @Override public String toString() { return key + "[" + (generated ? "generated" : "ignored") + "]" + ";crcClass=0x" + Long.toHexString(crcClass) + ";crcWeaved=0x" + Long.toHexString(crcWeaved) ; } } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java
/******************************************************************************* * Copyright (c) 2012 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: * John Kew (vmware) initial implementation * Lyor Goldstein (vmware) add support for weaved class being re-defined *******************************************************************************/ package org.aspectj.weaver.tools.cache; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.OutputStream; import java.util.Map; import org.aspectj.bridge.MessageUtil;
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java
import org.aspectj.util.FileUtil; import org.aspectj.util.LangUtil; /** * Naive File-Backed Class Cache with no expiry or application * centric invalidation. * <p/> * Enabled with the system property, "aj.weaving.cache.dir" * If this system property is not set, no caching will be * performed. * <p/> * A CRC checksum is stored alongside the class file to verify * the bytes on read. If for some reason there is an error * reading either the class or crc file, or if the crc does not * match the class data the cache entry is deleted. * <p/> * An alternate implementation of this could store the class file * as a jar/zip directly, which would have the required crc; as * a first pass however it is somewhat useful to view these files * in expanded form for debugging. */ public class DefaultFileCacheBacking extends AbstractIndexedFileCacheBacking { private final Map<String, IndexEntry> index; private static final Object LOCK = new Object(); protected DefaultFileCacheBacking(File cacheDir) { super(cacheDir); index = readIndex(); } public static final DefaultFileCacheBacking createBacking(File cacheDir) { if (!cacheDir.exists()) { if (!cacheDir.mkdirs()) {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java
MessageUtil.error("Unable to create cache directory at " + cacheDir.getName()); return null; } } else if (!cacheDir.isDirectory()) { MessageUtil.error("Not a cache directory at " + cacheDir.getName()); return null; } if (!cacheDir.canWrite()) { MessageUtil.error("Cache directory is not writable at " + cacheDir.getName()); return null; } return new DefaultFileCacheBacking(cacheDir); } @Override protected Map<String, IndexEntry> getIndex() { return index; } @Override protected IndexEntry resolveIndexMapEntry (File cacheDir, IndexEntry ie) { File cacheEntry = new File(cacheDir, ie.key); if (ie.ignored || cacheEntry.canRead()) { return ie; } else { return null; } } private void removeIndexEntry(String key) { synchronized (LOCK) { index.remove(key); writeIndex();
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java
} } private void addIndexEntry(IndexEntry ie) { synchronized (LOCK) { index.put(ie.key, ie); writeIndex(); } } @Override protected Map<String, IndexEntry> readIndex() { synchronized (LOCK) { return super.readIndex(); } } @Override protected void writeIndex() { synchronized (LOCK) { super.writeIndex(); } } public void clear() { File cacheDir=getCacheDirectory(); int numDeleted=0; synchronized (LOCK) { numDeleted = FileUtil.deleteContents(cacheDir); } if ((numDeleted > 0) && (logger != null) && logger.isTraceEnabled()) { logger.info("clear(" + cacheDir + ") deleted"); } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java
public static CacheBacking createBacking(String scope) { String cache = System.getProperty(WEAVED_CLASS_CACHE_DIR); if (cache == null) { return null; } File cacheDir = new File(cache, scope); return createBacking(cacheDir); } @Override public String[] getKeys(final String regex) { File cacheDirectory = getCacheDirectory(); File[] files = cacheDirectory.listFiles(new FilenameFilter() { public boolean accept(File file, String s) { if (s.matches(regex)) { return true; } return false; } }); if (LangUtil.isEmpty(files)) { return EMPTY_KEYS; } String[] keys = new String[files.length]; for (int i = 0; i < files.length; i++) { keys[i] = files[i].getName(); } return keys; } public CachedClassEntry get(CachedClassReference ref, byte[] originalBytes) { File cacheDirectory = getCacheDirectory();
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java
String refKey=ref.getKey(); File cacheFile = new File(cacheDirectory, refKey); IndexEntry ie = index.get(refKey); if (ie == null) { delete(cacheFile); return null; } if (crc(originalBytes) != ie.crcClass) { delete(cacheFile); return null; } if (ie.ignored) { return new CachedClassEntry(ref, WeavedClassCache.ZERO_BYTES, CachedClassEntry.EntryType.IGNORED); } if (cacheFile.canRead()) { byte[] bytes = read(cacheFile, ie.crcWeaved); if (bytes != null) { if (!ie.generated) { return new CachedClassEntry(ref, bytes, CachedClassEntry.EntryType.WEAVED); } else { return new CachedClassEntry(ref, bytes, CachedClassEntry.EntryType.GENERATED); } } } return null; } public void put(CachedClassEntry entry, byte[] originalBytes) {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java
File cacheDirectory = getCacheDirectory(); String refKey = entry.getKey(); IndexEntry ie = index.get(refKey); File cacheFile = new File(cacheDirectory, refKey); final boolean writeEntryBytes; if ((ie != null) && ((ie.ignored != entry.isIgnored()) || (ie.generated != entry.isGenerated()) || (crc(originalBytes) != ie.crcClass))) { delete(cacheFile); writeEntryBytes = true; } else { writeEntryBytes = !cacheFile.exists(); } if (writeEntryBytes) { ie = new IndexEntry(); ie.key = entry.getKey(); ie.generated = entry.isGenerated(); ie.ignored = entry.isIgnored(); if (!entry.isIgnored()) { ie.crcClass = crc(originalBytes); ie.crcWeaved = write(cacheFile, entry.getBytes()); } addIndexEntry(ie); } } public void remove(CachedClassReference ref) { File cacheDirectory = getCacheDirectory(); String refKey = ref.getKey(); File cacheFile = new File(cacheDirectory, refKey); synchronized (LOCK) {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java
removeIndexEntry(refKey); delete(cacheFile); } } @Override protected void delete(File file) { synchronized (LOCK) { super.delete(file); } } protected byte[] read(File file, long expectedCRC) { byte[] bytes=null; synchronized (LOCK) { FileInputStream fis = null; try { fis = new FileInputStream(file); bytes = FileUtil.readAsByteArray(fis); } catch (Exception e) { if ((logger != null) && logger.isTraceEnabled()) { logger.warn("read(" + file.getAbsolutePath() + ")" + " failed (" + e.getClass().getSimpleName() + ")" + " to read contents: " + e.getMessage(), e); } } finally { close(fis, file); } if ((bytes == null) || (crc(bytes) != expectedCRC)) { delete(file); return null;
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java
} } return bytes; } protected long write(File file, byte[] bytes) { synchronized (LOCK) { if (file.exists()) { return -1L; } OutputStream out = null; try { out = new FileOutputStream(file); out.write(bytes); } catch (Exception e) { if ((logger != null) && logger.isTraceEnabled()) { logger.warn("write(" + file.getAbsolutePath() + ")" + " failed (" + e.getClass().getSimpleName() + ")" + " to write contents: " + e.getMessage(), e); } delete(file); return -1L; } finally { close(out, file); } return crc(bytes); } } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/CacheTests.java
/******************************************************************************* * Copyright (c) 2012 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: * John Kew (vmware) initial implementation *******************************************************************************/ package org.aspectj.weaver.tools.cache; import junit.framework.Test; import junit.framework.TestSuite; /** */ public class CacheTests { public static Test suite() { TestSuite suite = new TestSuite(CacheTests.class.getName()); suite.addTestSuite(SimpleClassCacheTest.class); suite.addTestSuite(WeavedClassCacheTest.class); suite.addTestSuite(DefaultCacheKeyResolverTest.class); suite.addTestSuite(DefaultFileCacheBackingTest.class); return suite; } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolverTest.java
/******************************************************************************* * Copyright (c) 2012 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: * John Kew (vmware) initial implementation *******************************************************************************/ package org.aspectj.weaver.tools.cache; import junit.framework.TestCase; import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; import java.util.Collections; /** */ public class DefaultCacheKeyResolverTest extends TestCase {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolverTest.java
byte[] FAKE_BYTES = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; String FAKE_CLASS = "com.example.foo.Bar"; DefaultCacheKeyResolver resolver = new DefaultCacheKeyResolver(); class BasicTestCL extends ClassLoader { } class URLTestCL extends URLClassLoader { public URLTestCL(URL... urls) { super(urls); } } public void testNonURLClassLoaderScope() throws Exception { String scope = resolver.createClassLoaderScope(new BasicTestCL(), Collections.<String>emptyList()); assertTrue(scope.startsWith(BasicTestCL.class.getSimpleName())); } public void testCreateURLClassLoaderScope() throws Exception { URL testURLA = new URL("http://example.com"); URL testURLB = new URL("file:///tmp"); URL testURLC = new URL("ftp://ftp.example.com"); URLTestCL A = new URLTestCL(testURLA); URLTestCL AB = new URLTestCL(testURLA, testURLB); URLTestCL BC = new URLTestCL(testURLB, testURLC); URLTestCL BC2 = new URLTestCL(testURLC, testURLB); String[] a = {"one", "two", "three", "four"}; String[] a2 = {"one", "two", "three"}; String scopeAa = resolver.createClassLoaderScope(A, Arrays.asList(a)); String scopeABa = resolver.createClassLoaderScope(AB, Arrays.asList(a));
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolverTest.java
String scopeBCa = resolver.createClassLoaderScope(BC, Arrays.asList(a)); String scopeBC2a = resolver.createClassLoaderScope(BC2, Arrays.asList(a)); String scopeAa2 = resolver.createClassLoaderScope(A, Arrays.asList(a2)); String scopeABa2 = resolver.createClassLoaderScope(AB, Arrays.asList(a2)); String scopeBCa2 = resolver.createClassLoaderScope(BC, Arrays.asList(a2)); String scopeBC2a2 = resolver.createClassLoaderScope(BC2, Arrays.asList(a2)); assertFalse(scopeAa.equals(scopeABa)); assertFalse(scopeAa.equals(scopeBCa)); assertFalse(scopeABa.equals(scopeBCa)); assertTrue(scopeBC2a.equals(scopeBCa)); assertFalse(scopeAa.equals(scopeAa2)); assertFalse(scopeABa.equals(scopeABa2)); assertFalse(scopeBCa.equals(scopeBCa2)); assertFalse(scopeBC2a.equals(scopeBC2a2)); } public void testCreateGeneratedCacheKey() throws Exception { CachedClassReference ref = resolver.generatedKey(FAKE_CLASS); assertTrue(ref.getKey().startsWith(FAKE_CLASS)); assertTrue(ref.getKey().matches(resolver.getGeneratedRegex())); assertEquals(FAKE_CLASS, resolver.keyToClass(ref.getKey())); } public void testCreateCacheKey() throws Exception { CachedClassReference ref = resolver.weavedKey(FAKE_CLASS, FAKE_BYTES); assertTrue("key " + ref.getKey() + " does not match " + resolver.getWeavedRegex(), ref.getKey().matches(resolver.getWeavedRegex())); String className = resolver.keyToClass(ref.getKey()); assertEquals("class " + FAKE_CLASS + " != " + className, FAKE_CLASS, className); } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultFileCacheBackingTest.java
/******************************************************************************* * Copyright (c) 2012 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: * John Kew (vmware) initial implementation * Lyor Goldstein (vmware) add support for weaved class being re-defined *******************************************************************************/ package org.aspectj.weaver.tools.cache; import java.io.File; import java.util.zip.CRC32; import junit.framework.TestCase; import org.aspectj.util.FileUtil; import org.aspectj.util.LangUtil; import org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking.IndexEntry; /** */ public class DefaultFileCacheBackingTest extends TestCase { private final byte[] FAKE_BYTES = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; private final String FAKE_CLASS = "com.example.foo.Bar";
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultFileCacheBackingTest.java
private final CacheKeyResolver resolver = new DefaultCacheKeyResolver(); private final CachedClassReference fakeRef = resolver.weavedKey(FAKE_CLASS, FAKE_BYTES); private final String fakeKey=fakeRef.getKey(); private File root; public DefaultFileCacheBackingTest () { super(); } @Override public void setUp() throws Exception { if (root == null) { File tempFile = File.createTempFile("aspectj", "test"); File tempDir = tempFile.getParentFile(); root = new File(tempDir, "aspectj-test-cache"); } } @Override public void tearDown() throws Exception { FileUtil.deleteContents(root); root = null; } public void testCreateBacking() throws Exception { CacheBacking backing = DefaultFileCacheBacking.createBacking(root); assertNotNull(backing); assertTrue("Root folder not created: " + root, root.exists()); assertTrue("Root folder not a directory: " + root, root.isDirectory()); } public void testClear() { CacheBacking backing = DefaultFileCacheBacking.createBacking(root); backing.put(new CachedClassEntry(fakeRef, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED), FAKE_BYTES); assertNotNull(backing.get(fakeRef, FAKE_BYTES));
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultFileCacheBackingTest.java
backing.clear(); assertNull(backing.get(fakeRef, FAKE_BYTES)); } private CachedClassEntry createTestEntry(String key) { return new CachedClassEntry(new CachedClassReference(key, key), FAKE_BYTES, CachedClassEntry.EntryType.WEAVED); } public void testGetKeys() throws Exception { CacheBacking backing = DefaultFileCacheBacking.createBacking(root); backing.put(createTestEntry("apple"), FAKE_BYTES); backing.put(createTestEntry("apply"), FAKE_BYTES); backing.put(createTestEntry("orange"), FAKE_BYTES); String[] matches = backing.getKeys("app.*"); assertEquals(2, matches.length); matches = backing.getKeys("orange"); assertEquals(1, matches.length); assertEquals("orange", matches[0]); } public void testPut() throws Exception { CacheBacking backing = DefaultFileCacheBacking.createBacking(root); backing.put(new CachedClassEntry(fakeRef, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED), FAKE_BYTES); File cachedFile = new File(root, fakeKey); assertTrue(cachedFile.exists()); assertTrue(cachedFile.isFile()); assertEquals(FAKE_BYTES.length, cachedFile.length()); } public void testGet() throws Exception { DefaultFileCacheBacking backing = DefaultFileCacheBacking.createBacking(root); assertNull(backing.get(fakeRef, FAKE_BYTES)); backing.put(new CachedClassEntry(fakeRef, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED), FAKE_BYTES); File cachedFile = new File(root, fakeKey);
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultFileCacheBackingTest.java
assertTrue(cachedFile.isFile()); assertEquals(FAKE_BYTES.length, cachedFile.length()); CRC32 expectedCRC = new CRC32(); expectedCRC.update(FAKE_BYTES); assertTrue(indexEntryExists(backing, fakeKey, expectedCRC.getValue())); CachedClassEntry entry = backing.get(fakeRef, FAKE_BYTES); assertEquals(FAKE_BYTES.length, entry.getBytes().length); } public void testRemove() throws Exception { DefaultFileCacheBacking backing = DefaultFileCacheBacking.createBacking(root); backing.put(new CachedClassEntry(fakeRef, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED), FAKE_BYTES); File cachedFile = new File(root, fakeKey); assertTrue("Cached file not found: " + cachedFile, cachedFile.exists()); assertTrue("Cached file not a file: " + cachedFile, cachedFile.isFile()); CRC32 expectedCRC = new CRC32(); expectedCRC.update(FAKE_BYTES); assertTrue("Cached entry index not found", indexEntryExists(backing, fakeKey, expectedCRC.getValue())); backing.remove(fakeRef); assertFalse("CacheFile Still exists: " + cachedFile, cachedFile.exists()); assertFalse("Cached file is a file: " + cachedFile, cachedFile.isFile()); assertFalse("Cached entry index not removed", indexEntryExists(backing, fakeKey, expectedCRC.getValue())); } public void testMultiFile() throws Exception { CachedClassEntry entry; File cachedFile; CRC32 expectedCRC = new CRC32(); expectedCRC.update(FAKE_BYTES); DefaultFileCacheBacking backing = DefaultFileCacheBacking.createBacking(root); CachedClassReference wref = resolver.weavedKey(FAKE_CLASS + "WEAVED", FAKE_BYTES);
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultFileCacheBackingTest.java
entry = new CachedClassEntry(wref, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED); backing.put(entry, FAKE_BYTES); cachedFile = new File(root, wref.getKey()); assertTrue(cachedFile.exists()); assertTrue(cachedFile.isFile()); assertTrue(indexEntryExists(backing, wref.getKey(), expectedCRC.getValue())); CachedClassReference gref = resolver.generatedKey(FAKE_CLASS + "GENERATED"); entry = new CachedClassEntry(gref, FAKE_BYTES, CachedClassEntry.EntryType.GENERATED); backing.put(entry, FAKE_BYTES); cachedFile = new File(root, gref.getKey()); assertTrue(cachedFile.exists()); assertTrue(cachedFile.isFile()); assertTrue(indexEntryExists(backing, gref.getKey(), expectedCRC.getValue())); CachedClassReference iref = resolver.generatedKey(FAKE_CLASS + "IGNORED"); entry = new CachedClassEntry(iref, FAKE_BYTES, CachedClassEntry.EntryType.IGNORED); backing.put(entry, FAKE_BYTES); cachedFile = new File(root, iref.getKey()); assertFalse(cachedFile.exists()); assertTrue(indexEntryExists(backing, iref.getKey(), expectedCRC.getValue())); backing.remove(wref); backing.remove(gref); backing.remove(iref); } public void testOriginalClassBytesChanged () { DefaultFileCacheBacking backing = DefaultFileCacheBacking.createBacking(root); backing.put(new CachedClassEntry(fakeRef, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED), FAKE_BYTES); CachedClassEntry entry = backing.get(fakeRef, FAKE_BYTES);
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultFileCacheBackingTest.java
assertNotNull("No initial entry", entry); byte[] newBytes=new byte[FAKE_BYTES.length]; for (int index=0; index < FAKE_BYTES.length; index++) { newBytes[index] = (byte) (0 - FAKE_BYTES[index]); } entry = backing.get(fakeRef, newBytes); assertNull("Unexpected modified bytes entry: " + entry, entry); File cachedFile = new File(root, fakeKey); assertFalse("Cache file not removed", cachedFile.exists()); } private boolean indexEntryExists(AbstractIndexedFileCacheBacking cache, String key, long expectedCRC) throws Exception { long storedCRC = 0L; IndexEntry[] index = cache.readIndex(new File(root, AbstractIndexedFileCacheBacking.INDEX_FILE)); if (LangUtil.isEmpty(index)) { return false; } for (IndexEntry ie : index) { if (ie.key.equals(key)) { storedCRC = ie.crcWeaved; if (!ie.ignored) { assertEquals(expectedCRC, storedCRC); } return true; } } return false; } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/SimpleClassCacheTest.java
/******************************************************************************* * Copyright (c) 2012 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: * Abraham Nevado (lucierna) initial implementation ********************************************************************************/ package org.aspectj.weaver.tools.cache; import junit.framework.TestCase; import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessageHandler; import org.aspectj.weaver.tools.GeneratedClassHandler; import java.io.File; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Set; /** */ public class SimpleClassCacheTest extends TestCase {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/SimpleClassCacheTest.java
byte[] FAKE_BYTES_V1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; byte[] FAKE_BYTES_V2 = {1, 1, 2, 3, 4, 5, 6, 7, 8, 9}; byte[] FAKE_WOVEN_BYTES_V1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10}; byte[] FAKE_WOVEN_BYTES_V2 = {1, 1, 2, 3, 4, 5, 6, 7, 8, 9,10}; private SimpleCache createCache() throws Exception { return new SimpleCache(System.getProperty("java.io.tmpdir"),true); } public void testCache() throws Exception { String classA = "com.generated.A"; SimpleCache cache = createCache(); cache.put(classA, FAKE_BYTES_V1, FAKE_WOVEN_BYTES_V1);
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/SimpleClassCacheTest.java
byte result[] = cache.getAndInitialize(classA, FAKE_BYTES_V1, null, null); for(int i = 0; i < result.length; i ++){ assertEquals("Cached version byte[" +i+"] should be equal to the original woven classe",result[i],FAKE_WOVEN_BYTES_V1[i]); } File f = new File (System.getProperty("java.io.tmpdir") + File.separator + "com.generated.A-1164760902"); assertTrue("Class should be backed up to backing folder, with te CRC:1164760902 ",f.exists()); } public void testDifferentVersionCache() throws Exception { String classA = "com.generated.A"; SimpleCache cache = createCache(); cache.put(classA, FAKE_BYTES_V1, FAKE_WOVEN_BYTES_V1); cache.put(classA, FAKE_BYTES_V2, FAKE_WOVEN_BYTES_V2); byte result[] = cache.getAndInitialize(classA, FAKE_BYTES_V1, null, null); for(int i = 0; i < result.length; i ++){ assertEquals("Cached version v1 byte[" +i+"] should be equal to the original woven classe",result[i],FAKE_WOVEN_BYTES_V1[i]); } result = cache.getAndInitialize(classA, FAKE_BYTES_V2, null, null); for(int i = 0; i < result.length; i ++){ assertEquals("Cached version v2 byte[" +i+"] should be equal to the original woven classe",result[i],FAKE_WOVEN_BYTES_V2[i]); } } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/WeavedClassCacheTest.java
/******************************************************************************* * Copyright (c) 2012 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: * John Kew (vmware) initial implementation *******************************************************************************/ package org.aspectj.weaver.tools.cache; import junit.framework.TestCase; import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessageHandler; import org.aspectj.weaver.tools.GeneratedClassHandler; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Set; /** */ public class WeavedClassCacheTest extends TestCase {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/WeavedClassCacheTest.java
String FAKE_CLASS = "com.example.foo.Bar"; byte[] FAKE_BYTES = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; public class MemoryCacheBacking implements CacheBacking { HashMap<String, CachedClassEntry> cache = new HashMap<String, CachedClassEntry>(); public String[] getKeys(String regex) { Set<String> keys = cache.keySet(); List<String> matches = new LinkedList<String>(); for (String key : keys) { if (key.matches(regex)) { matches.add(key); } }
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/WeavedClassCacheTest.java
return matches.toArray(new String[0]); } public void remove(CachedClassReference ref) { cache.remove(ref.getKey()); } public void clear() { cache.clear(); } public CachedClassEntry get(CachedClassReference ref, byte[] originalBytes) { return cache.get(ref.getKey()); } public void put(CachedClassEntry entry, byte[] originalBytes) { assertNotNull("put(" + entry + ") no original bytes", originalBytes); cache.put(entry.getKey(), entry); } } MemoryCacheBacking memoryBacking = new MemoryCacheBacking(); IMessageHandler messageHandler = new IMessageHandler() { public boolean handleMessage(IMessage message) throws AbortException { return true; } public boolean isIgnoring(IMessage.Kind kind) { return true; } public void dontIgnore(IMessage.Kind kind) { } public void ignore(IMessage.Kind kind) { } }; public class TestGeneratedClassHandler implements GeneratedClassHandler {
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/WeavedClassCacheTest.java
public int accepts = 0; public List<String> classesISaw = new LinkedList<String>(); @Override public void acceptClass (String name, byte[] originalBytes, byte[] wovenBytes) { accepts++; classesISaw.add(name); } } TestGeneratedClassHandler generatedClassHandler = new TestGeneratedClassHandler(); CacheKeyResolver resolver = new DefaultCacheKeyResolver(); private WeavedClassCache createCache() throws Exception { return new WeavedClassCache(generatedClassHandler, messageHandler, "test", memoryBacking, resolver); } private void reset() throws Exception { memoryBacking.cache.clear(); generatedClassHandler.accepts = 0; generatedClassHandler.classesISaw.clear(); } public void testGetCachingClassHandler() throws Exception { WeavedClassCache cache = createCache(); GeneratedClassHandler newHandle = cache.getCachingClassHandler(); assertTrue(generatedClassHandler != newHandle); assertTrue(newHandle instanceof GeneratedCachedClassHandler);
391,123
Bug 391123 Added support for more cache backing(s)
null
closed fixed
df1823b
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-10-29T19:46:03Z"
"2012-10-04T14:13:20Z"
weaver/testsrc/org/aspectj/weaver/tools/cache/WeavedClassCacheTest.java
} public void testCache() throws Exception { reset(); WeavedClassCache cache = createCache(); CacheStatistics stats = cache.getStats(); CachedClassReference ref = cache.createCacheKey(FAKE_CLASS, FAKE_BYTES); assertNull(cache.get(ref, FAKE_BYTES)); cache.put(ref, FAKE_BYTES, FAKE_BYTES); assertNotNull(cache.get(ref, FAKE_BYTES)); assertEquals(new String(FAKE_BYTES), new String(cache.get(ref, FAKE_BYTES).getBytes())); ref = cache.createGeneratedCacheKey(FAKE_CLASS); assertNull(cache.get(ref, FAKE_BYTES)); cache.put(ref, FAKE_BYTES, FAKE_BYTES); assertNotNull(cache.get(ref, FAKE_BYTES)); assertEquals(new String(FAKE_BYTES), new String(cache.get(ref, FAKE_BYTES).getBytes())); assertEquals(4, stats.getHits()); assertEquals(2, stats.getMisses()); } public void testRemove() throws Exception { reset(); WeavedClassCache cache = createCache(); CachedClassReference ref = cache.createCacheKey(FAKE_CLASS, FAKE_BYTES); assertNull(cache.get(ref, FAKE_BYTES)); cache.put(ref, FAKE_BYTES, FAKE_BYTES); assertNotNull(cache.get(ref, FAKE_BYTES)); cache.remove(ref); assertNull(cache.get(ref, FAKE_BYTES)); } }
394,234
Bug 394234 Invalid StackMapTable generated in Java 7
When compiling for Java 7, AspectJ can compute an invalid StackMapTable. The verifier will throw a ClassNotFoundException when the generated class is loaded. Example: class Parent<T> {} class ChildA<T> extends Parent<T> {} class ChildB<T> extends Parent<T> {} public Object methodWithBadStackMapTable(boolean value) { return value ? new ChildA<String>() : new ChildB<String>(); } javap shows the computed StackMapTable to be: StackMapTable: number_of_entries = 2 frame_type = 15 /* same */ frame_type = 71 /* same_locals_1_stack_item */ stack = [ class "Parent<T>" ] when it should be: StackMapTable: number_of_entries = 2 frame_type = 15 /* same */ frame_type = 71 /* same_locals_1_stack_item */ stack = [ class Parent ]
resolved fixed
fc55431
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-11-14T23:41:57Z"
"2012-11-13T23:40:00Z"
weaver/src/org/aspectj/weaver/bcel/asm/StackMapAdder.java
/* ******************************************************************* * Copyright (c) 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 * * Contributors: * Andy Clement * ******************************************************************/ package org.aspectj.weaver.bcel.asm; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.World; import aj.org.objectweb.asm.*;
394,234
Bug 394234 Invalid StackMapTable generated in Java 7
When compiling for Java 7, AspectJ can compute an invalid StackMapTable. The verifier will throw a ClassNotFoundException when the generated class is loaded. Example: class Parent<T> {} class ChildA<T> extends Parent<T> {} class ChildB<T> extends Parent<T> {} public Object methodWithBadStackMapTable(boolean value) { return value ? new ChildA<String>() : new ChildB<String>(); } javap shows the computed StackMapTable to be: StackMapTable: number_of_entries = 2 frame_type = 15 /* same */ frame_type = 71 /* same_locals_1_stack_item */ stack = [ class "Parent<T>" ] when it should be: StackMapTable: number_of_entries = 2 frame_type = 15 /* same */ frame_type = 71 /* same_locals_1_stack_item */ stack = [ class Parent ]
resolved fixed
fc55431
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-11-14T23:41:57Z"
"2012-11-13T23:40:00Z"
weaver/src/org/aspectj/weaver/bcel/asm/StackMapAdder.java
/** * Uses asm to add the stack map attribute to methods in a class. The class is passed in as pure byte data and then a reader/writer * process it. The writer is wired into the world so that types can be resolved and getCommonSuperClass() can be implemented without * class loading using the context class loader. * * It is important that the constant pool is preserved here and asm does not try to remove unused entries. That is because some * entries are refered to from classfile attributes. Asm cannot see into these attributes so does not realise the constant pool * entries are in use. In order to ensure the copying of cp occurs, we use the variant super constructor call in AspectJConnectClassWriter * that passes in the classreader. However, ordinarily that change causes a further optimization: that if a classreader sees * a methodvisitor that has been created by a ClassWriter then it just copies the data across without changing it (and so it * fails to attach the stackmapattribute). In order to avoid this further optimization we use our own minimal MethodVisitor. * * @author Andy Clement */ public class StackMapAdder { public static byte[] addStackMaps(World world, byte[] data) { try { ClassReader cr = new ClassReader(data); ClassWriter cw = new AspectJConnectClassWriter(cr, world); ClassVisitor cv = new AspectJClassVisitor(cw); cr.accept(cv, 0); return cw.toByteArray(); } catch (Throwable t) { System.err.println("AspectJ Internal Error: unable to add stackmap attributes. " + t.getMessage()); AsmDetector.isAsmAround = false; return data; } } private static class AspectJClassVisitor extends ClassVisitor {
394,234
Bug 394234 Invalid StackMapTable generated in Java 7
When compiling for Java 7, AspectJ can compute an invalid StackMapTable. The verifier will throw a ClassNotFoundException when the generated class is loaded. Example: class Parent<T> {} class ChildA<T> extends Parent<T> {} class ChildB<T> extends Parent<T> {} public Object methodWithBadStackMapTable(boolean value) { return value ? new ChildA<String>() : new ChildB<String>(); } javap shows the computed StackMapTable to be: StackMapTable: number_of_entries = 2 frame_type = 15 /* same */ frame_type = 71 /* same_locals_1_stack_item */ stack = [ class "Parent<T>" ] when it should be: StackMapTable: number_of_entries = 2 frame_type = 15 /* same */ frame_type = 71 /* same_locals_1_stack_item */ stack = [ class Parent ]
resolved fixed
fc55431
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-11-14T23:41:57Z"
"2012-11-13T23:40:00Z"
weaver/src/org/aspectj/weaver/bcel/asm/StackMapAdder.java
public AspectJClassVisitor(ClassVisitor classwriter) { super(Opcodes.ASM4, classwriter); } @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); return new AJMethodVisitor(mv); } static class AJMethodVisitor extends MethodVisitor { public AJMethodVisitor(MethodVisitor mv) { super(Opcodes.ASM4,mv); } } } private static class AspectJConnectClassWriter extends ClassWriter {
394,234
Bug 394234 Invalid StackMapTable generated in Java 7
When compiling for Java 7, AspectJ can compute an invalid StackMapTable. The verifier will throw a ClassNotFoundException when the generated class is loaded. Example: class Parent<T> {} class ChildA<T> extends Parent<T> {} class ChildB<T> extends Parent<T> {} public Object methodWithBadStackMapTable(boolean value) { return value ? new ChildA<String>() : new ChildB<String>(); } javap shows the computed StackMapTable to be: StackMapTable: number_of_entries = 2 frame_type = 15 /* same */ frame_type = 71 /* same_locals_1_stack_item */ stack = [ class "Parent<T>" ] when it should be: StackMapTable: number_of_entries = 2 frame_type = 15 /* same */ frame_type = 71 /* same_locals_1_stack_item */ stack = [ class Parent ]
resolved fixed
fc55431
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-11-14T23:41:57Z"
"2012-11-13T23:40:00Z"
weaver/src/org/aspectj/weaver/bcel/asm/StackMapAdder.java
private final World world; public AspectJConnectClassWriter(ClassReader cr, World w) { super(cr, ClassWriter.COMPUTE_FRAMES); this.world = w; } protected String getCommonSuperClass(final String type1, final String type2) { ResolvedType resolvedType1 = world.resolve(UnresolvedType.forName(type1.replace('/', '.'))); ResolvedType resolvedType2 = world.resolve(UnresolvedType.forName(type2.replace('/', '.'))); if (resolvedType1.isAssignableFrom(resolvedType2)) { return type1; } if (resolvedType2.isAssignableFrom(resolvedType1)) { return type2; } if (resolvedType1.isInterface() || resolvedType2.isInterface()) { return "java/lang/Object"; } else { do { resolvedType1 = resolvedType1.getSuperclass(); } while (!resolvedType1.isAssignableFrom(resolvedType2)); return resolvedType1.getName().replace('.', '/'); } } } }
395,221
Bug 395221 weird error about unbound formals when mixing generics with annotation style
From the mailing list: I have following problem with following Aspect: @Aspect public class CounterAspect extends AbstractMoskitoAspect { @Around(value = "execution(* *(..)) && (@annotation(method))") public Object countMethod(ProceedingJoinPoint pjp, Count method) throws Throwable { return count(pjp, method.producerId(), method.subsystem(), method.category()); } @Around(value = "execution(* *(..)) && (@annotation(method))") public Object countByParameter(ProceedingJoinPoint pjp, CountByParameter method) throws Throwable { return countByParameter(pjp, method.producerId(), method.subsystem(), method.category()); } @Around(value = "execution(* *.*(..)) && (@within(clazz))") public Object countClass(ProceedingJoinPoint pjp, Count clazz) throws Throwable { return count(pjp, clazz.producerId(), clazz.subsystem(), clazz.category()); } private Object countByParameter(ProceedingJoinPoint pjp, String aProducerId, String aSubsystem, String aCategory) throws Throwable { .... It works. However, since I have two similar aspects that differ only in using some internal classes, I made my super class using generics: public class AbstractMoskitoAspect<S extends IStats> { @Aspect public class CounterAspect extends AbstractMoskitoAspect<CounterStats> { this breaks the build instantly with the very unhelpful error message: [ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.4:compile (default) on project moskito-aop: Compiler errors: [ERROR] error at @Around(value = "execution(* *(..)) && (@annotation(method))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:24:0::0 the parameter pjp is not bound in [all branches of] pointcut [ERROR] error at @Around(value = "execution(* *(..)) && (@annotation(method))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:29:0::0 the parameter pjp is not bound in [all branches of] pointcut [ERROR] error at @Around(value = "execution(* *.*(..)) && (@within(clazz))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:34:0::0 the parameter pjp is not bound in [all branches of] pointcut what am i doing wrong here?
resolved fixed
3e5af0f
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-11-27T22:52:33Z"
"2012-11-27T23:46:40Z"
org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndPointcut.java
/* ******************************************************************* * 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: * PARC initial implementation * ******************************************************************/ package org.aspectj.weaver.patterns; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; import org.aspectj.weaver.ast.Test; public class AndPointcut extends Pointcut {
395,221
Bug 395221 weird error about unbound formals when mixing generics with annotation style
From the mailing list: I have following problem with following Aspect: @Aspect public class CounterAspect extends AbstractMoskitoAspect { @Around(value = "execution(* *(..)) && (@annotation(method))") public Object countMethod(ProceedingJoinPoint pjp, Count method) throws Throwable { return count(pjp, method.producerId(), method.subsystem(), method.category()); } @Around(value = "execution(* *(..)) && (@annotation(method))") public Object countByParameter(ProceedingJoinPoint pjp, CountByParameter method) throws Throwable { return countByParameter(pjp, method.producerId(), method.subsystem(), method.category()); } @Around(value = "execution(* *.*(..)) && (@within(clazz))") public Object countClass(ProceedingJoinPoint pjp, Count clazz) throws Throwable { return count(pjp, clazz.producerId(), clazz.subsystem(), clazz.category()); } private Object countByParameter(ProceedingJoinPoint pjp, String aProducerId, String aSubsystem, String aCategory) throws Throwable { .... It works. However, since I have two similar aspects that differ only in using some internal classes, I made my super class using generics: public class AbstractMoskitoAspect<S extends IStats> { @Aspect public class CounterAspect extends AbstractMoskitoAspect<CounterStats> { this breaks the build instantly with the very unhelpful error message: [ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.4:compile (default) on project moskito-aop: Compiler errors: [ERROR] error at @Around(value = "execution(* *(..)) && (@annotation(method))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:24:0::0 the parameter pjp is not bound in [all branches of] pointcut [ERROR] error at @Around(value = "execution(* *(..)) && (@annotation(method))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:29:0::0 the parameter pjp is not bound in [all branches of] pointcut [ERROR] error at @Around(value = "execution(* *.*(..)) && (@within(clazz))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:34:0::0 the parameter pjp is not bound in [all branches of] pointcut what am i doing wrong here?
resolved fixed
3e5af0f
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-11-27T22:52:33Z"
"2012-11-27T23:46:40Z"
org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndPointcut.java
Pointcut left, right; private int couldMatchKinds; public AndPointcut(Pointcut left, Pointcut right) { super(); this.left = left; this.right = right; this.pointcutKind = AND; setLocation(left.getSourceContext(), left.getStart(), right.getEnd()); couldMatchKinds = left.couldMatchKinds() & right.couldMatchKinds(); } public int couldMatchKinds() { return couldMatchKinds; } public FuzzyBoolean fastMatch(FastMatchInfo type) { return left.fastMatch(type).and(right.fastMatch(type)); } protected FuzzyBoolean matchInternal(Shadow shadow) { FuzzyBoolean leftMatch = left.match(shadow); if (leftMatch.alwaysFalse()) { return leftMatch; } return leftMatch.and(right.match(shadow)); } public String toString() { return "(" + left.toString() + " && " + right.toString() + ")";
395,221
Bug 395221 weird error about unbound formals when mixing generics with annotation style
From the mailing list: I have following problem with following Aspect: @Aspect public class CounterAspect extends AbstractMoskitoAspect { @Around(value = "execution(* *(..)) && (@annotation(method))") public Object countMethod(ProceedingJoinPoint pjp, Count method) throws Throwable { return count(pjp, method.producerId(), method.subsystem(), method.category()); } @Around(value = "execution(* *(..)) && (@annotation(method))") public Object countByParameter(ProceedingJoinPoint pjp, CountByParameter method) throws Throwable { return countByParameter(pjp, method.producerId(), method.subsystem(), method.category()); } @Around(value = "execution(* *.*(..)) && (@within(clazz))") public Object countClass(ProceedingJoinPoint pjp, Count clazz) throws Throwable { return count(pjp, clazz.producerId(), clazz.subsystem(), clazz.category()); } private Object countByParameter(ProceedingJoinPoint pjp, String aProducerId, String aSubsystem, String aCategory) throws Throwable { .... It works. However, since I have two similar aspects that differ only in using some internal classes, I made my super class using generics: public class AbstractMoskitoAspect<S extends IStats> { @Aspect public class CounterAspect extends AbstractMoskitoAspect<CounterStats> { this breaks the build instantly with the very unhelpful error message: [ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.4:compile (default) on project moskito-aop: Compiler errors: [ERROR] error at @Around(value = "execution(* *(..)) && (@annotation(method))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:24:0::0 the parameter pjp is not bound in [all branches of] pointcut [ERROR] error at @Around(value = "execution(* *(..)) && (@annotation(method))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:29:0::0 the parameter pjp is not bound in [all branches of] pointcut [ERROR] error at @Around(value = "execution(* *.*(..)) && (@within(clazz))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:34:0::0 the parameter pjp is not bound in [all branches of] pointcut what am i doing wrong here?
resolved fixed
3e5af0f
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-11-27T22:52:33Z"
"2012-11-27T23:46:40Z"
org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndPointcut.java
} public boolean equals(Object other) { if (!(other instanceof AndPointcut)) { return false; } AndPointcut o = (AndPointcut) other; return o.left.equals(left) && o.right.equals(right); } public int hashCode() { int result = 19; result = 37 * result + left.hashCode(); result = 37 * result + right.hashCode(); return result; } public void resolveBindings(IScope scope, Bindings bindings) { left.resolveBindings(scope, bindings); right.resolveBindings(scope, bindings); } public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.AND); left.write(s); right.write(s); writeLocation(s); } public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { AndPointcut ret = new AndPointcut(Pointcut.read(s, context), Pointcut.read(s, context)); ret.readLocation(context, s); return ret; } protected Test findResidueInternal(Shadow shadow, ExposedState state) {
395,221
Bug 395221 weird error about unbound formals when mixing generics with annotation style
From the mailing list: I have following problem with following Aspect: @Aspect public class CounterAspect extends AbstractMoskitoAspect { @Around(value = "execution(* *(..)) && (@annotation(method))") public Object countMethod(ProceedingJoinPoint pjp, Count method) throws Throwable { return count(pjp, method.producerId(), method.subsystem(), method.category()); } @Around(value = "execution(* *(..)) && (@annotation(method))") public Object countByParameter(ProceedingJoinPoint pjp, CountByParameter method) throws Throwable { return countByParameter(pjp, method.producerId(), method.subsystem(), method.category()); } @Around(value = "execution(* *.*(..)) && (@within(clazz))") public Object countClass(ProceedingJoinPoint pjp, Count clazz) throws Throwable { return count(pjp, clazz.producerId(), clazz.subsystem(), clazz.category()); } private Object countByParameter(ProceedingJoinPoint pjp, String aProducerId, String aSubsystem, String aCategory) throws Throwable { .... It works. However, since I have two similar aspects that differ only in using some internal classes, I made my super class using generics: public class AbstractMoskitoAspect<S extends IStats> { @Aspect public class CounterAspect extends AbstractMoskitoAspect<CounterStats> { this breaks the build instantly with the very unhelpful error message: [ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.4:compile (default) on project moskito-aop: Compiler errors: [ERROR] error at @Around(value = "execution(* *(..)) && (@annotation(method))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:24:0::0 the parameter pjp is not bound in [all branches of] pointcut [ERROR] error at @Around(value = "execution(* *(..)) && (@annotation(method))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:29:0::0 the parameter pjp is not bound in [all branches of] pointcut [ERROR] error at @Around(value = "execution(* *.*(..)) && (@within(clazz))") [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] /Users/another/projects/moskito/moskito-aop/java/net/anotheria/moskito/aop/aspect/CounterAspect.java:34:0::0 the parameter pjp is not bound in [all branches of] pointcut what am i doing wrong here?
resolved fixed
3e5af0f
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2012-11-27T22:52:33Z"
"2012-11-27T23:46:40Z"
org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndPointcut.java
return Test.makeAnd(left.findResidue(shadow, state), right.findResidue(shadow, state)); } public Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { AndPointcut ret = new AndPointcut(left.concretize(inAspect, declaringType, bindings), right.concretize(inAspect, declaringType, bindings)); ret.copyLocationFrom(this); return ret; } public Pointcut parameterizeWith(Map typeVariableMap, World w) { AndPointcut ret = new AndPointcut(left.parameterizeWith(typeVariableMap, w), right.parameterizeWith(typeVariableMap, w)); ret.copyLocationFrom(this); return ret; } public Pointcut getLeft() { return left; } public Pointcut getRight() { return right; } public Object accept(PatternNodeVisitor visitor, Object data) { return visitor.visit(this, data); } public Object traverse(PatternNodeVisitor visitor, Object data) { Object ret = accept(visitor, data); left.traverse(visitor, ret); right.traverse(visitor, ret); return ret; } }
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
/******************************************************************************* * Copyright (c) 2012 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: * Andy Clement - initial API and implementation *******************************************************************************/ package org.aspectj.systemtest.ajc172; import java.io.File; import junit.framework.Test; import org.aspectj.testing.XMLBasedAjcTestCase; /** * @author Andy Clement */ public class Ajc172Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testInconsistentClassFile_pr389750() { runTest("inconsistent class file"); }
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
public void testInconsistentClassFile_pr389750_2() { runTest("inconsistent class file 2"); } public void testInconsistentClassFile_pr389750_3() { runTest("inconsistent class file 3"); } public void testInconsistentClassFile_pr389750_4() { runTest("inconsistent class file 4"); } public void testAnnotationValueError_pr389752_1() { runTest("annotation value error 1"); } public void testAnnotationValueError_pr389752_2() { runTest("annotation value error 2"); } public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Ajc172Tests.class); } @Override protected File getSpecFile() { return new File("../tests/src/org/aspectj/systemtest/ajc172/ajc172.xml"); } }
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
/* ******************************************************************* * 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: * PARC initial implementation * Alexandre Vasseur perClause support for @AJ aspects * ******************************************************************/ package org.aspectj.weaver.bcel; import java.io.File; import java.io.IOException; import java.lang.reflect.Modifier; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map;
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
import java.util.StringTokenizer; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.ClassParser; import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.generic.FieldInstruction; import org.aspectj.apache.bcel.generic.INVOKEINTERFACE; import org.aspectj.apache.bcel.generic.Instruction; import org.aspectj.apache.bcel.generic.InstructionHandle; import org.aspectj.apache.bcel.generic.InvokeInstruction; import org.aspectj.apache.bcel.generic.MULTIANEWARRAY; import org.aspectj.apache.bcel.generic.ObjectType; import org.aspectj.apache.bcel.generic.Type; import org.aspectj.apache.bcel.util.ClassLoaderReference; import org.aspectj.apache.bcel.util.ClassLoaderRepository; import org.aspectj.apache.bcel.util.ClassPath; import org.aspectj.apache.bcel.util.NonCachingClassLoaderRepository; import org.aspectj.apache.bcel.util.Repository; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IRelationship; import org.aspectj.asm.internal.CharOperation; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessageHandler; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.Message; import org.aspectj.bridge.MessageUtil; import org.aspectj.bridge.WeaveMessage; import org.aspectj.weaver.Advice; import org.aspectj.weaver.AdviceKind; import org.aspectj.weaver.AnnotationAJ;
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
import org.aspectj.weaver.AnnotationOnTypeMunger; import org.aspectj.weaver.BCException; import org.aspectj.weaver.Checker; import org.aspectj.weaver.ICrossReferenceHandler; import org.aspectj.weaver.IWeavingSupport; import org.aspectj.weaver.Member; import org.aspectj.weaver.MemberImpl; import org.aspectj.weaver.MemberKind; import org.aspectj.weaver.NewParentTypeMunger; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ReferenceTypeDelegate; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedMemberImpl; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.ResolvedTypeMunger; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.World; import org.aspectj.weaver.loadtime.definition.Definition; import org.aspectj.weaver.loadtime.definition.DocumentParser; import org.aspectj.weaver.model.AsmRelationshipProvider; import org.aspectj.weaver.patterns.DeclareAnnotation; import org.aspectj.weaver.patterns.DeclareParents; import org.aspectj.weaver.patterns.ParserException; import org.aspectj.weaver.patterns.PatternParser; import org.aspectj.weaver.patterns.TypePattern; import org.aspectj.weaver.tools.Trace; import org.aspectj.weaver.tools.TraceFactory; public class BcelWorld extends World implements Repository {
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
private final ClassPathManager classPath; protected Repository delegate; private BcelWeakClassLoaderReference loaderRef; private final BcelWeavingSupport bcelWeavingSupport = new BcelWeavingSupport(); private boolean isXmlConfiguredWorld = false; private WeavingXmlConfig xmlConfiguration; private List<TypeDelegateResolver> typeDelegateResolvers; private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelWorld.class); public BcelWorld() { this(""); } public BcelWorld(String cp) { this(makeDefaultClasspath(cp), IMessageHandler.THROW, null); } public IRelationship.Kind determineRelKind(ShadowMunger munger) { AdviceKind ak = ((Advice) munger).getKind();
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
if (ak.getKey() == AdviceKind.Before.getKey()) { return IRelationship.Kind.ADVICE_BEFORE; } else if (ak.getKey() == AdviceKind.After.getKey()) { return IRelationship.Kind.ADVICE_AFTER; } else if (ak.getKey() == AdviceKind.AfterThrowing.getKey()) { return IRelationship.Kind.ADVICE_AFTERTHROWING; } else if (ak.getKey() == AdviceKind.AfterReturning.getKey()) { return IRelationship.Kind.ADVICE_AFTERRETURNING; } else if (ak.getKey() == AdviceKind.Around.getKey()) { return IRelationship.Kind.ADVICE_AROUND; } else if (ak.getKey() == AdviceKind.CflowEntry.getKey() || ak.getKey() == AdviceKind.CflowBelowEntry.getKey() || ak.getKey() == AdviceKind.InterInitializer.getKey() || ak.getKey() == AdviceKind.PerCflowEntry.getKey() || ak.getKey() == AdviceKind.PerCflowBelowEntry.getKey() || ak.getKey() == AdviceKind.PerThisEntry.getKey() || ak.getKey() == AdviceKind.PerTargetEntry.getKey() || ak.getKey() == AdviceKind.Softener.getKey() || ak.getKey() == AdviceKind.PerTypeWithinEntry.getKey()) { return null; } throw new RuntimeException("Shadow.determineRelKind: What the hell is it? " + ak); } @Override public void reportMatch(ShadowMunger munger, Shadow shadow) { if (getCrossReferenceHandler() != null) { getCrossReferenceHandler().addCrossReference(munger.getSourceLocation(), shadow.getSourceLocation(), determineRelKind(munger).getName(), ((Advice) munger).hasDynamicTests() ); } if (!getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) {
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
reportWeavingMessage(munger, shadow); } if (getModel() != null) { AsmRelationshipProvider.addAdvisedRelationship(getModelAsAsmManager(), shadow, munger); } } /* * Report a message about the advice weave that has occurred. Some messing about to make it pretty ! This code is just asking * for an NPE to occur ... */ private void reportWeavingMessage(ShadowMunger munger, Shadow shadow) { Advice advice = (Advice) munger; AdviceKind aKind = advice.getKind(); if (aKind == null || advice.getConcreteAspect() == null) { return; } if (!(aKind.equals(AdviceKind.Before) || aKind.equals(AdviceKind.After) || aKind.equals(AdviceKind.AfterReturning) || aKind.equals(AdviceKind.AfterThrowing) || aKind.equals(AdviceKind.Around) || aKind.equals(AdviceKind.Softener))) { return; } if (shadow.getKind() == Shadow.SynchronizationUnlock) { if (advice.lastReportedMonitorExitJoinpointLocation == null) {
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation(); } else { if (areTheSame(shadow.getSourceLocation(), advice.lastReportedMonitorExitJoinpointLocation)) { advice.lastReportedMonitorExitJoinpointLocation = null; return; } advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation(); } } String description = advice.getKind().toString(); String advisedType = shadow.getEnclosingType().getName(); String advisingType = advice.getConcreteAspect().getName(); Message msg = null; if (advice.getKind().equals(AdviceKind.Softener)) { msg = WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_SOFTENS, new String[] { advisedType, beautifyLocation(shadow.getSourceLocation()), advisingType, beautifyLocation(munger.getSourceLocation()) }, advisedType, advisingType); } else { boolean runtimeTest = advice.hasDynamicTests(); String joinPointDescription = shadow.toString(); msg = WeaveMessage .constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ADVISES, new String[] { joinPointDescription, advisedType, beautifyLocation(shadow.getSourceLocation()), description, advisingType, beautifyLocation(munger.getSourceLocation()), (runtimeTest ? " [with runtime test]" : "") }, advisedType, advisingType); } getMessageHandler().handleMessage(msg);
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
} private boolean areTheSame(ISourceLocation locA, ISourceLocation locB) { if (locA == null) { return locB == null; } if (locB == null) { return false; } if (locA.getLine() != locB.getLine()) { return false; } File fA = locA.getSourceFile(); File fB = locA.getSourceFile(); if (fA == null) { return fB == null; } if (fB == null) { return false; } return fA.getName().equals(fB.getName()); } /* * Ensure we report a nice source location - particular in the case where the source info is missing (binary weave). */ private String beautifyLocation(ISourceLocation isl) { StringBuffer nice = new StringBuffer(); if (isl == null || isl.getSourceFile() == null || isl.getSourceFile().getName().indexOf("no debug info available") != -1) { nice.append("no debug info available"); } else {
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
int takeFrom = isl.getSourceFile().getPath().lastIndexOf('/'); if (takeFrom == -1) { takeFrom = isl.getSourceFile().getPath().lastIndexOf('\\'); } int binary = isl.getSourceFile().getPath().lastIndexOf('!'); if (binary != -1 && binary < takeFrom) { String pathToBinaryLoc = isl.getSourceFile().getPath().substring(0, binary + 1); if (pathToBinaryLoc.indexOf(".jar") != -1) { int lastSlash = pathToBinaryLoc.lastIndexOf('/'); if (lastSlash == -1) { lastSlash = pathToBinaryLoc.lastIndexOf('\\'); } nice.append(pathToBinaryLoc.substring(lastSlash + 1)); } } nice.append(isl.getSourceFile().getPath().substring(takeFrom + 1)); if (isl.getLine() != 0) { nice.append(":").append(isl.getLine()); } if (isl.getSourceFileName() != null) { nice.append("(from " + isl.getSourceFileName() + ")"); } } return nice.toString(); } private static List<String> makeDefaultClasspath(String cp) { List<String> classPath = new ArrayList<String>();
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
classPath.addAll(getPathEntries(cp)); classPath.addAll(getPathEntries(ClassPath.getClassPath())); return classPath; } private static List<String> getPathEntries(String s) { List<String> ret = new ArrayList<String>(); StringTokenizer tok = new StringTokenizer(s, File.pathSeparator); while (tok.hasMoreTokens()) { ret.add(tok.nextToken()); } return ret; } public BcelWorld(List classPath, IMessageHandler handler, ICrossReferenceHandler xrefHandler) { this.classPath = new ClassPathManager(classPath, handler); setMessageHandler(handler); setCrossReferenceHandler(xrefHandler); delegate = this; } public BcelWorld(ClassPathManager cpm, IMessageHandler handler, ICrossReferenceHandler xrefHandler) { classPath = cpm; setMessageHandler(handler); setCrossReferenceHandler(xrefHandler); delegate = this; } /** * Build a World from a ClassLoader, for LTW support *
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
* @param loader * @param handler * @param xrefHandler */ public BcelWorld(ClassLoader loader, IMessageHandler handler, ICrossReferenceHandler xrefHandler) { classPath = null; loaderRef = new BcelWeakClassLoaderReference(loader); setMessageHandler(handler); setCrossReferenceHandler(xrefHandler); } public void ensureRepositorySetup() { if (delegate == null) { delegate = getClassLoaderRepositoryFor(loaderRef); } } public Repository getClassLoaderRepositoryFor(ClassLoaderReference loader) { if (bcelRepositoryCaching) { return new ClassLoaderRepository(loader); } else { return new NonCachingClassLoaderRepository(loader); } } public void addPath(String name) { classPath.addPath(name, this.getMessageHandler()); } public static Type makeBcelType(UnresolvedType type) { return Type.getType(type.getErasureSignature());
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
} static Type[] makeBcelTypes(UnresolvedType[] types) { Type[] ret = new Type[types.length]; for (int i = 0, len = types.length; i < len; i++) { ret[i] = makeBcelType(types[i]); } return ret; } static String[] makeBcelTypesAsClassNames(UnresolvedType[] types) { String[] ret = new String[types.length]; for (int i = 0, len = types.length; i < len; i++) { ret[i] = types[i].getName(); } return ret; } public static UnresolvedType fromBcel(Type t) { return UnresolvedType.forSignature(t.getSignature()); } static UnresolvedType[] fromBcel(Type[] ts) { UnresolvedType[] ret = new UnresolvedType[ts.length]; for (int i = 0, len = ts.length; i < len; i++) { ret[i] = fromBcel(ts[i]); } return ret; } public ResolvedType resolve(Type t) { return resolve(fromBcel(t)); } @Override protected ReferenceTypeDelegate resolveDelegate(ReferenceType ty) {
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
String name = ty.getName(); ensureAdvancedConfigurationProcessed(); JavaClass jc = lookupJavaClass(classPath, name); if (jc == null) { if (typeDelegateResolvers != null) { for (TypeDelegateResolver tdr : typeDelegateResolvers) { ReferenceTypeDelegate delegate = tdr.getDelegate(ty); if (delegate != null) { return delegate; } } } return null; } else { return buildBcelDelegate(ty, jc, false, false); } } public BcelObjectType buildBcelDelegate(ReferenceType type, JavaClass jc, boolean artificial, boolean exposedToWeaver) { BcelObjectType ret = new BcelObjectType(type, jc, artificial, exposedToWeaver); return ret; } private JavaClass lookupJavaClass(ClassPathManager classPath, String name) { if (classPath == null) { try { ensureRepositorySetup(); JavaClass jc = delegate.loadClass(name); if (trace.isTraceEnabled()) { trace.event("lookupJavaClass", this, new Object[] { name, jc }); }
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
return jc; } catch (ClassNotFoundException e) { if (trace.isTraceEnabled()) { trace.error("Unable to find class '" + name + "' in repository", e); } return null; } } ClassPathManager.ClassFile file = null; try { file = classPath.find(UnresolvedType.forName(name)); if (file == null) { return null; } ClassParser parser = new ClassParser(file.getInputStream(), file.getPath()); JavaClass jc = parser.parse(); return jc; } catch (IOException ioe) { return null; } finally { if (file != null) { file.close(); } } } public BcelObjectType addSourceObjectType(JavaClass jc, boolean artificial) { return addSourceObjectType(jc.getClassName(), jc, artificial);
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
} public BcelObjectType addSourceObjectType(String classname, JavaClass jc, boolean artificial) { BcelObjectType ret = null; if (!jc.getClassName().equals(classname)) { throw new RuntimeException(jc.getClassName() + "!=" + classname); } String signature = UnresolvedType.forName(jc.getClassName()).getSignature(); ResolvedType fromTheMap = typeMap.get(signature); if (fromTheMap != null && !(fromTheMap instanceof ReferenceType)) { StringBuffer exceptionText = new StringBuffer(); exceptionText.append("Found invalid (not a ReferenceType) entry in the type map. "); exceptionText.append("Signature=[" + signature + "] Found=[" + fromTheMap + "] Class=[" + fromTheMap.getClass() + "]"); throw new BCException(exceptionText.toString()); } ReferenceType nameTypeX = (ReferenceType) fromTheMap; if (nameTypeX == null) { if (jc.isGeneric() && isInJava5Mode()) { nameTypeX = ReferenceType.fromTypeX(UnresolvedType.forRawTypeName(jc.getClassName()), this); ret = buildBcelDelegate(nameTypeX, jc, artificial, true); ReferenceType genericRefType = new ReferenceType(UnresolvedType.forGenericTypeSignature(signature, ret.getDeclaredGenericSignature()), this); nameTypeX.setDelegate(ret); genericRefType.setDelegate(ret); nameTypeX.setGenericType(genericRefType); typeMap.put(signature, nameTypeX); } else { nameTypeX = new ReferenceType(signature, this); ret = buildBcelDelegate(nameTypeX, jc, artificial, true); typeMap.put(signature, nameTypeX);
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
} } else { ret = buildBcelDelegate(nameTypeX, jc, artificial, true); } return ret; } public BcelObjectType addSourceObjectType(String classname, byte[] bytes, boolean artificial) { BcelObjectType ret = null; String signature = UnresolvedType.forName(classname).getSignature(); ResolvedType fromTheMap = typeMap.get(signature); if (fromTheMap != null && !(fromTheMap instanceof ReferenceType)) { StringBuffer exceptionText = new StringBuffer(); exceptionText.append("Found invalid (not a ReferenceType) entry in the type map. "); exceptionText.append("Signature=[" + signature + "] Found=[" + fromTheMap + "] Class=[" + fromTheMap.getClass() + "]"); throw new BCException(exceptionText.toString()); } ReferenceType nameTypeX = (ReferenceType) fromTheMap; if (nameTypeX == null) { JavaClass jc = Utility.makeJavaClass(classname, bytes); if (jc.isGeneric() && isInJava5Mode()) { nameTypeX = ReferenceType.fromTypeX(UnresolvedType.forRawTypeName(jc.getClassName()), this); ret = buildBcelDelegate(nameTypeX, jc, artificial, true); ReferenceType genericRefType = new ReferenceType(UnresolvedType.forGenericTypeSignature(signature, ret.getDeclaredGenericSignature()), this); nameTypeX.setDelegate(ret); genericRefType.setDelegate(ret); nameTypeX.setGenericType(genericRefType); typeMap.put(signature, nameTypeX); } else {
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
nameTypeX = new ReferenceType(signature, this); ret = buildBcelDelegate(nameTypeX, jc, artificial, true); typeMap.put(signature, nameTypeX); } } else { Object o = nameTypeX.getDelegate(); if (!(o instanceof BcelObjectType)) { throw new IllegalStateException("For " + classname + " should be BcelObjectType, but is " + o.getClass()); } ret = (BcelObjectType) o; if (ret.isArtificial() || ret.isExposedToWeaver()) { ret = buildBcelDelegate(nameTypeX, Utility.makeJavaClass(classname, bytes), artificial, true); } else { ret.setExposedToWeaver(true); } } return ret; } void deleteSourceObjectType(UnresolvedType ty) { typeMap.remove(ty.getSignature()); } public static Member makeFieldJoinPointSignature(LazyClassGen cg, FieldInstruction fi) { ConstantPool cpg = cg.getConstantPool();
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
return MemberImpl.field(fi.getClassName(cpg), (fi.opcode == Constants.GETSTATIC || fi.opcode == Constants.PUTSTATIC) ? Modifier.STATIC : 0, fi.getName(cpg), fi.getSignature(cpg)); } public Member makeJoinPointSignatureFromMethod(LazyMethodGen mg, MemberKind kind) { Member ret = mg.getMemberView(); if (ret == null) { int mods = mg.getAccessFlags(); if (mg.getEnclosingClass().isInterface()) { mods |= Modifier.INTERFACE; } return new ResolvedMemberImpl(kind, UnresolvedType.forName(mg.getClassName()), mods, fromBcel(mg.getReturnType()), mg.getName(), fromBcel(mg.getArgumentTypes())); } else { return ret; } } public Member makeJoinPointSignatureForMonitorEnter(LazyClassGen cg, InstructionHandle h) { return MemberImpl.monitorEnter(); } public Member makeJoinPointSignatureForMonitorExit(LazyClassGen cg, InstructionHandle h) { return MemberImpl.monitorExit(); } public Member makeJoinPointSignatureForArrayConstruction(LazyClassGen cg, InstructionHandle handle) { Instruction i = handle.getInstruction(); ConstantPool cpg = cg.getConstantPool(); Member retval = null; if (i.opcode == Constants.ANEWARRAY) { Type ot = i.getType(cpg);
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
UnresolvedType ut = fromBcel(ot); ut = UnresolvedType.makeArray(ut, 1); retval = MemberImpl.method(ut, Modifier.PUBLIC, UnresolvedType.VOID, "<init>", new ResolvedType[] { INT }); } else if (i instanceof MULTIANEWARRAY) { MULTIANEWARRAY arrayInstruction = (MULTIANEWARRAY) i; UnresolvedType ut = null; short dimensions = arrayInstruction.getDimensions(); ObjectType ot = arrayInstruction.getLoadClassType(cpg); if (ot != null) { ut = fromBcel(ot); ut = UnresolvedType.makeArray(ut, dimensions); } else { Type t = arrayInstruction.getType(cpg); ut = fromBcel(t); } ResolvedType[] parms = new ResolvedType[dimensions]; for (int ii = 0; ii < dimensions; ii++) { parms[ii] = INT; } retval = MemberImpl.method(ut, Modifier.PUBLIC, UnresolvedType.VOID, "<init>", parms); } else if (i.opcode == Constants.NEWARRAY) { Type ot = i.getType(); UnresolvedType ut = fromBcel(ot); retval = MemberImpl.method(ut, Modifier.PUBLIC, UnresolvedType.VOID, "<init>", new ResolvedType[] { INT }); } else { throw new BCException("Cannot create array construction signature for this non-array instruction:" + i); } return retval; }
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
public Member makeJoinPointSignatureForMethodInvocation(LazyClassGen cg, InvokeInstruction ii) { ConstantPool cpg = cg.getConstantPool(); String name = ii.getName(cpg); String declaring = ii.getClassName(cpg); UnresolvedType declaringType = null; String signature = ii.getSignature(cpg); int modifier = (ii instanceof INVOKEINTERFACE) ? Modifier.INTERFACE : (ii.opcode == Constants.INVOKESTATIC) ? Modifier.STATIC : (ii.opcode == Constants.INVOKESPECIAL && !name .equals("<init>")) ? Modifier.PRIVATE : 0; if (ii.opcode == Constants.INVOKESTATIC) { ResolvedType appearsDeclaredBy = resolve(declaring); for (Iterator<ResolvedMember> iterator = appearsDeclaredBy.getMethods(true, true); iterator.hasNext();) { ResolvedMember method = iterator.next(); if (Modifier.isStatic(method.getModifiers())) { if (name.equals(method.getName()) && signature.equals(method.getSignature())) { declaringType = method.getDeclaringType(); break; } } } } if (declaringType == null) { if (declaring.charAt(0) == '[') { declaringType = UnresolvedType.forSignature(declaring);
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
} else { declaringType = UnresolvedType.forName(declaring); } } return MemberImpl.method(declaringType, modifier, name, signature); } @Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append("BcelWorld("); buf.append(")"); return buf.toString(); } /** * Retrieve a bcel delegate for an aspect - this will return NULL if the delegate is an EclipseSourceType and not a * BcelObjectType - this happens quite often when incrementally compiling. */ public static BcelObjectType getBcelObjectType(ResolvedType concreteAspect) { if (concreteAspect == null) { return null; } if (!(concreteAspect instanceof ReferenceType)) { return null; } ReferenceTypeDelegate rtDelegate = ((ReferenceType) concreteAspect).getDelegate(); if (rtDelegate instanceof BcelObjectType) { return (BcelObjectType) rtDelegate; } else { return null;
398,588
Bug 398588 Using aspect 'requires' clause causes all aspects with 'requires' clauses not be loaded regardless
The usage of the 'requires' clause causes all aspects that have have 'requires' clauses not to be loaded regardless of whether the specified required class exists or not. Here is the scenario and why it happens: Let's assume we have a bunch of aspects (A1, A2, A3, etc.) - all with 'requires' clauses and all referencing classes that can be satisfied. ClassLoaderWeavingAdaptor#registerAspects goes over the aspects in a Definition one by one. It reaches aspect A1 and detects that it has a 'requires' clause, and so it invokes BcelWorld#addAspectRequires. This causes the aspect A1 and its required class to be registered in an internal 'aspectRequiredTypes' map. Then the code calls BcelWeaver#addLibraryAspect with A1 as the argument, which in turn calls addOrReplaceAspect which invokes 'hasUnsatisfiedDependency'. The 'hasUnsatisfiedDependency' has been written to run only ONCE - i.e., it checks if it has already run, and if so then it does nothing. Otherwise, it removes from the 'aspectRequiredTypes' map all the types that can be resolved, thus leaving only those that cannot be resolved. In other words, it assumes that after having run (once !!!) any remaining type must be unsatified. Thus, when it is invoked with A1, being the 1st time, it resolves the required type by A1 and leaves the 'aspectRequiredTypes' map empty - but also marks that no further running is required. When the ClassLoaderWeavingAdaptor#registerAspects loop reaches A2, it call BcelWorld#addAspectRequires since A2 also declares a 'requires' clause. This causes A2 and its referenced class to be mapped in the 'aspectRequiredTypes' map. However, when BcelWeaver#addLibraryAspect is called with A2 and the code reaches 'hasUnsatisfiedDependency' - the code assumes that it has already run (which it has - with A1), so it does not check if indeed A2's referenced class can be satisfied (which we assume it can). In other words, all subsequent aspects (A2, A3, etc.) are declared as having unsatisified dependencies - which they don't. The (quick) bugfix seems rather simple: every time BcelWorld#addAspectRequires method is called, it should mark 'aspectRequiredTypesProcessed' as FALSE, in order to force a re-evaluation in case 'hasUnsatisfiedDependency' is called.
resolved fixed
96ebaae
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
"2013-01-21T18:46:15Z"
"2013-01-20T05:33:20Z"
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
} } public void tidyUp() { classPath.closeArchives(); typeMap.report(); typeMap.demote(true); } public JavaClass findClass(String className) { return lookupJavaClass(classPath, className); } public JavaClass loadClass(String className) throws ClassNotFoundException { return lookupJavaClass(classPath, className); } public void storeClass(JavaClass clazz) { } public void removeClass(JavaClass clazz) { throw new RuntimeException("Not implemented"); } public JavaClass loadClass(Class clazz) throws ClassNotFoundException { throw new RuntimeException("Not implemented"); } public void clear() { delegate.clear(); }