Skip to content
Roberto Gentili edited this page Sep 9, 2024 · 572 revisions

Tweet

Burningwave Core is an advanced and highly optimized Java library to build frameworks and it is useful for scanning class paths, generating classes at runtime, facilitating the use of reflection, scanning the filesystem, executing stringified source code and much more…

With it it's possible to search classes by every criteria that your imagination can make by using lambda expressions. Scan engine is highly optimized using direct allocated ByteBuffers to avoid heap saturation; searches are executed in multithreading context and are not affected by "the issue of the same class loaded by different classloaders" (normally if you try to execute "isAssignableFrom" method on a same class loaded from different classloader it returns false).

Below you will find how to include the library in your projects and a simple code example. In the right side links you will find examples about the ClassHunter, ClassPathHunter, ClassFactory (for generating classes at runtime or for executing stringified code) and of some components. Here you can find some junit tests of the ClassHunter and here you can find some junit test of all most used components.

For assistance see the related section on the home page.

Get started

To include Burningwave Core library in your projects simply use with Apache Maven:

<dependency>
    <groupId>org.burningwave</groupId>
    <artifactId>core</artifactId>
    <version>12.65.2</version>
</dependency>

Requiring the Burningwave Core module

To use Burningwave Core as a Java module add the following to your module-info.java:

requires io.github.toolfactory.narcissus;
requires org.burningwave.core;

... And now the code: let's retrieve all classes of the runtime classpath!

import java.util.Collection;

import org.burningwave.core.assembler.ComponentContainer;
import org.burningwave.core.assembler.ComponentSupplier;
import org.burningwave.core.classes.ClassHunter;
import org.burningwave.core.classes.SearchConfig;
import org.burningwave.core.io.PathHelper;

public class Finder {

    public Collection<Class<?>> find() {
        ComponentSupplier componentSupplier = ComponentContainer.getInstance();
        PathHelper pathHelper = componentSupplier.getPathHelper();
        ClassHunter classHunter = componentSupplier.getClassHunter();

        SearchConfig searchConfig = SearchConfig.forPaths(
            //Here you can add all absolute path you want:
            //both folders, zip, jar, war, ear and jmod will be recursively scanned.
            //For example you can add: "C:\\Users\\user\\.m2"
            //With the row below the search will be executed on runtime Classpaths
            pathHelper.getMainClassPaths()
        );
        

        try (ClassHunter.SearchResult searchResult = classHunter.find()) {
            return searchResult.getClasses();
        }
    }

}

Examples of use of some components:

BackgroundExecutor
ClassFactory
ClassHunter
ClassPathHunter
CodeExecutor
Constructors
Fields
FileSystemItem
FunctionalInterfaceFactory
IterableObjectHelper
JavaMemoryCompiler
Methods
PathHelper
PropertyAccessor
UnitSourceGenerator

HitCount

Clone this wiki locally