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
Ïà¹ØÎĵµ£º
ÏÈÀ´Á˽âÒ»ÏÂÁ´±íģʽµÄÔÀí£º
Ê×ÏÈдһ¸öJavaBean£¬ÄÚÈÝÊÇÒªÌí¼ÓµÄÔªËغ͸ÃÔªËصĽڵ㡣
public class NodeBean implements Serializable
{
private Object data; //ÔªËر¾Éí
private NodeBean next; //ÏÂÒ»¸ö½Úµã
&n ......
½«Ä³ class ²úÉú³öÒ»¸ö instance Ö®ºó£¬´Ë class ËùÓÐµÄ instance field ¶¼»áÐÂÔöÒ»·Ý£¬ÄÇôËùÓÐµÄ instance method ÊÇ·ñÒ²»áÐÂÔöÒ»·Ý£¿´ð°¸ÊDz»»á£¬ÎÒÃÇÓÃfield±íʾ×ֶΣ¬ÓÃmethod±íʾ·½·¨£¬ÄÇô¼ÓÉÏstaticÇø·Öºó¾Í ÓÐËÄÖÖ£º
class field£ºÓÐÓÃstaticÐÞÊεÄfield
class method£ºÓÐÓÃstaticÐÞÊεÄmethod
instance fi ......
ʱ¼ä¹ýµÄÕæ¿ì£¬²»Öª²»¾õÀ´µ½´«ÖDz¥¿ÍÒѾһ¸ö¶àÔÂÁË£¬ÕâÒ»¸öÔÂÖ÷ҪѧϰÁËJava»ù´¡²¿·Ö£¬ËäȻÿÌ춼ÊÇÇôúÂëµ½ÍíÉÏ1¡¢2µã²Å˯¾õ£¬µ«ÊÇ»¹ÊǸоõʱ¼ä²»¹»Óã¬ÒòΪÐèҪѧϰ¹®¹ÌµÄ¶«Î÷Ì«¶àÌ«¶àÁË£¬×ܸоõÕÆÎյIJ»¹»ºÃ£¬ÕâÒ»¸öÔ¹ýµÄºÜÀÛµ«Ò²ºÜ³äʵ¡£
Õ⼸Ì쿪ʼ ......
Ò».±àд¹¹ÔìÆ÷µÄÓÐЧ׼Ôò£º Óþ¡¿ÉÄܼòµ¥µÄ·½·¨Ê¹¶ÔÏó½øÈëÕý³£×´Ì¬£¬Èç¹û¿ÉÒԵĻ°£¬±ÜÃâµ÷ÓÃÆäËû·½·¨¡£ÔÚ¹¹ÔìÆ÷ÄÚΨһÄܹ»°²È«µ÷ÓõÄÄÇЩ·½·¨ÊÇ»ùÀàÖеÄfinal·½·¨£¨Ò²ÊÊÓÃÓÚprivate·½·¨£¬ËüÃÇ×Ô¶¯ÊôÓÚfinal·½·¨£©¡£ ¶þ.Óü̳нøÐÐÉè¼ÆµÄ×¼Ôò£º Óü̳бí´ïÐÐΪ¼äµÄ²îÒ ......
Ê×ÏÈ£¬ÒªÏÂÔØÒ»¸öÁ¬½ÓmysqlÊý¾Ý¿âµÄÇý¶¯³ÌÐò: mysql-connector-java-3.0.15-ga-bin.jar, Õâ¸öÇý¶¯³ÌÐò²»ÐèÒª×öÆäËüÅäÖÃ,Ò²¾ÍÊÇ˵£¬¶ÔÓÚmysqlÊý¾Ý¿â£¬²»±ØÏñaccess»òÕßoracleÒª½¨Á¢odbcÊý¾ÝÔ´¡£
Æä´Î£¬½«ÉÏÃæµÄ.jarÎļþ¼ÓÈëµ½classpath»·¾³±äÁ¿ÖС£
×îºó£¬¾ÍÊÇд´úÂë½øÐвâÊÔÁË¡£
Ö÷Òª´úÂëÈçÏ£º
......