Java Reflection Depth Test

Source: Internet
Author: User

Constructs the object through the Reflection API and accesses the object's Public/private methods and fields using reflection invocation.

Package lavasoft.test;
/**
* Test the Business class
*
* @author leizhimin 2010-5-6 20:16:10
*/
public class MyService {
Private String msg;
Public MyService () {
System.out.println ("Log: Parameterless construction method Lavasoft.test.MyService.MyService () has been invoked!" ");
}
Public MyService (String msg) {
System.out.println ("Log: Parametric construction method Lavasoft.test.MyService.MyService () has been invoked!" ");
this.msg = msg;
}
public string dosomething (string person, string something) {
System.out.println ("LOG: Business method Lavasoft.test.MyService.doSomething () has been invoked!") ");
Return person + ' is doing ' + something + '! "+
"Additional message:" + msg;
}
Public String getmsg () {
System.out.println ("LOG:LAVASOFT.TEST.MYSERVICE.GETMSG") has been invoked! ");
return msg;
}
public void Setmsg (String msg) {
System.out.println ("LOG:LAVASOFT.TEST.MYSERVICE.SETMSG") has been invoked! ");
this.msg = msg;
}
Private String doprivate () {
System.out.println ("Log: Private method Lavasoft.test.MyService.doPrivate () has been invoked!") ");
Return "Private Method Doprivate () was called!";
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.