Spring Reflection Tool Class Reflectionutils

Source: Internet
Author: User

    public static final int public           = 0x00000001;       public static final int PRIVATE          = 0x00000002;     public static final int PROTECTED        = 0x00000004;       public static final int static           = 0x00000008;       public static final int final            = 0x00000010;        public static final int SYNCHRONIZED     = 0x00000020;         public static final int VOLATILE         = 0x00000040;          public static final int TRANSIENT        = 0x00000080;         public static final int NATIVE           = 0x00000100;          public static final int INTERFACE        = 0x00000200;         public static final int ABSTRACT         = 0x00000400;         public static final int STRICT           = 0x00000800;
Above is the static property defined in the modifier

And each one defines a method of interpretation, such as

public static Boolean isPublic (Int. MoD) {return (mod & public)! = 0;    }
public static Boolean isprivate (int mod) {return (mod & PRIVATE)! = 0;    }
  public static Boolean isStatic (int mod) {return (mod & static)! = 0;    }


Reflectionutils This reflection tool class has several tool methods, first introduces several methods of controlling access rights makeaccessible

It consists of 3 overloads, respectively, for attributes, methods, and constructs


Property

public static void makeaccessible (Field field) {if (! Modifier.ispublic (Field.getmodifiers ()) | | ! Modifier.ispublic (Field.getdeclaringclass (). getmodifiers ()) | | Modifier.isfinal (Field.getmodifiers ())) &&!field.isaccessible ()) {field.setaccessible (true);}}
Method
public static void Makeaccessible (method method) {if (! Modifier.ispublic (Method.getmodifiers ()) | | ! Modifier.ispublic (Method.getdeclaringclass (). getmodifiers ())) &&!method.isaccessible ()) { Method.setaccessible (True);}}
Structure
public static void Makeaccessible (Constructor<?> ctor) {if (! Modifier.ispublic (Ctor.getmodifiers ()) | | ! Modifier.ispublic (Ctor.getdeclaringclass (). getmodifiers ())) &&!ctor.isaccessible ()) {ctor.setaccessible ( true);}}

Spring Reflection Tool Class Reflectionutils

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.