How can i see every method called in a Java Application? [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is there a way to get textual output of every method invoked by the JVM at runtime?

If you are using Eclipse you can right click the method and choose "Open call hierarchy"
I am not very sure if you are looking for ASM, it is used for analyzing the bytecodes
ASM is an all purpose Java bytecode manipulation and analysis
framework. It can be used to modify existing classes or dynamically
generate classes, directly in binary form. Provided common
transformations and analysis algorithms allow to easily assemble
custom complex transformations and code analysis tools.
ASM offer similar functionality as other bytecode frameworks, but it
is focused on simplicity of use and performance. Because it was
designed and implemented to be as small and as fast as possible, it
makes it very attractive for using in dynamic systems*.

My suggestion is please use debugger to see the whole process is being done.

You can write a CGLIB proxy to trace your methods.

You should use Java profiler tool. There are two well-known profilers - YourKit Java Profiler and JProfiler.
I prefer first one, but you can try both and make your choice.

Related

Bytecode modification of an existing loaded class [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to mutate a function of a class that is loaded at runtime (it has a bug in it but the project is long gone so i cannot build the binary). What i want to do instead is write a piece of code which will run during the application initialization phase and mutate this function so that it works fine. And simply keep that code around until the replacement is ready.
Having no experience with bytecode modification what library could i use to modify and reload a class at runtime? Specifically i need to replace a throw instruction with a noop instruction (i did this once using hex editor but lost the binary).
Also if you know any tutorial on how to do something like that please share.
I can see many libraries for doing this but i cant know which ones are good/bad do the job...
I think use Java Attach API. Java Attach API is procedure of loading a Java agent into an already running JVM. you can understand the work of javaagents by reading the Java Instrument javadoc. AgentMain help to you.
Agentmain is invoked when an agent is started after the application is already running. Agents started with agentmain can be attached programatically using the Sun tools API (for Sun/Oracle JVMs only -- the method for introducing dynamic agents is implementation-dependent).
This tutorial is useful about java instrumentation.

what is best way to use trained tensorflow in java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am coding UI by javaFx in eclipse
because I can only use java, no python, no c.
Now I try to use trained tensorflow file in this UI. (this tensorflow file is under python)
I am looking for several ways (API, jython, TCP/IP) but I am not sure which one is best.
Please write your opinion which has more advantages or fewer disadvantages.
I think there are two ways for that,
tensorflow-serving which uses grpc to connect from java to the serving server, making it independent of any language. Look here for details.
Use tensorflow java API. Here and Here is an example of using object detection model in native java program.
Now, tensorflow-serving is the preferred way to go, as there are several advantages. Serving is heavily optimized for speed and resource management like GPU. It also stacks multiple requests (if there is too many) and then processes them in a batch which utilizes the GPU efficiently.

Which design patterns should we use with Selenium WebDriver? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Page Object Pattern is obvious. But what I can do more to build better automated test cases for web application?
I may not be able to talk about any standard pattern, but here are a few things that I consider:
Make good use of Test Execution frameworks. I use TestNG.
I create a base file which makes use of most of the TestNG annotations for Setting and Tearing up.
Separate your Re-usable functions and call it wherever needed. I generally add these in the base class.
I personally prefer keeping locators too in the base file if they are too complicated. This would help you to change the locator from one place and get reflected for all. In this case, do follow a good naming convention.
Use collections wherever possible.
You can use something like ReportNG for more user friendly reports.
Make more use of implicit waits and avoid using JavascriptExecutors.
Copy the Drivers and libraries within the project folders for better mobility and less external dependencies.
Adding selenium WD javadoc to your project will be of some help.
We also make sure we have a screenshot for failed test case by over-riding the onTestFailure method.
Rest all are simple coding basics for cleaner and easy to understand code that I believe you'll be following anyway.
Hope this was of some help. Will add more points if I'm able to recall. Also, please let me know if you need more details for any of these things.

How to build and maintain a library for multiple languages? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need to implement a library which will be called from multiple languages - Java, Python, Perl and possibly more in the future. I'd hate to implement (and maintain) the same thing again and again in multiple languages.
One option I can think of is to write the core functionality in C/C++ and use SWIG to generate bindings for target languages; or maybe write the bindings myself.
Thre are some reasons why it can't be an independent service.
Are there any other mature alternatives? I am looking for options to compare before I settle for one.
Ideally, I'd like to do it using a source to source compiler or a source code generator. But I can't find one that supports all of the above languages - with potential for future additions.
I may consider any alternative binding generators if they provide any advantages over SWIG.
Thanks in advance for any pointers!
The simplest way is to write the library in C with a simple API. Every non-obscure language has some way to interface with C code.
Depending on the style of the API, SWIG can save some time in generating the bindings; but unless it's very big and regular, you might find it easier to write the bindings by hand.
Some Languages (at least Python in your question) have an FFI mechanism, that lets you write the whole binding in the target language, making it much easier to deploy and maintain. Note that most of those are focused on C APIs, not C++.
Depends on how you plan on access the library, is it possible to expose the public API via Web Services?
This way you can write the shared module in any language and access it via a common protocol such as a RESTfull web service.
Look at Microservices architecture.

Guidelines for writing Scala API as wrapper over Java API [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have java product with rich set of api. I want to write scala api as a wrapper over those java api. Are there any guidelines for the same. Please share your experience
This is a very vague question as others have noted, but I suppose there are some broad suggestions:
Use JavaConverters to translate Java collections to Scala collections.
Use Scala annotations to represent properties or characteristics represented by other means in Java. Examples of these include #deprecated, #throws, and #BeanProperty. #BeanProperty is especially useful if you want to use a library that specifically demands JavaBeans (i.e conforms to the specification).
If the Java code uses Spring, maybe look into Spring Scala if necessary. Or use more constructor-args. Or asInstanceOf to cast any beans you manually fetch from the context.
Build files. Perhaps you want to replace any Java-specific build mechanism with SBT. Or transform your Java-focused Gradle build file to be more Scala-focused. That kind of thing.
That's all I can think of. Hopefully others will point out other considerations I've missed.

Categories