public native boolean isPrimitive();
该方法只有八种基本类型的wrapper 类以及void 的wrapper类会返回true.
/** * Gets the signers of this class. * * @return the signers of this class, or null if there are no signers. In * particular, this method returns null if this object represents * a primitive type or void. * @since JDK1.1 */ public native Object[] getSigners(); /** * Set the signers of this class. */ native void setSigners(Object[] signers);
这2个方法的意思很简单,就是get/set签名,但我 不清楚这2个方法有啥子用途>>>
public Method getEnclosingMethod() { EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo();//得到enclosing类的信息 if (enclosingInfo == null) return null; else { if (!enclosingInfo.isMethod())//排除构造方法 return null; MethodRepository typeInfo = MethodRepository.make(enclosingInfo.getDescriptor(), getFactory()); Class<?> returnType = toClass(typeInfo.getReturnType()); Type [] parameterTypes = typeInfo.getParameterTypes(); Class<?>[] parameterClasses = new Class<?>[parameterTypes.length]; //得到enclosing方法的返回值类型,参数类型 // Convert Types to Classes; returned types *should* // be class objects since the methodDescriptor's used // don't have generics information for(int i = 0; i < parameterClasses.length; i++) parameterClasses[i] = toClass(parameterTypes[i]); /* * Loop over all declared methods; match method name, * number of and type of parameters, *and* return * type. Matching return type is also necessary * because of covariant returns, etc. */ //比对类的返回值,名字,参数等信息,得到相同的method并返回 for(Method m: enclosingInfo.getEnclosingClass().getDeclaredMethods()) { if (m.getName().equals(enclosingInfo.getName()) ) { Class<?>[] candidateParamClasses = m.getParameterTypes(); if (candidateParamClasses.length == parameterClasses.length) { boolean matches = true; for(int i = 0; i < candidateParamClasses.length; i++) { if (!candidateParamClasses[i].equals(parameterClasses[i])) { matches = false; break; } } if (matches) { // finally, check return type if (m.getReturnType().equals(returnType) ) return m; } } } } throw new InternalError("Enclosing method not found"); } }
类似的方法还有下面这个getEnclosingConstructor(),就不多做解释了
public Constructor<?> getEnclosingConstructor()
这些方法的重点在于: getEnclosingMethodInfo() 方法
private EnclosingMethodInfo getEnclosingMethodInfo() { Object[] enclosingInfo = getEnclosingMethod0(); // 如果方法内没有local class 或者Anonymous class,则enclosingInfo == null,如果有,就新建一个EnclosingMethodInfo 类 if (enclosingInfo == null) return null; else { return new EnclosingMethodInfo(enclosingInfo); } }
在看看2个方法
public native Class<?> getDeclaringClass(); //可以发现 getEnclosingClass()方法进一步wrapper了getDeclaringClass //如果得到的enclosingInfo 为null 就调用getDeclaringClass 方法 // 也就是说 getEnclosingClass不仅可以定位非方法内部类的声明位置,也可以定位方法内部类的声明位置 public Class<?> getEnclosingClass() { EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo(); //如果当前的Class不是方法内部类,则enclosingInfo为null, 否则有值非null。 if (enclosingInfo == null) { // This is a top level or a nested class or an inner class (a, b, or c) //不是方法内部类,直接调用getDeclaringClass() 方法 return getDeclaringClass(); } else { Class<?> enclosingClass = enclosingInfo.getEnclosingClass(); // This is a local class or an anonymous class (d or e) if (enclosingClass == this || enclosingClass == null) throw new InternalError("Malformed enclosing method information"); else //方法内部类,返回 enclosingInfo的属性 enclosingClass,也就是外层包围类 return enclosingClass; } }
相关推荐
历史学习软件越南越南学生的历史学习软件
#### 2 HSFDONES数据仓库 ##### 2.1 数据仓库结构 液压系统的故障信息通常存储在诸如数据库、Excel、TXT等不同格式的文件中,这些不同格式的数据无法有效地提供知识。数据仓库技术是解决这一问题的有效方案[1];...
2. **数据结构**:数据结构是编程中的核心概念,包括数组、链表、栈、队列、树、图等。这些mini程序可能设计了实现这些数据结构的代码,帮助你理解它们的运作方式以及如何在实际问题中应用。 3. **算法**:算法是...
Book name: Introduce for machine leaning 4th edition Author: Ethem Alpaydin
这个名为"spring-boot-leaning_Springbootleaning_springbootDemo_"的项目是为初学者设计的一个学习示例,旨在帮助那些对SpringBoot感兴趣的新手快速入门。 SpringBoot的核心特性包括: 1. **自动配置**:...
书籍默认解压密码 kevin.blog.csdn.net 没有积分联系博主获取。【声明】本书籍来源于网络,版权归原作者所有,仅供大家共同分享学习,请勿用于商业用途。
《Leaning OpenCV》英文原版附带得源码,很有用得东西哦!
2. **经典层次聚类(Hierarchical Clustering)**: 层次聚类分为凝聚型(Agglomerative)和分裂型(Divisive)。前者从单个数据点开始,逐步合并相似的簇;后者则从所有数据点组成的大簇开始,不断分裂成更小的簇...
LearningOpenCV英文版+学习OpenCV中文版+书中例程 + Leaning OpenCV3 完整版 图像处理学习入门资料,英文原LearningOpenCV,中文版学习opencv,以及书中涉及到的例程。对图像处理入门很大的帮助。
Springboot42讲打包资源,包括文档和源码,需要学习的可以下载. Springboot42讲打包资源,包括文档和源码,需要学习的可以下载. Springboot42讲打包资源,包括文档和源码,需要学习的可以下载.
machine leaning 谷歌课程
在“Leaning-PHP”这个项目中,我们可以看到作者正在通过实践来学习和提升PHP编程技能。PHP(Hypertext Preprocessor)是一种广泛使用的开源脚本语言,特别适合于Web开发,可嵌入到HTML中。它允许开发者动态地创建...
在提供的文件信息中,我们看到了一个关于斯坦福机器学习课程讲义的概述,其中详细描述了监督学习的一些基础概念,以及线性回归的入门知识。下面我们将详细梳理这些知识点。 首先,讲义提到了监督学习问题的几个例子...
e-leaning
斯坦福机器学习讲义
《Leaning Spring MVC》
该文档主要介绍了OPENCV的基础知识和一些基本操作(如图像、视频读取以及图像处理等)
spring-boot-leaning:Spring Boot 2.X最全课程代码