-
Notifications
You must be signed in to change notification settings - Fork 344
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
added the static method check in INVOKESTATIC.java #501
base: master
Are you sure you want to change the base?
added the static method check in INVOKESTATIC.java #501
Conversation
Thank you for your pull request. I'm currently running the CI build to see the results on the CI server. |
Some of the tests are failing due to IST-related issues, and one of the tests, which I already mentioned in the description, is also failing |
The second added test case fails because the code runs normally. You can a regular dynamic method in a regular way, so the code in the test does not throw an exception. |
okay I will work on your suggested changes and will come back with the complete solution. |
package gov.nasa.jpf.jvm; import gov.nasa.jpf.util.test.TestJPF; public class InvokeStaticTest extends TestJPF {
} This is the test code I have added. Could you please review it and let me know where I might be going wrong? |
Hi, |
Hi, Thank you for the feedback. I understand now that using reflection to invoke a dynamic method with a null instance doesn't truly simulate a static method invocation. I'll look into JPF's method descriptors to see if there's a way to simulate this behavior directly, without modifying or recompiling the source code. I'll also explore any existing JPF test cases or listeners that could help with this. Thanks again for your guidance! |
What you could try to do is to change the STATIC modifier in the method descriptor that JPF uses: |
Thank you for the detailed suggestion. I understand the approach now: modifying the modifiers field in MethodInfo to toggle the STATIC flag at runtime using a native peer. I'll investigate how to make this change and see if I can access and modify the method descriptor dynamically as you suggested. I'll keep you updated on my progress. |
Hi, Now that my exams are behind me, I am committed to refocusing on the problem and catching up. Thank you for your understanding, and I truly appreciate your guidance and patience. |
What was fixed:
Static Method Check:
A check was added to INVOKESTATIC.java to verify if the method being invoked is static.
If the method is not static, the code now throws an IncompatibleClassChangeError, ensuring that incorrect method invocations are properly handled and aligned with JVM behavior.
Error Handling:
The system now correctly throws a java.lang.IncompatibleClassChangeError when a non-static method is invoked with the INVOKESTATIC instruction.
Tests Added:
Two tests were added to InvokeStaticTest.java to validate the changes made in INVOKESTATIC.java:
testInvokeStaticSuccess:
This test verifies that invoking a static method using INVOKESTATIC behaves correctly and does not throw any exceptions. Result: The test passed successfully, confirming that valid static method invocations work as expected.
testInvokeStaticFailure:
This test simulates an attempt to invoke a non-static method using INVOKESTATIC and ensures that JPF throws a java.lang.IncompatibleClassChangeError.
Result: The test failed with an AssertionError at InvokeStaticTest.java:33. This suggests that the current logic for detecting non-static method invocations with INVOKESTATIC requires further debugging or adjustments to correctly handle the failure scenario.
Test Summary:
Total tests: 2
Passed: 1 (testInvokeStaticSuccess)
Failed: 1 (testInvokeStaticFailure)