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 want to hook some system api in Android, but some of them are static method. So can I hook a java static method by reflection or any other method without tool like xposed?
Java does not support monkey-patching (like you could do in javascript for instance). The only way of achieving this would be by working with your own classloader and instrumenting the class before you return it -- which would obviously not work for an Android system api.
If you want to intercept your own calls to the api and replace them in some specific cases, create a facade for the api (with non-static methods) and access it through your facade. Then you can use a decorator on that facade to modify its behavior on the fly.
Related
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'm trying to decide if JNI is for our use case.
We have a library written in C++ that fetches data from Database/RPC using multiple threads, and we want to create a wrapper to let Java code be able to call it.
I'm not familiar with JNI, so I would like to know if C++ multithreading will still work properly in this case.
Thanks.
I don't see any major issues in neither direction. Unless you have something really specific.
Here you have sample that calls JNI code from multiple threads:
http://jnicookbook.owsiak.org/recipe-No-024/
Here you have sample that calls Java from multiple C threads:
http://jnicookbook.owsiak.org/recipe-no-027/
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
The specific problem encountered is mocking context, state stores, and window objects pass into the function process.
Looks like all the examples, e.g., here and here are unit tests at the stream level (e.g., mockStreams, or using EmbeddedKafkaCluster).
If you're looking to test a single processor implementation, and need to mock context, state stores, etc, I would just use whatever testing tools you ordinarily use to mock things (Mockito, CGLIB, etc).
Beyond the scope of your question, there is also the ProcessorTopologyTestDriver. Posting in case you missed it. Kafka Streams is getting new/improved testing functionality in an upcoming version.
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 9 years ago.
Improve this question
I can't find the relative code to the native methods memchr, memcmp, memcpy, memmove, memset in Java. Could someone explain what do these methods stand for? What do they really do?
I want to acceed to the value pointed to by a variable in my program and I'm wondering if these methods could help me.
Thank you in advance.
Java native methods are not encouraged to use unless you can not get the things done using available java methods. Also implementations of native methods can be differ from java versions. If you really want to see them you just download the jdk with source code from openJDK and have a look at them. On the other hand you can have your own implementations for these native methods as well. Have a look at here
to get more details on how to override these native methods
There aren't any. Therefore your question about what they do doesn't make sense. The closest approach in Java is System.arraycopy().
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 9 years ago.
Improve this question
Currently, my code uses an implementation of slf4j. The logger is fetched using a url (wsdl). Due to this, I am unable to test my code in a stand alone dev env, unless I bring up the giant server which hosts the service. Other than commenting the relevant code, does anyone know of a way I could make my eclipse ignore the usage of org.slf4j,impl.LoggingService in a class? I think an annotation like #Ignore which takes class params would have been fantastic. This could help someone pass those classes as params which being called in code need to be ignored. I am open to writing my own annotation implementations for it. Thank you
SLF4J seperates out the logging API from the underlying implementation, you should be able to switch out the implementation at runtime by selecting a different logging implementation. So for example slf4j-noop.jar that ignores all logging requests.
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 am trying to check if methods that acquire a resource also release it. What is the best tool to use to find out callers of a method in the classes in a single jar file? Can I do this with CheckStyle or FindBugs? How?
I guess I can do this using BCEL or such-like, but I have never worked with byte-code before and would take too long to do this.
Searching for "java call graph" did not find anything useful, but this seems to be a very basic functionality so I probably missed a good match. However, I would like to not have to generate the entire call graph on this very large project.