aionnetwork / AVM

Enabling Java code to run in a blockchain environment
https://theoan.com/
MIT License
49 stars 25 forks source link

Add TimeUnit to shadow class library #332

Closed aionick closed 5 years ago

aionick commented 5 years ago

The TimeUnit class provides contracts with a more descriptive way of talking about time, rather than arbitrarily hard-coding numbers, and duration is a not uncommon feature that smart contracts need to make use of in certain cases.

The class has some unwanted functionality that needs to be removed for our scope, but in general is probably the most elegant means of talking about time that Java provides.

jeff-aion commented 5 years ago

The version of this defined by the JDK is found here: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/TimeUnit.html

I suspect that we want to implement this but exclude methods which reference ChronoUnit or thread interactions. Specifically, this would mean removing of(ChronoUnit), sleep(long), timedJoin(Thread, long), timedWait(Object, long), and toChronoUnit(). I suspect that the other JDK10 methods should be included.