Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPF seems unable to handle local variable annotations #6

Closed
y553546436 opened this issue Jul 19, 2021 · 1 comment
Closed

JPF seems unable to handle local variable annotations #6

y553546436 opened this issue Jul 19, 2021 · 1 comment

Comments

@y553546436
Copy link
Owner

y553546436 commented Jul 19, 2021

I added the logic to print local variable annotation information in the JPF listener and tried to run something like this in JPF:

public static void main(String[] args) {
  @BitFlip int a;
  int a=0;
}

The result shows that there is no AnnotationInfo for this local variable a. Therefore, our @bitflip annotation cannot work with local variables now.

@y553546436
Copy link
Owner Author

The problem is not with JPF, but it is because that "Local variable annotations are not retained in class files (or at runtime) regardless of the retention policy set on the annotation type." (from eclipse doc), which means any bytecode analyzer cannot process the local variable annotations. The local variable annotations are designed mainly for checking at compilation time.
A workaround could be to annotate the local variables with type annotations, which is retained in the bytecode.

y553546436 added a commit that referenced this issue Sep 15, 2021
… Java programs. (javapathfinder#295)

* add BitFlip annotation for parameters, fields and local variables

* faulty implementation of getBitFlip API

* Address the getBitFlip API issue by (1) moving the logic of choosing flipping positions to Java level and (2) call getInt__II__I only once in MJI level and decode.
I keep the code of both approaches in Verify.java and JPF_gov_nasa_jpf_vm_Verify.java respectively. The one that takes effect for now is (2) in JPF_gov_nasa_jpf_vm_Verify.java, because with getBitFlip__JII__J method in JPF_gov_nasa_jpf_vm_Verify.java, JPF will execute getBitFlip__JII__J instead of getBitFlip in Verify.java.

* explicitly limit up to 7 bits to flip, add more comment to explain the code

* add local Example repository to JPF classpath in jpf.properties

* add Verify.getBitFlip API for double, float and boolean typed variables

* faulty implementation of bit flips for annotated arguments

* move the examples into this repo

* give the ChoiceGenerator of getBitFlip a unique String id

* change the AnnotationSimpleExample to flip 2 bits; remove faulty implementation of parameter bit flips in JVMStackFrame.java

* add listener-based parameter bit flip implementation

* clear the lastFlippedBits entry after exploring all choices

* delete deprecated example classes in src/tests

* add JPF test class BitFlipTest.java to test getBitFlip API and @bitflip annotation

* address issue #4

* refactor the code, move certain part of code out of BitFlipListener to StackFrame and Types, which can hopefully reduce code duplication later

* partly resolve #5: add implementation for local variable and field annotations, but JPF cannot parse local variables internally; add tests for field annotations in BitFlipTest

* uncomment the testLocalVariableBitFlip test, and annotate it with @ignore

* resolve #6 by annotating local variables with type annotations

* resolve #7 : add support for command line specified bit flips for fields, parameters and local variables; add tests for them in BitFlipTest.java

* add more comment; add license for new files; clean unnessary changes; move the examples out

* resolve issue #9: add 5 more complex tests for bit flips

* small changes to some comments and variable/method names

* change the new files to use the JPF Apache License
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant