)proxyInstances
- .computeIfAbsent(ps,
- ps0 -> newProxyInstance(this.classLoader(),
- interfaces,
- // Anonymous class, not lambda, due to Throwable in the signature
- new InvocationHandler() {
- @Override // InvocationHandler
- public final Object invoke(final Object p,
- final Method m,
- final Object[] a)
- throws Throwable {
- return switch (m) {
- case Method x when equalsMethod(x) -> p == a[0];
- case Method x when hashCodeMethod(x) -> System.identityHashCode(p);
- default -> m.invoke(instanceSupplier.get(), a);
- };
- }
- }));
- }
-
-}
diff --git a/src/main/java/org/microbean/reference/Request.java b/src/main/java/org/microbean/reference/Request.java
index b4e224a..85cd7dd 100644
--- a/src/main/java/org/microbean/reference/Request.java
+++ b/src/main/java/org/microbean/reference/Request.java
@@ -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
@@ -17,7 +17,11 @@
import java.util.function.Supplier;
-import org.microbean.assign.AttributedType;
+import javax.lang.model.AnnotatedConstruct;
+
+import javax.lang.model.type.TypeMirror;
+
+import org.microbean.assign.Annotated;
import org.microbean.assign.Selectable;
import org.microbean.bean.Bean;
@@ -37,8 +41,8 @@
import static java.util.Objects.requireNonNull;
/**
- * A central object representing a request for dependencies that is a {@link Creation} (and therefore also a {@link
- * Destruction}), a {@link DestructorRegistry}, and a {@link References}.
+ * A central object representing a request for dependencies that is a {@link Creation} (and therefore also, per
+ * contract, a {@link Destruction}), a {@link DestructorRegistry}, and a {@link References}.
*
* Instances of this class are the heart and soul of a dependency injection and acquisition system.
*
@@ -70,7 +74,7 @@ public final class Request implements Creation, Destruction, Destructor
private final Domain domain;
- private final Selectable super AttributedType, Bean>> beans;
+ private final Selectable super Annotated extends AnnotatedConstruct>, Bean>> beans;
private final Instances instances;
@@ -80,7 +84,7 @@ public final class Request implements Creation, Destruction, Destructor
private final Bean b; // nullable; B and R must then be (effectively) Void
- private final AttributedType rType; // nullable; R must then be Void
+ private final Annotated extends AnnotatedConstruct> rConstruct; // nullable; R must then be Void
/*
@@ -93,7 +97,7 @@ public final class Request implements Creation, Destruction, Destructor
*
* @param d a {@link Domain}; must not be {@code null}
*
- * @param s a {@link Selectable} providing access to {@link Bean}s by {@link AttributedType}; must not be {@code
+ * @param s a {@link Selectable} providing access to {@link Bean}s by {@link AnnotatedConstruct}; must not be {@code
* null}; must be safe for concurrent use by multiple threads; often assembled out of methods present in the {@link
* org.microbean.bean.Selectables} and {@link org.microbean.bean.Beans} classes, among other such utility classes
*
@@ -107,7 +111,7 @@ public final class Request implements Creation, Destruction, Destructor
* @see #Request(Domain, Selectable, Instances, DestructorTree, ClientProxier)
*/
public Request(final Domain d,
- final Selectable super AttributedType, Bean>> s,
+ final Selectable super Annotated extends AnnotatedConstruct>, Bean>> s,
final Instances instances,
final ClientProxier cp) {
this(d, s, instances, null, cp, null, null);
@@ -118,7 +122,7 @@ public Request(final Domain d,
*
* @param d a {@link Domain}; must not be {@code null}
*
- * @param s a {@link Selectable} providing access to {@link Bean}s by {@link AttributedType}; must not be {@code
+ * @param s a {@link Selectable} providing access to {@link Bean}s by {@link AnnotatedConstruct}; must not be {@code
* null}; must be safe for concurrent use by multiple threads; often assembled out of methods present in the {@link
* org.microbean.bean.Selectables} and {@link org.microbean.bean.Beans} classes, among other such utility classes
*
@@ -133,7 +137,7 @@ public Request(final Domain d,
* @exception NullPointerException if {@code s}, {@code instances}, or {@code cp} is {@code null}
*/
public Request(final Domain d,
- final Selectable super AttributedType, Bean>> s,
+ final Selectable super Annotated extends AnnotatedConstruct>, Bean>> s,
final Instances instances,
final DestructorTree destructorTree, // nullable
final ClientProxier cp) {
@@ -141,19 +145,19 @@ public Request(final Domain d,
}
private Request(final Domain d,
- final Selectable super AttributedType, Bean>> s,
+ final Selectable super Annotated extends AnnotatedConstruct>, Bean>> s,
final Instances instances,
final DestructorTree destructorTree, // nullable
final ClientProxier cp,
final Bean b, // nullable
- final AttributedType rType) { // the type of the references returned (); nullable
+ final Annotated extends AnnotatedConstruct> rConstruct) { // the type of the references returned (); nullable
this.domain = requireNonNull(d, "d");
this.beans = requireNonNull(s, "s");
this.instances = requireNonNull(instances, "instances");
this.cp = requireNonNull(cp, "cp");
this.destructorTree = destructorTree == null ? new DefaultDestructorTree() : destructorTree;
this.b = b;
- this.rType = rType;
+ this.rConstruct = rConstruct;
}
@@ -201,16 +205,16 @@ public final R reference(final Bean bean) {
@Override // ReferencesSelector
@SuppressWarnings("unchecked")
- public final References references(final AttributedType rType) {
- return this.rType == rType ? (References)this :
- // This basically returns "this" but with a new rType. But Request is immutable so we make a copy.
+ public final References references(final Annotated extends AnnotatedConstruct> rConstruct) {
+ return this.rConstruct == rConstruct ? (References)this :
+ // This basically returns "this" but with a new rConstruct. But Request is immutable so we make a copy.
new Request<>(this.domain,
- this.beans,
- this.instances,
- this.destructorTree, // deliberately NO this.destructorTree.newChild() call
- this.cp,
- this.b, // nullable; will then be (effectively) Void
- rType); // nullable; will then be Void
+ this.beans,
+ this.instances,
+ this.destructorTree, // deliberately NO this.destructorTree.newChild() call
+ this.cp,
+ this.b, // nullable; will then be (effectively) Void
+ rConstruct); // nullable; will then be Void
}
@Override // DestructorTree (DestructorRegistry)
@@ -220,7 +224,7 @@ public final boolean register(final Object reference, final Destructor destructo
@Override // References
public final int size() {
- return this.rType == null ? 0 : this.beans.select(this.rType).size();
+ return this.rConstruct == null ? 0 : this.beans.select(this.rConstruct).size();
}
/*
@@ -228,7 +232,7 @@ public final int size() {
*/
private final Iterator> beanIterator() {
- return this.rType == null ? emptyIterator() : this.beans.select(this.rType).iterator();
+ return this.rConstruct == null ? emptyIterator() : this.beans.select(this.rConstruct).iterator();
}
@SuppressWarnings("unchecked")
@@ -242,12 +246,12 @@ private final Iterator> beanIterator() {
}
return
new Request(this.domain,
- this.beans,
- this.instances,
- this.destructorTree.newChild(), // critical; !b.equals(this.b)
- this.cp,
- b, // nullable; if so, better resolve to Void
- null); // rType; resolves to Void
+ this.beans,
+ this.instances,
+ this.destructorTree.newChild(), // critical; !b.equals(this.b)
+ this.cp,
+ b, // nullable; if so, better resolve to Void
+ null); // rConstruct; resolves to Void
}
@@ -265,7 +269,7 @@ private final class ReferencesIterator implements Iterator {
private ReferencesIterator() {
super();
- if (rType == null) {
+ if (Request.this.rConstruct == null) {
this.i = emptyIterator();
}
}