Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9206625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:12:55+00:00 2026-06-18T00:12:55+00:00

I am calling a method via reflection , which throws an exception. However when

  • 0

I am calling a method via reflection , which throws an exception.

However when I get the stacktrace via

StackTraceElement[] elements = Thread.currentThread().getStackTrace();

i don’t get the entire stack trace upto the reflected method. It gets the stack trace only uptil my method which implements reflection.

The reflected class is in a different project altogether.

EDIT : Adding code snippet

Project A

Class ReflectionImpl {

   public void callMethodsviaReflection{
     try{
              // Reflection code to call the method

         }catch(InvocationTargetException iTE){

           StringBuilder errorLogBuilder = new StringBuilder();
            errorLogBuilder.append(ex.toString());
            errorLogBuilder.append("\n");

            StackTraceElement[] elements = Thread.currentThread().getStackTrace();

             for (int i=0;i<elements.length;i++) {

                 errorLogBuilder.append((elements[i].toString()));
                 errorLogBuilder.append("\n");
             }

            System.out.println(errorLogBuilder.toString());
        }
    }
}

Project B –> References Project A in Eclipse

Class ReflectedClass{

 List<String> nameList = null;

 public void reflectedMethod(){

     nameList.add("Hello");
    }      
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:12:56+00:00Added an answer on June 18, 2026 at 12:12 am

    At the particular point where you are calling:

    StackTraceElement[] elements = Thread.currentThread().getStackTrace();
    

    your ‘reflective invocation’ has already been completed, which is reflected in the call stack you get back from the call. Sounds more like you want:

    iTE.getCause().getStackTrace();
    

    Which will give you the call stack up to and including the method that actually threw the exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When calling a method via methodInfo.Invoke, if an exception is thrown it does not
I have a method which I would like to call via reflection. The method
Is it possible (via reflection?) to iterate all fields of an object calling a
My problem is that when I am calling the protocol method dataLoading via the
In my C# application I'm calling a method which returns an array: projectArray =
I am calling a WebService method via a Command Line Exe. This method call
Flash gives access to query-string parameters via calling loaderInfo.parameters() method. And I couldn't delete
Is there a way via System.Reflection, System.Diagnostics or other to get a reference to
I'm calling a method via interop that returns an out IntPtr parameter. How can
Edit: an important piece might be that I'm calling a cfc method via ajax...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.