坑爹的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 ...
随机推荐
- (9)How to take a picture of a black hole
https://www.ted.com/talks/katie_bouman_what_does_a_black_hole_look_like/transcript 00:13In the movie ...
- Win7 VS2015环境编译cegui-0.8.5
首先是去官网下载源码与依赖库 http://cegui.org.uk/ 然后得提一下,编译DX11版本带Effects11框架的话会有问题,也就是默认情况编译有问题,这是因为VS2015升级后编译器对 ...
- [转载]使用PHP_CodeSniffer规范php代码
为什么使用PHP_CodeSniffer 一个开发团队统一的编码风格,有助于他人对代码的理解和维护,对于大项目来说尤其重要. PHP_CodeSniffer是PEAR中的一个用PHP5写的用来检查嗅探 ...
- 第24章:MongoDB-聚合操作--MapReduce
①MapReduce 在MongoDB的聚合框架中,还可以使用MapReduce,它非常强大和灵活,但具有一定的复杂性,专门用于实现一些复杂的聚合功能. MongoDB中的MapReduce使用Jav ...
- ubuntu server sudo出现sudo:must be setuid root 完美解决办法
原文链接:http://blog.csdn.net/supercrsky/article/details/9788397 1.开机按shift或esc先进行recovery模式 2.选择root命令行 ...
- Codeforces Round #540 (Div. 3)--1118F1 - Tree Cutting (Easy Version)
https://codeforces.com/contest/1118/problem/F1 #include<bits/stdc++.h> using namespace std; in ...
- SSM_CRUD新手练习(6)分页后台控制器编写
经过测试基础环境已经搭建好了,现在我们开始编写CRUD. 我们来看一下查询的逻辑该怎么写: 1.访问index.jsp页面 2.index.jsp页面发送查询员工的请求 3.EmployeeContr ...
- POJ 1191棋盘分割问题
棋盘分割问题 题目大意,将一个棋盘分割成k-1个矩形,每个矩形都对应一个权值,让所有的权值最小求分法 很像区间DP,但是也不能说就是 我们只要想好了一个怎么变成两个,剩下的就好了,但是怎么变,就是变化 ...
- js-图片轮播
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content=&q ...
- DDL和DML的区别
DML(data Manipulation Language)数据库操纵语言: 使用范围:对数据库中的数据进行一些简单的操作,如IDUS(增删改查) DDL(Data Definiton Langua ...