All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.fushizen.invokedynamic.proxy.ConcreteMethodTracker Maven / Gradle / Ivy

Go to download

A Java runtime proxy class generator using invokedynamic for better performance and more capabilities than the standard Java proxies.

There is a newer version: 1.2.1
Show newest version
package net.fushizen.invokedynamic.proxy;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashSet;

class ConcreteMethodTracker {
    private HashSet contributors = new HashSet<>();

    public void add(Method m) {
        if ((m.getModifiers() & Modifier.ABSTRACT) != 0) return;

        // Remove any concrete implementations that come from superclasses of the class that owns this new method
        // (this new class shadows them).
        contributors.removeIf(m2 -> m2.getDeclaringClass().isAssignableFrom(m.getDeclaringClass()));

        contributors.add(m);
    }

    public Method getOnlyContributor() {
        if (contributors.size() != 1) return null;

        return contributors.iterator().next();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy