I do the clickety-clackety that make the computer go brrr
bnorm / auto-weave Goto Github PK
View Code? Open in Web Editor NEWAutoWeave generates AOP weaved classes using Java Annotation Processing
License: Apache License 2.0
AutoWeave generates AOP weaved classes using Java Annotation Processing
License: Apache License 2.0
I do the clickety-clackety that make the computer go brrr
It is possible to retrieve the target annotations via reflection but it would also (hopefully) be easy to generate the values into the static pointcut. However, we should be careful to only store those annotations that have a retention of source.
But, maybe this is all pointless and the advice writer should have to deal with it themselves? Is this feature creep? Since a single piece of advice can apply to many different target annotations, maybe this is worth it?
Even though it won't reduce the runtime dependencies by much, it is still a good idea to do so. This would allow extended dependencies in the compile time module without effecting the size of the runtime. It's also just a good practice being adopted by a lot of annotation processing libraries.
Singleton should only pull public static final fields. Not any field.
The Google Java format might be a good start:
https://github.com/google/google-java-format
https://github.com/HPI-Information-Systems/Metanome/wiki/Installing-the-google-styleguide-settings-in-intellij-and-eclipse
Right now, each aspect is an instance field in the weaved class. It should be possible to be defined as static or even a singleton somewhere.
Currently the Chain class is rethrowing the method exception as a runtime exception. It is expected by the generated code that this will be a MethodException. Maybe this is were the exception should be sneaky thrown? At the very least, it should be thrown as a MethodException.
The current implementation requires creating a lot of objects for each call to a weaved method. Use the following implementation design to reduce that number.
final class ManualWeave_Target extends Target {
private static final StaticPointcut methodPointcut = StaticPointcut.create("method",
Target.class,
String.class,
Arrays.<Class<?>>asList());
private final TraceAspect traceAspect = new TraceAspect();
private final Advice[] methodAdvice = new Advice[] {new AroundAdvice() {
@Override
public Object around(Tracer tracer) {
return traceAspect.around(tracer);
}
}, new AroundAdvice() {
@Override
public Object around(Tracer tracer) {
return traceAspect.around(tracer);
}
}, new AroundAdvice() {
@Override
public Object around(Tracer tracer) {
return traceAspect.around(tracer);
}
}};
public ManualWeave_Target() {
super();
}
@Override
@Trace
String method(int i) {
try {
return (String) new Tracer(methodAdvice, this, methodPointcut, i) {
@Override
protected Object call() throws Throwable {
return ManualWeave_Target.super.method(i);
}
}.proceed();
} catch (MethodException e) {
if (e.getCause() instanceof Error) {
throw (Error) e.getCause();
} else if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw new AssertionError("Please contact the library developer", e.getCause());
}
}
}
}
public abstract class Tracer { // implements all the joinpoints!
private final Advice[] advice;
private int index;
protected Tracer(Advice[] advice, Object target, StaticPointcut staticPointcut, Object... args) {
this.advice = advice;
this.index = 0;
}
public Object proceed() {
if (index < advice.length) {
return advice[index++].call(this);
} else {
try {
return call();
} catch (Throwable error) {
throw new RuntimeException(error);
}
}
}
protected abstract Object call() throws Throwable;
}
Probably the largest performance impact besides the chain class and stack navigation is the Arrays.asList() call for every method invocation. Maybe this should be an object array? This would mean that it is mutable and can be changed by advice. Does this matter? Is this a premature optimization?
Testing this project with android data binding revealed that the data binding objects were not being imported correctly. Probably need to delay generating until the second/third/etc round somehow.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.