www.cs.helsinki.fi/u/pohjalai/
이 논문은 Byte code에 대한 dynamic instrumentation 방법에 대해서 설명한다. 주요 내용으로 2.2장에서 Aspect-oriented programming에 대한 설명을 한다. 내용은 아래와 같다.
A core problem that AOP is trying to solve is that modern object-oriented systems often have code that handles mutiple concerns (along with the core concern, i.e. the business logic itself) on the same level of code. Typical examples of such concerns are security, logging and transaction handling. AOP tries to extract and separate these so-called cross-cutting concerns into reusable aspects that are implemented in one place and then used all around the codebase.
이것을 설명하는 이유를 정확히는 모르겠다. ㅡ.ㅡ 아마도 이 또한 dynamic binding 형태를 가지고 있기 때문이 아닌가 생각을 해 보았다. (논문에서는 구체적인 설명을 하지 않았다.)
ASM 에 대해서 설명을 한다. 이 부분이 논문의 주요 내용인 듯 하다. 그러나 visitor pattern기반의 사용방법 정도에 국한되어 있다.
...
a widely adopted Java bytecode manipulation framework
...
그리고 ASM기반 어떻게 dynamic bytecode instrumentation을 수행할 수 있을지 설명한다. 기본적인 방법은 Visitor pattern을 기반으로 한다. 그 예는 아래와 같다.
byte[] originalBytecode = ...;
ClassWriter writer = new ClassWriter(true);
ProfilerVisitor visitor = new ProfilerVisitor(writer);
ClassReader reader = new ClassReader(originalBytecode);
reader.accept(visitor, false);
byte[] instrumentedBytecode = writer.toByteArrary();
Java 1.5.0 이상에서는 java.lang.instrument 라는 package를 제공한다. 그리고 이것에서 제공되는 class들을 상속받아 instrumentation방안을 구현할 수 있는 듯 하다.
'잡담' 카테고리의 다른 글
Test Code Generator (0) | 2008.07.27 |
---|---|
Hyper-Threading Technology (0) | 2008.07.19 |
multi-core관련 (0) | 2008.06.15 |
For a good presentation (0) | 2008.06.12 |
Condition/Decision Coverage (0) | 2008.04.23 |