1

If any, what is the java equivalent of Assembly.GetCallingAssembly().GetName().Name?

Background and Research:

I am working on translating some C# code into Java. At the moment I am unable to test what the Assemblyname returns, and so I am unable to figure out what kind of String I am actually looking for. I have figured out that the Assembly is compared with the compiled .jar file, and that the method retrieves variables related to the compiled running instance.

Further on, it seems like the variables I need might be in the manifest, and that the manifest might be retrieved like this question's answers suggest: Reading my own Jar's Manifest.

This is however where I got stuck. Since I am not able to figure out exactly what I am looking for, it is hard to find the equivalent variable. I realize that my question might be missing some key information, but on the chance that someone can understand what I need, better than myself, here i write. Pointers to what kind of information is needed to solve my problem, is also very welcome.

EDIT 1:

Realizing that I am probably looking for the name of an invoker of the title's containing method, I have found this link: How do I find the caller of a method using stacktrace or reflection?

It seems like it is a step in the right direction, but I am still not sure.

Community
  • 1
  • 1
jumps4fun
  • 3,994
  • 10
  • 50
  • 96
  • From a class you can get the "protection domain" and from this the URL for the code for that class. To get the class of a caller you can use an internal API or take a stack trace and lookup the class by name. – Peter Lawrey Apr 28 '14 at 10:05
  • This made me realize that I hadn't understood the "Calling"-part of the method. Am I correct to assume that this method indeed is looking for the name of an invoking assembly (thread?) and that I am actually looking for an identifier of the assembly that called the method that containts the questions title method? – jumps4fun Apr 28 '14 at 10:16

0 Answers0