??xml version="1.0" encoding="utf-8" standalone="yes"?>视频一区二区在线播放,一区二区三区四区在线免费视频,最新97超碰在线http://www.aygfsteel.com/zyl/category/14524.html好好学习Q天天向?/description>zh-cnTue, 17 Apr 2007 05:39:26 GMTTue, 17 Apr 2007 05:39:26 GMT60用泛型时遇到的尴问?/title><link>http://www.aygfsteel.com/zyl/archive/2007/04/17/111128.html</link><dc:creator>布衣?/dc:creator><author>布衣?/author><pubDate>Tue, 17 Apr 2007 00:22:00 GMT</pubDate><guid>http://www.aygfsteel.com/zyl/archive/2007/04/17/111128.html</guid><wfw:comment>http://www.aygfsteel.com/zyl/comments/111128.html</wfw:comment><comments>http://www.aygfsteel.com/zyl/archive/2007/04/17/111128.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zyl/comments/commentRss/111128.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zyl/services/trackbacks/111128.html</trackback:ping><description><![CDATA[    几天前遇到这么一个问题,让我郁闷了半天。当初ؓ了方便定义了以下的一个接口:<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">interface</span><span style="color: #000000;"> IBusinessObject</span><span style="color: #000000;"><</span><span style="color: #000000;">PK </span><span style="color: #0000ff;">extends</span><span style="color: #000000;"> Serializable</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #0000ff;">extends</span><span style="color: #000000;"> Serializable {<br>    PK getPrimaryKey();<br>    </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> setPrimaryKey(PK id);<br>}</span></div> <br>在我的子cM是这么实现的<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> Code </span><span style="color: #0000ff;">implements</span><span style="color: #000000;"> IBusinessObject</span><span style="color: #000000;"><</span><span style="color: #000000;">Long</span><span style="color: #000000;">></span><span style="color: #000000;">{<br> </span><span style="color: #0000ff;">private</span><span style="color: #000000;"> Long primaryKey;<br> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> setPrimaryKey(Long id){<br>    </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.primaryKey</span><span style="color: #000000;">=</span><span style="color: #000000;">id;<br> }<br> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long getPrimaryKey(){<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> primaryKey<br> }<br>}</span></div> <br><br>在通常的实例化q程中,是不会存在问题的。当时的问题是,我定义了另外一个类Q用于引用Code<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> TestBean {<br>    </span><span style="color: #0000ff;">private</span><span style="color: #000000;"> Code code;<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> setCode(){<img src="http://www.aygfsteel.com/Images/dot.gif">}<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Code getCode(){<img src="http://www.aygfsteel.com/Images/dot.gif">}<br>}</span></div> <br>当在spring环境中时Q用spring的bindcd理的时候,发现Q我的code.primaryKey的类型居然ؓSerializable,而不是我惌的Long<br>当时以ؓ其他地方搞错了,写了个简单的试代码<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">TestBean b</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> TextBean();<br>BeanWrapperImpl wrapper</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BeanWrapperImpl(b);<br>b.setPropertyValue(</span><span style="color: #000000;">"</span><span style="color: #000000;">code.primaryKey</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">1</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>assertTrue(b.getCode().getPrimaryKey() </span><span style="color: #0000ff;">instanceof</span><span style="color: #000000;"> Long);</span></div> <br>居然是失败的?br>只有?br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">b.setPropertyValue(</span><span style="color: #000000;">"</span><span style="color: #000000;">code.primaryKey</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Long(</span><span style="color: #000000;">1</span><span style="color: #000000;">));<br>assertTrue(b.getCode().getPrimaryKey() </span><span style="color: #0000ff;">instanceof</span><span style="color: #000000;"> Long);</span></div> <br>才成功?br>仔细跟踪Q发现原来,泛型的时候,产生的编译类中,有两个同名的Ҏ<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;"> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> setPrimaryKey(Long id){<br>    </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.primaryKey</span><span style="color: #000000;">=</span><span style="color: #000000;">id;<br> }<br> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long getPrimaryKey(){<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> primaryKey<br> }<br>?br> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> setPrimaryKey(Serializable id){<br>    </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.primaryKey</span><span style="color: #000000;">=</span><span style="color: #000000;">id;<br> }<br> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Serializable getPrimaryKey(){<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> primaryKey<br> } </span></div> <br>而java.beans规范对于q种情况是没有办法分清楚Q所以也导致了l果和预期的不同?br>如果是在E序中,q点不了问题。可是我需要在web的页面上q行值的l定Q而输入的东西Q只能ؓ字符丌Ӏ所以不可能出来Longcd?br>目前Q采用了一U比较傻的办法,在TestBean中增加了一个时变量xQ通过x向code传?br>如下Q?br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> setWsCode(String wsCode) {<br>        </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.wsCode </span><span style="color: #000000;">=</span><span style="color: #000000;"> wsCode;<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (StringUtils.isNumeric(wsCode))<br>            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.code.setPrimaryKey(NumberUtils.toLong(wsCode));<br>}</span></div> <br>不知道还有没有其他好的解x案?br><br><br><img src ="http://www.aygfsteel.com/zyl/aggbug/111128.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zyl/" target="_blank">布衣?/a> 2007-04-17 08:22 <a href="http://www.aygfsteel.com/zyl/archive/2007/04/17/111128.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于ehcache 配置http://www.aygfsteel.com/zyl/archive/2007/04/05/ehcache.html布衣?/dc:creator>布衣?/author>Thu, 05 Apr 2007 10:42:00 GMThttp://www.aygfsteel.com/zyl/archive/2007/04/05/ehcache.htmlhttp://www.aygfsteel.com/zyl/comments/108764.htmlhttp://www.aygfsteel.com/zyl/archive/2007/04/05/ehcache.html#Feedback0http://www.aygfsteel.com/zyl/comments/commentRss/108764.htmlhttp://www.aygfsteel.com/zyl/services/trackbacks/108764.html
ehcache的默认配|文件名为ehcache.xmlQ也可以自己指定。配|文件比较的单,基本上也是常用的几个元素?br>
配置元素说明Q?br>
diskStoreQ配|DiskStoreQ当需要用磁盘保存的时候,需要对象实现序列化接口

    属性:path 配置文g存储位置Q如user.homeQuser.dirQjava.io.tmpdir

