aspose file tools
The moose likes Java in General and the fly likes Reflection: To check whether static block is there or not! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Reflection: To check whether static block is there or not!" Watch "Reflection: To check whether static block is there or not!" New topic
Author

Reflection: To check whether static block is there or not!

Abhishek Chaudhari
Greenhorn

Joined: Feb 09, 2005
Posts: 11
**Hello.java
public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}

static
{
System.out.println("Static Block of Hello");
}
}
///////////////////////////
**Hello2.java
public class Hello2
{
public static void main(String[] args)
{
Class klass = Hello.class;
.......
}
}
///////////////////

Can I somehow know - using reflection - in class Hello2 through 'klass' whether there is a static block in class Hello?
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Um ... I don't think so. Just curious though, but what possible reason would you have for wanting to know if there is a static initialization block in a class?


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Reflection: To check whether static block is there or not!
 
Similar Threads
parameter passing
Difference between Hidden and overriden methods.
private final method
String Intern Method
K&B Anonymous Inner Class.