Reputation: 1059
I need to instrument parts of Java platform for a research project. Since the final tool can be used on different machines, I was wondering whether it is possible to instrument java files in one platform and simply reuse them for other platforms?
Therefore, my question is reduced to "is there any difference in java files of Java Platforms (e.g., in Windows and Mac), and if the answer is yes, where are those differences?
Upvotes: 1
Views: 95
Reputation: 308733
Can't tell without knowing more about what "instrument" .java files means.
I will say that there are lots of profiling tools available for use (e.g. dynaTrace, JProfiler, Visual VM, etc.). I think you'd be wise to investigate buy versus build before writing something.
Upvotes: 0
Reputation: 2081
The generated java bytecode (.class) is the same for all platforms.
The source files (.java) might use different encodings and/or line breaks, but the editor of your choice should be able to handle that.
You should be careful to actually code platform independent code. For example use line.seperator property instead of slashes or backslashes
Upvotes: -1
Reputation: 14534
If you use the core libraries of Java, you should experience few differences. Some things which depend on features of the platform may vary, e.g. file permissions in Windows are not the same as Unix/Mac OS X and will behave differently when accessed from Java.
In general though, for code that doesn't do anything in those areas you should be fine. Even if your instrumentation modifies the .class files, that code should still run correctly on a JVM in another platform.
Obviously if you are measuring performance, the different OSs will be faster and slower at different things such as thread switching, IO, etc.
Upvotes: 3