Aggressive Inlining on Mutable Objects

Bimbo youwonawindowsserver at yahoo.com
Mon Sep 1 04:41:29 UTC 2014


Hello,

I don't know if this type of question fits here but I'll try anyway. This is my first participation on a mailing list.

Are we sure that the client and server compilers do not do aggressive inlining for mutable objects on multithreaded environments?
For example, I'm thinking about the plus operator on Strings. This plus operator uses a new instance of the mutable class StringBuilder. 

I modified this example on the web where there is a single instance of MultithreadingClass being shared by multiple threads.

public class MultiThreadingClass extends SomeThirdPartyClassThatExtendsObject{
private String somePath = "c:\\somepath"; 
public void beginmt(String st) throws IOException {
//st is a thread number
st = new File(somePath).getCanonicalPath()+"\\"+st;
System.out.println(st);
}
}
There is unsafe publication due to somePath not being final but I'm thinking about possible unsafe publication on the StringBuilder when using the + operator.  I'm just wondering whether when there are a lot of calls to 
concatenation on multiple threads using the single instance of MultiThreadingClass, the compiler will maintain a single Stringbuilder instance for all the currently running threads.

I'm totally new to viewing Hotspot code and I only partly know stringopts.cpp so I'd be grateful if someone could point me to the codes (and some tutorials on the internals at the code level) to this. :-)

Thank you very much and regards,

Bimbo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20140831/38600689/attachment-0001.html>


More information about the hotspot-compiler-dev mailing list