s = SignatureAttribute.toClassSignature(sig).toString(); else if (kind == 'm') s = SignatureAttribute.toMethodSignature(sig).toString(); else s = SignatureAttribute.toFieldSignature(sig).toString();
s = SignatureAttribute.toClassSignature(sig).toString(); else if (kind == 'm') s = SignatureAttribute.toMethodSignature(sig).toString(); else s = SignatureAttribute.toFieldSignature(sig).toString();
private static String inferMethodTypeName(CtMethod method) { try { if ( method.getMethodInfo2().getAttribute( SignatureAttribute.tag ) == null ) { return method.getReturnType().getName(); } return inferGenericTypeName( method.getReturnType(), SignatureAttribute.toMethodSignature( method.getGenericSignature() ).getReturnType() ); } catch (BadBytecode ignore) { return null; } catch (NotFoundException e) { return null; } }
protected MethodSignature getMethodSignature() { if (!initializedMethodSignature) { try { String sig = behaviour.getGenericSignature(); if (sig != null) methodSignature = SignatureAttribute.toMethodSignature(sig); } catch (BadBytecode e) { throw new RuntimeException(e); } initializedMethodSignature = true; } return methodSignature; }
@Override public List<ResolvedTypeParameterDeclaration> getTypeParameters() { try { if (ctConstructor.getGenericSignature() == null) { return Collections.emptyList(); } SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctConstructor.getGenericSignature()); return Arrays.stream(methodSignature.getTypeParameters()).map((jasTp) -> new JavassistTypeParameter(jasTp, this, typeSolver)).collect(Collectors.toList()); } catch (BadBytecode badBytecode) { throw new RuntimeException(badBytecode); } }
@Override public List<ResolvedTypeParameterDeclaration> getTypeParameters() { try { if (ctMethod.getGenericSignature() == null) { return Collections.emptyList(); } SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctMethod.getGenericSignature()); return Arrays.stream(methodSignature.getTypeParameters()).map((jasTp) -> new JavassistTypeParameter(jasTp, this, typeSolver)).collect(Collectors.toList()); } catch (BadBytecode badBytecode) { throw new RuntimeException(badBytecode); } }
@Override public List<ResolvedTypeParameterDeclaration> getTypeParameters() { try { if (ctMethod.getGenericSignature() == null) { return Collections.emptyList(); } SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctMethod.getGenericSignature()); return Arrays.stream(methodSignature.getTypeParameters()).map((jasTp) -> new JavassistTypeParameter(jasTp, this, typeSolver)).collect(Collectors.toList()); } catch (BadBytecode badBytecode) { throw new RuntimeException(badBytecode); } }
@Override public List<ResolvedTypeParameterDeclaration> getTypeParameters() { try { if (ctConstructor.getGenericSignature() == null) { return Collections.emptyList(); } SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctConstructor.getGenericSignature()); return Arrays.stream(methodSignature.getTypeParameters()).map((jasTp) -> new JavassistTypeParameter(jasTp, this, typeSolver)).collect(Collectors.toList()); } catch (BadBytecode badBytecode) { throw new RuntimeException(badBytecode); } }
@Override public List<ResolvedTypeParameterDeclaration> getTypeParameters() { try { if (ctConstructor.getGenericSignature() == null) { return Collections.emptyList(); } SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctConstructor.getGenericSignature()); return Arrays.stream(methodSignature.getTypeParameters()).map((jasTp) -> new JavassistTypeParameter(jasTp, this, typeSolver)).collect(Collectors.toList()); } catch (BadBytecode badBytecode) { throw new RuntimeException(badBytecode); } }
@Override public List<ResolvedTypeParameterDeclaration> getTypeParameters() { try { if (ctMethod.getGenericSignature() == null) { return Collections.emptyList(); } SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctMethod.getGenericSignature()); return Arrays.stream(methodSignature.getTypeParameters()).map((jasTp) -> new JavassistTypeParameter(jasTp, this, typeSolver)).collect(Collectors.toList()); } catch (BadBytecode badBytecode) { throw new RuntimeException(badBytecode); } }
@Override public ResolvedType getReturnType() { try { if (ctMethod.getGenericSignature() != null) { javassist.bytecode.SignatureAttribute.Type genericSignatureType = SignatureAttribute.toMethodSignature(ctMethod.getGenericSignature()).getReturnType(); return JavassistUtils.signatureTypeToType(genericSignatureType, typeSolver, this); } else { return JavassistFactory.typeUsageFor(ctMethod.getReturnType(), typeSolver); } } catch (NotFoundException e) { throw new RuntimeException(e); } catch (BadBytecode e) { throw new RuntimeException(e); } }
@Override public ResolvedType getReturnType() { try { if (ctMethod.getGenericSignature() != null) { javassist.bytecode.SignatureAttribute.Type genericSignatureType = SignatureAttribute.toMethodSignature(ctMethod.getGenericSignature()).getReturnType(); return JavassistUtils.signatureTypeToType(genericSignatureType, typeSolver, this); } else { return JavassistFactory.typeUsageFor(ctMethod.getReturnType(), typeSolver); } } catch (NotFoundException e) { throw new RuntimeException(e); } catch (BadBytecode e) { throw new RuntimeException(e); } }
@Override public ResolvedType getReturnType() { try { if (ctMethod.getGenericSignature() != null) { javassist.bytecode.SignatureAttribute.Type genericSignatureType = SignatureAttribute.toMethodSignature(ctMethod.getGenericSignature()).getReturnType(); return JavassistUtils.signatureTypeToType(genericSignatureType, typeSolver, this); } else { return JavassistFactory.typeUsageFor(ctMethod.getReturnType(), typeSolver); } } catch (NotFoundException | BadBytecode e) { throw new RuntimeException(e); } }
@Override public ResolvedParameterDeclaration getParam(int i) { try { boolean variadic = false; if ((ctMethod.getModifiers() & javassist.Modifier.VARARGS) > 0) { variadic = i == (ctMethod.getParameterTypes().length - 1); } Optional<String> paramName = JavassistUtils.extractParameterName(ctMethod, i); if (ctMethod.getGenericSignature() != null) { SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctMethod.getGenericSignature()); SignatureAttribute.Type signatureType = methodSignature.getParameterTypes()[i]; return new JavassistParameterDeclaration(JavassistUtils.signatureTypeToType(signatureType, typeSolver, this), typeSolver, variadic, paramName.orElse(null)); } else { return new JavassistParameterDeclaration(ctMethod.getParameterTypes()[i], typeSolver, variadic, paramName.orElse(null)); } } catch (NotFoundException | BadBytecode e) { throw new RuntimeException(e); } }
private static String inferMethodTypeName(CtMethod method) { try { if ( method.getMethodInfo2().getAttribute( SignatureAttribute.tag ) == null ) { return method.getReturnType().getName(); } return inferGenericTypeName( method.getReturnType(), SignatureAttribute.toMethodSignature( method.getGenericSignature() ).getReturnType() ); } catch (BadBytecode ignore) { return null; } catch (NotFoundException e) { return null; } }
@Override public ResolvedParameterDeclaration getParam(int i) { try { boolean variadic = false; if ((ctMethod.getModifiers() & javassist.Modifier.VARARGS) > 0) { variadic = i == (ctMethod.getParameterTypes().length - 1); } if (ctMethod.getGenericSignature() != null) { SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctMethod.getGenericSignature()); SignatureAttribute.Type signatureType = methodSignature.getParameterTypes()[i]; return new JavassistParameterDeclaration(JavassistUtils.signatureTypeToType(signatureType, typeSolver, this), typeSolver, variadic); } else { return new JavassistParameterDeclaration(ctMethod.getParameterTypes()[i], typeSolver, variadic); } } catch (NotFoundException e) { throw new RuntimeException(e); } catch (BadBytecode badBytecode) { throw new RuntimeException(badBytecode); } }
@Override public ResolvedParameterDeclaration getParam(int i) { try { boolean variadic = false; if ((ctConstructor.getModifiers() & javassist.Modifier.VARARGS) > 0) { variadic = i == (ctConstructor.getParameterTypes().length - 1); } if (ctConstructor.getGenericSignature() != null) { SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctConstructor.getGenericSignature()); SignatureAttribute.Type signatureType = methodSignature.getParameterTypes()[i]; return new JavassistParameterDeclaration(JavassistUtils.signatureTypeToType(signatureType, typeSolver, this), typeSolver, variadic); } else { return new JavassistParameterDeclaration(ctConstructor.getParameterTypes()[i], typeSolver, variadic); } } catch (NotFoundException e) { throw new RuntimeException(e); } catch (BadBytecode badBytecode) { throw new RuntimeException(badBytecode); } }
@Override public ResolvedParameterDeclaration getParam(int i) { try { boolean variadic = false; if ((ctConstructor.getModifiers() & javassist.Modifier.VARARGS) > 0) { variadic = i == (ctConstructor.getParameterTypes().length - 1); } if (ctConstructor.getGenericSignature() != null) { SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctConstructor.getGenericSignature()); SignatureAttribute.Type signatureType = methodSignature.getParameterTypes()[i]; return new JavassistParameterDeclaration(JavassistUtils.signatureTypeToType(signatureType, typeSolver, this), typeSolver, variadic); } else { return new JavassistParameterDeclaration(ctConstructor.getParameterTypes()[i], typeSolver, variadic); } } catch (NotFoundException e) { throw new RuntimeException(e); } catch (BadBytecode badBytecode) { throw new RuntimeException(badBytecode); } }
private static InternalMethodDefinition toInternalMethodDefinition(CtMethod ctMethod, SymbolResolver resolver) { try { Map<String, TypeUsageNode.TypeVariableData> visibleTypeVariables = getVisibleTypeVariables(ctMethod); TypeUsage returnType = toTypeUsage(ctMethod.getReturnType(), resolver); if (ctMethod.getGenericSignature() != null) { SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(ctMethod.getGenericSignature()); returnType = toTypeUsage(methodSignature.getReturnType(), resolver, visibleTypeVariables); } return new InternalMethodDefinition(ctMethod.getName(), formalParameters(ctMethod, resolver), returnType, JavassistTypeDefinitionFactory.toMethodDefinition(ctMethod)); } catch (NotFoundException e) { throw new RuntimeException(e); } catch (BadBytecode badBytecode) { throw new RuntimeException(badBytecode); } }
private String transformMethodSignature(SignatureAttribute signatureAttribute) throws BadBytecode { String originalSig = signatureAttribute.getSignature(); SignatureAttribute.MethodSignature methodSignature = SignatureAttribute.toMethodSignature(originalSig); SignatureAttribute.ClassType returnType = new SignatureAttribute.ClassType("javax.ws.rs.core.Response"); SignatureAttribute.MethodSignature replacementSignature = new SignatureAttribute.MethodSignature( methodSignature.getTypeParameters(), methodSignature.getParameterTypes(), returnType, methodSignature.getExceptionTypes()); return replacementSignature.encode(); } }