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

Will TimeMachine fail? #182

Closed
Dr-wgy opened this issue May 25, 2023 · 3 comments
Closed

Will TimeMachine fail? #182

Dr-wgy opened this issue May 25, 2023 · 3 comments
Labels
good first issue 👍 Good for newcomers question ❓ Further information is requested

Comments

@Dr-wgy Dr-wgy added the enhancement ⭐ New feature or request label May 25, 2023
@mr3
Copy link
Collaborator

mr3 commented May 30, 2023

Yep, arex-agent also encounters the same problem.

For program execution performance, we do not recommend disable Intrinsic by default.

Instead of enhancing java.lang.System::currentTimeMillis, we choose to enchance the following methods.

java.time.Instant
java.time.LocalDate
java.time.LocalTime
java.time.LocalDateTime
java.util.Date
java.util.Calendar
org.joda.time.DateTimeUtils
java.time.ZonedDateTime

Click me see the source code: TimeMachineModuleInstrumentation.java

@mr3 mr3 added good first issue 👍 Good for newcomers question ❓ Further information is requested and removed enhancement ⭐ New feature or request labels May 30, 2023
@lucas-myx
Copy link
Collaborator

@Dr-wgy
If you use the java. lang. System#currentTimeMillis method in your project, you can also solve this problem by adding dynamic classes on the configuration page: (Settings->Record->Advanced->Dynamic Classes)
currenttimemills-config

The principle is that arex-agent replaces the parts of your .Class that use java. lang. System#currentTimeMillis with arex's own currentTimeMillis method, thus avoiding the problem of directly modifying the java. lang. System#currentTimeMillis method and being optimized by JIT to be ineffective.

refer to:
DynamicClassInstrumentation#replaceMethod

@mr3
Copy link
Collaborator

mr3 commented Jun 19, 2023

@Dr-wgy Please reopen this issue if you have further questions.

@mr3 mr3 closed this as completed Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue 👍 Good for newcomers question ❓ Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants