diff --git a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/MethodGraph.java b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/MethodGraph.java index f752facda95..d94c8b7d1c2 100644 --- a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/MethodGraph.java +++ b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/MethodGraph.java @@ -166,18 +166,22 @@ interface Compiler { class Default implements Compiler { + public static Compiler of(Harmonizer harmonizer) { + return new Default(harmonizer); + } + public static Compiler forJavaHierarchy() { - return new Default(Identifier.ForJavaMethod.INSTANCE); + return of(Harmonizer.ForJavaMethod.INSTANCE); } public static Compiler forJVMHierarchy() { - return new Default(Identifier.ForJVMMethod.INSTANCE); + return of(Harmonizer.ForJVMMethod.INSTANCE); } - private final Identifier identifier; + private final Harmonizer harmonizer; - public Default(Identifier identifier) { - this.identifier = identifier; + protected Default(Harmonizer harmonizer) { + this.harmonizer = harmonizer; } @Override @@ -227,7 +231,7 @@ protected Key.Store doAnalyze(GenericTypeDescription typeDescription, keyStore = keyStore.mergeWith(analyze(interfaceType, snapshots, nextMatcher, nextMatcher)); } for (MethodDescription methodDescription : typeDescription.getDeclaredMethods().filter(currentMatcher)) { - keyStore = keyStore.registerTopLevel(methodDescription, identifier); + keyStore = keyStore.registerTopLevel(methodDescription, harmonizer); } return keyStore; } @@ -235,131 +239,131 @@ protected Key.Store doAnalyze(GenericTypeDescription typeDescription, @Override public boolean equals(Object other) { return this == other || !(other == null || getClass() != other.getClass()) - && identifier.equals(((Default) other).identifier); + && harmonizer.equals(((Default) other).harmonizer); } @Override public int hashCode() { - return identifier.hashCode(); + return harmonizer.hashCode(); } @Override public String toString() { return "MethodGraph.Compiler.Default{" + - "identifier=" + identifier + + "harmonizer=" + harmonizer + '}'; } - public interface Identifier { + public interface Harmonizer { - T wrap(MethodDescription.Token methodToken); + S wrap(MethodDescription.Token methodToken); - enum ForJavaMethod implements Identifier { + enum ForJavaMethod implements Harmonizer { - INSTANCE; + INSTANCE; - @Override - public Token wrap(MethodDescription.Token methodToken) { - return new Token(methodToken); - } + @Override + public Token wrap(MethodDescription.Token methodToken) { + return new Token(methodToken); + } - @Override - public String toString() { - return "MethodGraph.Compiler.Default.Identifier.ForJavaMethod." + name(); - } + @Override + public String toString() { + return "MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod." + name(); + } - protected static class Token { + protected static class Token { - private final MethodDescription.Token methodToken; + private final MethodDescription.Token methodToken; - protected Token(MethodDescription.Token methodToken) { - this.methodToken = methodToken; - } + protected Token(MethodDescription.Token methodToken) { + this.methodToken = methodToken; + } - @Override - public boolean equals(Object other) { - if (this == other) return true; - if (!(other instanceof Token)) return false; - Token forJavaMethod = (Token) other; - List tokens = methodToken.getParameterTokens(), otherTokens = forJavaMethod.methodToken.getParameterTokens(); - if (tokens.size() != otherTokens.size()) return false; - for (int index = 0; index < tokens.size(); index++) { - if (!tokens.get(index).getType().asRawType().equals(otherTokens.get(index).getType().asRawType())) return false; - } - return true; - } + @Override + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof Token)) return false; + Token forJavaMethod = (Token) other; + List tokens = methodToken.getParameterTokens(), otherTokens = forJavaMethod.methodToken.getParameterTokens(); + if (tokens.size() != otherTokens.size()) return false; + for (int index = 0; index < tokens.size(); index++) { + if (!tokens.get(index).getType().asRawType().equals(otherTokens.get(index).getType().asRawType())) return false; + } + return true; + } - @Override - public int hashCode() { - int result = 17; - for (ParameterDescription.Token parameterToken : methodToken.getParameterTokens()) { - result = 31 * result + parameterToken.getType().asRawType().hashCode(); - } - return result; + @Override + public int hashCode() { + int result = 17; + for (ParameterDescription.Token parameterToken : methodToken.getParameterTokens()) { + result = 31 * result + parameterToken.getType().asRawType().hashCode(); } + return result; + } - @Override - public String toString() { - return "MethodGraph.Compiler.Default.Identifier.ForJavaMethod.Token{" + - "methodToken=" + methodToken + - '}'; - } + @Override + public String toString() { + return "MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.Token{" + + "methodToken=" + methodToken + + '}'; } } + } - enum ForJVMMethod implements Identifier { + enum ForJVMMethod implements Harmonizer { - INSTANCE; + INSTANCE; - @Override - public Token wrap(MethodDescription.Token methodToken) { - return new Token(methodToken); - } + @Override + public Token wrap(MethodDescription.Token methodToken) { + return new Token(methodToken); + } - @Override - public String toString() { - return "MethodGraph.Compiler.Default.Identifier.ForJVMMethod." + name(); - } + @Override + public String toString() { + return "MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod." + name(); + } - protected static class Token { + protected static class Token { - private final MethodDescription.Token methodToken; + private final MethodDescription.Token methodToken; - public Token(MethodDescription.Token methodToken) { - this.methodToken = methodToken; - } + public Token(MethodDescription.Token methodToken) { + this.methodToken = methodToken; + } - @Override - public boolean equals(Object other) { - if (this == other) return true; - if (!(other instanceof Token)) return false; - Token token = (Token) other; - if (!methodToken.getReturnType().asRawType().equals(token.methodToken.getReturnType().asRawType())) return false; - List tokens = methodToken.getParameterTokens(), otherTokens = token.methodToken.getParameterTokens(); - if (tokens.size() != otherTokens.size()) return false; - for (int index = 0; index < tokens.size(); index++) { - if (!tokens.get(index).getType().asRawType().equals(otherTokens.get(index).getType().asRawType())) return false; - } - return true; - } + @Override + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof Token)) return false; + Token token = (Token) other; + if (!methodToken.getReturnType().asRawType().equals(token.methodToken.getReturnType().asRawType())) return false; + List tokens = methodToken.getParameterTokens(), otherTokens = token.methodToken.getParameterTokens(); + if (tokens.size() != otherTokens.size()) return false; + for (int index = 0; index < tokens.size(); index++) { + if (!tokens.get(index).getType().asRawType().equals(otherTokens.get(index).getType().asRawType())) return false; + } + return true; + } - @Override - public int hashCode() { - int result = methodToken.getReturnType().asRawType().hashCode(); - for (ParameterDescription.Token parameterToken : methodToken.getParameterTokens()) { - result = 31 * result + parameterToken.getType().asRawType().hashCode(); - } - return result; + @Override + public int hashCode() { + int result = methodToken.getReturnType().asRawType().hashCode(); + for (ParameterDescription.Token parameterToken : methodToken.getParameterTokens()) { + result = 31 * result + parameterToken.getType().asRawType().hashCode(); } + return result; + } - @Override - public String toString() { - return "MethodGraph.Compiler.Default.Identifier.ForJVMMethod.Token{" + - "methodToken=" + methodToken + - '}'; - } + @Override + public String toString() { + return "MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.Token{" + + "methodToken=" + methodToken + + '}'; } } + } } protected abstract static class Key { @@ -386,8 +390,8 @@ public int hashCode() { protected static class Detached extends Key { - public static Key.Detached of(MethodDescription.Token methodToken) { - return new Key.Detached(methodToken.getInternalName(), Collections.singleton(methodToken)); + public static Detached of(MethodDescription.Token methodToken) { + return new Detached(methodToken.getInternalName(), Collections.singleton(methodToken)); } private final Set identifiers; @@ -417,31 +421,31 @@ public String toString() { } } - protected static class Identifying extends Key { + protected static class Harmonized extends Key { - public static Key.Identifying of(MethodDescription.InDefinedShape methodDescription, Identifier factory) { + public static Harmonized of(MethodDescription.InDefinedShape methodDescription, Harmonizer factory) { MethodDescription.Token methodToken = methodDescription.asToken(); - return new Key.Identifying(methodDescription.getInternalName(), Collections.singletonMap(factory.wrap(methodToken), Collections.singleton(methodToken))); + return new Harmonized(methodDescription.getInternalName(), Collections.singletonMap(factory.wrap(methodToken), Collections.singleton(methodToken))); } private final Map> identifiers; - protected Identifying(String internalName, Map> identifiers) { + protected Harmonized(String internalName, Map> identifiers) { super(internalName); this.identifiers = identifiers; } - protected Key.Detached asDetachedKey() { + protected Detached detach() { Set identifiers = new HashSet(); for (Set methodTokens : this.identifiers.values()) { for (MethodDescription.Token methodToken : methodTokens) { identifiers.add(methodToken); } } - return new Key.Detached(internalName, identifiers); + return new Detached(internalName, identifiers); } - protected Key.Identifying expandWith(MethodDescription methodDescription, Identifier factory) { + protected Harmonized expandWith(MethodDescription methodDescription, Harmonizer factory) { Map> identifiers = new HashMap>(this.identifiers); MethodDescription.Token methodToken = methodDescription.asToken(); V identifier = factory.wrap(methodToken); @@ -453,10 +457,10 @@ protected Key.Identifying expandWith(MethodDescription methodDescription, Ide methodTokens.add(methodToken); identifiers.put(identifier, methodTokens); } - return new Key.Identifying(internalName, identifiers); + return new Harmonized(internalName, identifiers); } - protected Key.Identifying mergeWith(Key.Identifying key) { + protected Harmonized mergeWith(Harmonized key) { Map> identifiers = new HashMap>(this.identifiers); for (Map.Entry> entry : key.identifiers.entrySet()) { Set methodTokens = identifiers.get(entry.getKey()); @@ -468,7 +472,7 @@ protected Key.Identifying mergeWith(Key.Identifying key) { identifiers.put(entry.getKey(), methodTokens); } } - return new Key.Identifying(internalName, identifiers); + return new Harmonized(internalName, identifiers); } @Override @@ -478,7 +482,7 @@ protected Set getIdentifiers() { @Override public String toString() { - return "MethodGraph.Compiler.Default.Key.Identifying{" + + return "MethodGraph.Compiler.Default.Key.Harmonized{" + "internalName='" + internalName + '\'' + ", identifiers=" + identifiers + '}'; @@ -489,23 +493,23 @@ protected static class Store { private static final int EMPTY = 0; - private final LinkedHashMap, Entry> entries; + private final LinkedHashMap, Entry> entries; protected Store() { - this(new LinkedHashMap, Entry>(EMPTY)); + this(new LinkedHashMap, Entry>(EMPTY)); } - private Store(LinkedHashMap, Entry> entries) { + private Store(LinkedHashMap, Entry> entries) { this.entries = entries; } - protected Store registerTopLevel(MethodDescription methodDescription, Identifier factory) { - Key.Identifying key = Key.Identifying.of(methodDescription.asDefined(), factory); + protected Store registerTopLevel(MethodDescription methodDescription, Harmonizer factory) { + Harmonized key = Harmonized.of(methodDescription.asDefined(), factory); Entry currentEntry = entries.get(key); Entry expandedEntry = (currentEntry == null ? new Entry.Initial(key) : currentEntry).expandWith(methodDescription, factory); - LinkedHashMap, Entry> entries = new LinkedHashMap, Entry>(this.entries); + LinkedHashMap, Entry> entries = new LinkedHashMap, Entry>(this.entries); entries.put(expandedEntry.getKey(), expandedEntry); return new Store(entries); } @@ -519,7 +523,7 @@ protected Store mergeWith(Store keyStore) { } protected Store inject(Entry entry) { - LinkedHashMap, Entry> entries = new LinkedHashMap, Entry>(this.entries); + LinkedHashMap, Entry> entries = new LinkedHashMap, Entry>(this.entries); Entry dominantEntry = entries.get(entry.getKey()); Entry mergedEntry = dominantEntry == null ? entry @@ -531,7 +535,7 @@ protected Store inject(Entry entry) { protected MethodGraph asGraph() { LinkedHashMap, Node> entries = new LinkedHashMap, Node>(this.entries.size()); for (Entry entry : this.entries.values()) { - entries.put(entry.getKey().asDetachedKey(), entry.asNode()); + entries.put(entry.getKey().detach(), entry.asNode()); } return new Graph(entries); } @@ -564,7 +568,7 @@ protected Graph(LinkedHashMap, Node> entries) { @Override public Node locate(MethodDescription.Token methodToken) { - Node node = entries.get(Key.Detached.of(methodToken)); + Node node = entries.get(Detached.of(methodToken)); return node == null ? Node.Illegal.INSTANCE : node; @@ -596,34 +600,34 @@ public String toString() { protected interface Entry { - Key.Identifying getKey(); + Harmonized getKey(); - Entry expandWith(MethodDescription methodDescription, Identifier identifierFactory); + Entry expandWith(MethodDescription methodDescription, Harmonizer harmonizer); - Entry mergeWith(Key.Identifying key); + Entry mergeWith(Harmonized key); Node asNode(); class Initial implements Entry { - private final Key.Identifying key; + private final Harmonized key; - protected Initial(Key.Identifying key) { + protected Initial(Harmonized key) { this.key = key; } @Override - public Identifying getKey() { + public Harmonized getKey() { throw new IllegalStateException("Cannot extract key without a registered method: " + this); } @Override - public Entry expandWith(MethodDescription methodDescription, Identifier identifierFactory) { - return new ForMethod(key.expandWith(methodDescription, identifierFactory), methodDescription, false); + public Entry expandWith(MethodDescription methodDescription, Harmonizer harmonizer) { + return new ForMethod(key.expandWith(methodDescription, harmonizer), methodDescription, false); } @Override - public Entry mergeWith(Identifying key) { + public Entry mergeWith(Harmonized key) { throw new IllegalStateException("Cannot merge initial entry without a registered method: " + this); } @@ -651,39 +655,39 @@ public String toString() { class ForMethod implements Entry { - private final Key.Identifying key; + private final Harmonized key; private final MethodDescription methodDescription; private final boolean madeVisible; - protected ForMethod(Key.Identifying key, MethodDescription methodDescription, boolean madeVisible) { + protected ForMethod(Harmonized key, MethodDescription methodDescription, boolean madeVisible) { this.key = key; this.methodDescription = methodDescription; this.madeVisible = madeVisible; } @Override - public Entry expandWith(MethodDescription methodDescription, Identifier identifierFactory) { - Key.Identifying key = this.key.expandWith(methodDescription, identifierFactory); + public Entry expandWith(MethodDescription methodDescription, Harmonizer harmonizer) { + Harmonized key = this.key.expandWith(methodDescription, harmonizer); return methodDescription.getDeclaringType().equals(this.methodDescription.getDeclaringType()) ? Ambiguous.of(key, methodDescription, this.methodDescription) : new ForMethod(key, methodDescription.isBridge() ? this.methodDescription : methodDescription, methodDescription.isBridge()); } @Override - public Entry mergeWith(Key.Identifying key) { + public Entry mergeWith(Harmonized key) { return new Entry.ForMethod(key.mergeWith(key), methodDescription, madeVisible); } @Override - public Key.Identifying getKey() { + public Harmonized getKey() { return key; } @Override public MethodGraph.Node asNode() { - return new Node(key.asDetachedKey(), methodDescription, madeVisible); + return new Node(key.detach(), methodDescription, madeVisible); } @Override @@ -715,13 +719,13 @@ public String toString() { protected static class Node implements MethodGraph.Node { - private final Key.Detached key; + private final Detached key; private final MethodDescription methodDescription; private final boolean madeVisible; - public Node(Key.Detached key, MethodDescription methodDescription, boolean madeVisible) { + public Node(Detached key, MethodDescription methodDescription, boolean madeVisible) { this.key = key; this.methodDescription = methodDescription; this.madeVisible = madeVisible; @@ -778,32 +782,32 @@ public String toString() { class Ambiguous implements Entry { - private final Key.Identifying key; + private final Harmonized key; private final TypeDescription declaringType; private final MethodDescription.Token methodToken; - protected static Entry of(Key.Identifying key, MethodDescription left, MethodDescription right) { + protected static Entry of(Harmonized key, MethodDescription left, MethodDescription right) { return left.isBridge() ^ right.isBridge() ? new ForMethod(key, left.isBridge() ? right : left, false) : new Ambiguous(key, left.getDeclaringType().asRawType(), right.asToken()); } - protected Ambiguous(Key.Identifying key, TypeDescription declaringType, MethodDescription.Token methodToken) { + protected Ambiguous(Harmonized key, TypeDescription declaringType, MethodDescription.Token methodToken) { this.key = key; this.declaringType = declaringType; this.methodToken = methodToken; } @Override - public Key.Identifying getKey() { + public Harmonized getKey() { return key; } @Override - public Entry expandWith(MethodDescription methodDescription, Identifier identifierFactory) { - Key.Identifying key = this.key.expandWith(methodDescription, identifierFactory); + public Entry expandWith(MethodDescription methodDescription, Harmonizer harmonizer) { + Harmonized key = this.key.expandWith(methodDescription, harmonizer); if (methodDescription.getDeclaringType().asRawType().equals(declaringType)) { return methodToken.isBridge() ^ methodDescription.isBridge() ? methodToken.isBridge() ? new ForMethod(key, methodDescription, false) : new Ambiguous(key, declaringType, methodToken) @@ -816,13 +820,13 @@ public Entry expandWith(MethodDescription methodDescription, Identifier id } @Override - public Entry mergeWith(Key.Identifying key) { + public Entry mergeWith(Harmonized key) { return new Ambiguous(key.mergeWith(key), declaringType, methodToken); } @Override public MethodGraph.Node asNode() { - return new Node(key.asDetachedKey(), declaringType, methodToken); + return new Node(key.detach(), declaringType, methodToken); } @Override @@ -854,13 +858,13 @@ public String toString() { protected static class Node implements MethodGraph.Node { - private final Key.Detached key; + private final Detached key; private final TypeDescription declaringType; private final MethodDescription.Token methodToken; - public Node(Key.Detached key, TypeDescription declaringType, MethodDescription.Token methodToken) { + public Node(Detached key, TypeDescription declaringType, MethodDescription.Token methodToken) { this.key = key; this.declaringType = declaringType; this.methodToken = methodToken; diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultIdentifierForJVMMethodTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultHarmonizerForJVMMethodTest.java similarity index 89% rename from byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultIdentifierForJVMMethodTest.java rename to byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultHarmonizerForJVMMethodTest.java index c1f5f16c7f7..bf0652d7ab9 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultIdentifierForJVMMethodTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultHarmonizerForJVMMethodTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class MethodGraphCompilerDefaultIdentifierForJVMMethodTest { +public class MethodGraphCompilerDefaultHarmonizerForJVMMethodTest { private static final String FOO = "foo", BAR = "bar"; @@ -50,7 +50,7 @@ public void setUp() throws Exception { @Test public void testMethodEqualityHashCode() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -58,7 +58,7 @@ public void testMethodEqualityHashCode() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)).hashCode(), - is(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + is(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -70,7 +70,7 @@ public void testMethodEqualityHashCode() throws Exception { @Test public void testMethodNameInequalityHashCode() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -78,7 +78,7 @@ public void testMethodNameInequalityHashCode() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)).hashCode(), - is(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(BAR, + is(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(BAR, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -90,7 +90,7 @@ public void testMethodNameInequalityHashCode() throws Exception { @Test public void testReturnTypeInequalityHashCode() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -98,7 +98,7 @@ public void testReturnTypeInequalityHashCode() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)).hashCode(), - not(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + not(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), second, @@ -110,7 +110,7 @@ public void testReturnTypeInequalityHashCode() throws Exception { @Test public void testParameterTypeInequalityHashCode() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -118,7 +118,7 @@ public void testParameterTypeInequalityHashCode() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)).hashCode(), - not(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + not(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -130,7 +130,7 @@ public void testParameterTypeInequalityHashCode() throws Exception { @Test public void testParameterTypeLengthInequalityHashCode() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -138,7 +138,7 @@ public void testParameterTypeLengthInequalityHashCode() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)).hashCode(), - not(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + not(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -150,7 +150,7 @@ public void testParameterTypeLengthInequalityHashCode() throws Exception { @Test public void testMethodEquality() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -158,7 +158,7 @@ public void testMethodEquality() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)), - is(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + is(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -170,7 +170,7 @@ public void testMethodEquality() throws Exception { @Test public void testMethodNameInequality() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -178,7 +178,7 @@ public void testMethodNameInequality() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)), - is(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(BAR, + is(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(BAR, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -190,7 +190,7 @@ public void testMethodNameInequality() throws Exception { @Test public void testReturnTypeInequality() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -198,7 +198,7 @@ public void testReturnTypeInequality() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)), - not(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + not(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), second, @@ -210,7 +210,7 @@ public void testReturnTypeInequality() throws Exception { @Test public void testParameterTypeInequality() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -218,7 +218,7 @@ public void testParameterTypeInequality() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)), - not(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + not(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -230,7 +230,7 @@ public void testParameterTypeInequality() throws Exception { @Test public void testParameterTypeLengthInequality() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -238,7 +238,7 @@ public void testParameterTypeLengthInequality() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)), - not(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + not(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), first, @@ -251,12 +251,12 @@ public void testParameterTypeLengthInequality() throws Exception { @Test public void testFactory() throws Exception { assertThat(MethodGraph.Compiler.Default.forJVMHierarchy(), is((MethodGraph.Compiler) new MethodGraph.Compiler - .Default(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.INSTANCE))); + .Default(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.INSTANCE))); } @Test public void testObjectProperties() throws Exception { - ObjectPropertyAssertion.of(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.Token.class).create(new ObjectPropertyAssertion.Creator() { + ObjectPropertyAssertion.of(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.Token.class).create(new ObjectPropertyAssertion.Creator() { @Override public MethodDescription.Token create() { MethodDescription.Token methodToken = mock(MethodDescription.Token.class); @@ -268,6 +268,6 @@ public MethodDescription.Token create() { return methodToken; } }).applyBasic(); - ObjectPropertyAssertion.of(MethodGraph.Compiler.Default.Identifier.ForJVMMethod.class).apply(); + ObjectPropertyAssertion.of(MethodGraph.Compiler.Default.Harmonizer.ForJVMMethod.class).apply(); } } diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultIdentifierForJavaMethodTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultHarmonizerForJavaMethodTest.java similarity index 90% rename from byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultIdentifierForJavaMethodTest.java rename to byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultHarmonizerForJavaMethodTest.java index bfadd47baf0..7201f88de91 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultIdentifierForJavaMethodTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultHarmonizerForJavaMethodTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class MethodGraphCompilerDefaultIdentifierForJavaMethodTest { +public class MethodGraphCompilerDefaultHarmonizerForJavaMethodTest { private static final String FOO = "foo", BAR = "bar"; @@ -50,7 +50,7 @@ public void setUp() throws Exception { @Test public void testMethodEquality() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), mock(GenericTypeDescription.class), @@ -58,7 +58,7 @@ public void testMethodEquality() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)), - is(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + is(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), mock(GenericTypeDescription.class), @@ -70,7 +70,7 @@ public void testMethodEquality() throws Exception { @Test public void testMethodNameInequality() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), mock(GenericTypeDescription.class), @@ -78,7 +78,7 @@ public void testMethodNameInequality() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)), - is(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(BAR, + is(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(BAR, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), mock(GenericTypeDescription.class), @@ -90,7 +90,7 @@ public void testMethodNameInequality() throws Exception { @Test public void testReturnTypeEquality() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), mock(GenericTypeDescription.class), @@ -98,7 +98,7 @@ public void testReturnTypeEquality() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)), - is(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + is(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), mock(GenericTypeDescription.class), @@ -110,7 +110,7 @@ public void testReturnTypeEquality() throws Exception { @Test public void testParameterTypeInequality() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), mock(GenericTypeDescription.class), @@ -118,7 +118,7 @@ public void testParameterTypeInequality() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)), - not(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + not(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), mock(GenericTypeDescription.class), @@ -130,7 +130,7 @@ public void testParameterTypeInequality() throws Exception { @Test public void testParameterTypeLengthInequality() throws Exception { - assertThat(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + assertThat(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), mock(GenericTypeDescription.class), @@ -138,7 +138,7 @@ public void testParameterTypeLengthInequality() throws Exception { Collections.singletonList(mock(GenericTypeDescription.class)), Collections.singletonList(mock(AnnotationDescription.class)), MethodDescription.NO_DEFAULT_VALUE)), - not(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, + not(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE.wrap(new MethodDescription.Token(FOO, MODIFIERS, Collections.singletonList(mock(GenericTypeDescription.class)), mock(GenericTypeDescription.class), @@ -151,12 +151,12 @@ public void testParameterTypeLengthInequality() throws Exception { @Test public void testFactory() throws Exception { assertThat(MethodGraph.Compiler.Default.forJavaHierarchy(), is((MethodGraph.Compiler) new MethodGraph.Compiler - .Default(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.INSTANCE))); + .Default(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.INSTANCE))); } @Test public void testObjectProperties() throws Exception { - ObjectPropertyAssertion.of(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.Token.class).create(new ObjectPropertyAssertion.Creator() { + ObjectPropertyAssertion.of(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.Token.class).create(new ObjectPropertyAssertion.Creator() { @Override public MethodDescription.Token create() { MethodDescription.Token methodToken = mock(MethodDescription.Token.class); @@ -169,6 +169,6 @@ public MethodDescription.Token create() { return methodToken; } }).applyBasic(); - ObjectPropertyAssertion.of(MethodGraph.Compiler.Default.Identifier.ForJavaMethod.class).apply(); + ObjectPropertyAssertion.of(MethodGraph.Compiler.Default.Harmonizer.ForJavaMethod.class).apply(); } } diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultKeyTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultKeyTest.java index 92e111f766b..69d02338548 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultKeyTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/MethodGraphCompilerDefaultKeyTest.java @@ -75,24 +75,21 @@ public void testNotEqualsDistinctSet() throws Exception { @Test(expected = IllegalStateException.class) @SuppressWarnings("unchecked") public void testInitialEntryCannotBeMerged() throws Exception { - new MethodGraph.Compiler.Default.Key.Store.Entry.Initial(new MethodGraph.Compiler.Default.Key - .Identifying(FOO, Collections.emptyMap())) - .mergeWith(mock(MethodGraph.Compiler.Default.Key.Identifying.class)); + new MethodGraph.Compiler.Default.Key.Store.Entry.Initial(new MethodGraph.Compiler.Default.Key.Harmonized(FOO, Collections.emptyMap())) + .mergeWith(mock(MethodGraph.Compiler.Default.Key.Harmonized.class)); } @Test(expected = IllegalStateException.class) @SuppressWarnings("unchecked") public void testInitialEntryCannotBeTransformed() throws Exception { - new MethodGraph.Compiler.Default.Key.Store.Entry.Initial(new MethodGraph.Compiler.Default.Key - .Identifying(FOO, Collections.emptyMap())) + new MethodGraph.Compiler.Default.Key.Store.Entry.Initial(new MethodGraph.Compiler.Default.Key.Harmonized(FOO, Collections.emptyMap())) .asNode(); } @Test(expected = IllegalStateException.class) @SuppressWarnings("unchecked") public void testInitialEntryCannotExposeKey() throws Exception { - new MethodGraph.Compiler.Default.Key.Store.Entry.Initial(new MethodGraph.Compiler.Default.Key - .Identifying(FOO, Collections.emptyMap())) + new MethodGraph.Compiler.Default.Key.Store.Entry.Initial(new MethodGraph.Compiler.Default.Key.Harmonized(FOO, Collections.emptyMap())) .getKey(); } @@ -104,7 +101,7 @@ public Set create() { return Collections.singleton(new Object()); } }).applyBasic(); - ObjectPropertyAssertion.of(MethodGraph.Compiler.Default.Key.Identifying.class).create(new ObjectPropertyAssertion.Creator>() { + ObjectPropertyAssertion.of(MethodGraph.Compiler.Default.Key.Harmonized.class).create(new ObjectPropertyAssertion.Creator>() { @Override public Set create() { return Collections.singleton(new Object());