cacheManagerEventListenerFactory Q指定CacheManagerEventListenerFactoryQ用于创建CacheManagerPeerProvider

用于提醒当CacheManager中的~存增加或者删除时?br>   
    属?class:完整的工厂类名称
         properties:逗号分割的属?br>
事g包括 增加cache和删除cache

cacheManagerPeerProviderFactory:指定CacheManagerPeerProviderFactoryQ用于创建CacheManagerPeerProviderQ用于在cluster中查找CacheManagersQ主要用于机环?br>
    属性:
        class:完整的工厂类名称
        properties:逗号分割的属?br>
默认的配|:
 
<cacheManagerPeerProviderFactory
                                class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
                                properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,
                                    multicastGroupPort=4446, timeToLive=32"/>
      
<cacheManagerPeerProviderFactory class=
                          "net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
                          properties="peerDiscovery=manual,
                          rmiUrls=//server1:40000/sampleCache1|//server2:40000/sampleCache1
                          | //server1:40000/sampleCache2|//server2:40000/sampleCache2"/>     

cacheManagerPeerListenerFactoryQ指定CacheManagerPeerListenerFactoryQ用于创建CacheManagerPeerListenerQ监听cluster中的复制信息
    属性:
        class:完整的工厂类名称
        properties:逗号分割的属?br>
默认配置
 
    <cacheManagerPeerListenerFactory
        class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
        properties="hostName=fully_qualified_hostname_or_ip,
                    port=40001,
                    socketTimeoutMillis=120000"/>     

defaultCache: 默认~存配置

    必须属性:
        name:讄~存的名Uͼ用于标志~存,惟一
        maxElementsInMemory:在内存中最大的对象数量
        maxElementsOnDiskQ在DiskStore中的最大对象数量,如ؓ0Q则没有限制
        eternalQ设|元素是否永久的Q如果ؓ怹Q则timeout忽略
        overflowToDiskQ是否当memory中的数量辑ֈ限制后,保存到Disk

    可选的属性:
        timeToIdleSecondsQ设|元素过期前的空闲时?br>        timeToLiveSecondsQ设|元素过期前的活动时?br>        diskPersistentQ是否disk store在虚拟机启动时持久化。默认ؓfalse
        diskExpiryThreadIntervalSeconds:q行diskl结U程的时_默认?20U?br>        memoryStoreEvictionPolicyQ策略关于Eviction

~存子元素:
   
    cacheEventListenerFactoryQ注册相应的的缓存监听类Q用于处理缓存事Ӟ如put,remove,update,和expire
    bootstrapCacheLoaderFactory:指定相应的BootstrapCacheLoaderQ用于在初始化缓存,以及自动讄?br>如下的例子:
 
 <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
         properties="replicateAsynchronously=true,
         replicatePuts=true,
         replicateUpdates=true,
         replicateUpdatesViaCopy=true,
         replicateRemovals=true "/>     
 
<bootstrapCacheLoaderFactory
        class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
        properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"/>     
 
 <defaultCache
            maxElementsInMemory="10000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            maxElementsOnDisk="10000000"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU"
            />     

cache配置同defaultCache
 
<cache name="sampleDistributedCache1"
           maxElementsInMemory="10"
           eternal="false"
           timeToIdleSeconds="100"
           timeToLiveSeconds="100"
           overflowToDisk="false">
        <cacheEventListenerFactory
                class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
        <bootstrapCacheLoaderFactory
                class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"/>
    </cache>     

基本上都比较单,当然也可以直接用程序实现相应的功能


]]>
使用ehcachehttp://www.aygfsteel.com/zyl/archive/2007/02/28/101208.html布衣?/dc:creator>布衣?/author>Wed, 28 Feb 2007 12:14:00 GMThttp://www.aygfsteel.com/zyl/archive/2007/02/28/101208.htmlhttp://www.aygfsteel.com/zyl/comments/101208.htmlhttp://www.aygfsteel.com/zyl/archive/2007/02/28/101208.html#Feedback2http://www.aygfsteel.com/zyl/comments/commentRss/101208.htmlhttp://www.aygfsteel.com/zyl/services/trackbacks/101208.html    一直以来懒得配|缓存,基本的缓存也是orm层,基本上都交给hibernate去配|了。这D|_感觉面速度太慢了,q是需要用缓存。现在的~存工具也挺多的Q较不错的属ehcache和oscache了。决定分别研I一下?br />    先来说说ehcacheQ目前的版本?.2,已经支持集群了。对于ehcache的用,感觉很容易上手,基本上都是配|。以前在hibernate的时候配|过Q所以也不是很陌生。API也挺单,如下的apiQ?br />    CacheManager主要的缓存管理类Q一般一个应用ؓ一个实例,如下
    CacheManager.create();也可以用new CacheManager的方式创?br />     默认的配|文件ؓehcache.xml文gQ也可以使用不同的配|:
     
 
CacheManager manager = new CacheManager("src/config/other.xml");    

~存的创建,采用自动的方?/b>
 
CacheManager singletonManager = CacheManager.create();
singletonManager.addCache("testCache");
Cache test = singletonManager.getCache("testCache");    

或者直接创建Cache

 
CacheManager singletonManager = CacheManager.create();
Cache memoryOnlyCache = new Cache("testCache", 5000, false, false, 5, 2);
manager.addCache(memoryOnlyCache);
Cache test = singletonManager.getCache("testCache");    

删除cache
 
CacheManager singletonManager = CacheManager.create();
singletonManager.removeCache("sampleCache1");    

在用ehcache后,需要关?/b>
 
CacheManager.getInstance().shutdown()    

caches 的?/b>
 
Cache cache = manager.getCache("sampleCache1");    

执行crud操作

 
Cache cache = manager.getCache("sampleCache1");
Element element = new Element("key1", "value1");
cache.put(element);    

update
 
