Protect your Java code with expiration dates.
Imagine this situation — you give a trial/demo of a product to a customer, yet you don't want them to use it indefinitely. That's where JTimeBomb comes in handy. You can give an expiration date to the code, so it cannot be run after a specified date has passed.
JTimeBomb can be used to easily include a proper time-bomb, instead of relying on a single utility method (that can be easily removed with a bit of tinkering) or manually repeating the same code multiple times.
This app works using pure bytecode transformations, providing way faster performance than standard annotation processing.
Only Java 21 (and beyond) is supported! I advise against using legacy Java versions.
Import the jtimebomb-annotations
library (for instructions, look at the next section), and add the necessary
annotations to methods that you want to be time-bombed.
import io.github.julwas797.jtimebomb.annotations.*;
class App {
@TimeBomb("2025-05-13T14:00")
public void doSomething() {
// Code here :)
}
}
The @TimeBomb
annotations uses ISO-8601 syntax for determining date.
After you've compiled the code run the jtimebomb-processor
tool, to automatically transform methods, such that
they’re now time-bombed. This tool uses the following syntax:
java -jar jtimebomb-processor.jar [input] [output]
The processor also removes the annotation using bytecode manipulations, so it's harder to trace it. It's also recommended to obfuscate the code beforehand. This greatly improves the effectiveness of this app. Some of the Java bytecode obfuscate tools include dProtect or yGuard.
-
Obtain the date by an NTP server(Users can define a customLocalDateTime
provider, and implement it using thetimeMethod
parameter) - Make a Gradle plugin
- Implement other types of time-bombs
- Incremental time-bombing (calculate time-delta at the time of processing)
This project is licensed under the MIT License. License doesn’t affect distributed JARs generated by the processor.