1. Why 
public abstract class ObjectSupport {
    public abstract boolean equals(Object self, Object other);
    public abstract int hashCode();
    public static ObjectSupport of(Lookup lookup, String... fields) {
        // impl details
    }
    // impl details
}

and not something like?
interface ObjectSupport<T> {
    public boolean equals(T self, T other);
    public int hashCode(T obj);
    public static <T, U extends ObjectSupport<T>> T of(Lookup lookup, Class<
U> iface, Class<T> obj) {
       // impl details
    }
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface ObjectSupportField {
}

2. I don't understand why you can't use 
https://docs.oracle.com/javase/9/docs/api/java/lang/invoke/MethodHandles.Lookup.html#defineClass-byte:A-
 instead 
of unsafe. If you can use 
https://docs.oracle.com/javase/8/docs/api/java/lang/invoke/LambdaMetafactory.html
 things 
might be easier to optimise because the VM doesn't trust nonstatic final 
fields but I don't think you'll need to rely on that.
3. The raw class file isn't always available at runtime so you can't 
necessarily use ObjectSupportImpl as a template.
4. 
https://github.com/forax/exotic/blob/master/src/main/java/com.github.forax.exotic/com/github/forax/exotic/ObjectSupport.java#L180
 Pretty 
sure you want a static final field here. You can do that if you're using 
ObjectSupportImpl as a raw template. Unfortunately defineClass doesn't 
accept arguments so you have to use wonky garbage like a hashmap to pass 
runtime data that can't be embedded in a class file easily.

-- 
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mechanical-sympathy+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to