Results 1 to 5 of 5
- 03-02-2009, 04:16 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 99
- Rep Power
- 0
getting the method and the class names (as argument, String varialbe)
I want to create text file for debug , that will track the flow of my programs.
for that I want to create a method that can be called from any other method. and its argument are the method and the class names (and other)
How can I do it ? ( beside manually )
- 03-02-2009, 07:45 PM #2
Note sure what you mean by "manually"?How can I do it ? ( beside manually )
Anyway, please see the following post on how to debug/log project information:
Debug challenge: how do you debug a Java program?
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 03-03-2009, 09:21 AM #3
Member
- Join Date
- Dec 2008
- Posts
- 99
- Rep Power
- 0
I have a lot of class and a lot of method . I dont want to write 500 time for each method its name - i can jsut make copy - paste..
instead of the line in red - i want the line in blue - ( hust instead method_name() and class_name() - a real java method that return the class name
Java Code:public class Student { public void setName() { [COLOR="Red"]DebugClass.writeSomething("Student","setName",otherArguments);[/COLOR] [COLOR="Blue"]DebugClass.writeSomething class_name() method_name(),otherArguments);[/COLOR] ... ... }
- 03-03-2009, 09:27 AM #4
the debug challenge has very good ideas.
you'd want to code them into a single class and put it in your classpath, then you can import it and reuse the class like a code library.USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
- 03-03-2009, 09:39 AM #5
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Have the "debug" class method get the stack trace and take the fourth item.
producesJava Code:package test; public class BogusStatic { public static void checkTrace() { StackTraceElement[] st = Thread.currentThread().getStackTrace(); System.out.println(st[0].getClassName()); System.out.println(st[0].getMethodName()); System.out.println(st[1].getClassName()); System.out.println(st[1].getMethodName()); System.out.println(st[2].getClassName()); System.out.println(st[2].getMethodName()); System.out.println(st[3].getClassName()); System.out.println(st[3].getMethodName()); } public static void main(String[] args) throws Exception { checkTrace(); } }
Java Code:java.lang.Thread dumpThreads java.lang.Thread getStackTrace test.BogusStatic checkTrace test.BogusStatic main
Similar Threads
-
Calling a method in a different class from within a method problem
By CirKuT in forum New To JavaReplies: 29Last Post: 09-25-2008, 07:55 PM -
Calling a method on original class from created class
By kpedersen in forum Advanced JavaReplies: 4Last Post: 08-20-2008, 12:25 AM -
Class Reflection: Finding super class names
By Java Tip in forum java.langReplies: 0Last Post: 04-23-2008, 08:12 PM -
Getting method names using Reflection
By Java Tip in forum Java TipReplies: 0Last Post: 01-24-2008, 03:18 PM -
Method for String to int conversion
By Java Tip in forum Java TipReplies: 0Last Post: 01-02-2008, 06:35 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks