Java Reflection
·´ÉäÊÇJavaÓïÑÔÖкÜÖØÒªµÄÒ»¸ö×é³É²¿·Ö£¬ËùÒԾʹ˻°ÌâÌÖÂÛµÄ×ÊÔ´¿ÉνÊýÖ®²»¾¡£¬ÈÕ³£¿ª·¢Ò²»á¾³£Ê¹Óõ½¹ØÓÚ·´ÉäµÄReflection
API¡£Java5.0
Tiger³öÏÖÒԺ󣬸ü¶Ô·´ÉäAPIÓÐÁËеÄÀ©Õ¹£¬¾¡¹ÜÌÖÂ۵Ļ°ÌâºÜ¶à£¬²»¹ýÎÒ»¹ÊǾõµÃ²»¹»È«Ã棬ÓÈÆäÊǶԷºÐÍÕâÒ»¿é£¬ËùÒÔ¾ÍÎÒËùÖª£¬ÔÙ»¨Á¦Æø×ܽáÒ»·¬
Ê×ÏÈ·´ÉäµÄÈë¿ÚÊÇ´ÓClass¿ªÊ¼µÄ£¬ËùÒÔÈçºÎ»ñÈ¡Class¾Í±äµÃÊ®·Ö¹Ø¼üÁË¡£ÕâÀï×ܽáÁ˼¸ÖÖ·½Ê½£º
1.ͨ¹ý${name}.class Óï·¨¡£ÕâÀï${name}¿ÉÒÔÊǶÔÏó£¬Ò²¿ÉÒÔÊÇÔʼÊý¾ÝÀàÐÍ£¬²»¹ý±ðÍüÁËvoid.classºÍVoid.class
2.ͨ¹ý${name}.TYPE Óï·¨¡£ÕâÀï${name}ÊÇ°ËÖÖÔʼÊý¾ÝµÄ°ü×°ÀàºÍVoid.TYPE
3.ͨ¹ý¶ÔÏóµÄgetClass()·½·¨¡£
4.ͨ¹ýClass¶ÔÏóµÄforName()·½·¨
5.ͨ¹ýÀàClassµÄgetSuperclass()»ñÈ¡¸¸Ç×ÀàClass
6.ͨ¹ýÀàClassµÄgetEnclosingClass()»ñÈ¡ÍⲿÀàClass
7.ͨ¹ýÀàClassµÄgetClasses()ºÍgetDeclaredClasses()»ñÈ¡ÄÚ²¿ÀàClass
ÏÂÃæÊÇÒ»ÕűíÓÃÀ´ËµÃ÷getClasses()ºÍgetDeclaredClasses()Á½¸ö·½·¨£¬ÉÔºó»¹»áÓøñí˵Ã÷ÆäËûReflection API
--------------------------------------------------------------------------------------------
Member
| Class API
| Return type
| Inherited members
| Private members
--------------------------------------------------------------------------------------------
Class | getDeclaredClasses() | Array | N | Y
| getClasses() | Array | Y | N
--------------------------------------------------------------------------------------------
Field | getDeclaredField() &
Ïà¹ØÎĵµ£º
ÓÐÁ½ÖÖ·½Ê½£º¾²Ì¬²¿ÊðºÍ¶¯Ì¬²¿Êð¡£ÔÚÏÂÎÄÖÐ$CATALINA_HOMEÖ¸µÄÊÇTomcat¸ùĿ¼¡£
Ò»¡¢¾²Ì¬²¿Êð
¾²Ì¬²¿ÊðÖ¸µÄÊÇÎÒÃÇÔÚ·þÎñÆ÷Æô¶¯Ö®Ç°²¿Êð³ÌÐò£¬Ö»Óе±·þÎñÆ÷Æô¶¯Ö®ºó£¬WebÓ¦ÓóÌÐò²ÅÄÜ·ÃÎÊ¡£ÒÔÏÂ3Öз½Ê½¶¼¿ÉÒÔ²¿Êð£º
1¡¢½«PetWebĿ¼¿½±´µ½$CATALINA_HOME\webappsÏ£¬È»ºóÆô¶¯·þÎñÆ÷¾Í¿ÉÒÔÁË¡£ÕâÖÖ·½Ê½±È½Ï¼òµ¥£¬µ«ÊÇweb ......
×î½üÏîÄ¿½ø¶È±È½Ï»ºÂý£¬³õ²½Ñо¿ÁËÒ»ÏÂOracleµÄ´æ´¢¹ý³Ì£¬½«´úÂëÌù³öÀ´¡£
Ê×ÏÈÏÈÌù³öÀ´OracleµÄ·ÖÒ³·ÖÒ³´æ´¢¹ý³Ì´úÂë°É¡£
1.ÕâÊÇ°üµÄ´úÂë
create or replace package DB_Oper is
-- Author : LIUBING
-- Created : 2009-10-28 15:01:30
-- Purpose : ²âÊÔOracleµ ......
1. import java.util.*;
2.(A) public class Test
{ public static void main(String[] args)
{
//Éú³É [0-n) ¸ö²»Öظ´µÄËæ»úÊý st ÓÃÀ´±£´æ ......
¡¡¡¡Ê×ÏÈÒýÓÃһƪÎÄÕ£¬½éÉÜÒ»¸ö¼òµ¥µÄJNIµÄµ÷ÓõĹý³Ì¡£¡¡¡¡JAVAÒÔÆä¿çƽ̨µÄÌØÐÔÉîÊÜÈËÃÇϲ°®£¬¶øÓÖÕýÓÉÓÚËüµÄ¿çƽ̨µÄÄ¿µÄ£¬Ê¹µÃËüºÍ±¾µØ»úÆ÷µÄ¸÷ÖÖÄÚ²¿ÁªÏµ±äµÃºÜÉÙ£¬Ô¼ÊøÁËËüµÄ¹¦ÄÜ¡£½â¾öJAVA¶Ô±¾µØ²Ù×÷µÄÒ»ÖÖ·½·¨¾ÍÊÇJNI¡£¡¡¡¡JAVAͨ¹ýJNIµ÷Óñ¾µØ·½·¨£¬¶ø±¾µØ·½·¨ÊÇÒÔ¿âÎļþµÄÐÎʽ´æ·ÅµÄ£¨ÔÚWINDOWSƽ̨ÉÏÊÇDL ......