坑爹的Sun JDK
Sun的这个java.lang.Throwable 源码 设计非常糟糕,完全没有扩展性,
我在IBM 的Java JDK下,继承java.lang.Throwable重新定义了一个ExceptionWrapper,重载了java.lang.Throwable的大部分方法,
目的就是,不用Java本身的那种堆栈信息,大家知道的,Java本身的堆栈信息冗余性非常大,点击一个Action报错就上百行,当时真正有价值的错误信息就几行。
IBM的JDK是可以重写java.lang.Throwable的方法的,但是Sun的JDK坑爹的是private的方法,重写不了!这种设计真是坑爹。
不只是我遇到这个问题,网上也有人再说,问题的详细描述如下:
Hello java gods! I've no idea, whether this is the right forum to post my request to, but I hope, some sun java developers will read it and may be able to do the following change: class Throwable, method void printStackTraceAsCause(PrintStream s, StackTraceElement[] causedTrace) and class Throwable, method void printStackTraceAsCause(PrintWriter s, StackTraceElement[] causedTrace) are both declared private. This should be protected, because we are developing a client server environment where exceptions are transferred over the network and for several reasons, I use a special own StackTraceElement. This is necessary, because the original StackTraceElements are created "magically" by the VM and cannot be constructed by normal code. Additionally, I need more information and have added fields to my own RemoteStackTraceElement. Well, if the above methods were protected instead of private, it would always execute my methods instead of the original ones, if one of my Exceptions is in the list of causes. This means, I could encapsulate my exception the following way, which is sometimes needed, e.g. in Listeners: void methodGivenByInterface() throws ExceptionGivenByInterface { try { client.execCmd(...); } catch (RemoteException x) { throw new ExceptionGivenByInterface(x); } } If the method that executes myMethod does a printStackTrace, it executes the one of ExceptionGivenByInterface. Because my RemoteException is the cause, the printStackTraceAsCause of it will be executed. But because it is declared private in Throwable, it does not execute my own printStackTraceAsCause but the one of Throwable. I hope, I could make clear, why it is necessary to change private to protected, and I hope, someone finds the time to change this one word at both methods Thousand thanks in advance for getting a protected Throwable.printStackTraceAsCause in j2sdk1.5x! Best regards, Marco
坑爹的Sun JDK的更多相关文章
- 无cookie下载Oracle otn上的sun jdk等软件
从Oracle下载sun jdk提示:In order to download products from Oracle Technology Network you must agree to th ...
- 第一章 删掉centos原有的openjdk并安装sun jdk
一.卸载原有openjdk rpm -qa | grep java 之后,将展示出来的全部卸载掉,我这里是5个 rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111 ...
- Ubuntu安装Sun JDK及如何设置默认java JDK
假设系统为Ubuntu 10.10 64位. 先来看看当前的系统默认的java版本,及提供商.通过命令java -version kemix@kemix-VB10-64:~$ jav ...
- CentOS 安装 Sun JDK
1. 卸载原Open JDK 查看已安装包 rpm -qa | grep java 如果已经安装有Open JDK,可能会列出类似下面的内容: tzdata-java-2015e-.el6.noarc ...
- Sun jdk, Openjdk, Icedtea jdk关系
转自: http://blog.chinaunix.net/uid-20648944-id-3204527.html Sun jdk与Openjdk版本发展历史如下图所示: 1. Openjdk ...
- openJdk和sun Jdk区别和安装
openJdk和sun jdk的区别 使用过LINUX的人都应该知道,在大多数LINUX发行版本里,内置或者通过软件源安装JDK的话,都是安装的OpenJDK, 那么到底什么是OpenJDK,它与SU ...
- 删掉centos原有的openjdk并安装sun jdk
[环境变量]删掉centos原有的openjdk并安装sun jdk 一.卸载原有openjdk rpm -qa | grep java 之后,将展示出来的全部卸载掉,我这里是5个 rpm -e ...
- 【环境变量】删掉centos原有的openjdk并安装sun jdk
一.卸载原有openjdk rpm -qa | grep java 之后,将展示出来的全部卸载掉,我这里是5个 rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111 ...
- Procedure for installing and setting Sun JDK Java on Default Amazon Linux AMI
# First verify the version of Java being used is not SunJSK. java -version # Get the latest Sun Ja ...
随机推荐
- 分享url带中文参数,打开html操作完毕跳转jsp页面中文乱码解决
1.在app端分享参数组合时不对传递的url进行任何编码. 2.打开html页面时使用 escape函数对有中文的参数进行编码 escape(GetQueryString("paramete ...
- WPF编程宝典(Pro wpf in c# 2012)(文摘)
第一部分 基础知识 第1章 WPF概述 第2章 XAML 第3章 布局 第4章 依赖项属性 第5章 路由事件 第二部分 进一步研究WPF 第6章 控件 第7章 Application类 第8章 元素绑 ...
- n维向量空间W中有子空间U,V,如果dim(U)=r dim(V)=n-r U交V !={0},那么U,V的任意2组基向量的组合必定线性相关
如题取U交V中的向量p (p!=0), 那么p可以由 U中的某一组基线性组合成(系数不全是零),同时,-p也可以由V中的某一组基线性组合成(系数不全为零) 考察p+(-p)=0 可知道,U中的这组基跟 ...
- 第09章:MongoDB-CRUD操作--文档--修改--update
①语法 db.collection.update( <query>, <update>, { upsert: <boolean>, multi: <boole ...
- java web 怎么下载大文件(上百M)
Java代码 ; ]; , )) != -) { , bytesRead); 13. } 14. toClient.write(buffer ...
- Unix传奇
转自 http://coolshell.cn/articles/2322.html 了解过去,我们才能知其然,更知所以然.总结过去,我们才会知道我们明天该如何去规划,该如何去走.在时间的滚轮中,许许多 ...
- 初始Hbase
Hbase 定义 HBase是一个开源的非关系型分布式数据库(NoSQL),它参考了谷歌的BigTable建模,实现 的编程语言为 Java. 是Apache软件基金会的Hadoop项目的一部分,运行 ...
- Word 如何实现表格快速一分为二
将光标定位在分断处,按快捷键“Ctrl+Shift+Enter“
- WINDOWS CLUSTER -- 时间不同步导致的群集问题
故障描述,重启服务器后,发现该重启节点未成功加入到Windows群集中,导致该节点上的Alwayson服务也受影响处于“正在解析”状态,尝试重启cluster服务,发现无效,查看windows日志,发 ...
- ASP.NET Web API 中使用 swagger 来管理 API 文档
本文以 ASP.NET Web API 为后台框架,利用 EF6 连接 postgreSQL 数据库,使用 swagger 来生成 REST APIs文档.文章分二个部分,第一部分主要讲如何用 EF6 ...