Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# microBean™ Client Proxy: Byte Buddy

[![Maven
Central](https://img.shields.io/maven-central/v/org.microbean/microbean-clientproxy-bytebuddy.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.microbean/microbean-clientproxy-bytebuddy)
Central](https://img.shields.io/maven-central/v/org.microbean/microbean-clientproxy-bytebuddy.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/org.microbean/microbean-clientproxy-bytebuddy)

![0% AI](https://img.shields.io/badge/%F0%9F%A4%96_AI-0%25_%F0%9F%8C%BC-brightgreen)

The microBean™ Client Proxy: Byte Buddy project provides classes and interfaces assisting with implementing <a
href="https://microbean.github.io/microbean-reference/apidocs/org.microbean.reference/org/microbean/reference/ClientProxy.html"><dfn>client
Expand All @@ -22,15 +24,16 @@ microBean™ Client Proxy: Byte Buddy requires a Java runtime of version 19 or h

# Installation

microBean™ Client Proxy: Byte Buddy is available on [Maven Central](https://search.maven.org/). Include microBean™
Client Proxy: Byte Buddy as a Maven dependency:
microBean™ Client Proxy: Byte Buddy is available on [Maven
Central](https://central.sonatype.com/artifact/org.microbean/microbean-clientproxy-bytebuddy). Include microBean™ Client
Proxy: Byte Buddy as a Maven dependency:

```xml
<dependency>
<groupId>org.microbean</groupId>
<artifactId>microbean-clientproxy-bytebuddy</artifactId>
<!-- Always check https://search.maven.org/artifact/org.microbean/microbean-clientproxy-bytebuddy for up-to-date available versions. -->
<version>0.0.2</version>
<!-- Always check https://central.sonatype.com/artifact/org.microbean/microbean-clientproxy-bytebuddy for up-to-date available versions. -->
<version>0.0.3</version>
</dependency>
```

Expand Down
29 changes: 13 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,49 +130,49 @@
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.18.3</version>
<version>1.18.5</version>
</dependency>

<dependency>
<groupId>org.microbean</groupId>
<artifactId>microbean-assign</artifactId>
<version>0.0.11</version>
<version>0.0.14</version>
</dependency>

<dependency>
<groupId>org.microbean</groupId>
<artifactId>microbean-bean</artifactId>
<version>0.0.22</version>
<version>0.0.23</version>
</dependency>

<dependency>
<groupId>org.microbean</groupId>
<artifactId>microbean-construct</artifactId>
<version>0.0.18</version>
<version>0.0.24</version>
</dependency>

<dependency>
<groupId>org.microbean</groupId>
<artifactId>microbean-producer</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
</dependency>

<dependency>
<groupId>org.microbean</groupId>
<artifactId>microbean-proxy</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
</dependency>

<dependency>
<groupId>org.microbean</groupId>
<artifactId>microbean-reference</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
</dependency>

<dependency>
<groupId>org.microbean</groupId>
<artifactId>microbean-scopelet</artifactId>
<version>0.0.11</version>
<version>0.0.12</version>
</dependency>

</dependencies>
Expand Down Expand Up @@ -363,7 +363,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>12.3.0</version>
<version>13.2.0</version>
</dependency>
</dependencies>
</plugin>
Expand All @@ -384,7 +384,7 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
<version>3.15.0</version>
<configuration>
<compilerArgs>
<arg>-Xlint:all</arg>
Expand All @@ -394,7 +394,7 @@
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.9.0</version>
<version>3.10.0</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down Expand Up @@ -484,9 +484,6 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>-XX:StartFlightRecording=duration=10s,filename=${project.build.directory}/recording.jfr</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-toolchains-plugin</artifactId>
Expand All @@ -500,7 +497,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.20.1</version>
<version>2.21.0</version>
</plugin>
<plugin>
<groupId>io.smallrye</groupId>
Expand All @@ -510,7 +507,7 @@
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.9.0</version>
<version>0.10.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central.sonatype.com</publishingServerId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
*
* Copyright © 2025 microBean™.
* Copyright © 2025–2026 microBean™.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -42,6 +42,8 @@

import static java.lang.invoke.MethodType.methodType;

import static java.util.Objects.requireNonNull;

/**
* An {@link AbstractToolkitProxier} and {@link ClientProxier} that uses <a href="https://bytebuddy.net/#/">Byte
* Buddy</a> to {@linkplain #generate(ProxySpecification) generate} {@linkplain org.microbean.proxy.Proxy client
Expand All @@ -54,15 +56,15 @@
public final class BBClientProxier extends AbstractToolkitProxier<ProxySpecification, DynamicType.Unloaded<?>> implements ClientProxier {

private static final Map<ProxySpecification, Object> clientProxyInstances = new ConcurrentHashMap<>();

private final TypeDefinitions tds;

private final BBClientProxyClassGenerator g;

/**
* Creates a new {@link BBClientProxier}.
*
* @param domain a {@link Domain}; must not be {@code null}
* @param domain a non-{@code null} {@link Domain}
*
* @exception NullPointerException if any argument is {@code null}
*
Expand All @@ -77,9 +79,9 @@ public BBClientProxier(final Domain domain) {
/**
* Creates a new {@link BBClientProxier}.
*
* @param domain a {@link Domain}; must not be {@code null}
* @param domain a non-{@code null} {@link Domain}
*
* @param typePool a {@link TypePool}; must not be {@code null}
* @param typePool a non-{@code null} {@link TypePool}
*
* @exception NullPointerException if any argument is {@code null}
*
Expand All @@ -97,27 +99,27 @@ public BBClientProxier(final Domain domain,
/**
* Creates a new {@link BBClientProxier}.
*
* @param domain a {@link Domain}; must not be {@code null}
* @param domain a non-{@code null} {@link Domain}; must not be {@code null}
*
* @param tds a {@link TypeDefinitions}; must not be {@code null}
* @param tds a non-{@code null} {@link TypeDefinitions}
*
* @param g a {@link BBClientProxyClassGenerator}; must not be {@code null}
* @param g a non-{@code nulll} {@link BBClientProxyClassGenerator}
*
* @exception NullPointerException if any argument is {@code null}
*/
public BBClientProxier(final Domain domain,
final TypeDefinitions tds,
final BBClientProxyClassGenerator g) {
final TypeDefinitions tds,
final BBClientProxyClassGenerator g) {
super(domain, MethodHandles.lookup());
this.tds = Objects.requireNonNull(tds, "tds");
this.g = Objects.requireNonNull(g, "g");
this.tds = requireNonNull(tds, "tds");
this.g = requireNonNull(g, "g");
}

@Override // ClientProxier
public <R> R clientProxy(final Id id, final Supplier<? extends R> instanceSupplier) {
return this.proxy(new ProxySpecification(this.domain(), id), instanceSupplier).$cast();
}

@Override // AbstractClientProxier<DynamicType.Unloaded<?>>
protected final DynamicType.Unloaded<?> generate(final ProxySpecification ps) {
return
Expand Down Expand Up @@ -145,7 +147,6 @@ public final <R> Proxy<R> proxy(final ProxySpecification ps, final Supplier<? ex
});
}


@Override // AbstractClientProxier<DynamicType.Unloaded<?>>
protected final Class<?> proxyClass(final DynamicType.Unloaded<?> dtu, final ClassLoader cl)
throws ClassNotFoundException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
*
* Copyright © 2025 microBean™.
* Copyright © 2025–2026 microBean™.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -35,7 +35,6 @@
import net.bytebuddy.implementation.HashCodeMethod;
import net.bytebuddy.implementation.EqualsMethod;
import net.bytebuddy.implementation.FieldAccessor;
import net.bytebuddy.implementation.MethodCall;

import net.bytebuddy.implementation.bytecode.assign.Assigner;

Expand All @@ -45,34 +44,28 @@

import static java.util.Objects.requireNonNull;

import static net.bytebuddy.description.modifier.Ownership.STATIC;
import static net.bytebuddy.description.modifier.SyntheticState.SYNTHETIC;
import static net.bytebuddy.description.modifier.Visibility.PRIVATE;
import static net.bytebuddy.description.modifier.Visibility.PUBLIC;

import static net.bytebuddy.description.type.TypeDescription.Generic.Builder.parameterizedType;
import static net.bytebuddy.description.type.TypeDescription.Generic.Builder.typeVariable;

import static net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.Default.NO_CONSTRUCTORS;

import static net.bytebuddy.implementation.MethodCall.invoke;
import static net.bytebuddy.implementation.MethodCall.invokeSelf;

import static net.bytebuddy.matcher.ElementMatchers.any;
import static net.bytebuddy.matcher.ElementMatchers.hasParameters;
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
import static net.bytebuddy.matcher.ElementMatchers.isDeclaredBy;
import static net.bytebuddy.matcher.ElementMatchers.isEquals;
import static net.bytebuddy.matcher.ElementMatchers.isFinal;
import static net.bytebuddy.matcher.ElementMatchers.isHashCode;
import static net.bytebuddy.matcher.ElementMatchers.isPackagePrivate;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.isToString;
import static net.bytebuddy.matcher.ElementMatchers.isVirtual;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.returns;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import static net.bytebuddy.matcher.ElementMatchers.takesNoArguments;

Expand All @@ -89,7 +82,7 @@ public final class BBClientProxyClassGenerator {
/**
* Creates a new {@link BBClientProxyClassGenerator}.
*
* @param typePool a {@link TypePool} (normally a {@link TypeElementTypePool}); must not be {@code null}
* @param typePool a non-{@code null} {@link TypePool} (normally a {@link TypeElementTypePool})
*
* @exception NullPointerException if {@code typePool} is {@code null}
*/
Expand All @@ -101,14 +94,14 @@ public BBClientProxyClassGenerator(final TypePool typePool) {
/**
* Creates and returns a new {@link DynamicType.Unloaded} representing a client proxy class.
*
* @param name the name of the client proxy class; must not be {@code null}; must be a valid Java class <a
* @param name the non-{@code null} name of the client proxy class; must be a valid Java class <a
* href="https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/lang/ClassLoader.html#binary-name">binary
* name</a>
*
* @param superclass a {@link TypeDefinition} representing a superclass; must not be {@code null}
* @param superclass a non-{@code null} {@link TypeDefinition} representing a superclass
*
* @param interfaces a {@link Collection} of {@link TypeDefinition}s representing interfaces the client proxy class
* will implement; must not be {@code null}
* @param interfaces a non-{@code null} {@link Collection} of {@link TypeDefinition}s representing interfaces the
* client proxy class will implement
*
* @return a new, non-{@code null} {@link DynamicType.Unloaded} representing a client proxy class
*
Expand Down
Loading