Skip to content

Commit

Permalink
Add names for generated cache variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Dec 20, 2020
1 parent 16b5411 commit e02a2f9
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public static ClassFileVersion ofJavaVersion(int javaVersion) {
*
* @return The currently running Java process's class file version.
*/
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("vm")
public static ClassFileVersion ofThisVm() {
return VERSION_LOCATOR.locate();
}
Expand Down
2 changes: 1 addition & 1 deletion byte-buddy-dep/src/main/java/net/bytebuddy/TypeCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public SimpleKey(Collection<? extends Class<?>> types) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return types.hashCode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private boolean equalsRepresentation(Object self, Object other) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = annotationType.hashCode();
result = 31 * result + values.hashCode();
Expand Down Expand Up @@ -433,7 +433,7 @@ public boolean isDocumented() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int hashCode = 0;
for (MethodDescription.InDefinedShape methodDescription : getAnnotationType().getDeclaredMethods()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ public AnnotationValue.Loaded<U> load(ClassLoader classLoader) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return propertyDelegate.hashCode(value);
}
Expand Down Expand Up @@ -1359,7 +1359,7 @@ public boolean represents(Object value) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return propertyDelegate.hashCode(value);
}
Expand Down Expand Up @@ -2143,7 +2143,7 @@ public AnnotationValue.Loaded<V> load(ClassLoader classLoader) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = 1;
for (AnnotationValue<?, ?> value : values) {
Expand Down Expand Up @@ -2254,7 +2254,7 @@ public boolean represents(Object value) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = 1;
for (AnnotationValue.Loaded<?> value : values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public String getActualName() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return getValue().hashCode() + 31 * getEnumerationType().hashCode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public SignatureToken asSignatureToken() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return getDeclaringType().hashCode() + 31 * (17 + getName().hashCode());
}
Expand Down Expand Up @@ -587,7 +587,7 @@ public SignatureToken asSignatureToken(TypeDescription declaringType) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = name.hashCode();
result = 31 * result + modifiers;
Expand Down Expand Up @@ -656,7 +656,7 @@ public TypeDescription getType() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = name.hashCode();
result = 31 * result + type.hashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ public boolean isBridgeCompatible(TypeToken typeToken) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int hashCode = 17 + getDeclaringType().hashCode();
hashCode = 31 * hashCode + getInternalName().hashCode();
Expand Down Expand Up @@ -1918,7 +1918,7 @@ public SignatureToken asSignatureToken(TypeDescription declaringType) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = name.hashCode();
result = 31 * result + modifiers;
Expand Down Expand Up @@ -2038,7 +2038,7 @@ public TypeToken asTypeToken() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = name.hashCode();
result = 31 * result + returnType.hashCode();
Expand Down Expand Up @@ -2121,7 +2121,7 @@ public List<TypeDescription> getParameterTypes() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = returnType.hashCode();
result = 31 * result + parameterTypes.hashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public Token asToken(ElementMatcher<? super TypeDescription> matcher) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return getDeclaringMethod().hashCode() ^ getIndex();
}
Expand Down Expand Up @@ -1254,7 +1254,7 @@ public Token accept(TypeDescription.Generic.Visitor<? extends TypeDescription.Ge
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = type.hashCode();
result = 31 * result + annotations.hashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ public Token accept(TypeDescription.Generic.Visitor<? extends TypeDescription.Ge
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = name.hashCode();
result = 31 * result + type.hashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3868,7 +3868,7 @@ public Iterator<TypeDefinition> iterator() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return asErasure().hashCode();
}
Expand Down Expand Up @@ -4423,7 +4423,7 @@ public StackSize getStackSize() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return getSort().isNonGeneric()
? asErasure().hashCode()
Expand Down Expand Up @@ -4716,7 +4716,7 @@ public StackSize getStackSize() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int lowerHash = 1, upperHash = 1;
for (Generic lowerBound : getLowerBounds()) {
Expand Down Expand Up @@ -5157,7 +5157,7 @@ public StackSize getStackSize() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = 1;
for (Generic typeArgument : getTypeArguments()) {
Expand Down Expand Up @@ -5756,7 +5756,7 @@ public Iterator<TypeDefinition> iterator() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return getTypeVariableSource().hashCode() ^ getSymbol().hashCode();
}
Expand Down Expand Up @@ -6337,7 +6337,7 @@ public boolean represents(java.lang.reflect.Type type) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return resolve().hashCode();
}
Expand Down Expand Up @@ -8174,7 +8174,7 @@ public Iterator<TypeDefinition> iterator() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return getName().hashCode();
}
Expand Down Expand Up @@ -9260,7 +9260,7 @@ protected InternalNameLazyType(ClassLoader classLoader, String internalName) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("delegate")
protected TypeDescription delegate() {
try {
return ForLoadedType.of(Class.forName(getName(), false, classLoader));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public TypeVariableToken accept(TypeDescription.Generic.Visitor<? extends TypeDe
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
int result = symbol.hashCode();
result = 31 * result + bounds.hashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,6 @@ public TypeDescription getDeclaringType() {
/**
* {@inheritDoc}
*/
@CachedReturnPlugin.Enhance
public Generic getSuperClass() {
return superClass == null
? Generic.UNDEFINED
Expand All @@ -1381,31 +1380,27 @@ public Generic getSuperClass() {
/**
* {@inheritDoc}
*/
@CachedReturnPlugin.Enhance
public TypeList.Generic getInterfaces() {
return new TypeList.Generic.ForDetachedTypes.WithResolvedErasure(interfaceTypes, TypeDescription.Generic.Visitor.Substitutor.ForAttachment.of(this));
}

/**
* {@inheritDoc}
*/
@CachedReturnPlugin.Enhance
public FieldList<FieldDescription.InDefinedShape> getDeclaredFields() {
return new FieldList.ForTokens(this, fieldTokens);
}

/**
* {@inheritDoc}
*/
@CachedReturnPlugin.Enhance
public MethodList<MethodDescription.InDefinedShape> getDeclaredMethods() {
return new MethodList.ForTokens(this, methodTokens);
}

/**
* {@inheritDoc}
*/
@CachedReturnPlugin.Enhance
public TypeList.Generic getTypeVariables() {
return TypeList.Generic.ForDetachedTypes.attachVariables(this, typeVariables);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public boolean isValid() {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return 31 * getMethodDescription().asSignatureToken().hashCode() + getTypeDescription().hashCode();
}
Expand Down
8 changes: 4 additions & 4 deletions byte-buddy-dep/src/main/java/net/bytebuddy/pool/TypePool.java
Original file line number Diff line number Diff line change
Expand Up @@ -6028,7 +6028,7 @@ public Loaded<V> load(ClassLoader classLoader) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("hashCode")
public int hashCode() {
return doResolve().hashCode();
}
Expand Down Expand Up @@ -6070,7 +6070,7 @@ private ForTypeValue(TypePool typePool, String typeName) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("resolved")
@SuppressWarnings("unchecked")
protected AnnotationValue<TypeDescription, Class<?>> doResolve() {
Resolution resolution = typePool.describe(typeName);
Expand Down Expand Up @@ -6107,7 +6107,7 @@ private ForAnnotationValue(TypePool typePool, AnnotationToken annotationToken) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("resolved")
protected AnnotationValue<AnnotationDescription, Annotation> doResolve() {
AnnotationToken.Resolution resolution = annotationToken.toAnnotationDescription(typePool);
if (!resolution.isResolved()) {
Expand Down Expand Up @@ -6154,7 +6154,7 @@ private ForEnumerationValue(TypePool typePool, String typeName, String value) {
}

@Override
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("resolved")
@SuppressWarnings("unchecked")
protected AnnotationValue<EnumerationDescription, Enum<?>> doResolve() {
Resolution resolution = typePool.describe(typeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public TypeDescription getTypeStub() {
* @return A loaded type of this Java type.
* @throws ClassNotFoundException If the represented type cannot be loaded.
*/
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("loaded")
public Class<?> load() throws ClassNotFoundException {
return Class.forName(typeDescription.getName(), false, ClassLoadingStrategy.BOOTSTRAP_LOADER);
}
Expand All @@ -244,7 +244,7 @@ public TypeDescription loadAsDescription() throws ClassNotFoundException {
*
* @return {@code true} if this type is available on the current JVM.
*/
@CachedReturnPlugin.Enhance
@CachedReturnPlugin.Enhance("available")
public boolean isAvailable() {
try {
load();
Expand Down

0 comments on commit e02a2f9

Please sign in to comment.