Skip to content
This repository has been archived by the owner on Oct 6, 2018. It is now read-only.
/ redprecursor Public archive

Access and modify your code before it will be transformed to bytecode by the compiler without AspectJ.

Notifications You must be signed in to change notification settings

echocat/redprecursor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

echocat RedPrecursor

The initial focus was to create a DBC-framework without the requirement of an Java-Agent or AspectJ. The result is a Annoation Processor for javac which get the parsed node tree after the evaluation of the compiler, could parse and modify it befor it will be transformed to the class bytecode.

Usage

You can use all normal annotations of JSR-305 and more anntations in org.echocat.redprecursor.annotations like GreaterThan, GreaterThanOrEqualTo, MatchesPattern, …

Examples

public void takeString(@Nonnull String toPrint) {
    System.out.println(toPrint);
}
...
takeString("Hello world!"); // Will print on the console Hello world!
takeString(null); // Will throw "NullPointerException: toPrint is null" 
@Nonnull public String integerToString(@Nonnegative int numberForString) {
    return Integer.toString(numberForString);
}
...
integerToString(666); // Will return "666"
integerToString(-666); // Will throw "IllegalArgumentException: numberForString is not greater than or equal to zero." 
@Nonnull public String getSomeString(boolean allowedToReturnSomeString) {
    return allowedToReturnSomeString ? "Hello world!" : null;
}
...
getSomeString(true); // Will return "Hello world!"
getSomeString(false); // Will throw "NullPointerException: The return value of getSomeString(..) is null" 

More?

Try the power out! ;-)

If you have more ideas open an issue or write us: contact@echocat.org

Links

Integrate

Generally you does not need a separate compiler, another tool, do not have to include a complex build mechanism or something else. You just have to add the compilerplugin to your classpath while compile of your application and bundle one of the runtimes with your application to make this library work. – Not more – Really!

with Maven

<repositories>
    <repository>
        <id>echocat</id>
        <url>http://repo.echocat.org/echocat</url>
        <!-- We need currently this settings because we
             only have a snapshot release currently packed. -->
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
           <enabled>true</enabled>
           <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
</repositories>

<dependencies>
    <!-- Choose this artifact if you just use the basic annotations. -->
    <dependency>
        <groupId>org.echocat.reprecursor</groupId>
        <artifactId>runtime</artifactId>
        <version>0.1.0-SNAPSHOT</version>
        <!-- This is already included by the compilerplugin. -->
        <scope>runtime</scope>
    </dependency>
    <!-- Choose this artifact if you use the basic and advanced annotations. -->
    <dependency>
        <groupId>org.echocat.reprecursor</groupId>
        <artifactId>advancedruntime</artifactId>
        <version>0.1.0-SNAPSHOT</version>
        <!-- This is already included by the compilerplugin. -->
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.echocat.reprecursor</groupId>
        <artifactId>compilerplugin</artifactId>
        <version>0.1.0-SNAPSHOT</version>
        <!-- We only want this jar to be available untile the compilation.
             Because this artifact contains the plugin for the javac. -->
        <scope>provided</scope>
    </dependency>
</dependencies>

Standalone

  • runtime.jar – Bundle it with your application to make javax.annotation and org.echocat.redprecursor.annotations available.
  • advancedruntime-bundled.jar – Bundle it with your application to make javax.annotation and org.echocat.redprecursor.annotations (including the advanced annoations) available.
  • compilerplugin-bundled.jar – Include this jar in the classpath while compile of your application. IMPORTANT: Do not bunlde it with your application.

Status

Currently the development status is ALPHA.

We currently test this code already with big production code of another closed source application but we develop this project with clearly defined coding conventions that make it be that your compiler plugin does not work with really all java code. Help us – test it with your code!

The danger does not belong to the compiled classes it primary belongs to the compilation process.

License

echocat RedPrecursor is licensed under MPL 2.0.

About

Access and modify your code before it will be transformed to bytecode by the compiler without AspectJ.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages