Assert ÔÚJavaºÍGroovyÖеÄÇø±ð
¶ÔÓÚ·ÀÓùÐÔ±à³Ì¶øÑÔ£¬assertÒ»Ö±¶¼ÊǷdz£ÖØÒªµÄ¹¤¾ß¡£µ«¶ÔÓÚÊìϤ-ea²ÎÊýµÄJava³ÌÐòÔ±¶øÑÔ£¬µ±ËûÃÇ¿´µ½ËùÓÐGroovy¶ÏÑÔÎÞÂÛÊÇ·ñÓÐ-ea¶¼ÕÕÑùÖ´ÐÐʱһ¶¨»á·Ç³£À§»ó¡£
ÊÂʵÉÏ£¬GroovyµÄ¶ÏÑÔÊÇÎÞÌõ¼þ¿ªÆôµÄ£¡
¶Ô´Ë£¬¿ª·¢ÈËÔ±Roshan Dawrani×öÁËÈçϽâÊÍ£º£¨ÔÎÄ£©
The JDK documentation has a long chapter on assertions that talks about the disabling feature for assertions and its impact on compiling, starting the VM, and resulting design issues. Although this is fine and the design rationale behind Java assertions is clear, we feel the disabling feature is the
biggest stumbling block for using assertions in Java. You can never be sure that your assertions are really executed.
ÔÚCore Java£¨»òÕßÊÇTIJ£¿¼Ç²»ÇåÁË£©À×÷ÕßÌáµ½assertionÀàËÆ“ÔÚº£±ß¿ªÈüͧҪ´øºÃÄãµÄ¿¨Í¨¾ÈÉúȦ£»Èç¹û´¬ÒѾÔÚ´óº£ÖÐÑ룬¾Í°Ñ¾ÈÉúȦÈÓµôºÃÁË”¡£²»¹ý£¬ÔÚGroovyÖУ¬ÏÔÈ»ÕâÖÖ·ÀÓù´ëÊ©»áÒ»Ö±¸úËæÄãµ½´óº£µÄÈÎÒâ½ÇÂ䣨ϣÍû²»ÊǺ£µ×£©¡£
PS£ºÈç¹û×Ðϸ¿´¿´Groovy¶ÏÑÔµÄÊä³ö£¬ÄãÒ»¶¨»áÒâʶµ½Ëü¶ÔÓÚdebugÊǶàôÓÐÓãº
1: def xml = new XmlParser().parseText("x")
2: assert "y" == xml.text()
3: -----
4: output:
5:
6: assert "y" == xml.text()
7: | | |
8: | | x
9: | test[attributes={}; value=[x]]
10: false
11:
******
Quote of the day:
I didn't really say everything I said. - Yogi Berra
Ïà¹ØÎĵµ£º
×¢Ò⣬Çë²»Òª±»ÎÒÎóµ¼£¬ÎÒûÓп´ÆäËû×ÊÁÏ£¬ÕâÊÇÎÒ×Ô¼º·ÖÎöµÄ£¬ÓÐЩ¿ÉÄÜÊDz»¶ÔµÄ
"DestroyJavaVM" prio=6 tid=0x00316800 nid=0x448 waiting on condition [0x00000000
..0x00a0fd4c]
java.lang.Thread.State: RUNNABLE
"Thread-1" prio=6 tid=0x02f85000 nid=0xd18 waiting for m ......
Design Patterns in Java
-----------------------------------------
Steven John Metsker
William C.Wake
-----------------------------------------
¹¨²¨µÈÒë
££££££££Ò»¡¢¶þÕ¶ÁÊé¼Ç¼££££££
ģʽÊǼ¯ÌåÖǻ۵Ľᾧ¡£Ëü¸ø³öÁËÏà¹ØÐÐÒµÖоÑé·á¸»µÄ´ÓÒµÕßËùÓ¦ÓõÄËùÓеĸÅÄîºÍ·½ ......
³ý °Ë¸ö»ù±¾ÀàÐÍ£¨Long ,short,int ,float,double,char,byte,boolean£©Í⣬ÆäËûµÄÊý¾ÝÀàÐͶ¼±»³ÆÎª“ÒýÓÃÀàÐÍ”£¬Ò²¼´£ºObject¡£ObjectµÄ²Ù×÷È«ÊÇͨ¹ý¶ÔÏóµÄÒýÓã¨Object references£©£¬ÒýÓÿÉÒÔÀí½âΪָÕ룬ÈÝÒ×ÈÃÈ˶ÔÓ¦µ½C£«£«µÄ´«Ö·ÉÏÃæÈ¥¡£ËùÒÔ£¬´ó¼ÒҪעÒâà¶£¡javaÀïÃæËä˵ûָÕ룬Æäʵȴ²»È»¡£ ......
ʵÑéÒªÇó£º
1.±àд»ùÓÚTCPÐÒéµÄͨÐųÌÐò£¬°üÀ¨ServerÓëClientÁ½¸ö²¿·Ö¡£ÊµÏÖ»ØÉù³ÌÐò£º¼´¿Í»§¶Ë·¢ËÍÏûÏ¢£¬·þÎñÆ÷¶Ë½«ÊÕµ½µÄÏûÏ¢ÔÑù»áË͸ø¿Í»§¶Ë¡£
2.ÔÚµ¥»úÉÏÔËÐÐËüÃÇ£¬ÑéÖ¤ÆäͨÐŽá¹û£»
3.ÔÚ¶à»úÉÏÔËÐÐËüÃÇ£¬ÑéÖ¤ÆäͨÐŽá¹û£»£¨ChatServerÖ»ÐèÔËÐÐÔÚһ̨Ö÷»úÉÏ£¬ChatClient¿ÉÔÚÆäËüÖ÷»úÉÏÔËÐУ¨ÒªÖªµÀChatServerËùÔ ......