Cache cache = manager.getCache("sampleCache1");
cache.put(new Element("key1", "value1");
//This updates the entry for "key1"
cache.put(new Element("key1", "value2");    

get Serializable

 
Cache cache = manager.getCache("sampleCache1");
Element element = cache.get("key1");
Serializable value = element.getValue();    

get non serializable
 
Cache cache = manager.getCache("sampleCache1");
Element element = cache.get("key1");
Object value = element.getObjectValue();    

remove
 
Cache cache = manager.getCache("sampleCache1");
Element element = new Element("key1", "value1"
cache.remove("key1");    

不过~存q是基本上以配置方式ZQ下一文章将会说明ehcache如何配置
    

    
    



]]>
使用javassist动态注入代?/title><link>http://www.aygfsteel.com/zyl/archive/2007/02/10/99171.html</link><dc:creator>布衣?/dc:creator><author>布衣?/author><pubDate>Sat, 10 Feb 2007 13:02:00 GMT</pubDate><guid>http://www.aygfsteel.com/zyl/archive/2007/02/10/99171.html</guid><wfw:comment>http://www.aygfsteel.com/zyl/comments/99171.html</wfw:comment><comments>http://www.aygfsteel.com/zyl/archive/2007/02/10/99171.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zyl/comments/commentRss/99171.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zyl/services/trackbacks/99171.html</trackback:ping><description><![CDATA[    关于java字节码的处理Q目前有很多工具Q如bcelQasm。不q这些都需要直接跟虚拟机指令打交道。如果你不想了解虚拟机指令,可以采用javassist。javassist是jboss的一个子目Q其主要的优点,在于单,而且快速。直接用java~码的Ş式,而不需要了解虚拟机指oQ就能动态改变类的结构,或者动态生成类?br />    下面通过一个简单的例子Q通过javassist来实现如何动态注入代码?br />    假设Q存在类A,如下Q?br />public class A {<br />    public void method() {<br />        for (int i = 0; i < 1000000; i++) {<br />        }<br />        System.out.println("method1");<br />    }<br />}<br />试cB如下Q?br />public class B {<br />    public static void main(String[] args) {<br />        A a = new A();<br />        a.method();    <br />    }<br />}<br />现在想统计一下method的执行时_<br />默认的实现是修改methodQ?br /> public void method() {<br />        long start = System.currentTimeMillis();<br />        for (int i = 0; i < 1000000; i++) {<br />        }<br />        System.out.println("method1");<br />        long end = System.currentTimeMillis();<br />        System.out.println(end - start);<br />    }<br />如果A的方法很多,l计Ҏ的执行时间的代码׃相应的增加。ؓ了减工作量Q通过动态注入代码的形式来实现?br />修改B的mainҎQ?br />    public static void main(String[] args) throws Exception {<br />      //用于取得字节码类Q必d当前的classpath中,使用全称<br />        CtClass ctClass = ClassPool.getDefault().get("org.esoft.A");<br />         //需要修改的Ҏ名称<br />        String mname = "method";        <br />        CtMethod mold = ctClass.getDeclaredMethod(mname);<br />         //修改原有的方法名U?br />        String nname = mname + "$impl";<br />        mold.setName(nname);<br />         //创徏新的ҎQ复制原来的Ҏ<br />        CtMethod mnew = CtNewMethod.copy(mold, mname, ctClass, null);<br />         //主要的注入代?br />        StringBuffer body = new StringBuffer();<br />        body.append("{\nlong start = System.currentTimeMillis();\n");<br />        //调用原有代码Q类gmethod();($$)表示所有的参数<br />        body.append(nname + "($$);\n");<br />        body.append("System.out.println(\"Call to method "<br />                    + mname<br />                    + " took \" +\n (System.currentTimeMillis()-start) + "<br />                    + "\" ms.\");\n");<br />       <br />        body.append("}");<br />         //替换新方?br />        mnew.setBody(body.toString());<br />         //增加新方?br />        ctClass.addMethod(mnew);<br />        //cdl更改,注意不能使用A a=new A();Q因为在同一个classloader中,不允许装载同一个类两次<br />        A a=(A)ctClass.toClass().newInstance();<br />        a.method();<br />    }<br />q只是简单的一个应用。javassistq提供了很多的功能,用于更改cȝ构。有兴趣的可以参考相x?br /><br /><img src ="http://www.aygfsteel.com/zyl/aggbug/99171.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zyl/" target="_blank">布衣?/a> 2007-02-10 21:02 <a href="http://www.aygfsteel.com/zyl/archive/2007/02/10/99171.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>基本的类装入异常 http://www.aygfsteel.com/zyl/archive/2007/02/04/97881.html布衣?/dc:creator>布衣?/author>Sun, 04 Feb 2007 12:58:00 GMThttp://www.aygfsteel.com/zyl/archive/2007/02/04/97881.htmlhttp://www.aygfsteel.com/zyl/comments/97881.htmlhttp://www.aygfsteel.com/zyl/archive/2007/02/04/97881.html#Feedback0http://www.aygfsteel.com/zyl/comments/commentRss/97881.htmlhttp://www.aygfsteel.com/zyl/services/trackbacks/97881.html    在java中,c装载异常虽然不是很常见Q可如果发生异常Q其处理q是比较ȝ的?br />    下面的几U异常是比较常见的:
ClassNotFoundException
    ClassNotFoundException 是最常见的类装入异常cd。它发生在装入阶DcJava 规范?ClassNotFoundException 的描q是q样的:
    当应用程序试N过cȝ字符串名Uͼ使用以下三种Ҏ装入c,但却找不到指定名U的cd义时抛出该异常?br />    * c?Class 中的 forName() Ҏ?br />    * c?ClassLoader 中的 findSystemClass() Ҏ?br />    * c?ClassLoader 中的 loadClass() Ҏ?br />    所以,如果昑ּ地装入类的尝试失败,那么抛?ClassNotFoundException?br />    q些异常修复h通常比较单。可以用  verbose 选项查类路径Q确保用的c\径设|正。如果类路径讄正确Q但是仍然看到这个错误,那么是需要的cdc\径中不存在。要修复q个问题Q可以把cȝ动到c\径中指定的目录或 JAR 文g中,或者把cL在的位置d到类路径中?br />
NoClassDefFoundError
    NoClassDefFoundError 是类装入器在装入阶段抛出的另一个常见异常。JVM 规范?NoClassDefFoundError 的定义如下:
    如果 Java 虚拟机或 ClassLoader 实例试图装入cd义(作ؓ正常的方法调用的一部分Q或者作Z?new 表达式创建新实例的一部分Q,但却没有扑ֈcd义时抛出该异常?br />    当目前执行的cdl编译,但是找不到它的定义时Q会存在 searched-for cd义?
    实际上,q意味着 NoClassDefFoundError 的抛出,是不成功的隐式类装入的结果?br />    单说来,是引用的类在类路径中没有找到?br />ClassCastException
    c装入器能够抛出的另一个异常是 ClassCastException。它是在cd比较中发C兼容cd的时候抛出的。JVM 规范指定 ClassCastException 是:
    该异常的抛出Q表明代码企图把对象的类型{换成一个子c,而该对象q不是这个子cȝ实例?
UnsatisfiedLinkError
    在把本地Ҏ调用链接到对应的本机定义Ӟc装入器扮演着重要角色。如果程序试图装入一个不存在或者放错的本机库时Q在链接阶段的解析过E会发生 UnsatisfiedLinkError。JVM 规范指定 UnsatisfiedLinkError 是:
    对于声明?native 的方法,如果 Java 虚拟机找不到和它对应的本a定义Q就会抛异常?
    当调用本机方法时Q类装入器会试装入定义了该Ҏ的本机库。如果找不到q个库,׃抛出q个错误?br />    本机库的装入p?System.loadLibrary() Ҏ的类的类装入器启?Q根据用的c装入器Q会搜烦不同的位|:
    * 对于?bootstrap c装入器装入的类Q搜?sun.boot.library.path?br />    * 对于由扩展类装入器装入的c,先搜?java.ext.dirsQ然后是 sun.boot.library.pathQ然后是 java.library.path?br />    * 对于ql类装入器装入的c,搜烦 sun.boot.library.pathQ然后是 java.library.path?br />ClassCircularityError
    JVM 规范指定 ClassCircularityError 的抛出条件是Q?br />    cL接口׃是自q类或超接口而不能被装入?
    q个错误是在链接阶段的解析过E中抛出的。这个错误有点奇怪,因ؓ Java ~译器不允许发生q种循环情况。但是,如果独立地编译类Q然后再把它们放在一P可能发生这个错误?br />ClassFormatError
JVM 规范指出Q抛?ClassFormatError 的条件是Q?br />    负责指定所h的编译类或接口的二进制数据Ş式有误?
    q个异常是在c装入的链接阶段的校验过E中抛出。如果字节码发生了更改,例如ȝ本号或次版本号发生了更改Q那么二q制数据的Ş式就会有误。例如,如果对字节码故意做了更改Q或者在通过|络传送类文g时现Z错误Q那么就可能发生q个异常?br />    修复q个问题的惟一Ҏ是获得字节码的正确副本Q可能需要重新进行编译?br />ExceptionInInitializerError
Ҏ JVM 规范Q抛?ExceptionInInitializer 的情冉|Q?br />    * 如果初始化器H然完成Q抛Z些异?EQ而且 E 的类不是 Error 或者它的某个子c,那么׃创徏 ExceptionInInitializerError cȝ一个新实例Qƈ?E 作ؓ参数Q用q个实例代替 E?br />    * 如果 Java 虚拟囑ֈ建类 ExceptionInInitializerError 的新实例Q但是因为出?Out-Of-Memory-Error 而无法创建新实例Q那么就抛出 OutOfMemoryError 对象作ؓ代替?br />


]]>
վ֩ģ壺 | | | | ʲ| Դ| ʡ| | ƺ| DZɽ| ѽ| Į| Ϫ| | | | | ǰ| ʤ| μԴ| ʹ| | | | ٽ| ƽ| | Ӧñر| | ó| | | ¯| | ӳ| | | | α| ľ| |