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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | * @return the woven bytes
* @exception IOException weave failed
*/
public byte[] weaveClass(String name, byte[] bytes, boolean mustWeave) throws IOException {
if (trace == null) {
System.err
.println("AspectJ Weaver cannot continue to weave, static state has been cleared. Are you under Tomcat? In order to weave '"
+ name
+ "' during shutdown, 'org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false' must be set (see https:bugs.eclipse.org/bugs/show_bug.cgi?id=231945).");
return bytes;
}
if (weaverRunning.get()) {
return bytes;
}
try {
weaverRunning.set(true);
if (trace.isTraceEnabled()) {
trace.enter("weaveClass", this, new Object[] { name, bytes });
}
if (!enabled) {
if (trace.isTraceEnabled()) {
trace.exit("weaveClass", false);
}
return bytes;
}
boolean debugOn = !messageHandler.isIgnoring(Message.DEBUG);
try {
delegateForCurrentClass = null; |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | name = name.replace('/', '.');
if (couldWeave(name, bytes)) {
if (accept(name, bytes)) {
CachedClassReference cacheKey = null;
byte[] original_bytes = bytes;
if (cache != null && !mustWeave) {
cacheKey = cache.createCacheKey(name, bytes);
CachedClassEntry entry = cache.get(cacheKey);
if (entry != null) {
if (entry.isIgnored()) {
return bytes;
}
return entry.getBytes();
}
}
if (debugOn) {
debug("weaving '" + name + "'");
}
bytes = getWovenBytes(name, bytes); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | if (cacheKey != null) {
if (Arrays.equals(original_bytes, bytes)) {
cache.ignore(cacheKey);
} else {
cache.put(cacheKey, bytes);
}
}
} else if (debugOn) {
debug("not weaving '" + name + "'");
}
} else if (debugOn) {
debug("cannot weave '" + name + "'");
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | } finally {
delegateForCurrentClass = null;
}
if (trace.isTraceEnabled()) {
trace.exit("weaveClass", bytes);
}
return bytes;
} finally {
weaverRunning.set(false);
}
}
/**
* @param name
* @return true if even valid to weave: either with an accept check or to munge it for @AspectJ aspectof support
*/
private boolean couldWeave(String name, byte[] bytes) {
return !generatedClasses.containsKey(name) && shouldWeaveName(name);
}
protected boolean accept(String name, byte[] bytes) {
return true;
}
protected boolean shouldDump(String name, boolean before) {
return false;
}
private boolean shouldWeaveName(String name) {
if ("osj".indexOf(name.charAt(0)) != -1) {
if ((weavingSpecialTypes & INITIALIZED) == 0) {
weavingSpecialTypes |= INITIALIZED; |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | Properties p = weaver.getWorld().getExtraConfiguration();
if (p != null) {
boolean b = p.getProperty(World.xsetWEAVE_JAVA_PACKAGES, "false").equalsIgnoreCase("true");
if (b) {
weavingSpecialTypes |= WEAVE_JAVA_PACKAGE;
}
b = p.getProperty(World.xsetWEAVE_JAVAX_PACKAGES, "false").equalsIgnoreCase("true");
if (b) {
weavingSpecialTypes |= WEAVE_JAVAX_PACKAGE;
}
}
}
if (name.startsWith("org.aspectj.")) {
return false;
}
if (name.startsWith("sun.reflect.")) {
return false;
}
if (name.startsWith("javax.")) {
if ((weavingSpecialTypes & WEAVE_JAVAX_PACKAGE) != 0) {
return true;
} else {
if (!haveWarnedOnJavax) {
haveWarnedOnJavax = true;
warn("javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified");
}
return false;
}
}
if (name.startsWith("java.")) { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | if ((weavingSpecialTypes & WEAVE_JAVA_PACKAGE) != 0) {
return true;
} else {
return false;
}
}
}
return true;
}
/**
* We allow @AJ aspect weaving so that we can add aspectOf() as part of the weaving (and not part of the source compilation)
*
* @param name
* @param bytes bytecode (from classloader), allow to NOT lookup stuff on disk again during resolve
* @return true if @Aspect
*/
private boolean shouldWeaveAnnotationStyleAspect(String name, byte[] bytes) {
if (delegateForCurrentClass == null) {
ensureDelegateInitialized(name, bytes);
}
return (delegateForCurrentClass.isAnnotationStyleAspect());
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | protected void ensureDelegateInitialized(String name, byte[] bytes) {
if (delegateForCurrentClass == null) {
BcelWorld world = (BcelWorld) weaver.getWorld();
delegateForCurrentClass = world.addSourceObjectType(name, bytes, false);
}
}
/**
* Weave a set of bytes defining a class.
*
* @param name the name of the class being woven
* @param bytes the bytes that define the class
* @return byte[] the woven bytes for the class
* @throws IOException
*/
private byte[] getWovenBytes(String name, byte[] bytes) throws IOException {
WeavingClassFileProvider wcp = new WeavingClassFileProvider(name, bytes); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | weaver.weave(wcp);
return wcp.getBytes();
}
/**
* Weave a set of bytes defining a class for only what is needed to turn @AspectJ aspect in a usefull form ie with aspectOf
* method - see #113587
*
* @param name the name of the class being woven
* @param bytes the bytes that define the class
* @return byte[] the woven bytes for the class
* @throws IOException
*/
private byte[] getAtAspectJAspectBytes(String name, byte[] bytes) throws IOException {
WeavingClassFileProvider wcp = new WeavingClassFileProvider(name, bytes);
wcp.setApplyAtAspectJMungersOnly();
weaver.weave(wcp);
return wcp.getBytes();
}
private void registerAspectLibraries(List aspectPath) {
for (Iterator i = aspectPath.iterator(); i.hasNext();) {
String libName = (String) i.next();
addAspectLibrary(libName);
}
weaver.prepareForWeave();
}
/*
* Register an aspect library with this classloader for use during weaving. This class loader will also return (unmodified) any
* of the classes in the library in response to a <code>findClass()</code> request. The library is not required to be on the
* weavingClasspath given when this classloader was constructed. |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | *
* @param aspectLibraryJarFile a jar file representing an aspect library
*
* @throws IOException
*/
private void addAspectLibrary(String aspectLibraryName) {
File aspectLibrary = new File(aspectLibraryName);
if (aspectLibrary.isDirectory() || (FileUtil.isZipFile(aspectLibrary))) {
try {
info("adding aspect library: '" + aspectLibrary + "'");
weaver.addLibraryJarFile(aspectLibrary);
} catch (IOException ex) {
error("exception adding aspect library: '" + ex + "'");
}
} else {
error("bad aspect library: '" + aspectLibrary + "'");
}
}
private static List<String> makeClasspath(String cp) {
List<String> ret = new ArrayList<String>();
if (cp != null) {
StringTokenizer tok = new StringTokenizer(cp, File.pathSeparator);
while (tok.hasMoreTokens()) {
ret.add(tok.nextToken());
}
}
return ret;
}
protected boolean debug(String message) {
return MessageUtil.debug(messageHandler, message); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | }
protected boolean info(String message) {
return MessageUtil.info(messageHandler, message);
}
protected boolean warn(String message) {
return MessageUtil.warn(messageHandler, message);
}
protected boolean warn(String message, Throwable th) {
return messageHandler.handleMessage(new Message(message, IMessage.WARNING, th, null));
}
protected boolean error(String message) {
return MessageUtil.error(messageHandler, message);
}
protected boolean error(String message, Throwable th) {
return messageHandler.handleMessage(new Message(message, IMessage.ERROR, th, null));
}
public String getContextId() {
return "WeavingAdaptor";
}
/**
* Dump the given bytcode in _dump/... (dev mode)
*
* @param name
* @param b
* @param before whether we are dumping before weaving
* @throws Throwable
*/
protected void dump(String name, byte[] b, boolean before) {
String dirName = getDumpDir();
if (before) { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | dirName = dirName + File.separator + "_before";
}
String className = name.replace('.', '/');
final File dir;
if (className.indexOf('/') > 0) {
dir = new File(dirName + File.separator + className.substring(0, className.lastIndexOf('/')));
} else {
dir = new File(dirName);
}
dir.mkdirs();
String fileName = dirName + File.separator + className + ".class";
try {
FileOutputStream os = new FileOutputStream(fileName);
os.write(b);
os.close();
} catch (IOException ex) {
warn("unable to dump class " + name + " in directory " + dirName, ex);
}
}
/**
* @return the directory in which to dump - default is _ajdump but it
*/
protected String getDumpDir() {
return "_ajdump";
}
/**
* Processes messages arising from weaver operations. Tell weaver to abort on any message more severe than warning.
*/
protected class WeavingAdaptorMessageHolder extends MessageHandler { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | private IMessageHandler delegate;
private List<IMessage> savedMessages;
protected boolean traceMessages = Boolean.getBoolean(TRACE_MESSAGES_PROPERTY);
public WeavingAdaptorMessageHolder(PrintWriter writer) {
this.delegate = new WeavingAdaptorMessageWriter(writer);
super.dontIgnore(IMessage.WEAVEINFO);
}
private void traceMessage(IMessage message) { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | if (message instanceof WeaveMessage) {
trace.debug(render(message));
} else if (message.isDebug()) {
trace.debug(render(message));
} else if (message.isInfo()) {
trace.info(render(message));
} else if (message.isWarning()) {
trace.warn(render(message), message.getThrown());
} else if (message.isError()) {
trace.error(render(message), message.getThrown());
} else if (message.isFailed()) {
trace.fatal(render(message), message.getThrown());
} else if (message.isAbort()) {
trace.fatal(render(message), message.getThrown());
} else {
trace.error(render(message), message.getThrown());
}
}
protected String render(IMessage message) {
return "[" + getContextId() + "] " + message.toString();
}
public void flushMessages() {
if (savedMessages == null) {
savedMessages = new ArrayList<IMessage>();
savedMessages.addAll(super.getUnmodifiableListView());
clearMessages();
for (IMessage message : savedMessages) {
delegate.handleMessage(message);
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | }
public void setDelegate(IMessageHandler messageHandler) {
delegate = messageHandler;
}
/*
* IMessageHandler
*/
@Override
public boolean handleMessage(IMessage message) throws AbortException {
if (traceMessages) {
traceMessage(message);
}
super.handleMessage(message);
if (abortOnError && 0 <= message.getKind().compareTo(IMessage.ERROR)) {
throw new AbortException(message);
}
if (savedMessages != null) {
delegate.handleMessage(message);
}
return true; |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | }
@Override
public boolean isIgnoring(Kind kind) {
return delegate.isIgnoring(kind);
}
@Override
public void dontIgnore(IMessage.Kind kind) {
if (null != kind && delegate != null) {
delegate.dontIgnore(kind);
}
}
@Override
public void ignore(Kind kind) {
if (null != kind && delegate != null) {
delegate.ignore(kind);
}
}
/*
* IMessageHolder
*/
@Override
public List<IMessage> getUnmodifiableListView() {
List<IMessage> allMessages = new ArrayList<IMessage>();
allMessages.addAll(savedMessages);
allMessages.addAll(super.getUnmodifiableListView());
return allMessages;
}
}
protected class WeavingAdaptorMessageWriter extends MessageWriter { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | private final Set<IMessage.Kind> ignoring = new HashSet<IMessage.Kind>();
private final IMessage.Kind failKind;
public WeavingAdaptorMessageWriter(PrintWriter writer) {
super(writer, true);
ignore(IMessage.WEAVEINFO);
ignore(IMessage.DEBUG);
ignore(IMessage.INFO);
this.failKind = IMessage.ERROR;
}
@Override
public boolean handleMessage(IMessage message) throws AbortException {
super.handleMessage(message);
if (abortOnError && 0 <= message.getKind().compareTo(failKind)) {
throw new AbortException(message);
}
return true;
}
@Override
public boolean isIgnoring(Kind kind) {
return ((null != kind) && (ignoring.contains(kind)));
}
/**
* Set a message kind to be ignored from now on |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | */
@Override
public void ignore(IMessage.Kind kind) {
if ((null != kind) && (!ignoring.contains(kind))) {
ignoring.add(kind);
}
}
/**
* Remove a message kind from the list of those ignored from now on.
*/
@Override
public void dontIgnore(IMessage.Kind kind) {
if (null != kind) {
ignoring.remove(kind);
}
}
@Override
protected String render(IMessage message) {
return "[" + getContextId() + "] " + super.render(message);
}
}
private class WeavingClassFileProvider implements IClassFileProvider {
private final UnwovenClassFile unwovenClass;
private final List<UnwovenClassFile> unwovenClasses = new ArrayList<UnwovenClassFile>();
private IUnwovenClassFile wovenClass;
private boolean isApplyAtAspectJMungersOnly = false;
public WeavingClassFileProvider(String name, byte[] bytes) {
ensureDelegateInitialized(name, bytes);
this.unwovenClass = new UnwovenClassFile(name, delegateForCurrentClass.getResolvedTypeX().getName(), bytes);
this.unwovenClasses.add(unwovenClass); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | if (shouldDump(name.replace('/', '.'), true)) {
dump(name, bytes, true);
}
}
public void setApplyAtAspectJMungersOnly() {
isApplyAtAspectJMungersOnly = true;
}
public boolean isApplyAtAspectJMungersOnly() {
return isApplyAtAspectJMungersOnly;
}
public byte[] getBytes() {
if (wovenClass != null) {
return wovenClass.getBytes();
} else {
return unwovenClass.getBytes();
}
}
public Iterator<UnwovenClassFile> getClassFileIterator() {
return unwovenClasses.iterator();
}
public IWeaveRequestor getRequestor() {
return new IWeaveRequestor() {
public void acceptResult(IUnwovenClassFile result) {
if (wovenClass == null) {
wovenClass = result;
String name = result.getClassName();
if (shouldDump(name.replace('/', '.'), false)) {
dump(name, result.getBytes(), false);
}
} else { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | String className = result.getClassName();
generatedClasses.put(className, result);
generatedClasses.put(wovenClass.getClassName(), result);
generatedClassHandler.acceptClass(className, result.getBytes());
}
}
public void processingReweavableState() {
}
public void addingTypeMungers() {
}
public void weavingAspects() {
}
public void weavingClasses() {
}
public void weaveCompleted() {
if (delegateForCurrentClass != null) {
delegateForCurrentClass.weavingCompleted();
}
}
};
}
}
public void setActiveProtectionDomain(ProtectionDomain protectionDomain) {
activeProtectionDomain = protectionDomain;
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/CacheBacking.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;
/**
* Interface for the backing to the cache; usually a file,
* but could be an in-memory backing for testing.
* <p/>
* aspectj and jvmti provide no suitable guarantees
* on locking for class redefinitions, so every implementation
* must have a some locking mechanism to prevent invalid reads.
*/
public interface CacheBacking {
/**
* Return a list of keys which match the given
* regex. |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/CacheBacking.java | *
* @param regex
* @return
*/
public String[] getKeys(String regex);
/**
* Remove an entry from the cache
*
* @param ref
*/
public void remove(CachedClassReference ref);
/**
* Clear the entire cache
*/
public void clear();
/**
* Get a cache entry
*
* @param ref entry to retrieve
* @return the cached bytes or null, if the entry does not exist
*/
public CachedClassEntry get(CachedClassReference ref);
/**
* Put an entry in the cache
*
* @param entry key of the entry
*/
public void put(CachedClassEntry entry);
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/CacheStatistics.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;
/**
* Maintains some basic statistics on the class cache.
*/
public class CacheStatistics {
private volatile int hits;
private volatile int misses;
private volatile int weaved;
private volatile int generated;
private volatile int ignored;
private volatile int puts;
private volatile int puts_ignored;
public void hit() {
hits++;
}
public void miss() { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/CacheStatistics.java | misses++;
}
public void weaved() {
weaved++;
}
public void generated() {
generated++;
}
public void ignored() {
ignored++;
}
public void put() {
puts++;
}
public void putIgnored() {
puts_ignored++;
}
public int getHits() {
return hits;
}
public int getMisses() {
return misses;
}
public int getWeaved() {
return weaved;
}
public int getGenerated() {
return generated;
}
public int getIgnored() { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/CacheStatistics.java | return ignored;
}
public int getPuts() {
return puts;
}
public int getPutsIgnored() {
return puts_ignored;
}
public void reset() {
hits = 0;
misses = 0;
weaved = 0;
generated = 0;
ignored = 0;
puts = 0;
puts_ignored = 0;
}
public String toString() {
return "CacheStatistics{" +
"hits=" + hits +
", misses=" + misses +
", weaved=" + weaved +
", generated=" + generated +
", ignored=" + ignored +
", puts=" + puts +
", puts_ignored=" + puts_ignored +
'}';
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/CachedClassEntry.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;
/**
* Represents a class which has been cached
*/
public class CachedClassEntry {
enum EntryType {
GENERATED,
WEAVED, |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/CachedClassEntry.java | IGNORED,
}
private final CachedClassReference ref;
private final byte[] bytes;
private final EntryType type;
public CachedClassEntry(CachedClassReference ref, byte[] bytes, EntryType type) {
this.bytes = bytes;
this.ref = ref;
this.type = type;
}
public String getClassName() {
return ref.getClassName();
}
public byte[] getBytes() {
return bytes;
}
public String getKey() {
return ref.getKey();
}
public boolean isGenerated() {
return type == EntryType.GENERATED;
}
public boolean isWeaved() {
return type == EntryType.WEAVED;
}
public boolean isIgnored() {
return type == EntryType.IGNORED;
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/CachedClassReference.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;
/**
* A typed reference to a cached class entry. The key to any
* cache entry is a simple string, but that string may contain
* some specialized encoding. This class handles all of that
* encoding.
* <p/>
* External users of the cache should not be able to create these
* objects manually.
*/
public class CachedClassReference { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/CachedClassReference.java | enum EntryType {
GENERATED,
WEAVED,
IGNORED,
}
private final String key;
private final String className;
protected CachedClassReference(String key, CacheKeyResolver resolver) {
this.key = key;
this.className = resolver.keyToClass(key);
}
/**
* Protected to allow only the WeavedClassCache initialization rights
*
* @param key encoded key of the class
* @param className the classname
*/
protected CachedClassReference(String key, String className) {
this.key = key;
this.className = className;
}
public String getKey() {
return key;
}
public String getClassName() {
return className;
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultCacheFactory.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;
/**
* Default factory for creating the backing and resolving classes.
*/
public class DefaultCacheFactory implements CacheFactory {
public CacheKeyResolver createResolver() {
return new DefaultCacheKeyResolver();
}
public CacheBacking createBacking(String scope) {
return DefaultFileCacheBacking.createBacking(scope, createResolver());
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolver.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 java.math.BigInteger;
import java.net.URL; |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolver.java | import java.net.URLClassLoader;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.CRC32;
/**
* Naive default class and classloader hashing implementation useful
* for some multi-classloader environments.
* <p/>
* This implementation creates classloader scopes of the form:<br/>
* "ExampleClassLoaderName.[crc hash]"
* <p/>
* And weaved class keys of the form:<br/>
* "com.foo.BarClassName.[bytes len][crc].weaved"
* <p/>
* And generated class keys of the form:<br/>
* "com.foo.BarClassName$AjClosure.generated
*/
public class DefaultCacheKeyResolver implements CacheKeyResolver {
public static final String GENERATED_SUFFIX = ".generated";
public static final String WEAVED_SUFFIX = ".weaved";
/**
* Create a scope from a set of urls and aspect urls. Creates scope
* of the form "ExampleClassLoaderName.[md5sum]" or
* "ExampleClassLoaderName.[crc]"
*
* @param cl the classloader which uses the cache, can be null |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolver.java | * @param aspects the aspects
* @return a unique string for URLClassloaders, otherwise a non-unique classname
*/
public String createClassLoaderScope(ClassLoader cl, List<String> aspects) {
String name = cl != null ? cl.getClass().getSimpleName() : "unknown";
List<String> hashableStrings = new LinkedList<String>();
StringBuilder hashable = new StringBuilder(256);
if (cl != null && cl instanceof URLClassLoader) {
URL[] urls = ((URLClassLoader) cl).getURLs();
for (int i = 0; i < urls.length; i++) {
hashableStrings.add(urls[i].toString());
}
}
hashableStrings.addAll(aspects);
Collections.sort(hashableStrings);
for (Iterator<String> it = hashableStrings.iterator(); it.hasNext(); ) {
String url = it.next();
hashable.append(url);
}
String hash = null;
byte[] bytes = hashable.toString().getBytes();
hash = crc(bytes);
return name + '.' + hash;
}
private String crc(byte[] input) {
CRC32 crc32 = new CRC32();
crc32.update(input);
return String.valueOf(crc32.getValue());
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolver.java | public String getGeneratedRegex() {
return ".*" + GENERATED_SUFFIX;
}
public String getWeavedRegex() {
return ".*" + WEAVED_SUFFIX;
}
/**
* Converts a cache key back to a className
*
* @param key to convert
* @return className, e.g. "com.foo.Bar"
*/
public String keyToClass(String key) {
if (key.endsWith(GENERATED_SUFFIX)) {
return key.replaceAll(GENERATED_SUFFIX + "$", "");
}
if (key.endsWith(WEAVED_SUFFIX)) {
return key.replaceAll("\\.[^.]+" + WEAVED_SUFFIX, "");
}
return key;
}
public CachedClassReference weavedKey(String className, byte[] original_bytes) {
String hash = crc(original_bytes);
return new CachedClassReference(className + "." + hash + WEAVED_SUFFIX, className);
}
public CachedClassReference generatedKey(String className) {
return new CachedClassReference(className + GENERATED_SUFFIX, className);
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | 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
*******************************************************************************/
package org.aspectj.weaver.tools.cache; |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java | import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FileUtil;
import java.io.*;
import java.util.HashMap;
import java.util.zip.CRC32;
/**
* 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 implements CacheBacking {
public static final String WEAVED_CLASS_CACHE_DIR = "aj.weaving.cache.dir";
public static final String INDEX_FILE = "cache.idx";
public static class IndexEntry implements Serializable {
public String key;
public boolean generated;
public boolean ignored; |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java | public long crc;
}
private final File cacheDirectory;
private final CacheKeyResolver resolver;
private final HashMap<String, IndexEntry> index = new HashMap<String, IndexEntry>();
private static final Object LOCK = new Object();
protected DefaultFileCacheBacking(File cacheDirectory, CacheKeyResolver resolver) {
this.cacheDirectory = cacheDirectory;
this.resolver = resolver;
readIndex();
}
public static CacheBacking createBacking(File cacheDir, CacheKeyResolver resolver) {
if (!cacheDir.exists()) {
if (!cacheDir.mkdirs()) {
MessageUtil.error("Unable to create 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, resolver);
}
public static IndexEntry[] readIndex(File indexFile) {
IndexEntry[] iea = new IndexEntry[0];
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
if (!indexFile.canRead()) { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java | return iea;
}
fis = new FileInputStream(indexFile);
ois = new ObjectInputStream(fis);
iea = (IndexEntry[]) ois.readObject();
} catch (Exception e) {
delete(indexFile);
} finally {
close(fis, indexFile);
close(ois, indexFile);
}
return iea;
}
private void readIndex() {
synchronized (LOCK) {
IndexEntry[] idx = readIndex(new File(cacheDirectory, INDEX_FILE));
for (IndexEntry ie : idx) {
File cacheFile = new File(cacheDirectory, ie.key);
if (cacheFile.canRead() || ie.ignored) {
index.put(ie.key, ie);
}
}
}
}
private void writeIndex() {
synchronized (LOCK) {
if (!cacheDirectory.exists())
cacheDirectory.mkdirs();
File indexFile = new File(cacheDirectory, INDEX_FILE);
FileOutputStream fos = null; |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java | ObjectOutputStream oos = null;
try {
delete(indexFile);
fos = new FileOutputStream(indexFile);
oos = new ObjectOutputStream(fos);
oos.writeObject(index.values().toArray(new IndexEntry[0]));
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
close(fos, indexFile);
close(oos, indexFile);
}
}
}
private void removeIndexEntry(String key) {
synchronized (LOCK) {
index.remove(key);
writeIndex();
}
}
private void addIndexEntry(IndexEntry ie) {
synchronized (LOCK) {
index.put(ie.key, ie);
writeIndex();
}
}
public void clear() {
synchronized (LOCK) {
FileUtil.deleteContents(cacheDirectory);
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java | }
public static CacheBacking createBacking(String scope, CacheKeyResolver resolver) {
String cache = System.getProperty(WEAVED_CLASS_CACHE_DIR);
if (cache == null) {
return null;
}
File cacheDir = new File(cache, scope);
return createBacking(cacheDir, resolver);
}
public String[] getKeys(final String regex) {
File[] files = cacheDirectory.listFiles(new FilenameFilter() {
public boolean accept(File file, String s) {
if (s.matches(regex)) {
return true;
}
return false;
}
});
if (files == null) {
return new String[0];
}
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) {
IndexEntry ie = index.get(ref.getKey());
if (ie != null && ie.ignored) { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java | return new CachedClassEntry(ref, WeavedClassCache.ZERO_BYTES, CachedClassEntry.EntryType.IGNORED);
}
File cacheFile = new File(cacheDirectory, ref.getKey());
if (cacheFile.canRead()) {
if (ie == null) {
delete(cacheFile);
return null;
}
byte[] bytes = read(cacheFile, ie.crc);
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) {
File cacheFile = new File(cacheDirectory, entry.getKey());
if (!cacheFile.exists()) {
IndexEntry ie = new IndexEntry();
ie.key = entry.getKey();
ie.generated = entry.isGenerated();
ie.ignored = entry.isIgnored();
if (!entry.isIgnored()) {
ie.crc = write(cacheFile, entry.getBytes());
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java | addIndexEntry(ie);
}
}
public void remove(CachedClassReference ref) {
synchronized (LOCK) {
File cacheFile = new File(cacheDirectory, ref.getKey());
removeIndexEntry(ref.getKey());
delete(cacheFile);
}
}
protected byte[] read(File file, long expectedCRC) {
CRC32 checksum = new CRC32();
synchronized (LOCK) {
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
byte[] bytes = FileUtil.readAsByteArray(fis);
checksum.update(bytes);
if (checksum.getValue() == expectedCRC) {
return bytes;
}
} catch (FileNotFoundException e) {
MessageUtil.error("File not found " + file.getName());
} catch (IOException e) {
MessageUtil.error("Error reading cached class " + e.getLocalizedMessage());
} finally {
close(fis, file);
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java | delete(file);
}
return null;
}
protected long write(File file, byte[] bytes) {
if (file.exists()) {
return -1;
}
synchronized (LOCK) {
if (file.exists()) {
return -1;
}
OutputStream out = null;
ObjectOutputStream crcOut = null;
CRC32 checksum = new CRC32();
try {
out = new FileOutputStream(file);
out.write(bytes);
checksum.update(bytes);
return checksum.getValue();
} catch (FileNotFoundException e) {
MessageUtil.error("Error writing (File Not Found) " + file.getName() + ": " + e.getLocalizedMessage());
} catch (IOException e) {
MessageUtil.error("Error writing " + file.getName());
} finally {
close(out, file);
}
delete(file); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/DefaultFileCacheBacking.java | }
return -1;
}
protected static void delete(File file) {
if (file.exists()) {
file.delete();
}
}
protected static void close(OutputStream out, File file) {
if (out != null) {
try {
out.close();
} catch (IOException e) {
MessageUtil.error("Error closing write file " + file.getName());
}
}
}
protected static void close(InputStream in, File file) {
if (in != null) {
try {
in.close();
} catch (IOException e) {
MessageUtil.error("Error closing read file " + file.getName());
}
}
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/GeneratedCachedClassHandler.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 org.aspectj.weaver.tools.GeneratedClassHandler;
/**
* Handler for generated classes; such as Shadowed closures, etc. This wraps the normal
* generated class handler with caching
*/
public class GeneratedCachedClassHandler implements GeneratedClassHandler { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/GeneratedCachedClassHandler.java | private final WeavedClassCache cache;
private final GeneratedClassHandler nextGeneratedClassHandler;
public GeneratedCachedClassHandler(WeavedClassCache cache, GeneratedClassHandler nextHandler) {
this.cache = cache;
this.nextGeneratedClassHandler = nextHandler;
}
public void acceptClass(String name, byte[] bytes) {
CachedClassReference ref = cache.createGeneratedCacheKey(name.replace('/', '.'));
cache.put(ref, bytes);
if (nextGeneratedClassHandler != null) {
nextGeneratedClassHandler.acceptClass(name, bytes);
}
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/WeavedClassCache.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 org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.Message;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.weaver.tools.GeneratedClassHandler;
import java.util.LinkedList;
import java.util.List;
/**
* Manages a cache of weaved and generated classes similar to Eclipse Equinox,
* except designed to operate across multiple restarts of the JVM and with one
* cache per classloader; allowing URLClassLoaders with the same set of URI
* paths to share the same cache (with the default configuration).
* <p/>
* To enable the default configuration two system properties must be set:
* <pre>
* "-Daj.weaving.cache.enabled=true" |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/WeavedClassCache.java | * "-Daj.weaving.cache.dir=/some/directory"
* </pre>
* <p/>
* The class cache is often something that application developers or
* containers would like to manage, so there are a few interfaces for overriding the
* default behavior and performing other management functions.
* <p/>
* {@link CacheBacking} <br/>
* Provides an interface for implementing a custom backing store
* for the cache; The default implementation in {@link DefaultFileCacheBacking}
* provides a naive file-backed cache. An alternate implementation may ignore
* caching until signaled explicitly by the application, or only cache files
* for a specific duration. This class delegates the locking and synchronization
* requirements to the CacheBacking implementation.
* <p/>
* {@link CacheKeyResolver} <br/>
* Provides methods for creating keys from classes to be cached and for
* creating the "scope" of the cache itself for a given classloader and aspect
* list. The default implementation is provided by {@link DefaultCacheKeyResolver}
* but an alternate implementation may want to associate a cache with a particular
* application running underneath a container.
* <p/>
* This naive cache does not normally invalidate *any* classes; the interfaces above
* must be used to implement more intelligent behavior. Cache invalidation
* problems may occur in at least three scenarios:
* <pre>
* 1. New aspects are added dynamically somewhere in the classloader hierarchy; affecting
* other classes elsewhere.
* 2. Use of declare parent in aspects to change the type hierarchy; if the cache
* has not invalidated the right classes in the type hierarchy aspectj may not |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/WeavedClassCache.java | * be reconstruct the class incorrectly.
* 3. Similarly to (2), the addition of fields or methods on classes which have
* already been weaved and cached could have inter-type conflicts.
* </pre>
*/
public class WeavedClassCache {
public static final String WEAVED_CLASS_CACHE_ENABLED = "aj.weaving.cache.enabled";
private static CacheFactory DEFAULT_FACTORY = new DefaultCacheFactory();
public static final byte[] ZERO_BYTES = new byte[0];
private final IMessageHandler messageHandler;
private final GeneratedCachedClassHandler cachingClassHandler;
private final CacheBacking backing;
private final CacheStatistics stats;
private final CacheKeyResolver resolver;
private final String name;
private static final List<WeavedClassCache> cacheRegistry = new LinkedList<WeavedClassCache>();
protected WeavedClassCache(GeneratedClassHandler existingClassHandler,
IMessageHandler messageHandler,
String name,
CacheBacking backing,
CacheKeyResolver resolver) {
this.resolver = resolver;
this.name = name;
this.backing = backing;
this.messageHandler = messageHandler;
initializeGenerated(existingClassHandler);
cachingClassHandler = new GeneratedCachedClassHandler(this, existingClassHandler);
this.stats = new CacheStatistics();
synchronized (cacheRegistry) { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/WeavedClassCache.java | cacheRegistry.add(this);
}
}
/**
* Creates a new cache using the resolver and backing returned by the DefaultCacheFactory.
*
* @param loader classloader for this cache
* @param aspects list of aspects used by the WeavingAdapter
* @param existingClassHandler the existing GeneratedClassHandler used by the weaver
* @param messageHandler the existing messageHandler used by the weaver
* @return
*/
public static WeavedClassCache createCache(ClassLoader loader, List<String> aspects, GeneratedClassHandler existingClassHandler, IMessageHandler messageHandler) {
CacheKeyResolver resolver = DEFAULT_FACTORY.createResolver();
String name = resolver.createClassLoaderScope(loader, aspects);
if (name == null) {
return null;
}
CacheBacking backing = DEFAULT_FACTORY.createBacking(name);
if (backing != null) {
return new WeavedClassCache(existingClassHandler, messageHandler, name, backing, resolver);
}
return null;
}
public String getName() {
return name;
}
/**
* The Cache and be extended in two ways, through a specialized CacheKeyResolver and
* a specialized CacheBacking. The default factory used to create these classes can |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/WeavedClassCache.java | * be set with this method. Since each weaver will create a cache, this method must be
* called before the weaver is first initialized.
*
* @param factory
*/
public static void setDefaultCacheFactory(CacheFactory factory) {
DEFAULT_FACTORY = factory;
}
/**
* Created a key for a generated class
*
* @param className ClassName, e.g. "com.foo.Bar"
* @return the cache key, or null if no caching should be performed
*/
public CachedClassReference createGeneratedCacheKey(String className) {
return resolver.generatedKey(className);
}
/**
* Create a key for a normal weaved class
*
* @param className ClassName, e.g. "com.foo.Bar"
* @param originalBytes Original byte array of the class
* @return a cache key, or null if no caching should be performed
*/
public CachedClassReference createCacheKey(String className, byte[] originalBytes) {
return resolver.weavedKey(className, originalBytes);
}
/**
* Returns a generated class handler which wraps the handler this cache was initialized
* with; this handler should be used to make sure that generated classes are added |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/WeavedClassCache.java | * to the cache
*/
public GeneratedClassHandler getCachingClassHandler() {
return cachingClassHandler;
}
/**
* Has caching been enabled through the System property,
* WEAVED_CLASS_CACHE_ENABLED
*
* @return true if caching is enabled
*/
public static boolean isEnabled() {
return System.getProperty(WEAVED_CLASS_CACHE_ENABLED) != null;
}
/**
* Put a class in the cache
*
* @param ref reference to the entry, as created through createCacheKey
* @param weavedBytes bytes to cache
*/
public void put(CachedClassReference ref, byte[] weavedBytes) {
CachedClassEntry.EntryType type = CachedClassEntry.EntryType.WEAVED;
if (ref.getKey().matches(resolver.getGeneratedRegex())) {
type = CachedClassEntry.EntryType.GENERATED;
}
backing.put(new CachedClassEntry(ref, weavedBytes, type));
stats.put();
}
/**
* Get a cache value |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/WeavedClassCache.java | *
* @param ref reference to the cache entry, created through createCacheKey
* @return the CacheEntry, or null if no entry exists in the cache
*/
public CachedClassEntry get(CachedClassReference ref) {
CachedClassEntry entry = backing.get(ref);
if (entry == null) {
stats.miss();
} else {
stats.hit();
if (entry.isGenerated()) stats.generated();
if (entry.isWeaved()) stats.weaved();
if (entry.isIgnored()) stats.ignored();
}
return entry;
}
/**
* Put a cache entry to indicate that the class should not be
* weaved; the original bytes of the class should be used.
*
* @param ref
*/
public void ignore(CachedClassReference ref) {
stats.putIgnored();
backing.put(new CachedClassEntry(ref, ZERO_BYTES, CachedClassEntry.EntryType.IGNORED));
}
/**
* Invalidate a cache entry
*
* @param ref |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/WeavedClassCache.java | */
public void remove(CachedClassReference ref) {
backing.remove(ref);
}
/**
* Clear the entire cache
*/
public void clear() {
backing.clear();
}
/**
* Get the statistics associated with this cache, or
* null if statistics have not been enabled.
*
* @return
*/
public CacheStatistics getStats() {
return stats;
}
/**
* Return a list of all WeavedClassCaches which have been initialized
*
* @return
*/
public static List<WeavedClassCache> getCaches() {
synchronized (cacheRegistry) {
return new LinkedList<WeavedClassCache>(cacheRegistry);
}
}
/** |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/WeavedClassCache.java | * Get all generated classes which have been cached
*
* @return
*/
protected CachedClassEntry[] getGeneratedClasses() {
return getEntries(resolver.getGeneratedRegex());
}
/**
* Get all weaved classes which have been cached
*
* @return
*/
protected CachedClassEntry[] getWeavedClasses() {
return getEntries(resolver.getWeavedRegex());
}
/**
* For each cached, generated class, pass that class through the given
* GeneratedClassHandler, typically which defines that handler within the
* current ClassLoader.
*
* @param handler class handler
*/
private void initializeGenerated(GeneratedClassHandler handler) {
if (handler == null)
return;
CachedClassEntry[] classes = getGeneratedClasses();
for (CachedClassEntry entry : classes) {
handler.acceptClass(entry.getClassName(), entry.getBytes());
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/src/org/aspectj/weaver/tools/cache/WeavedClassCache.java | /**
* Gets an array of CacheClassEntries with the given regex
*
* @param regex filter
* @return array of entries
*/
protected CachedClassEntry[] getEntries(String regex) {
String[] keys = backing.getKeys(regex);
List<CachedClassEntry> entries = new LinkedList<CachedClassEntry>();
for (int i = 0; i < keys.length; i++) {
String key = keys[i];
CachedClassReference ref = new CachedClassReference(key, resolver);
CachedClassEntry entry = backing.get(ref);
if (entry != null) {
entries.add(entry);
}
}
return entries.toArray(new CachedClassEntry[entries.size()]);
}
protected void error(String message, Throwable th) {
messageHandler.handleMessage(new Message(message, IMessage.ERROR, th, null));
}
protected void error(String message) {
MessageUtil.error(messageHandler, message);
}
protected void info(String message) {
MessageUtil.info(message);
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | 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
*******************************************************************************/
package org.aspectj.weaver.tools.cache;
import junit.framework.TestCase;
import org.aspectj.util.FileUtil;
import java.io.File;
import java.util.zip.CRC32;
/**
*/
public class DefaultFileCacheBackingTest extends TestCase {
File root = null;
byte[] FAKE_BYTES = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
String FAKE_CLASS = "com.example.foo.Bar";
CacheKeyResolver resolver = new DefaultCacheKeyResolver();
CachedClassReference fakeRef = resolver.weavedKey(FAKE_CLASS, FAKE_BYTES);
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");
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultFileCacheBackingTest.java | }
public void tearDown() throws Exception {
FileUtil.deleteContents(root);
root = null;
}
public void testCreateBacking() throws Exception {
CacheBacking backing = DefaultFileCacheBacking.createBacking(root, resolver);
assertNotNull(backing);
assertTrue(root.exists());
assertTrue(root.isDirectory());
}
public void testClear() {
CacheBacking backing = DefaultFileCacheBacking.createBacking(root, resolver);
backing.put(new CachedClassEntry(fakeRef, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED));
assertNotNull(backing.get(fakeRef));
backing.clear();
assertNull(backing.get(fakeRef));
}
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, resolver);
backing.put(createTestEntry("apple"));
backing.put(createTestEntry("apply"));
backing.put(createTestEntry("orange"));
String[] matches = backing.getKeys("app.*");
assertEquals(2, matches.length);
matches = backing.getKeys("orange");
assertEquals(1, matches.length); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultFileCacheBackingTest.java | assertEquals("orange", matches[0]);
}
public void testPut() throws Exception {
CacheBacking backing = DefaultFileCacheBacking.createBacking(root, resolver);
backing.put(new CachedClassEntry(fakeRef, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED));
File cachedFile = new File(root, fakeRef.getKey());
assertTrue(cachedFile.exists());
assertTrue(cachedFile.isFile());
assertEquals(FAKE_BYTES.length, cachedFile.length());
}
private boolean indexEntryExists(String key, long expectedCRC) throws Exception {
long storedCRC = 0;
DefaultFileCacheBacking.IndexEntry[] index = DefaultFileCacheBacking.readIndex(new File(root, DefaultFileCacheBacking.INDEX_FILE));
if (index == null) {
throw new NullPointerException("No index at " + root.getAbsolutePath());
}
for (DefaultFileCacheBacking.IndexEntry ie : index) {
if (ie.key.equals(key)) {
storedCRC = ie.crc;
if (!ie.ignored) {
assertEquals(expectedCRC, storedCRC);
}
return true;
}
}
return false;
}
public void testGet() throws Exception {
CacheBacking backing = DefaultFileCacheBacking.createBacking(root, resolver);
assertNull(backing.get(fakeRef)); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultFileCacheBackingTest.java | backing.put(new CachedClassEntry(fakeRef, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED));
File cachedFile = new File(root, fakeRef.getKey());
assertTrue(cachedFile.isFile());
assertEquals(FAKE_BYTES.length, cachedFile.length());
CRC32 expectedCRC = new CRC32();
expectedCRC.update(FAKE_BYTES);
assertTrue(indexEntryExists(fakeRef.getKey(), expectedCRC.getValue()));
CachedClassEntry entry = backing.get(fakeRef);
assertEquals(FAKE_BYTES.length, entry.getBytes().length);
}
public void testRemove() throws Exception {
CacheBacking backing = DefaultFileCacheBacking.createBacking(root, resolver);
backing.put(new CachedClassEntry(fakeRef, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED));
File cachedFile = new File(root, fakeRef.getKey());
assertTrue(cachedFile.exists());
assertTrue(cachedFile.isFile());
CRC32 expectedCRC = new CRC32();
expectedCRC.update(FAKE_BYTES);
assertTrue(indexEntryExists(fakeRef.getKey(), expectedCRC.getValue()));
backing.remove(fakeRef);
cachedFile = new File(root, fakeRef.getKey());
assertFalse("CacheFile Still exists!" + cachedFile.getAbsolutePath(), cachedFile.exists());
assertFalse(cachedFile.isFile());
assertFalse(indexEntryExists(fakeRef.getKey(), expectedCRC.getValue()));
}
public void testMultiFile() throws Exception {
CachedClassEntry entry;
File cachedFile;
CRC32 expectedCRC = new CRC32();
expectedCRC.update(FAKE_BYTES); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/testsrc/org/aspectj/weaver/tools/cache/DefaultFileCacheBackingTest.java | CacheBacking backing = DefaultFileCacheBacking.createBacking(root, resolver);
CachedClassReference wref = resolver.weavedKey(FAKE_CLASS + "WEAVED", FAKE_BYTES);
entry = new CachedClassEntry(wref, FAKE_BYTES, CachedClassEntry.EntryType.WEAVED);
backing.put(entry);
cachedFile = new File(root, wref.getKey());
assertTrue(cachedFile.exists());
assertTrue(cachedFile.isFile());
assertTrue(indexEntryExists(wref.getKey(), expectedCRC.getValue()));
CachedClassReference gref = resolver.generatedKey(FAKE_CLASS + "GENERATED");
entry = new CachedClassEntry(gref, FAKE_BYTES, CachedClassEntry.EntryType.GENERATED);
backing.put(entry);
cachedFile = new File(root, gref.getKey());
assertTrue(cachedFile.exists());
assertTrue(cachedFile.isFile());
assertTrue(indexEntryExists(gref.getKey(), expectedCRC.getValue()));
CachedClassReference iref = resolver.generatedKey(FAKE_CLASS + "IGNORED");
entry = new CachedClassEntry(iref, FAKE_BYTES, CachedClassEntry.EntryType.IGNORED);
backing.put(entry);
cachedFile = new File(root, iref.getKey());
assertFalse(cachedFile.exists());
assertTrue(indexEntryExists(iref.getKey(), expectedCRC.getValue()));
backing.remove(wref);
backing.remove(gref);
backing.remove(iref);
}
} |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | 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 { |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | 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);
}
}
return matches.toArray(new String[0]);
}
public void remove(CachedClassReference ref) {
cache.remove(ref.getKey());
}
public void clear() {
cache.clear(); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/testsrc/org/aspectj/weaver/tools/cache/WeavedClassCacheTest.java | }
public CachedClassEntry get(CachedClassReference ref) {
return cache.get(ref.getKey());
}
public void put(CachedClassEntry entry) {
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 {
public int accepts = 0;
public List<String> classesISaw = new LinkedList<String>();
public void acceptClass(String name, byte[] bytes) {
accepts++;
classesISaw.add(name);
}
}
TestGeneratedClassHandler generatedClassHandler = new TestGeneratedClassHandler(); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/testsrc/org/aspectj/weaver/tools/cache/WeavedClassCacheTest.java | 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);
}
public void testExistingGeneratedClassesPassedThroughHandler() throws Exception {
String classA = "com.generated.A";
String classB = "com.generated.B";
reset();
memoryBacking.put(new CachedClassEntry(resolver.generatedKey(classA), FAKE_BYTES, CachedClassEntry.EntryType.GENERATED));
memoryBacking.put(new CachedClassEntry(resolver.generatedKey(classB), FAKE_BYTES, CachedClassEntry.EntryType.GENERATED));
createCache();
assertEquals(2, generatedClassHandler.accepts);
for (String cName : generatedClassHandler.classesISaw) {
assertTrue("Got: " + cName, cName.equals(classA) || cName.equals(classB));
}
}
public void testCache() throws Exception {
reset();
WeavedClassCache cache = createCache(); |
389,967 | Bug 389967 Weaved aspects mechanism does not take into account modified classes | The current caching mechanism assumes that if the same class is encountered then its cached weaved version can be used. However, the mechanism uses only the (fully qualified) class name to identify the class and does not take into account the fact that the class bytes may have changed (e.g., the user re-compiled and re-deployed some changes to the same class). | resolved fixed | 9a3cc2b | AspectJ | https://github.com/eclipse/org.aspectj | eclipse/org.aspectj | java | null | null | null | "2012-10-01T20:22:37Z" | "2012-09-20T05:46:40Z" | weaver/testsrc/org/aspectj/weaver/tools/cache/WeavedClassCacheTest.java | CacheStatistics stats = cache.getStats();
CachedClassReference ref = cache.createCacheKey(FAKE_CLASS, FAKE_BYTES);
assertNull(cache.get(ref));
cache.put(ref, FAKE_BYTES);
assertNotNull(cache.get(ref));
assertEquals(new String(FAKE_BYTES), new String(cache.get(ref).getBytes()));
assertEquals(1, cache.getWeavedClasses().length);
assertEquals(ref.getKey(), cache.getWeavedClasses()[0].getKey());
ref = cache.createGeneratedCacheKey(FAKE_CLASS);
assertNull(cache.get(ref));
cache.put(ref, FAKE_BYTES);
assertNotNull(cache.get(ref));
assertEquals(new String(FAKE_BYTES), new String(cache.get(ref).getBytes()));
assertEquals(1, cache.getGeneratedClasses().length);
assertEquals(ref.getKey(), cache.getGeneratedClasses()[0].getKey());
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));
cache.put(ref, FAKE_BYTES);
assertNotNull(cache.get(ref));
cache.remove(ref);
assertNull(cache.get(ref));
}
} |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.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 |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | * which accompanies this distribution and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.internal.tools.ant.taskdefs;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
/**
* Check that included .java files contain license and copyright strings for MPL 1.0 (default), Apache, or CPL. Use list="true" to
* get a list of known license variants {license}-{copyrightHolder} todo reimplement with regexp and jdiff FileLine utilities
*/
public class Checklics extends MatchingTask { |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | /*
* This does not enforce that copyrights are correct/current, only that they exist. E.g., the default behavior requires MPL but
* permits either Xerox or PARC copyright holders and any valid year.
*/
public static final String MPL_TAG = "mpl";
public static final String APACHE_TAG = "apache";
public static final String CPL_IBM_PARC_TAG = "cpl-ibm|parc";
public static final String CPL_IBM_TAG = "cpl-ibm";
public static final String MPL_XEROX_PARC_TAG = "mpl-parc|xerox";
public static final String MPL_ONLY_TAG = "mpl-only";
public static final String MPL_PARC_TAG = "mpl-parc";
public static final String PARC_COPYRIGHT_TAG = "parc-copy";
public static final String CPL_IBM_PARC_XEROX_TAG = "cpl-ibm|parc|xerox";
public static final String CPL_IBM_PARC_XEROX_OTHERS_TAG = "cpl-ibm|parc|xerox|others";
public static final String EPL_CPL_IBM_PARC_XEROX_OTHERS_TAG = "epl-cpl-ibm|parc|xerox|others";
public static final String DEFAULT = EPL_CPL_IBM_PARC_XEROX_OTHERS_TAG;
static final Map LICENSES;
static {
final String CONTRIBUTORS = "Contributors";
final String XEROX = "Xerox";
final String PARC = "Palo Alto Research Center";
final String APACHE = "The Apache Software Foundation";
final String IBM = "IBM";
final String IBM_LONG = "International Business Machines";
final String LIC_APL = "Apache Software Foundation (http://www.apache.org/)";
final String LIC_MPL = "http://aspectj.org/MPL/"; |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | final String LIC_CPL = "Eclipse Public License";
final String LIC_ECPL = " Public License";
License APL = new License(APACHE_TAG, LIC_APL, APACHE);
License MPL = new License(MPL_TAG, LIC_MPL, XEROX);
License MPL_XEROX_PARC = new License(DEFAULT, LIC_MPL, XEROX, PARC);
License CPL_IBM_PARC = new License(CPL_IBM_PARC_TAG, LIC_CPL, new String[] { IBM_LONG, IBM, PARC });
License CPL_IBM_PARC_XEROX = new License(CPL_IBM_PARC_XEROX_TAG, LIC_CPL, new String[] { IBM_LONG, IBM, PARC, XEROX });
License CPL_IBM_PARC_XEROX_OTHERS = new License(CPL_IBM_PARC_XEROX_OTHERS_TAG, LIC_CPL, new String[] { IBM_LONG, IBM, PARC,
XEROX, CONTRIBUTORS });
License EPL_CPL_IBM_PARC_XEROX_OTHERS = new License(EPL_CPL_IBM_PARC_XEROX_OTHERS_TAG, LIC_ECPL, new String[] { IBM_LONG,
IBM, PARC, XEROX, CONTRIBUTORS });
License CPL_IBM = new License(CPL_IBM_TAG, LIC_CPL, IBM, IBM_LONG);
License MPL_ONLY = new License(MPL_ONLY_TAG, LIC_MPL);
License MPL_PARC = new License(MPL_PARC_TAG, LIC_MPL, PARC);
License PARC_COPYRIGHT = new License(PARC_COPYRIGHT_TAG, null, PARC);
LICENSES = new Hashtable();
LICENSES.put(APL.tag, APL);
LICENSES.put(MPL.tag, MPL);
LICENSES.put(MPL_PARC.tag, MPL_PARC);
LICENSES.put(MPL_XEROX_PARC.tag, MPL_XEROX_PARC);
LICENSES.put(CPL_IBM_PARC.tag, CPL_IBM_PARC);
LICENSES.put(MPL_ONLY.tag, MPL_ONLY);
LICENSES.put(CPL_IBM.tag, CPL_IBM);
LICENSES.put(PARC_COPYRIGHT.tag, PARC_COPYRIGHT);
LICENSES.put(CPL_IBM_PARC_XEROX.tag, CPL_IBM_PARC_XEROX);
LICENSES.put(CPL_IBM_PARC_XEROX_OTHERS.tag, CPL_IBM_PARC_XEROX_OTHERS);
LICENSES.put(EPL_CPL_IBM_PARC_XEROX_OTHERS.tag, EPL_CPL_IBM_PARC_XEROX_OTHERS);
}
public static void main(String[] 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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | switch (args.length) {
case 1:
runDirect(args[0], null, false);
break;
case 2:
runDirect(args[0], args[1], false);
break;
default:
String options = "{replace-headers|get-years|list|{licenseTag}}";
System.err.println("java {me} sourcepath " + options);
break;
}
}
/**
* Run the license check directly
*
* @param sourcepaths String[] of paths to source directories
* @param license the String tag for the license, if any
* @param failonerror boolean flag to pass to Checklics
* @throws IllegalArgumentException if sourcepaths is empty
* @return total number of failed licenses
*/
public static int runDirect(String sourcepath, String license, boolean failonerror) {
if ((null == sourcepath) || (1 > sourcepath.length())) {
throw new IllegalArgumentException("bad sourcepath: " + sourcepath);
}
Checklics me = new Checklics();
Project p = new Project();
p.setName("direct interface to Checklics");
p.setBasedir("."); |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | me.setProject(p);
me.setFailOnError(failonerror);
me.setSourcepath(new Path(p, sourcepath));
if (null != license) {
if ("replace-headers".equals(license)) {
me.setReplaceheaders(true);
} else if ("get-years".equals(license)) {
me.setGetYears(true);
} else if ("list".equals(license)) {
me.setList(true);
} else {
me.setLicense(license);
}
}
me.execute();
return me.failed;
}
private Path sourcepath;
private License license;
private boolean list;
private String streamTag;
private boolean failOnError;
private boolean getYears;
private boolean replaceHeaders;
private int failed;
private int passed;
private boolean printDirectories;
public void setList(boolean list) {
this.list = list; |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | }
public void setPrintDirectories(boolean print) {
printDirectories = print;
}
/**
* When failOnError is true, if any file failed, throw BuildException listing number of files that file failed to pass license
* check
*
* @param fail if true, report errors by throwing BuildException
*/
public void setFailOnError(boolean fail) {
this.failOnError = fail;
}
public void setLicense(String tl) {
License input = (License) LICENSES.get(tl);
if (null == input) {
throw new BuildException("no license known for " + tl);
}
license = input;
}
public void setSourcepath(Path path) {
if (sourcepath == null) {
sourcepath = path;
} else {
sourcepath.append(path);
}
}
public Path createSourcepath() {
return sourcepath == null ? (sourcepath = new Path(project)) : sourcepath.createPath(); |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | }
public void setSourcepathRef(Reference id) {
createSourcepath().setRefid(id);
}
public void setOutputStream(String out) {
this.streamTag = out;
}
public void setReplaceheaders(boolean replaceHeaders) {
this.replaceHeaders = replaceHeaders;
}
public void setGetYears(boolean getYears) {
this.getYears = getYears;
}
public void execute() throws BuildException {
if (list) {
list();
} else if (replaceHeaders) {
replaceHeaders();
} else if (getYears) {
getYears();
} else {
checkLicenses();
}
}
private PrintStream getOut() {
return ("err".equals(streamTag) ? System.err : System.out);
}
interface FileVisitor { |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | void visit(File file);
}
private void visitAll(FileVisitor visitor) {
String[] dirs = sourcepath.list();
for (int i = 0; i < dirs.length; i++) {
File dir = project.resolveFile(dirs[i]);
String[] files = getDirectoryScanner(dir).getIncludedFiles();
for (int j = 0; j < files.length; j++) {
File file = new File(dir, files[j]);
String path = file.getPath();
if (path.endsWith(".java")) {
visitor.visit(file);
}
}
}
}
private void replaceHeaders() {
class YearVisitor implements FileVisitor { |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | public void visit(File file) {
HeaderInfo info = Header.checkFile(file);
if (!Header.replaceHeader(file, info)) {
throw new BuildException("failed to replace header for " + file + " using " + info);
}
}
}
visitAll(new YearVisitor());
}
private void getYears() {
final PrintStream out = getOut();
class YearVisitor implements FileVisitor {
public void visit(File file) {
HeaderInfo info = Header.checkFile(file);
out.println(info.toString());
}
}
visitAll(new YearVisitor());
}
private void checkLicenses() throws BuildException {
if (null == license) {
setLicense(DEFAULT);
}
final License license = this.license;
if (null == license) {
throw new BuildException("no license");
}
final PrintStream out = getOut();
class Visitor implements FileVisitor { |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | int failed = 0;
int passed = 0;
public void visit(File file) {
if (license.checkFile(file)) {
passed++;
} else {
failed++;
String path = file.getPath();
if (!license.foundLicense()) {
out.println(license.tag + " LICENSE FAIL: " + path);
}
if (!license.foundCopyright()) {
out.println(license.tag + " COPYRIGHT FAIL: " + path);
}
}
}
}
Visitor visitor = new Visitor();
visitAll(visitor);
this.failed = visitor.failed;
this.passed = visitor.passed;
if (0 < visitor.failed) {
getOut().println("Total passed: " + visitor.passed + (visitor.failed == 0 ? "" : " failed: " + visitor.failed)); |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | if (failOnError) {
throw new BuildException(failed + " files failed license check");
}
}
}
private void list() {
Iterator enu = LICENSES.keySet().iterator();
StringBuffer sb = new StringBuffer();
sb.append("known license keys:");
boolean first = true;
while (enu.hasNext()) {
sb.append((first ? " " : ", ") + enu.next());
if (first) {
first = false;
}
}
getOut().println(sb.toString());
}
/**
* Encapsulate license and copyright specifications to check files use hokey string matching.
*/
public static class License {
static final String[] YEARS =
new String[] { "2002 ", "2003 ", "2004 ", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2001 ", "2000 ",
"1999 " };
public final String tag;
public final String license;
private final String[] copyright;
private boolean gotLicense; |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | private boolean gotCopyright;
License(String tag, String license) {
this(tag, license, (String[]) null);
}
License(String tag, String license, String copyright) {
this(tag, license, new String[] { copyright });
}
License(String tag, String license, String copyright, String altCopyright) {
this(tag, license, new String[] { copyright, altCopyright });
}
License(String tag, String license, String[] copyright) {
this.tag = tag;
if ((null == tag) || (0 == tag.length())) {
throw new IllegalArgumentException("null tag");
}
this.license = license;
this.copyright = copyright;
}
public final boolean gotValidFile() {
return foundLicense() && foundCopyright();
}
public final boolean foundLicense() {
return ((null == license) || gotLicense);
}
public final boolean foundCopyright() {
return ((null == copyright) || gotCopyright);
}
public boolean checkFile(final File file) { |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | clear();
BufferedReader input = null;
int lineNum = 0;
try {
input = new BufferedReader(new FileReader(file));
String line;
while (!gotValidFile() && (line = input.readLine()) != null) {
lineNum++;
checkLine(line);
}
} catch (IOException e) {
System.err.println("reading line " + lineNum + " of " + file);
e.printStackTrace(System.err);
} finally {
if (null != input) {
try {
input.close();
} catch (IOException e) {
}
}
}
return gotValidFile();
}
public String toString() {
return tag;
}
private void checkLine(String line) {
if ((null == line) || (0 == line.length())) {
return; |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | }
if (!gotLicense && (null != license) && (-1 != line.indexOf(license))) {
gotLicense = true;
}
if (!gotCopyright && (null != copyright)) {
int loc;
for (int j = 0; !gotCopyright && (j < YEARS.length); j++) {
if (-1 != (loc = line.indexOf(YEARS[j]))) {
loc += YEARS[j].length();
String afterLoc = line.substring(loc).trim();
for (int i = 0; !gotCopyright && (i < copyright.length); i++) {
if (0 == afterLoc.indexOf(copyright[i])) {
gotCopyright = true;
}
}
}
}
}
}
private void clear() {
if (gotLicense) {
gotLicense = false;
}
if (gotCopyright) {
gotCopyright = false;
}
}
}
}
class HeaderInfo { |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | public final File file;
public final List years;
public final int lastLine;
public final boolean hasLicense;
public HeaderInfo(File file, int lastLine, List years, boolean hasLicense) {
this.lastLine = lastLine;
this.file = file;
this.hasLicense = hasLicense;
List newYears = new ArrayList();
newYears.addAll(years);
Collections.sort(newYears);
this.years = Collections.unmodifiableList(newYears);
if ((null == file) || !file.canWrite()) {
throw new IllegalArgumentException("bad file: " + this);
}
if (!hasLicense) {
if ((0 > lastLine) || (65 < lastLine)) {
throw new IllegalArgumentException("bad last line: " + this);
}
} else {
if ((null == years) || (1 > years.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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | throw new IllegalArgumentException("no years: " + this);
}
if ((20 > lastLine) || (65 < lastLine)) {
throw new IllegalArgumentException("bad last line: " + this);
}
}
}
public String toString() {
return file.getPath() + ":" + lastLine + " " + years;
}
public void writeHeader(PrintWriter writer) {
if (!hasLicense) {
writer.println(TOP);
writer.println(PARC_ONLY);
writeRest(writer);
} else {
final int size = years.size();
if (1 > size) {
throw new Error("no years found in " + toString());
}
String first = (String) years.get(0);
String last = (String) years.get(size - 1);
boolean lastIs2002 = "2002".equals(last);
String xlast = last;
if (lastIs2002) {
xlast = (String) (size > 1 ? years.get(size - 2) : null);
if (first.equals(xlast) && !"2001".equals(xlast)) {
xlast = "2001";
} |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | }
String xyears = first + "-" + xlast;
if (first.equals(last)) {
xyears = first;
}
writer.println(TOP);
if (!lastIs2002) {
writer.println(XEROX_PREFIX + xyears + XEROX_SUFFIX + ". ");
} else if (size == 1) {
writer.println(PARC_ONLY);
} else {
writer.println(XEROX_PREFIX + xyears + XEROX_SUFFIX + ", ");
writer.println(PARC);
}
writeRest(writer);
}
}
void writeRest(PrintWriter writer) {
writer.println(" * All rights reserved. ");
writer.println(" * This program and the accompanying materials are made available ");
writer.println(" * under the terms of the Eclipse Public License v1.0 ");
writer.println(" * which accompanies this distribution and is available at ");
writer.println(" * http://www.eclipse.org/legal/epl-v10.html ");
writer.println(" * ");
writer.println(" * Contributors: ");
writer.println(" * Xerox/PARC initial implementation ");
writer.println(" * ******************************************************************/");
writer.println("");
}
public static final String TOP = "/* *******************************************************************"; |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | public static final String PARC = " * 2002 Palo Alto Research Center, Incorporated (PARC).";
public static final String PARC_ONLY = " * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).";
public static final String XEROX_PREFIX = " * Copyright (c) ";
public static final String XEROX_SUFFIX = " Xerox Corporation";
/*
* /* ******************************************************************* Copyright (c) 1998-2001 Xerox Corporation, 2002 Palo
* Alto Research Center, Incorporated (PARC). All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which accompanies this distribution and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Xerox/PARC initial implementation ******************************************************************
*/
}
/**
* header search/replace using hokey string matching
*/
class Header {
public static boolean replaceHeader(File file, HeaderInfo info) {
BufferedReader input = null;
PrintWriter output = null;
FileWriter outWriter = null;
int lineNum = 0;
boolean result = false;
final File inFile = new File(file.getPath() + ".tmp");
try {
File outFile = new File(file.getPath());
if (!file.renameTo(inFile) || !inFile.canRead()) { |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | throw new Error("unable to rename " + file + " to " + inFile);
}
outWriter = new FileWriter(outFile);
input = new BufferedReader(new FileReader(inFile));
output = new PrintWriter(outWriter, true);
info.writeHeader(output);
String line;
while (null != (line = input.readLine())) {
lineNum++;
if (lineNum > info.lastLine) {
output.println(line);
}
}
} catch (IOException e) {
System.err.println("writing line " + lineNum + " of " + file);
e.printStackTrace(System.err);
result = false;
} finally {
if (null != input) {
try {
input.close();
} catch (IOException e) {
result = false;
}
}
if (null != outWriter) {
try {
outWriter.close();
} catch (IOException e) {
result = 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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | }
}
result = inFile.delete();
}
return result;
}
public static HeaderInfo checkFile(final File file) {
ArrayList years = new ArrayList();
int endLine = 0;
BufferedReader input = null;
int lineNum = 0;
try {
input = new BufferedReader(new FileReader(file));
String line;
while (null != (line = input.readLine())) {
lineNum++;
String ll = line.trim();
if (ll.startsWith("package ") || ll.startsWith("import ")) {
break;
}
if (checkLine(line, years)) {
endLine = lineNum;
break;
}
}
} catch (IOException e) {
System.err.println("reading line " + lineNum + " of " + file);
e.printStackTrace(System.err);
} finally {
if (null != input) { |
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" | build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | try {
input.close();
} catch (IOException e) {
}
}
}
return new HeaderInfo(file, endLine, years, endLine > 0);
}
/**
* Add any years found (as String) to years, and return true at the first end-of-comment
*
* @return true if this line has end-of-comment
*/
private static boolean checkLine(String line, ArrayList years) {
if ((null == line) || (0 == line.length())) {
return false;
}
int loc;
int start = 0;
while ((-1 != (loc = line.indexOf("199", start)) || (-1 != (loc = line.indexOf("200", start))))) {
char c = line.charAt(loc + 3);
if ((c <= '9') && (c >= '0')) {
years.add(line.substring(loc, loc + 4));
}
start = loc + 4;
}
return (-1 != line.indexOf("*/"));
}
} |
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 | /* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available |
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 | * under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http:www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.util;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.security.PrivilegedActionException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
/**
*
*/
public class LangUtil { |
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 final String EOL;
private static double vmVersion;
static {
StringWriter buf = new StringWriter();
PrintWriter writer = new PrintWriter(buf);
writer.println("");
String eol = "\n";
try {
buf.close();
StringBuffer sb = buf.getBuffer();
if (sb != null) {
eol = buf.toString();
}
} catch (Throwable t) {
}
EOL = eol;
}
static {
try {
String vm = System.getProperty("java.version");
if (vm == null) {
vm = System.getProperty("java.runtime.version");
}
if (vm == null) {
vm = System.getProperty("java.vm.version");
} |
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 (vm == null) {
new RuntimeException(
"System properties appear damaged, cannot find: java.version/java.runtime.version/java.vm.version")
.printStackTrace(System.err);
vmVersion = 1.5;
} else {
try {
String versionString = vm.substring(0, 3);
Double temp = new Double(Double.parseDouble(versionString));
vmVersion = temp.floatValue();
} catch (Exception e) {
vmVersion = 1.4;
}
}
} catch (Throwable t) {
new RuntimeException(
"System properties appear damaged, cannot find: java.version/java.runtime.version/java.vm.version", t)
.printStackTrace(System.err);
vmVersion = 1.5;
}
}
public static boolean is13VMOrGreater() {
return 1.3 <= vmVersion;
}
public static boolean is14VMOrGreater() {
return 1.4 <= vmVersion;
}
public static boolean is15VMOrGreater() {
return 1.5 <= vmVersion;
} |
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 boolean is16VMOrGreater() {
return 1.6 <= vmVersion;
}
public static boolean is17VMOrGreater() {
return 1.7 <= vmVersion;
}
/**
* Shorthand for "if null, throw IllegalArgumentException"
*
* @throws IllegalArgumentException "null {name}" if o is null
*/
public static final void throwIaxIfNull(final Object o, final String name) {
if (null == o) {
String message = "null " + (null == name ? "input" : name);
throw new IllegalArgumentException(message);
}
}
/**
* Shorthand for "if not null or not assignable, throw IllegalArgumentException"
*
* @param c the Class to check - use null to ignore type check
* @throws IllegalArgumentException "null {name}" if o is null
*/
public static final void throwIaxIfNotAssignable(final Object ra[], final Class<?> c, final String name) {
throwIaxIfNull(ra, name);
String label = (null == name ? "input" : name);
for (int i = 0; i < ra.length; i++) {
if (null == ra[i]) {
String m = " null " + label + "[" + i + "]";
throw new IllegalArgumentException(m); |
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 | } else if (null != c) {
Class<?> actualClass = ra[i].getClass();
if (!c.isAssignableFrom(actualClass)) {
String message = label + " not assignable to " + c.getName();
throw new IllegalArgumentException(message);
}
}
}
}
/**
* Shorthand for "if not null or not assignable, throw IllegalArgumentException"
*
* @throws IllegalArgumentException "null {name}" if o is null
*/
public static final void throwIaxIfNotAssignable(final Object o, final Class<?> c, final String name) {
throwIaxIfNull(o, name);
if (null != c) {
Class<?> actualClass = o.getClass();
if (!c.isAssignableFrom(actualClass)) {
String message = name + " not assignable to " + c.getName();
throw new IllegalArgumentException(message);
}
}
}
/**
*/ |
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 | }
}
}
/**
* Shorthand for "if false, throw IllegalArgumentException"
*
* @throws IllegalArgumentException "{message}" if test is false
*/
public static final void throwIaxIfFalse(final boolean test, final String message) {
if (!test) {
throw new IllegalArgumentException(message);
}
}
}
public static boolean isEmpty(String s) {
return ((null == s) || (0 == s.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 | public static boolean isEmpty(Object[] ra) {
return ((null == ra) || (0 == ra.length));
}
public static boolean isEmpty(Collection<?> collection) {
return ((null == collection) || (0 == collection.size()));
}
public static boolean isEmpty(Map<?,?> map) {
return ((null == map) || (0 == map.size()));
}
/**
* Splits <code>text</code> at whitespace.
*
* @param text <code>String</code> to split.
*/
public static String[] split(String text) {
return (String[]) strings(text).toArray(new String[0]);
}
/**
* Splits <code>input</code> at commas, trimming any white space.
*
* @param input <code>String</code> to split.
* @return List of String of elements.
*/
public static List<String> commaSplit(String input) {
return anySplit(input, ",");
}
/**
* Split string as classpath, delimited at File.pathSeparator. Entries are not trimmed, but empty entries are ignored. |
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 classpath the String to split - may be null or empty
* @return String[] of classpath entries
*/
public static String[] splitClasspath(String classpath) {
if (LangUtil.isEmpty(classpath)) {
return new String[0];
}
StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator);
ArrayList<String> result = new ArrayList<String>(st.countTokens());
while (st.hasMoreTokens()) {
String entry = st.nextToken();
if (!LangUtil.isEmpty(entry)) {
result.add(entry);
}
}
return (String[]) result.toArray(new String[0]);
}
/**
* Get System property as boolean, but use default value where the system property is not set.
*
* @return true if value is set to true, false otherwise
*/
public static boolean getBoolean(String propertyName, boolean defaultValue) {
if (null != propertyName) {
try {
String value = System.getProperty(propertyName);
if (null != value) {
return Boolean.valueOf(value).booleanValue();
} |
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 | } catch (Throwable t) {
}
}
return defaultValue;
}
/**
* Splits <code>input</code>, removing delimiter and trimming any white space. Returns an empty collection if the input is null.
* If delimiter is null or empty or if the input contains no delimiters, the input itself is returned after trimming white
* space.
*
* @param input <code>String</code> to split.
* @param delim <code>String</code> separators for input.
* @return List of String of elements.
*/
public static List<String> anySplit(String input, String delim) {
if (null == input) {
return Collections.emptyList();
}
ArrayList<String> result = new ArrayList<String>();
if (LangUtil.isEmpty(delim) || (-1 == input.indexOf(delim))) {
result.add(input.trim());
} else {
StringTokenizer st = new StringTokenizer(input, delim);
while (st.hasMoreTokens()) {
result.add(st.nextToken().trim());
}
}
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 | /**
* Splits strings into a <code>List</code> using a <code>StringTokenizer</code>.
*
* @param text <code>String</code> to split.
*/
public static List<String> strings(String text) {
if (LangUtil.isEmpty(text)) {
return Collections.emptyList();
}
List<String> strings = new ArrayList<String>();
StringTokenizer tok = new StringTokenizer(text);
while (tok.hasMoreTokens()) {
strings.add(tok.nextToken());
}
return strings;
}
public static <T> List<T> safeList(List<T> list) {
return (null == list ? Collections.<T>emptyList() : Collections.unmodifiableList(list));
}
/**
*/ |
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 | }
/**
*/
}
}
}
}
}
/**
* copy non-null two-dimensional String[][]
*
* @see extractOptions(String[], String[][]) |