The method newInstance() from the type Class is deprecated since version 9
newInstance()在 java9中已被弃用
JAVA9之前用法
Class.forName("类的全限定名").newInstance();
JAVA9之后用法
Class.forName("类的全限定名").getDeclaredConstructor().newInstance();
源码说明
/**
* Uses the constructor represented by this {@code Constructor} object to
* create and initialize a new instance of the constructor's
* declaring class, with the specified initialization parameters.
* Individual parameters are automatically unwrapped to match
* primitive formal parameters, and both primitive and reference
* parameters are subject to method invocation conversions as necessary.
*
* <p>If the number of formal parameters required by the underlying constructor
* is 0, the supplied {@code initargs} array may be of length 0 or null.
*
* <p>If the constructor's declaring class is an inner class in a
* non-static context, the first argument to the constructor needs
* to be the enclosing instance; see section 15.9.3 of
* <cite>The Java™ Language Specification</cite>.
*
* <p>If the required access and argument checks succeed and the
* instantiation will proceed, the constructor's declaring class
* is initialized if it has not already been initialized.
*
* <p>If the constructor completes normally, returns the newly
* created and initialized instance.
*
* @param initargs array of objects to be passed as arguments to
* the constructor call; values of primitive types are wrapped in
* a wrapper object of the appropriate type (e.g. a {@code float}
* in a {@link java.lang.Float Float})
*
* @return a new object created by calling the constructor
* this object represents
*
* @exception IllegalAccessException if this {@code Constructor} object
* is enforcing Java language access control and the underlying
* constructor is inaccessible.
* @exception IllegalArgumentException if the number of actual
* and formal parameters differ; if an unwrapping
* conversion for primitive arguments fails; or if,
* after possible unwrapping, a parameter value
* cannot be converted to the corresponding formal
* parameter type by a method invocation conversion; if
* this constructor pertains to an enum type.
* @exception InstantiationException if the class that declares the
* underlying constructor represents an abstract class.
* @exception InvocationTargetException if the underlying constructor
* throws an exception.
* @exception ExceptionInInitializerError if the initialization provoked
* by this method fails.
*/
@CallerSensitive
@ForceInline // to ensure Reflection.getCallerClass optimization
public T newInstance(Object ... initargs)
throws InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException
{
Class<?> caller = override ? null : Reflection.getCallerClass();
return newInstanceWithCaller(initargs, !override, caller);
}
The method newInstance() from the type Class is deprecated since version 9的更多相关文章
- The method buildSessionFactory() from the type Configuration is deprecated.SessionFactory的变化
在创建Configuration对象之后:Configuration cfg = new Configuration().configure(); 要通过Configuration创建SessionF ...
- The method onClick(View) of type new View.OnClickListener(){} must override a superclass
最近在做一个jWebSocket Android客户端的Demo时遇到如下错误: ok —————— 最近在做一个jWebSocket Android客户端的Demo时遇到如下错误: ".. ...
- eclise -The method onClick(View) of type new View.OnClickListener(){} must override a superclass method
在做arcgis android开发的时候,突然遇到这种错误,The method onClick(View) of type new View.OnClickListener(){} must ov ...
- Bean property ‘mapperHelper’ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
spring boot 报错: Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ...
- JAVA克隆对象报错:The method clone() from the type Object is not visible
将一个对象复制一份,称为对象的克隆技术.在Object类汇总存在一个clone()方法:protected Onject clone() throws CloneNotSupportedExcepti ...
- eclise -The method onClick(View) of type new View.OnClickListener(){} must override a superclass method 在做arcgis android开发的时候,突然遇到这种错误,The method onClick(View) of type new View.OnClickListener(){} mus
eclise -The method onClick(View) of type new View.OnClickListener(){} must override a superclass met ...
- No control record for Activity type 1000/4220/1442 in version 000 / 2017 activity planning/qty planning
No control record for Activity type 1000/4220/1442 in version 000 / 2017 activity planning/qty plann ...
- IDEA Method definition shorthands are not supported by current JavaScript version
sentinel-dashboard前端用到了AngularJS v1.4.8,在IDEA里修改js,触发js验证时有一些js文件会出现红色波浪线. 在代码行里鼠标一上去提示信息:Method def ...
- 报错:Method definition shorthands are not supported by current JavaScript version
当你在html中使用调用js中的方法时,会出现这行报错: method definition shorthands are not supported by current JavaScript ve ...
随机推荐
- Java 创建线程的3种方法及各自优势
1. 继承 Thread 类,然后调用 start 方法. class MyThread extends Thread { //重写run方法,线程运行后,跑的就是run方法 public void ...
- SpringCloud微服务(05):Zuul组件,实现路由网关控制
本文源码:GitHub·点这里 || GitEE·点这里 一.Zuul组件简介 1.基础概念 Zuul 网关主要提供动态路由,监控,弹性,安全管控等功能.在分布式的微服务系统中,系统被拆为了多个微服务 ...
- Jupyter Notebook 使用小记
简介 Jupyter Notebook 是一款几乎综合所有编程语言,能够把软件代码.计算输出.解释文档.多媒体资源整合在一起的多功能科学计算平台.具有如下优点: 整合所有资源 交互性编程体验 零成本重 ...
- GO-切片拷贝以及赋值
一.拷贝 package main import "fmt" func main(){ //copy函数,把一个切片copy到另一个切片之上 var a [1000]int=[10 ...
- python爬取网业信息案例
需求:爬取网站上的公司信息 代码如下: import json import os import shutil import requests import re import time reques ...
- Easy User Manager System writeup
0x01 解题 思路 一个进程用自己的ip去申请拿到code然后进入verify页面,另外一个进程去申请8.8.8.8 步骤 1. 首先注册一个账号 然后用两个不同的浏览器进入Change页面.这里我 ...
- iOS-基于TCP连接<Scoket-客户端>
一:前言(本文为TCP客户端) TCP首先要服务器开放一个端口 然后客户端去连接服务端的IP地址和端口号 连接成功之后再进行数据传输 要经历三次握手 二:代码在GitHub 1.需要的工具类 自行下载 ...
- AudioRecord 录制播放PCM音频
AudioRecord 与 MediaRecorder 区别 AudioRecord 基于字节流录制,输出的是pcm数据,未进行压缩,直接保存的pcm文件不能被播放器识别播放. 可以对音频文件进行实时 ...
- 团队展示&选题
团队展示 1.队名:螺旋升天队 2.队员学号: 李光证 3117004660 (队长) 卢俊杰 3117004662 吴子昊 3117004671 陈浩民 3117004646 陈俊铭 3117004 ...
- 编译原理之不懂就问-First集
老师PPT: 这条语言实在是..通俗易懂