GithubHelp home page GithubHelp logo

generators-jvm's Introduction

generators-jvm

Continuation-based generators for the JVM.

Module generators contain the core classes, AbstractGenerator, ConsumerGenerator and RunnableGenerator.

AbstractGenerator defines the generator procedure as an abstract method. Concrete generators must extend from AbstractGenerator. The generator procedure has protected access to this.yield. Benchmarking indicates this imposes quite the overhead.

ConsumerGenerator defines the generator as a functional object. Concrete generators may extend or aggregate ConsumerGenerator. The generator procedure receives this::yield as a parameter. Benchmarking indicates this imposes some overhead.

RunnableGenerator defines the generator as a functional object. Concrete generators may extend or aggregate RunnableGenerator. The generator procedure has public static access to RunnableGenerator.yield. Benchmarking indicates this imposes the least overhead. However, it cannot type check the yielded value!

Applications are demonstrated in readers.

building

Build is driven by Gradle.

Have JAVA_HOME point to a JDK version up to 19.

Unpack JDK 21 EA into ${rootDir}/jdk-21. Alternatively, edit ${rootDir}/gradle.properties. For more information, see: https://docs.gradle.org/8.1/userguide/toolchains.html

To build and run automated tests: ./gradlew build

To build benchmarks: ./gradlew jmhJar

To run benchmarks: ./gradlew --console=plain jmh

You may manually run a benchmark by doing something like:

java --add-exports java.base/jdk.internal.vm=ALL-UNNAMED --enable-preview -jar .\readers\ber\build\libs\ber-1.0-SNAPSHOT-jmh.jar -h

using

The generators module require JDK version 21 with preview features enabled.

Because the generators refer to package jdk.internal.vm from module java.base, client code must force exporting that package by that module.

To configure a Gradle consumer project:

build.gradle.kts
plugins {
    id("java")
}

dependencies {
    implementation("br.dev.pedrolamarao.generators:generators:1.0-SNAPSHOT")
}

tasks.withType<JavaCompile>().configureEach {
    options.compilerArgs = listOf("--add-exports","java.base/jdk.internal.vm=br.dev.pedrolamarao.generators","--enable-preview")
}

tasks.withType<Test>().configureEach {
    jvmArgs = listOf("--add-exports","java.base/jdk.internal.vm=br.dev.pedrolamarao.generators","--enable-preview")
}

generators-jvm's People

Contributors

pedrolamarao avatar

Stargazers

mtrudeau avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.