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检查引发的更改的更多相关文章

  1. 由 System.arraycopy 引发的巩固:对象引用 与 对象 的区别

    作者:林冠宏 / 指尖下的幽灵 掘金:https://juejin.im/user/587f0dfe128fe100570ce2d8 博客:http://www.cnblogs.com/linguan ...

  2. Java中 System.arraycopy() 和 Arrays.copyOf()方法

    System.arraycopy() 和 Arrays.copyOf()方法 阅读源码的话,我们就会发现 ArrayList 中大量调用了这两个方法.比如:我们上面讲的扩容操作以及add(int in ...

  3. 002-jdk-数据结构-工具类Collections、Arrays、System.arraycopy

    常用备注 一.LIst to Array List<String> list = new ArrayList<String>(); Object[] array=list.to ...

  4. System.arraycopy()和Arrays.copyOf()的区别

    先看看System.arraycopy()的声明: public static native void arraycopy(Object src,int srcPos, Object dest, in ...

  5. 求System.arraycopy的用法

    public class Shuzufuzhi { public static void main(String args[]) {  int myArray[]={1,2,3,4,5,6};  in ...

  6. System.arrayCopy()和普通数组复制之间的效率差别

    都是System.arrayCopy() 效率高,到底有多高呢,拉出来遛遛就知道了: package JCF.ArrayList; import java.util.Date; public clas ...

  7. java System.arraycopy 数组复制和合并

    public class Test { public static void main(String[] args) { Integer[] a = {1,2,3}; Integer[] b = {4 ...

  8. Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V

    最近下载一个新版本的adt-bundle,Android API是20. 把Plain Text控件往布局上面拖时,发现拖不上去,出现了下面的错误: Exception raised during r ...

  9. Java数组的复制Arrays.copyOf()、System.arraycopy()、nums.clone()

    public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length); a ...

随机推荐

  1. opencv环境的搭建,并打开一个本地PC摄像头。

    1.opencv环境结构 推荐连结 http://www.cnblogs.com/Anykong/archive/2011/04/06/Anykong_OpenCV1.html 2.以下是基本測试,和 ...

  2. XMPP我写底层协议(零)--废话和准备开幕前

    当我想写一个非常早期的一点总结.但总是忙没有时间停止做这样的事情. 秦与我的兄弟之前说的,这并不是说我没开灵.但是,因为很多事情还没有时间来写blog. 我没有完全理解,真到自己在这个位置上的时间,能 ...

  3. 使用python+django+twistd 开发自己的操作和维护系统的一个

    许多开源操作系统和维护系统,例nagios.zabbix.cati等等,但是,当他们得到的时间自己的个性化操作和维护需求,始终无力! 最近的一项研究python.因此,我们认为python+djang ...

  4. PHP安装mcrypt.so报错 mcrypt.h not found 的解决的方法

    报错内容:configure: error: mcrypt.h not found. Please reinstall libmcrypt 网上搜索了非常多,包含自带的 yum install lib ...

  5. POJ3623:Best Cow Line, Gold(后缀数组)

    Description FJ is about to take his N (1 ≤ N ≤ 30,000) cows to the annual"Farmer of the Year&qu ...

  6. 数据结构 - 双链表(C++)

    // ------DoublyLinkedList.h------ template <class T> class DNode { private: // 指向左.右结点的指针 DNod ...

  7. Java 打开文件的两种方式

    import java.awt.Desktop; import java.io.File; import java.io.IOException; public class LnkDemo { pub ...

  8. 他们主动布局(autolayout)环境的图像编辑器

    hi,all: 在经过了一番犹豫之后.我决定将我自己做的这个小APP的源代码发布给大家: 其出发点是和大家一起学习iOS开发.仅供学习參考之用. 之前代码是托管与gitlab 上的,今天我将其pull ...

  9. MVC5+EF6 入门完整教程 总目录

    本系列文章会从一个主干开始,逐渐深入,初步规划30篇.初级10篇,中级10篇,综合项目实战10篇 初级10篇 MVC5+EF6 入门完整教程10:多对多关联表更新&使用原生SQL@201505 ...

  10. [LeetCode] Regular Expression Matching [6]

    称号: Implement regular expression matching with support for '.' and '*'. '.' Matches any single chara ...