lite-beans

LiteBeans is implementation of the java.beans package based on the Apache Harmony project

License

License

GroupId

GroupId

com.github.panga
ArtifactId

ArtifactId

lite-beans
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

lite-beans
LiteBeans is implementation of the java.beans package based on the Apache Harmony project
Project URL

Project URL

https://github.com/panga/lite-beans
Source Code Management

Source Code Management

https://github.com/panga/lite-beans.git

Download lite-beans

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.panga/lite-beans/ -->
<dependency>
    <groupId>com.github.panga</groupId>
    <artifactId>lite-beans</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.panga/lite-beans/
implementation 'com.github.panga:lite-beans:1.0.0'
// https://jarcasting.com/artifacts/com.github.panga/lite-beans/
implementation ("com.github.panga:lite-beans:1.0.0")
'com.github.panga:lite-beans:jar:1.0.0'
<dependency org="com.github.panga" name="lite-beans" rev="1.0.0">
  <artifact name="lite-beans" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.panga', module='lite-beans', version='1.0.0')
)
libraryDependencies += "com.github.panga" % "lite-beans" % "1.0.0"
[com.github.panga/lite-beans "1.0.0"]

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-core jar 1.3

Project Modules

There are no modules declared in this project.

LiteBeans Project

LiteBeans is implementation of the java.beans package based on the Apache Harmony project.

Problem

The java.desktop module introduced in JDK 9 encapsulates all AWT, Swing, Image and Sound packages from Java standard libraries.

In addition to that, it contains the java.beans package with helper classes to interact with Java Beans, specifically bean introspection and property change listeners.

Due to its tight dependency with AWT and Swing, it cannot be easily removed from java.desktop module, causing any thirdparty library that uses java.beans package to be dependent of all java.desktop classes.

The extra overhead of java.desktop module adds 12mb of size into the JVM installation and increases memory usage.

Solution

Implemented java.beans package with only java.base module dependency based on Apache Harmony project source code.

The implementation is a subset of official JDK java.beans classes, it does not implement the full interface.

However, it adds enough classes to be used by Object Mapping (xml, json) libraries and Dependency Injection (Spring, CDI) frameworks in a transparent way.

The total size of LiteBeans library is less than 150kb.

Usage

Using as a java.beans alternative

  1. Add Maven Dependency
<dependency>
    <groupId>com.github.panga</groupId>
    <artifactId>lite-beans</artifactId>
    <version>1.0.0</version>
</dependency>
  1. Find all ocurrencies of import java.beans and replace with import lite.beans.

Using as a module patch (hacking JPMS)

  1. Add Maven Dependency or download the JAR (notice the classifier)
<dependency>
    <groupId>com.github.panga</groupId>
    <artifactId>lite-beans</artifactId>
    <version>1.0.0</version>
    <classifier>patch</classifier>
</dependency>
  1. Run your application in a minimal JRE without java.desktop module:
java \
    --patch-module java.base=lite-beans-1.0.0-patch.jar \
    --add-exports java.base/java.beans=acme.myapp \
    --module-path target/modules --module acme.myapp \

Note: See usage in https://github.com/panga/hammock-jpms example.

Contributors

License

Apache License 2.0

Versions

Version
1.0.0