zoukankan      html  css  js  c++  java
  • jdk 1.8 InvocationHandler 中文注释

    JDK动态代理实现了接口InvocationHandler重写了invoke类
    动态代理的底层是通过反射技术来实现

    先翻译这一点,知道这是干啥的了。下面的解释以后有机会再翻译

    /*
     * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
     * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
     */
    package java.lang.reflect;
    /**
     * {@code InvocationHandler} 由代理实例 invocation handler 实现的接口.
     * invocation handler:调用处理程序
     *
     * <p>每个代理实例都有一个关联的 invocation handler.
     * 当一个方法被一个代理实例调用时, 将对该方法调用进行编码,
     * 并将其调度到invocation handler的 {@code invoke}方法.
     * 
     * @author      Peter Jones
     * @translator  oc
     * @see         Proxy
     * @since       1.3
     */
    public interface InvocationHandler {
        /**
         * 处理代理实例上的方法调用并返回结果。
         * 在与之关联的代理实例上调用方法时,将在调用处理程序上调用该方法。
         *
         * @param   proxy 被调用方法上的代理实例
         *
         * @param   method the {@code Method} instance corresponding to
         * the interface method invoked on the proxy instance.  The declaring
         * class of the {@code Method} object will be the interface that
         * the method was declared in, which may be a superinterface of the
         * proxy interface that the proxy class inherits the method through.
         *
         * @param   args an array of objects containing the values of the
         * arguments passed in the method invocation on the proxy instance,
         * or {@code null} if interface method takes no arguments.
         * Arguments of primitive types are wrapped in instances of the
         * appropriate primitive wrapper class, such as
         * {@code java.lang.Integer} or {@code java.lang.Boolean}.
         *
         * @return  the value to return from the method invocation on the
         * proxy instance.  If the declared return type of the interface
         * method is a primitive type, then the value returned by
         * this method must be an instance of the corresponding primitive
         * wrapper class; otherwise, it must be a type assignable to the
         * declared return type.  If the value returned by this method is
         * {@code null} and the interface method's return type is
         * primitive, then a {@code NullPointerException} will be
         * thrown by the method invocation on the proxy instance.  If the
         * value returned by this method is otherwise not compatible with
         * the interface method's declared return type as described above,
         * a {@code ClassCastException} will be thrown by the method
         * invocation on the proxy instance.
         *
         * @throws  Throwable the exception to throw from the method
         * invocation on the proxy instance.  The exception's type must be
         * assignable either to any of the exception types declared in the
         * {@code throws} clause of the interface method or to the
         * unchecked exception types {@code java.lang.RuntimeException}
         * or {@code java.lang.Error}.  If a checked exception is
         * thrown by this method that is not assignable to any of the
         * exception types declared in the {@code throws} clause of
         * the interface method, then an
         * {@link UndeclaredThrowableException} containing the
         * exception that was thrown by this method will be thrown by the
         * method invocation on the proxy instance.
         *
         * @see     UndeclaredThrowableException
         */
        public Object invoke(Object proxy, Method method, Object[] args)
            throws Throwable;
    }
    
  • 相关阅读:
    Gym 100553B Burrito King 无脑背包
    BestCoder Round #85 A B C
    poj 1687 Buggy Sat 简单计算几何
    HDU 1863 Kruskal求最小生成树
    记2016商大ACM省赛
    COMP9517 Week7 Tracking
    COMP9517 week7 Motion
    COMP9313 week7b Spark SQL
    COMP9313 Week 7 Product Quantization and K-Means Clustering
    COMP9517 lab3 image segementation
  • 原文地址:https://www.cnblogs.com/ZCWang/p/12766146.html
Copyright © 2011-2022 走看看