System.arraycopy--findbugs检查引发的更改
EI2:
This code stores a reference to an externally mutable object into the internal representation of the object. If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
import java.io.Serializable;
public class TableModel implements Serializable {
private static final long serialVersionUID = 6121579860453189567L;
private String[][] data;
private String[] columnNames;
public TableModel(String[][] data, String[] columnNames) {
this.data = new String[data.length][];
System.arraycopy(data, 0, this.data, 0, data.length);
this.columnNames = new String[columnNames.length];
System.arraycopy(columnNames, 0, this.columnNames, 0, columnNames.length);
}
public void travel() {
System.out.println(this.data == null);
System.out.println(this.columnNames == null);
}
public static void main(String[] args) {
String[][] data = {{"A1", "B1"}, {"A2", "B2"}, {"A3", "B3"}, {"A4", "B4"},};
String[] columnNames = {"COL1", "COL2"};
TableModel tableModel = new TableModel(data, columnNames);
tableModel.travel();
}
}
System.arraycopy--findbugs检查引发的更改的更多相关文章
- 由 System.arraycopy 引发的巩固:对象引用 与 对象 的区别
作者:林冠宏 / 指尖下的幽灵 掘金:https://juejin.im/user/587f0dfe128fe100570ce2d8 博客:http://www.cnblogs.com/linguan ...
- Java中 System.arraycopy() 和 Arrays.copyOf()方法
System.arraycopy() 和 Arrays.copyOf()方法 阅读源码的话,我们就会发现 ArrayList 中大量调用了这两个方法.比如:我们上面讲的扩容操作以及add(int in ...
- 002-jdk-数据结构-工具类Collections、Arrays、System.arraycopy
常用备注 一.LIst to Array List<String> list = new ArrayList<String>(); Object[] array=list.to ...
- System.arraycopy()和Arrays.copyOf()的区别
先看看System.arraycopy()的声明: public static native void arraycopy(Object src,int srcPos, Object dest, in ...
- 求System.arraycopy的用法
public class Shuzufuzhi { public static void main(String args[]) { int myArray[]={1,2,3,4,5,6}; in ...
- System.arrayCopy()和普通数组复制之间的效率差别
都是System.arrayCopy() 效率高,到底有多高呢,拉出来遛遛就知道了: package JCF.ArrayList; import java.util.Date; public clas ...
- java System.arraycopy 数组复制和合并
public class Test { public static void main(String[] args) { Integer[] a = {1,2,3}; Integer[] b = {4 ...
- Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V
最近下载一个新版本的adt-bundle,Android API是20. 把Plain Text控件往布局上面拖时,发现拖不上去,出现了下面的错误: Exception raised during r ...
- Java数组的复制Arrays.copyOf()、System.arraycopy()、nums.clone()
public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length); a ...
随机推荐
- C# 6.0 (C# vNext) 的新功能:Expression Bodied Functions and Properties
Expression Bodied Function 它可以用在: methods user-defined operators type conversions read-only properti ...
- 询url包括字符串参数(js高度注意事项)
以防万一 url="http://write.blog.csdn.net/postedit? id=5&search=ok" function getArgs() { v ...
- oracle错误之 ora-01017
ora-01017 现象描述: scott用户和其它建立的用户,都登的上.但sys和system用户登录不上 方案一(试过,不行): 1,打开目录:F:\app\Administrator\produ ...
- Grub2配置详解(转)
grub2基础教程-修订版 smallapple 目录 一.grub2新特性 二.grub2安装与启动 三.grub2配置文件 ...
- SharePoint 2013 创建web应用程序报错"This page can’t be displayed"
错误描写叙述 This page can't be displayed •Make sure the web address http://centeradmin is correct. •Look ...
- 快速排序java
快速排序(Quicksort)是对冒泡排序的一种改进.它是先在数组中找到一个关键数,第一趟排序将比关键数小的放在它的左边,比关键数大的放在它的右边.当第一趟排序结束后,再依次递归将左边和右边的进行排序 ...
- Javascript设计模式系列三
继承,一个类或对象继承另一个类或对象的三种方法.类式继承.原型式继承.掺元类. 一.类式继承,原型链.Extend函数. <script type="text/javascript&q ...
- 【原创】leetCodeOj ---Construct Binary Tree from Preorder and Inorder Traversal 解题报告
原题地址: https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 题目 ...
- TCP拥塞控制 (1)
Basic: TCP,传输控制协定,它是目前最广泛使用的网络传输协议.SMTP.SSH.FTP.HTTP等因特网底层协议均是TCP. TCP面向连接,提供端到端的数据可靠传输.连接时三次握手.断开是四 ...
- or1200中IMMU分析(续)
下面内容摘自<步步惊芯--软核处理器内部设计分析>一书 2 IMMU中的特殊寄存器 OR1200处理器中的IMMU包括第2组特殊寄存器,如表10.1所看到的. ITLBW0MRx是指令TL ...