# 代理模式 **Repository Path**: gitLDR_admin/proxy_pattern ## Basic Information - **Project Name**: 代理模式 - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-03-15 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 代理模式 #### 思考:为什么JDK动态代理中要求目标类实现的接口数量不能超过65535个? JVM虚拟机规范规定的。 ``` ClassFile 结构体,如下: ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; } ``` interfaces_count 接口计数器,interfaces_count 的值表示当前类或接口的直接父接口数量。类型是u2, 2个字节,即 2^16-1 = 65536-1 = 65535,所以目标类实现的接口数量不能超过65535个