有没有人有java注释"java.lang.Synthetic“的背景。我在列出JavaEE企业应用程序中出现的注解时遇到了这个问题。该注释出现在com.sun.xml包中的几个类上。我没有找到关于这个注解的文档。它是正式的注解吗,比如说,由java编译器产生来指示合成访问器(例如,参见Synthetic accessor method warning)?这似乎不太可能,因为没有可用的文档。但是,"java.lang“包中的位置使注释看起来有点正式。
发布于 2013-09-13 07:54:19
也许这就是你要找的?
http://javapapers.com/core-java/java-synthetic-class-method-field/
发布于 2013-09-17 04:00:52
仔细阅读ASM,就会发现这是ASM添加的一个“虚拟”参数注释。
请参见:
http://asm.ow2.org/index.html
http://websvn.ow2.org/filedetails.php?repname=asm&path=%2Ftrunk%2Fasm%2Fsrc%2Forg%2Fobjectweb%2Fasm%2FClassReader.java
通过以下方式:
private void readParameterAnnotations(int v, final String desc,
final char[] buf, final boolean visible, final MethodVisitor mv) {
int i;
int n = b[v++] & 0xFF;
// workaround for a bug in javac (javac compiler generates a parameter
// annotation array whose size is equal to the number of parameters in
// the Java source file, while it should generate an array whose size is
// equal to the number of parameters in the method descriptor - which
// includes the synthetic parameters added by the compiler). This work-
// around supposes that the synthetic parameters are the first ones.
int synthetics = Type.getArgumentTypes(desc).length - n;
AnnotationVisitor av;
for (i = 0; i < synthetics; ++i) {
// virtual annotation to detect synthetic parameters in MethodWriter
av = mv.visitParameterAnnotation(i, "Ljava/lang/Synthetic;", false);
if (av != null) {
av.visitEnd();
}
}
for (; i < n + synthetics; ++i) {
int j = readUnsignedShort(v);
v += 2;
for (; j > 0; --j) {
av = mv.visitParameterAnnotation(i, readUTF8(v, buf), visible);
v = readAnnotationValues(v + 2, buf, true, av);
}
}
}https://stackoverflow.com/questions/18769282
复制相似问题