tag:blogger.com,1999:blog-8656465666508353224.post3743422703948993476..comments2015-11-22T07:44:41.222-08:00Comments on Mutability Detector Blog: v0.9 released, java.lang.String now considered immutable!Graham Allanhttp://www.blogger.com/profile/16539618370362116733noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-8656465666508353224.post-15267175682034222122015-11-22T07:44:41.222-08:002015-11-22T07:44:41.222-08:00Hi, apologies for long response time. I&#39;m sure...Hi, apologies for long response time. I&#39;m sure I replied to this, but I suspect blogspot swallowed the response.<br /><br />This is now an open issue and will hopefully be resolved soon: https://github.com/MutabilityDetector/MutabilityDetector/issues/64Graham Allanhttps://www.blogger.com/profile/16539618370362116733noreply@blogger.comtag:blogger.com,1999:blog-8656465666508353224.post-79108499169811731312015-08-11T03:34:30.710-07:002015-08-11T03:34:30.710-07:00Hi Graham,
thanks for you reply! Now I understand...Hi Graham,<br /><br />thanks for you reply! Now I understand the behaviour, though I think it&#39;s more desirable to make it consistent by design. I find it a bit confusing that String members are considered immutable, but the String class itself not. *At least* you should point that out in the documentation.<br /><br />Here&#39;s the background; I&#39;m sure you&#39;ll find this is a perfect valid use case: I have an Event class that contains a couple of members which must be immutable and members that are not immutable. The must-be-immutable members have an annotation @EventVariable. So I wrote a Unit-Test that determines all @EventVariable members and requires these to be immutable. That works fine, until I saw that String members are not immutable. Then my research brought me to this page where I read String is considered immutable being a contradition to my unit tests.<br /><br />Best regards,<br />steffenAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8656465666508353224.post-69082898293106193842015-08-04T13:02:54.229-07:002015-08-04T13:02:54.229-07:00That&#39;s an interesting point, I hadn&#39;t cons...That&#39;s an interesting point, I hadn&#39;t considered that before.<br /><br />I certainly could let the areEffectivelyImmutable() matcher accept classes that are immutable, but I&#39;m not sure what the use case would be. Is this behaviour, albeit slightly confusing, preventing you from doing something?Grahamnoreply@blogger.comtag:blogger.com,1999:blog-8656465666508353224.post-76995927233006494972015-08-04T12:59:52.537-07:002015-08-04T12:59:52.537-07:00Hi Steffen,
Great to hear you&#39;re trying out t...Hi Steffen,<br /><br />Great to hear you&#39;re trying out the tool!<br /><br />With java.lang.String, you&#39;re not doing it wrong. The behaviour you see is by design. String is hardcoded to be immutable because the analysis is not powerful enough to detect its internal mutation is safe. This lead to lots of false positives of other classes, because the mutability is transitive, and kind of &quot;infects&quot; other classes. Hardcoding it allows classes that have String fields to still be considered immutable, but if you test the class directly, it gives the &quot;real&quot; result. I expected this behaviour would suit most users, as they don&#39;t make changes directly to String, instead, they use String in their own classes.<br /><br />Does that make sense?<br /><br />~ Graham (though posting anonymous as Google won&#39;t let me log in for some reason)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8656465666508353224.post-28396827831906754942015-08-03T11:10:11.414-07:002015-08-03T11:10:11.414-07:00Hi again,
same with &quot;assertInstancesOf(myCla...Hi again,<br /><br />same with &quot;assertInstancesOf(myClass, Matchers.anyOf(MutabilityMatchers.areImmutable(), MutabilityMatchers.areEffectivelyImmutable()));&quot;. And I get messages like &quot;Expected: java.time.Instant to be EFFECTIVELY_IMMUTABLE, but: java.time.Instant is actually IMMUTABLE&quot;. Doesn&#39;t being immutable imply being effectively immutable?<br /><br /><br />Regards<br />SteffenAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8656465666508353224.post-91813494718996443752015-08-03T10:45:40.983-07:002015-08-03T10:45:40.983-07:00Hi Graham,
thank you very much for your amazing t...Hi Graham,<br /><br />thank you very much for your amazing tool. But my first tests failed because I still get the message &quot;Expected: java.lang.String to be IMMUTABLE, but: java.lang.String is actually NOT_IMMUTABLE&quot;. Well I added a maven dependency to &quot;org.mutabilitydetector / MutabilityDetector / 0.9.5&quot; and run &quot;MutabilityAssert.assertImmutable(myClass)&quot;.<br /><br />What am I doing wrong?<br /><br />Regards,<br />SteffenAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8656465666508353224.post-61956082695740950612013-03-07T09:21:24.890-08:002013-03-07T09:21:24.890-08:00Hi Jc,
I&#39;ve added a wiki page with download l...Hi Jc,<br /><br />I&#39;ve added a wiki page with download links, since GitHub has deprecated the downloads page. The links are to the artifacts hosted on Maven Central, which you can just download from your browser. Hopefully that&#39;s not too close to Maven to put you off :)<br /><br />Link: https://github.com/MutabilityDetector/MutabilityDetector/wiki/Downloads<br /><br />Do let me know what you think.<br /><br />Regards,<br />GrahamGraham Allanhttps://www.blogger.com/profile/16539618370362116733noreply@blogger.comtag:blogger.com,1999:blog-8656465666508353224.post-91702880707988341062013-03-07T05:39:58.780-08:002013-03-07T05:39:58.780-08:00Hi,
I just discovered your project and I&#39;d li...Hi,<br /><br />I just discovered your project and I&#39;d like to give it a try.<br />Could you update the download link here: https://github.com/MutabilityDetector/MutabilityDetector/downloads<br /><br />Because I don&#39;t want to use Maven :)<br /><br />Many thanks<br />JcAnonymousnoreply@blogger.com