Exemplo n.º 1
0
 /**
  * Extracts a handle type for the given identifier.
  *
  * @param identifier The identifier to extract a handle type for.
  * @return The representing handle type.
  */
 protected static HandleType of(int identifier) {
   for (HandleType handleType : HandleType.values()) {
     if (handleType.getIdentifier() == identifier) {
       return handleType;
     }
   }
   throw new IllegalArgumentException("Unknown handle type: " + identifier);
 }
Exemplo n.º 2
0
 /**
  * Returns a method handle for a getter of the given field.
  *
  * @param fieldDescription The field to represent.
  * @return A method handle for a getter of the given field.
  */
 public static MethodHandle ofSetter(FieldDescription fieldDescription) {
   return new MethodHandle(
       HandleType.ofSetter(fieldDescription),
       fieldDescription.getDeclaringType().asRawType(),
       fieldDescription.getInternalName(),
       TypeDescription.VOID,
       Collections.singletonList(fieldDescription.getType().asRawType()));
 }
Exemplo n.º 3
0
 /**
  * Returns a method handle for a setter of the given field.
  *
  * @param fieldDescription The field to represent.
  * @return A method handle for a setter of the given field.
  */
 public static MethodHandle ofGetter(FieldDescription fieldDescription) {
   return new MethodHandle(
       HandleType.ofGetter(fieldDescription),
       fieldDescription.getDeclaringType().asRawType(),
       fieldDescription.getInternalName(),
       fieldDescription.getType().asRawType(),
       Collections.<TypeDescription>emptyList());
 }
Exemplo n.º 4
0
 /**
  * Creates a method handle representation of the given method.
  *
  * @param methodDescription The method ro represent.
  * @return A method handle representing the given method.
  */
 public static MethodHandle of(MethodDescription methodDescription) {
   return new MethodHandle(
       HandleType.of(methodDescription),
       methodDescription.getDeclaringType().asRawType(),
       methodDescription.getInternalName(),
       methodDescription.getReturnType().asRawType(),
       methodDescription.getParameters().asTypeList().asRawTypes());
 }
Exemplo n.º 5
0
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    try {

      String requestURL = req.getRequestURL().toString();
      String handle = DisectHandle.disectHandle(requestURL);
      handle = URLDecoder.decode(handle, "UTF-8");

      HandleType handleType = HandleType.createType(handle);

      handleType.redirect(handle, solrAccess, req, resp);

    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
      resp.sendError(500);
    }
  }
Exemplo n.º 6
0
 @Override
 public int hashCode() {
   int result = handleType.hashCode();
   result = 31 * result + ownerType.hashCode();
   result = 31 * result + name.hashCode();
   result = 31 * result + returnType.hashCode();
   result = 31 * result + parameterTypes.hashCode();
   return result;
 }
Exemplo n.º 7
0
 /**
  * Creates a method handle representation of the given method for an explicit special method
  * invocation of an otherwise virtual method.
  *
  * @param methodDescription The method ro represent.
  * @param typeDescription The type on which the method is to be invoked on as a special method
  *     invocation.
  * @return A method handle representing the given method as special method invocation.
  */
 public static MethodHandle ofSpecial(
     MethodDescription methodDescription, TypeDescription typeDescription) {
   if (!methodDescription.isSpecializableFor(typeDescription)) {
     throw new IllegalArgumentException(
         "Cannot specialize " + methodDescription + " for " + typeDescription);
   }
   return new MethodHandle(
       HandleType.ofSpecial(methodDescription),
       typeDescription,
       methodDescription.getInternalName(),
       methodDescription.getReturnType().asRawType(),
       methodDescription.getParameters().asTypeList().asRawTypes());
 }
Exemplo n.º 8
0
 /**
  * Creates a method handles representation of a loaded method handle .
  *
  * @param methodHandle The loaded method handle to represent.
  * @param lookup The lookup object to use for analyzing the method handle.
  * @return A representation of the loaded method handle
  */
 public static MethodHandle of(Object methodHandle, Object lookup) {
   if (!JavaType.METHOD_HANDLE.getTypeStub().isInstance(methodHandle)) {
     throw new IllegalArgumentException("Expected method handle object: " + methodHandle);
   } else if (!JavaType.METHOD_HANDLES_LOOKUP.getTypeStub().isInstance(lookup)) {
     throw new IllegalArgumentException("Expected method handle lookup object: " + lookup);
   }
   Object methodHandleInfo =
       REVEAL_DIRECT.isInvokable()
           ? REVEAL_DIRECT.invoke(lookup, methodHandle)
           : NEW_METHOD_HANDLE_INFO.invokeStatic(methodHandle);
   Object methodType = GET_METHOD_TYPE.invoke(methodHandleInfo);
   return new MethodHandle(
       HandleType.of((Integer) GET_REFERENCE_KIND.invoke(methodHandleInfo)),
       new TypeDescription.ForLoadedType(
           (Class<?>) GET_DECLARING_CLASS.invoke(methodHandleInfo)),
       (String) GET_NAME.invoke(methodHandleInfo),
       new TypeDescription.ForLoadedType((Class<?>) RETURN_TYPE.invoke(methodType)),
       new TypeList.ForLoadedType((Class<?>[]) PARAMETER_ARRAY.invoke(methodType)));
 }