soot-oss / soot

Soot - A Java optimization framework
GNU Lesser General Public License v2.1
2.87k stars 708 forks source link

VisibilityLocalVariableAnnotationTag should provide type information #1999

Open clearlove2077 opened 1 year ago

clearlove2077 commented 1 year ago

Describe the bug

I use soot to analyze some java programs, but it cannot provide detailed type information of VisibilityLocalVariableAnnotationTag. Considering the consistency between LocalVariableAnnotationTag and ParameterAnnotationTag, it also should provide type information. Please see the case below.

Input file

void method() {
    @A String s = new String();
}
package org.annotation;
@Retention(RUNTIME)
@Target({TYPE_USE})
@interface A {}

To reproduce

  1. Compile this source code file into bytecode;
  2. Use soot to analyze class file;
  3. We can find the AnnotationTag does not have accurate type information, like:
Visibility LocalVariable Annotation: num Annotation: 1 kind: 0
Visibility Annotation: level: RUNTIME (runtime-visible)
 Annotations:
Annotation type: (I)V without elements

Expected behavior

The document said LocalVariableAnnotationTag and ParameterAnnotationTag differ only in the type of marked object, but we can directly get the type information like Annotation type: Annotation type: Lorg/annotation/B; without elements (See the below code example).

package org.annotation;

@Retention(RUNTIME)
@Target({PARAMETER})
@interface B {}

void method(@B String s) {}

So, Soot should provide Lorg/annotation/A type information in the LocalVariableAnnotationTag.