- 浏览: 1218854 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
masuweng:
嗯,写的很好
Mysql之Incorrect string value: '\xF0\x9F\x98\x89 \xE6...' -
秋水涛静:
来来来 你告诉我你贴的这代码有什么用??你给的下载包又有什么 ...
利用diyUpload做多图片上传及预览 -
andseny:
如果可以的话,求一份源码,谢谢 邮箱:846526948@q ...
利用diyUpload做多图片上传及预览 -
alloyer:
不错!可以使用,已验证。
Spring与jcaptcha集成 -
bewithme:
这和我去官网看有啥区别?
web之日期组件My97DatePicker
1 )原代码如下: protected String[] a = null; public void test(String[] str){ this.a = str; } findbugs描述为: 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. 网上翻译如下: 可能因使引用可指向多个对象而暴露内部存储结构。 修改如下: public void test(String[] str){ if(str!=null) this.a = str.clone(); } -------------------------------------------------------------------------------- 2 )在bean中定义数组类型的bug [参考]http://topic.csdn.net/u/20080115/20/c8893ce0-5546-4762-97bb-9b00d10885cc.html 原代码: private String[] name; bug描述: [EI] May expose internal representation by returning reference to mutable object [EI_EXPOSE_REP] 解决: private String[] name; 说明: 所有容器类型如ArrayList和数组类型,如果你都自动生成get set,都会有这个警告。 Returning a reference to a mutable object value stored in one of the object's fields exposes 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. Returning a new copy of the object is better approach in many situations. -------------------------------------------------------------------------------- 3) 序列化问题 源码: private Obj[] obj; public void getObj(){ Obj[] tep = obj; return tep; } public Obj[] setObj(Obj[] o){ Obj[] tep = o; this.obj = tep; } bug描述: This Serializable class defines a non-primitive instance field which is neither transient, Serializable, or java.lang.Object, and does not appear to implement the Externalizable interface or the readObject() and writeObject() methods. Objects of this class will not be deserialized correctly if a non-Serializable object is stored in this field. 修改: public class Obj implements Serializable { ... } 4 ) new Integer(int) 和 Integer.valueOf(int) bug描述: [Bx] Method invokes inefficient Number constructor; use static valueOf instead [DM_NUMBER_CTOR] Using 说明: [参考]http://www.cnblogs.com/hyddd/articles/1391318.html FindBugs推荐使用Integer.ValueOf(int)代替new Integer(int),因为这样可以提高性能。如果当你的int值介于-128~127时,Integer.ValueOf(int)的效率比Integer(int)快大约3.5倍。 下面看看JDK的源码,看看到Integer.ValueOf(int)里面做了什么优化: 从源代码可以知道,ValueOf对-128~127这256个值做了缓存(IntegerCache),如果int值的范围是:-128~127,在ValueOf(int)时,他会直接返回IntegerCache的缓存给你。 所以你会看到这样的一个现象: 结果是: true 因为:java在编译的时候 Integer a = 100; 被翻译成-> Integer a = Integer.valueOf(100);,所以a和b得到都是一个Cache对象,并且是同一个!而c和d是新创建的两个不同的对象,所以c自然不等于d。 再看看这段代码: 结果是:false 因为在对a操作时(a=a+1或者a++),a重新创建了一个对象,而b对应的还是缓存里的100,所以输出的结果为false。 -------------------------------------------------------------------------------- 5) toString() 和 String 源码: return a.toString(); bug描述 [Dm] Method invokes toString() method on a String [DM_STRING_TOSTRING] 修改为: return (String) a; *************************************************************************** 未解决bug 1、 [DMI] Code contains a hard coded reference to an absolute pathname [DMI_HARDCODED_ABSOLUTE_FILENAME] This code constructs a File object using a hard coded to an absolute pathname (e.g.,
这代码使一个指向外部多个对象的引用指向了一个内部对象存储地址。
如果实例被未被信任代码访问或多个对象发生了未经检查的改变就会危及安全性或其它重要属性,
你需要去做一些不同的事情。存储一个对象的拷贝在许多情况下会是一个更好的方法。
public String[] getName() {
return name;
}
public void setName(String[] name) {
this.name = name;
}
public String[] getName() {
String[] temp = name;
return temp;
}
public void setName(String[] name) {
String[] temp = name;
this.name = temp;
}
这个警告的主要目的是:一般的get set直接把此对象中某一容器的引用放到外部,可以随便更改,违反了封装的原则,至于那个temp的方法,由于不是直接对内部容器进行操作,故没有警告,但没有实际意义,自己知道即可。new Integer(int)
is guaranteed to always result in a new object whereas Integer.valueOf(int)
allows caching of values to be done by the compiler, class library, or JVM. Using of cached values avoids object allocation and the code will be faster.
final int offset = 128;
if (i >= -128 && i <= 127) { // must cache
return IntegerCache.cache[i + offset];
}
return new Integer(i);
}
private static class IntegerCache {
private IntegerCache(){}
static final Integer cache[] = new Integer[-(-128) + 127 + 1];
static {
for(int i = 0; i < cache.length; i++)
cache = new Integer(i - 128);
}
}
Integer a = 100;
Integer b = 100;
System.out.println(a==b);
Integer c = new Integer(100);
Integer d = new Integer(100);
System.out.println(c==d);
}
false
Integer a = 100;
Integer b = a;
a = a + 1; //或者a++;
System.out.println(a==b);
}
Calling String.toString()
is just a redundant operation. Just use the String.new File("/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment");
发表评论
-
Java中的非对称加密算法RSA实现
2018-08-01 11:14 640需求:实现RSA非对称加密算法实现:public stati ... -
apache common包的configuration2使用
2018-08-01 11:13 1059需求:利用apache的common包中的configura ... -
Java标准库提取URL的域名
2018-08-01 11:12 1192需求:基于Java的标准库提取URL对应的域名并拼接成base ... -
Solr之Solrj封装
2018-04-10 22:08 885基本信息: 版本:7.0.0 单机版,cloud版本有所 ... -
Solr之IKAnalyzer集成
2018-04-10 22:12 1025基本信息: 版本:7.0.0 Solr安装路径记作$SO ... -
linux之jdk安装
2018-04-04 21:41 594环境: jdk-8u161-linux-x64.tar.g ... -
使用jsoup或者httpclient解析https协议通用方法
2018-04-04 18:19 847需求: 基于jsoup或者httpclient爬取htt ... -
javax.mail发email报501 Syntax: HELO hostname
2016-04-07 14:46 3937问题描述: 在linux服务器下用javamail发ema ... -
Gson之map解析
2015-10-20 18:26 2639需求: 把json字符串解析成map 实现: Gson ... -
Java之浮点运算
2015-06-01 16:20 654Java中的浮点数计算主要涉及float和double,他 ... -
Java之IO字节流和字符流
2015-03-19 17:43 976Java中的IO分为两大线,字节流和字符流 字节流基类:I ... -
apache common之CSV文件操作
2015-03-18 18:39 2661依赖jar: <dependency> & ... -
poi组件读取xls文件
2014-11-25 17:24 898依赖: <dependency> < ... -
java检测文本(字节流)的编码方式
2014-10-30 18:37 2296需求: 某文件或者某字节流要检测他的编码格式。 实现: ... -
fastjson报can not access a member of class with modifiers ""错误
2014-07-08 17:22 1925执行json解析的时候报错如下: Caused by: j ... -
Java HotSpot(TM) 64-Bit Server VM warning: Insufficient space for shared memory
2014-05-04 15:38 5924异常信息: Java HotSpot(TM) 64-Bit ... -
Java以行读写文件
2014-04-10 16:56 1637场景: 基于行读写文件是基本的需求,有时候数据文件比较大那 ... -
Map之Value排序实现
2014-03-20 10:07 1226需求: 在做统计分析的时候,有时候需要最value做排序, ... -
Java之UncaughtExceptionHandler
2014-01-23 11:09 2514概述: UncaughtExceptionHandler ... -
Java之wait()和notify()
2014-01-22 17:32 1452概述: Java多线程并发模型中的实现可以基于wait() ...
相关推荐
帮助查找bug的 eclipse插件 findBugs
eclipse 插件 findbugs 更方便的来找出bug。 更有用的是在andorid 中可以帮助找到闪退的原因,修复闪退 使用方法:直接解压到eclipse目录下的plugin 目录下
Eclipse集成findBugs步骤,包含:FindBugs介绍,在Eclipse中安装FindBugs插件,在Eclipse中使用FindBugs,配置FindBugs,其它分析工具(PMD,CheckStyle),配套的Bug解释模式,实际项目中Bug类型统计
Eclipse集成findBugs,一款很好用的查找BUG的插件,希望对大家有所帮助,提高代码质量!
一款EcliPSe插件,能够发现java代码中的bug,针对各种问题,它并且提供了简单的修改意见供我们重构时进行参考; 通过使用它,可以一定程度上降低我们code review的工作量,并且会提高review效率。 通过findbugs找到...
NULL 博文链接:https://knight-black-bob.iteye.com/blog/2330285
FindBugs是一个匹配编译代码模式,而非使用bug数据库的工具。当提供源代码时,FindBugs还可高亮显示检测出bug的代码行。...除了图形用户界面,FindBugs还提供一个命令行界面,Ant任务,以及Eclipse插件。
kepler_Eclipse插件安装、SVN插件安装、Jetty插件安装、3、JQUERY提示插件安装、4、FindBugs-BUG分析工具的安装和使用、FindBugs的配置、JSHint JS分析工具的安装和使用
图 1 显示了分析一个匿名项目的结果(为防止可怕的犯罪,这里不给出它的名字): 在FindBugs的GUI中,需要先选择待扫描的.class文件(FindBugs其实就是对编译后的class进行扫描,藉以发现一些隐藏的bug。)。如果你...
用于eclipse工程中,发现程序中存在的bug。
一款Eclipse插件,能够发现java代码中的bug,针对各种问题,它并且提供了简单的修改意见供我们重构时进行参考; 通过使用它,可以一定程度上降低我们code review的工作量,并且会提高review效率。 通过findbugs找到...
FindBugs supports Java 8 now (both as runtime and target platform). FindBugs requires minimum Java 7 as runtime environment!...FindBugs是一个能静态分析源代码中可能会出现Bug的Eclipse插件工具。
FindBugs是一个能静态分析源代码中可能会出现Bug的Eclipse插件工具。 下载之后 将文件解压到plugins下面。 FindBugs地执行: 选中 所在项目,鼠标右键 > Find Bugs > Find Bugs执
FindBugs是一个能静态分析源代码中可能会出现Bug的Eclipse插件工具。FindBugs的设置: 安装好之后,可以通过 Projects > Property > FindBugs标签对其进行设置。设置方法可以根据自己的需要进行调整。 另外在 问题...
查找bug的eclipse插件,findbugs-1.3.5 相当好用
一款Eclipse插件,能够发现java代码中的bug
findbugs是一个开源的eclipse 代码检查工具;它可以简单高效全面地帮助我们发现程序代码中存在的bug,bad smell,以及潜在隐患. 下载的文件包含如下: 1.findbugs的eclipse插件source包 2.安装及使用说明文档
findbugs对照表。错误表,eclipsebug表。这个用于在eclipse中使用findbugs插件,后显示的错误对照表。可以帮助快速查询原因
findBugs是一款代码质量控制工具,能帮助程序员找出程序中隐藏bug的是插件
FindBugs不注重代码风格和格式,而是专注于检测真正的bug及潜在的性能问题,并尽可能地抑制误报(false positives)。 FindBugs提供了一个可视化的界面,方便用户操作,也可以作为Eclipse的一个插件来使用。...