Code Monkey home page Code Monkey logo

jisolate's Introduction

Jisolate

Build Status Coverage Status

Jisolate is an API for isolating Java classes using either classloader or VM isolation.

Why Isolation?

Isolates are useful to load the same class multiple times, typically using different configurations. For example, some frameworks are configured using static singletons. For tests, it is often useful to start multiple instances of these frameworks, each with its own configuration.

Classloader Isolation

Classloader isolation uses a child-first classloader combined with thread-local system properties to ensure that non-JDK classes can be loaded multiple times in the same JVM.

Classloader isolation is the isolation approach of choice as it is the most performant approach of ensuring isolation and allows for an easy way to communicate results from the isolated code back to its invoker.

Jisolate.classLoaderIsolation()
    .withIsolatableClass(IsolatedClass.class)
    .withIsolatableArguments("foo")
    .isolate();

VM Isolation

VM isolation spawns a child VM process. This provides even better isolation than the classloader approach, but it takes slightly longer to setup.

Jisolate.jvmIsolation()
    .withMainClass(IsolatedClass.class)
    .withMainClassArguments("foo")
    .isolate();

Lifecycle control

VM isolation also allows for forcefully terminating the isolated JVM process when it's no longer needed:

try (JvmIsolate isolate = Jisolate.jvmIsolation()
    .withMainClass(IsolatedClass.class)
    .withMainClassArguments("foo")
    .isolate()) {
    
    // The isolated JVM is automatically terminated on leaving this block    
}

JSR-121

Jisolate is not an implementation of JSR-121, the Application Isolation API Specification. Instead, it is a light-weight and pragmatic approach of providing a best effort isolation of Java classes that is useful for many scenarios.

jisolate's People

Contributors

chrisgleissner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.