Skip to main content

You Do Or You Don't

Posted by editor on August 16, 2007 at 7:05 AM PDT


Putting your method in lockdown

Usually, the "Not-So-Stupid Question" articles require a little back-and-forth with the readers who send them in. Some people send in a few paragraphs of thinking through the ideas, but in most cases I get a one-line question and need to follow-up to get more details.

Today's article is an example of that. The initial question was straightforward enough: how do you do something like the private access modifier, but reverse its effect, so that instead of preventing incoming calls, it forbids the method to make calls outside its own class.

It's not that I didn't understand the question, or have some thoughts about implementations (probably involving annotations), it's that I didn't see the point. My first reaction was "if you don't want to make an outside call, then, um, don't make any."

But the questioner made a case that this isn't as trivial as it might seem. What if you're on a team where you can't know (or trust) what others are doing with the code? What if you want to enforce a specific code hierarchy and eliminate cyclic references, and have too much code to permit auditing the contents of every method? I suspect that the context may speak to a broader need for static code analysis, but I'll leave that for the community to discuss in the comments on the article.

For now, I hope you'll take a look at this
Feature Article,
(Not So) Stupid Questions 18: Reverse Access Modifiers, which asks "What do you do when you want to avoid any calls from inside your own methods to outside classes," and offer some thoughts of your own.


In Java Today,
a blog from Sun's Stefan Schneider offers A short Primer to Java Memory Pool Sizing and Garbage Collectors. He says the "Java SE 6.0 is doing a wonderful job in picking the right options for a system based on the available system resources." He explains the various HotSpot memory pools, their purposes, and their tuning, and then goes on to artificially misconfigure several pathological cases and show what problematic memory management looks like. But most users will never see cases like this, because 'the Java SE 6 Hotspot VM is doing an outstanding job to optimize its behaviour based on the existing hardware platform. The configuration of the maximum heap size ( -Xmx option) will be sufficient for most applications."

In the latest installment of the Java Mobility Podcast, MSpot brings the world of entertainment to the mobile phone. Derek Lyon of MSPOT shares their experience in using JavaME technologies on multiple phones, the custom frameworks the company developed, marketing, and how they identified the demographics of their target audience in delivering a whole host of entertainment products in both audio and video formats. For more information about MSPOT go to their website.

Daniel Spiewak feels he's got some explaining to do about a column in a recent Javalobby newsletter. In "Sun Open Sources JCK" Clarifications, he writes, "Almost immediately, I got several emails from people around the community, wanting to ensure that certain ambiguous or possibly misleading sections of my column weren't taken erroneously by the community at large. The two main points were as follows: Sun is not "open sourcing" the JCK, and
Apache is interested in the JCK scholarship program, not the relicensing."


In today's Forums,
ccvo wants to know
How to automatically stop a Midlet when calling platformRequest(url).
"I want to automatically exit my Midlet when calling platformRequest(url). So, I have tried the following ways, but the Midlet is still running after calling platformRequest():

platformRequest(url);

destroyApp(true);

The Midlet is likely to be re-invoked by AMS. Can anyone can help me?

Still in the ME forums, sschang123 is tracking down an native hang in
Re: CVM hangs at CVMjniInvokeNative() on Montavista/Mips platform.
"After tracing, I found it crashed at line 246 in invokeNative_mips.S. If I try to dump memory adress (a2), it will show "Can't access memory" in gdb. But a2 seems equal SWITCHBASE+SIGBYTE, and SWITCHBASE equals $arg_jumps in line 210. I have no idea about this. Is there any different in between one cvm executable and cvm+libcvm.so? That's all I found now. Look forward to your suggestion."

Finally, wnast wonders about
How to reuse a (un)marshaller without old data?
"I want to reuse a marshaller and an unmarshaller in my program. Sometimes the methods marshall and unmarshall are called often of the (un)marshaller and the memory is OK. When I have a large XML-File that is used to marshall or unmarshall, I must remove(set the references to null) the marshaller or unmarshaller to free the large XML-File, or I can call the methode again with a small XML-File. Is it possible to clean the references of the marshaller/unmarshaller to the old data?"


In today's Weblogs, James Gosling reports on graphics innovation now that he's
Back from Siggraph.
"Siggraph has been a lot more interesting the last couple of years. For a while there it felt as though there was an algorithm for generating Siggraph papers: dig through 100 year old physics papers, then do the straight-forward brute force numerical evaluation. Moore's law creates magic."

In Temperature SPOT - Part 1, Manfred Riem presents
"a simple SunSPOT application that sends the temperature to another SunSPOT when requested."

Finally, Felipe Gaucho looks at the
Mozilla about cache. "You can inspect all objects stored in your browser cache, both memory and disk cache. Check that and other tricks about view layer optimizations in web applications."


Current and upcoming Java
Events
:

Registered users can submit event listings for the href="http://www.java.net/events">java.net Events Page using our href="http://today.java.net/cs/user/create/e">events submission form.
All submissions go through an editorial review before being posted to the
site.


Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.

Putting your method in lockdown