Re: custom Nano time provider

Thorsten via Concurrency-interest <[email protected]> Mon, 6 Apr 2020 12:53:04 +0200
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <[email protected]>
Hello

To expand on Peters answer: For testing purpose to get reproducible 
results you might to look into some mocking frameworks.

For example in jmockit i can just do this

final MockUp mockUp =new MockUp(System.class) {
     @Mock long nanoTime() {
         return 1234; }
}; System.out.println(" = " + System.nanoTime());

Boom custom nanoTime Provider.

Best regards,

Thorsten Goetzke

Am 06/04/2020 um 11:55 schrieb Peter Levart via Concurrency-interest:
> You could perhaps use bytecode instrumentation 
> (https://www.baeldung.com/java-instrumentation) to "patch" System 
> class and redirect/delegate it's execution to your custom time source.
>
> Peter
>
> On 4/5/20 1:23 PM, Francesco Nigro via Concurrency-interest wrote:
>> Hi folks,
>>
>> In the recent period I am working on some high availability solution 
>> in the project I currently work and I have noticed how is important 
>> for testing purposes to use custom System::currentTimeMillis and 
>> System::nanoTime providers to trigger specific reproducible 
>> conditions: there is any plan to allow something similar in some of 
>> the concurrent primitive that make uses of such functions?
>> I believe this could help both implementors and users.
>>
>>
>> Thanks,
>> Franz
>>
>> _______________________________________________
>> Concurrency-interest mailing list
>> [email protected]
>> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
> _______________________________________________
> Concurrency-interest mailing list
> [email protected]
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest

_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest