Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
ca27b986
Commit
ca27b986
authored
17 years ago
by
brinn
Browse files
Options
Downloads
Patches
Plain Diff
add: method getMethodOnStack()
SVN: 536
parent
870b8d35
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/source/java/ch/systemsx/cisd/common/utilities/ClassUtils.java
+18
-3
18 additions, 3 deletions
...ce/java/ch/systemsx/cisd/common/utilities/ClassUtils.java
with
18 additions
and
3 deletions
common/source/java/ch/systemsx/cisd/common/utilities/ClassUtils.java
+
18
−
3
View file @
ca27b986
...
...
@@ -74,13 +74,28 @@ public final class ClassUtils
* Returns <code>null</code> if none could be found.
* </p>
*/
public
final
static
Method
getCurrentMethod
()
{
return
getMethodOnStack
(
2
);
}
/**
* Returns the <code>Method</code> on the stack of <var>level</var>.
* <p>
* <code>level=0</code> is this method itself, <code>level=1</code> is the method that called it and so forth.
* @return <code>null</code> if none could be found.
* </p>
*/
// TODO 2007-06-14 Christian Ribeaud: 'method.getName()' is not specific enough. You have to used kind of
// or part of 'Method.toGenericString()'.
public
final
static
Method
get
CurrentMethod
(
)
public
final
static
Method
get
MethodOnStack
(
int
level
)
{
StackTraceElement
[]
elements
=
new
Throwable
().
getStackTrace
();
// Index 0 is *this* method
StackTraceElement
element
=
elements
[
1
];
if
(
elements
.
length
<=
level
)
{
return
null
;
}
StackTraceElement
element
=
elements
[
level
];
String
methodName
=
element
.
getMethodName
();
try
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment