|
|
Java News Feed |
|
|
|
| Blog Posts that Attract Attention |
| Blogs are now a dime a dozen, and bloggers need to make their blog posts stand out. Developing a blog following is not as easy as it once was. Learn how to write blog posts that attract readers and retain their attention. Follow these guidelines to cultivate readers... <br />
<br />
<a href="http://www.rss-specifications.com/blog-post-attention.htm" target="_blank" >Blog Posts that Attract Attention</a> |
Source:
Rss |
| Ten Podcasting Tips that Lead to a Great Sound |
| The sound quality, and the way a podcast is recorded, will impact the value of the podcast as well. Podcast structure and pre-planning are also important; do not skimp on the production, as it too can make or break a podcast.<br />
<br />
<a href="http://www.feedforall.com/top-podcasting-great-sound.htm" target="_blank" >Ten Podcasting Tips that Lead to a Great Sound</a> |
Source:
Rss |
| Real Estate Video Podcast Tips |
| The use of technology can define the success or failure of a business. This is no more evident than in the real estate industry. Realtors who flocked to the latest technologies, adopted them, and applied them in order to enhance and sell property, are still prospering. <br />
<br />
<a href="http://www.rss-specifications.com/real-estate-video-podcast.htm" target="_blank" >Real Estate Video Podcast</a> |
Source:
Rss |
| RSS Guidelines |
| In general, the following are guidelines for constructing an RSS feed. It is good to get into the habit of validating the RSS feed, either with software, or with an online validator. <br />
<br />
<a href="http://www.rss-specifications.com/rss-feed-etiquette.htm" target="_blank" >Here are some general guidelines for creating RSS Feeds</a><br /> |
Source:
Rss |
| Create Professional RSS Feeds |
| More and more companies are using RSS as a means to communicate, so having an RSS feed that is professional and well polished will help differentiate your company from your competition. What makes an RSS feed professional? Follow these simple steps to polish your RSS feed and take it to the next level... <br />
<br />
<a href="http://www.rss-specifications.com/create-professional-feeds.htm" target="_blank" >Create Professional RSS Feeds</a> |
Source:
Rss |
| Realty and RSS Feeds |
| RSS feeds are becoming an essential tool for Realtors, who are struggling in a declining market. Real estate offices that adopt technology as a marketing tool will remain one step ahead of their competition. <br />
<br />
<a href="http://www.feedforall.com/realty-and-rss.htm" target="_blank" >Realty and RSS Feeds</a> |
Source:
Rss |
| Banks and Finance Companies RSS Feeds |
| Financial institutions are reaching out to clients using RSS feeds. While banks and financial institutions are usually slow to adopt new technology, that is not the case with RSS adoption. More and more professionals are using RSS in innovative ways, to stay ahead of their competition. <br />
<br />
<a href="http://www.rss-specifications.com/finance-rss-feeds.htm" target="_blank" >Finance Companies Use RSS</a> |
Source:
Rss |
| Law Field and Legal RSS Feeds |
| Lawyers have never been known as a technical bunch, but more and more often you see a lawyer with a palm pilot making appointments and a blackberry for those urgent messages. Electronic gadgets are now common in the courthouses across the US. Lawyers have increased productivity by utilizing technology so it should come as no surprise that lawyers are using RSS feeds as a means to grow and manage their practices. <br />
<br />
Lawyers are using RSS feeds a number of different ways to increase efficiency and productivity. <br />
<br />
<a href="http://www.rss-specifications.com/legal-rss-feeds.htm" target="_blank" >Law Field and Legal RSS Feeds</a> |
Source:
Rss |
| RSS and Education |
1. Share Resources
Academics are using social bookmarking websites to share quality websites that relate to their area of expertise with colleagues and students.
RSS and Education]]>
|
Source:
Rss |
| 13 Tips to Maintaining and Growing a Feed Subscriber Base |
1. Original Content
A consistent stream of original content will do well to earn subscribers loyalty. The best RSS feeds provide content that is compelling and unique. Do not rehash existing content, look for a unique angle or spin if you wish to cover something that is hot in the blogosphere.
2. Quality Over Frequency
A posts quality is far more important than a post's frequency. Readers will tire of rambling or nonsensical posts that contain no real value. Time is precious and there are plenty of feeds and blogs, in order to retain readers provide quality not quantity.
13 Tips to Growing RSS Feed Subscribers]]>
|
Source:
Rss |
| Vertical Marketing with RSS Feeds |
| Just as the second generation of search engines and directories evolved into niche topic specific portals we are seeing the same occur in the area of RSS feed directories and search engines. While some directories are admittedly more niche than others the trend is obvious. <br />
<br />
Vertical search and niche directories are becoming authority sites in a crowded online world. These niche directories will help individuals in specific industries locate topics essential to their industries. <br />
<br />
<a href="http://www.rss-specifications.com/industry-feeds.htm" target="_blank" >Vertical Marketing with RSS Feeds</a><br /> |
Source:
Rss |
| RSS Does Not Equal Blogs |
| Many assume that RSS is only for syndicating the contents of blogs, nothing could be further from the truth. Blogs and online journals have rocketed to popularity in the last few years, and many bloggers use RSS as a means to distribute and syndicate their blog posts. Subscribers receive information each time the blog is updated. However this is NOT the only use for RSS. RSS can deliver any kind of content, including forum posts, discount coupons, newsletters or press releases. Blogs are just one type of information syndicated by RSS feeds. <br />
<br />
Blogs may be syndicated using RSS, but do not assume that content found in an RSS feed is from a blog. <br />
<br />
<a href="http://www.feedforall.com/rss-does-not-equal-blogs.htm" target="_blank" >RSS Does Not Equal Blogs</a> |
Source:
Rss |
| Jenabean: Easily bind JavaBeans to RDF |
| |
Source:
IBM Tue, 29 Apr 2008 12:00:00 EDT |
| Scala and XML |
| |
Source:
IBM Tue, 22 Apr 2008 12:00:00 EDT |
| Mobile Developer Certification Programs |
| Developing Mobile Phone Applications With Java ME Technology on using CLDC, MIDP, and Java ME. The Sun Certified Mobile Application Developer (SCMAD) exam is for developers who create mobile applications using Java ME technologies for smart devices.]]> |
Source:
sun |
| Using StAX to Clone an XML Document |
| To clone an XML document at runtime, use the StAX XMLEventReader and XMLEventWriter classes. |
Source:
Devx Tue, 29 Apr 2008 16:14:28 PST |
| Tracking Events Using a Semi-Structured Repository |
| Tracking the activities of a system and its users is too often not considered until the application is already deployed. Learn how to demonstrate an (almost) no hassle persistent bean pool that you can use to track the activities of an already developed system for later review. |
Source:
Devx Thu, 24 Apr 2008 15:55:08 PST |
| Mobilize Your Java Applications with Java ME Technologies |
| Read this beginner's guide to extending an enterprise application to mobile devices with the Java ME technologies. |
Source:
Devx Tue, 22 Apr 2008 23:08:32 PST |
| The Mobile Platform Cheat Sheet |
| With the fragmented mobile development landscape forcing developers to make a number of crucial choices, get a high-level comparison of the different platforms and recommendations for what purposes they fit. |
Source:
Devx Tue, 22 Apr 2008 23:04:45 PST |
| Start Your Engines: Mobile Application Development |
| A fifth of the world's population will soon have a mobile device and access to the Internet. With that many potential users, is an explosion of mobile applications inevitable? If so, what technologies will lead the way in their development? |
Source:
Devx Tue, 22 Apr 2008 23:03:46 PST |
| Grid Enable Your Java Applications with GridGain |
| Grid computing, the idea of executing code among various computers to solve complex time- and resource-intensive algorithms, has intrigued researchers for decades. GridGain lets Java developers tap into the grid. |
Source:
Devx Thu, 17 Apr 2008 21:15:07 PST |
| Load an Image Using the JAI API |
| Find out how to use JAI API to load an image in just three lines of code. |
Source:
Devx Mon, 07 Apr 2008 17:09:21 PST |
| The Easiest and Most Efficient Way to Modify XML Documents |
| The easiest most and most efficient way to update XML documents is to use non-extractive parsers (such as VTD-XML) because they support incremental content update. |
Source:
Devx Mon, 31 Mar 2008 18:16:01 PST |
| Apply an Identical Transformation to a DOM Tree Using TrAX |
| The code in this tip is a full example that applies an identical transformation to a DOM tree. |
Source:
Devx Mon, 31 Mar 2008 18:11:24 PST |
| Build an Entity Resolver to Redirect a SAX Parser |
| This tip shows you how to bulid an entity resolver to "change" a public indentifier into a system identifier. |
Source:
Devx Mon, 31 Mar 2008 17:29:17 PST |
| Neal Gafter's proposal for constructor type inference |
| <p>Neal gafter has proposed that java language include <a href="http://gafter.blogspot.com/2007/07/constructor-type-inference.html">Constructor Type Inference</a> in order to reduce verbosity. So what was </p>
<pre class="jsccJAVA">
Map<String,List<Thing>> map = new HashMap<String,List<Thing>>();
</pre>
<p>looks like:</p>
<pre class="jsccJAVA">
Map<String,List<Thing>> map = new HashMap<>();
</pre>
<p>Though there is an alternate proposal to deduce the LHS type instead, like:</p>
<pre class="jsccJAVA">
map := new HashMap<String,List<Thing>>();
</pre>
<p>I find Neal's proposal more appealing and more natural to java. It feels so Java, that I have already used it thrice since morning only to be surprised by IDEA's warnings! So, if anyone is counting votes, +1 from me.</p><img src="http://feeds.feedburner.com/~r/cafefeed/~4/131227359" height="1" width="1"/> |
Source:
Feedburner Fri, 06 Jul 2007 16:01:14 -0500 |
| Why do catch clauses need to be ordered? |
| <p>Looking at question #15 on JDJs <a href="http://java.sys-con.com/read/48839.htm">Secrets Of The Masters: Core Java Job Interview Questions</a> (Secrets of the masters???!! Whhoaaah!!), I was reminded of the question Vinod once asked me: "Why do catch clauses have to be ordered?"</p>
<p>It is generally known that, in Java, the order of the catch clauses is important. The more specific exceptions have to be handled first followed by the less specific exceptions. So, the following snippet of code causes a compilation error, as FileNotFoundException is more specific than IOException (FileNotFoundException extends IOException).</p>
<pre class="jsccJAVA">
try{
//Some File I/O operations here
}catch(IOException e){
//handle the I/O error
}catch(FileNotFoundException fnfe){
//handle the case when the file is not found
}
</pre>
<p>To fix it, you need to change the order in which the exceptions are handled by moving the more specific exception (FileNotFoundException) before the less specific exception (IOException), like so:</p>
<pre class="jsccJAVA">
try{
//Some File I/O operations here
}catch(FileNotFoundException fnfe){
//handle the case when the file is not found
}catch(IOException e){
//handle the I/O error
}
</pre>
<p>This change is so straight forward that, any smart IDE can do it for you</p>
<img src="http://www.me.umn.edu/~shivane/blogs/cafefeed/resources/14-jun-2007/ide-suggestions.png" alt="Screenshot of IntelliJ IDEA's suggestion to move catch clauses around"/>
<p>So Vinod's question really was: Why didn't the designers of the Java language make the compiler smart enough to sort the catch clauses automatically (instead of pushing the burden on to the IDEs/developers)?. To quote him verbatim (including the typos) from my messenger archive: ".. i mean you are asking the programmer to think like compiler than compiler think like a programmer ... from a programmer perspective... i want to catch FNFE if the exception is of that type other wise cathc IO". Interesting point .. I never thought of it before.</p>
<p>Spoiler: I don't know the answer, what follows are my thoughts or possibly my <a href="http://en.wikipedia.org/wiki/Stream_of_consciousness_writing">stream of consciousness</a>, like my article on <a href="http://www.me.umn.edu/~shivane/blogs/cafefeed/2005/09/why-is-finalize-method-protected.html">Why is finalize method protected?</a>.
<p>Having found no clues in <a href="http://java.sun.com/docs/books/jls/">The Java language specification</a> I thought the answer probably lies in the history of Java. <a href="https://duke.dev.java.net/green/">A Brief History of the Green Project</a> is a good place to start. This page gives history of Java (it was originally called Oak) and has a copy of the <a href="https://duke.dev.java.net/green/OakSpec0.2.ps">version 0.2 of the Oak language specification</a> [<a href="http://www.me.umn.edu/~shivane/blogs/cafefeed/resources/14-jun-2007/OakSpec0.2.zip">PDF</a>]. The spec gives an interesting perspective on how the Java language evolved.</p>
<h3>Side tracking: Interesting tidbits from the Oak specification</h3>
<p><ul>
<li><code>Throwable</code> was earlier called <code>GenericException</code></li>
<li>Asynchronous Exceptions: one thread can throw an exception (using Thread’s postException() instance method) to another thread</li>
<li>The protect/unprotect keywords</li>
<li>You could use <code>//* javadoc here</code> notation to write java docs apart from <code>/** javadoc here</code></li>
<li><code>print</code> and <code>println</code> were operators. <code>System.out<code> was possibly a refactoring</li>
<li>Interfaces declared constants using <code>const</code> instead of <code>public static final</code>. Like <code> const int aConstant = 42;</code></li>
<li>Supported assertions, preconditions and postconditions</li>
<li>Has no details on threads, serialization nor does it have a BNF</li>
</ul></p>
<h3>Side tracking again: Catching multiple exceptions in one catch clause</h3>
<p>Many a times people ask me: "Why can't I catch multiple exceptions in one catch clause, I generally end up pasting same error recovery code in all the catch clauses. Why isn't a catch clause <em>like a method signature</em>, where I can have a comma separated list of all the exceptions to be handled?" What they want is some thing like this:
</p>
<pre class="jsccJAVA">
try{
//Some File I/O operations here
}catch(FileNotFoundException fnfe, IOException e){
//common error handling
}
</pre>
<p>The question itself seems to have the answer. If all the exceptions were listed like method parameters, the above snippet of code would mean "Do the common error handling if BOTH FileNotFoundException and IOException are raised" instead of "Do the common error handling if EITHER FileNotFoundException or IOException is raised". The solution probably would be to use the OR operator "||" instead of commas? Some thing like:</p>
<pre class="jsccJAVA">
try{
//Some File I/O operations here
}catch(FileNotFoundException||IOException||MyNewException e){
//common error handling
}
</pre>
<p>Incidentally, the Oak specification also compares catch clauses to method definitions. From section 9.4:</p>
<q>A catch clause is like a method definition with exactly one parameter and no return type. When an exception occurs, the runtime system searches the nested try/catch clauses. *snip*</q>
<p>If you have two overloaded methods called handle, of which one takes <code>FileNotFoundException</code> as a parameter and the other takes <code>IOException</code> as a parameter, java always knows which method to call. It automatically calls the most specific method based on the runtime type of the object.</p>
<pre class="jsccJAVA">
private void handle(FileNotFoundException fnfe){
}
private void handle(IOException e){
}
</pre>
<p>Now, as suggested by the spec, each catch clause can be treated as an overloaded method which takes a subclass of Throwable as a method parameter and no return type. Now extending the method overloading analogy shouldn't java be able to detect which catch clause to invoke? Unfortunately, the complete paragraph from section 9.4 reads:</p>
<q>A catch clause is like a method definition with exactly one parameter and no return type. When an exception occurs, the runtime system searches the nested try/catch clauses. <b>The first one with a parameter type that is the same class or a superclass of the thrown object has its catch clause executed.</b> After the catch clause executes, execution resumes after the try/catch statement. It is not possible for an exception handler to resume execution at the point that the exception occurred.</q>
<p>The question now is, instead of continuing the method definition analogy and supporting overloading semantics to the catch clauses, why does the spec say the first catch clause will be chosen?</p>
<p>One possible reason could be for ease of compiler development. This seems to be an unlikely motivation.</p>
<p>Other possible reason could be for code clarity. What if the java developers start to expect that all the exception handlers that match are invoked? The problem exists with or without auto-sorting of catch clauses. A switch like construct would have been more appropriate then:</p>
<pre class="jsccJAVA">
try{
//Some File I/O operations here
}catch(Throwable t){
switchOnClass(t){ //using a hypothetical keyword switchOnClass
case FileNotFoundException:
//handle file not found error
break;
case FileNotFoundException:
case MyNewException:
//some processing for both FileNotFoundException and MyNewException
break;
}
}
</pre>
<p>Or the other possible reason is because Java's exception handling was based on C++'s (as mentioned in the foot notes of the Oak spec page 26). C++ allows multiple inheritance. So my class <code>MusicStreamingException</code> could extend both <code>MusicPlayerException</code> and <code>IOException</code>. Now assume the compiler see's this piece of code:</p>
<pre class="jsccJAVA">
try{
if(someCheckHere())
throw new MusicStreamingException();
}catch(IOException e){
}catch(MusicPlayerException e){
}
</pre>
<p>Both the catch clauses match equally and the compiler has no way of determining which one to invoke. Hence the best policy would be to choose the first catch clause. However, this would never happen in Java as it does not allow multiple inheritance, else the same problem would exist in overloaded methods. Is it possible that this requirement in the spec is only a legacy from C++? And can it be done away with without impacting the existing code?</p><img src="http://feeds.feedburner.com/~r/cafefeed/~4/124771971" height="1" width="1"/> |
Source:
Feedburner Thu, 14 Jun 2007 06:03:36 -0500 |
| Backward compatibility of specified, under-specified and un-specified features/API |
| <p>Backward compatibility is a challenge for everyone from the guy writing the kernel to guy building the application. </p>
<p><a href="http://blogs.msdn.com/oldnewthing/">Raymond Chen</a> has written a lot of anecdotes on compatibility issues in windows. (See <a href="http://www.microsoft.com/technet/technetmag/issues/2006/10/WindowsConfidential/">Compatibility Constraints</a> and <a href=http://www.microsoft.com/technet/technetmag/issues/2006/11/WindowsConfidential/>Handling Compatibility Hacks</a>.) He has also authored a book with the same title as that of his blog: <a href="http://blogs.msdn.com/oldnewthing/archive/2006/12/25/1361289.aspx">The old new thing</a>, which I am sure will have even more interesting tidbits.</p>
<p>Even application developers have to worry about the API they expose and its backward compatibility. The fine people at <a href="http://viewvc.tigris.org/">viewvc</a> believed the URL scheme used by viewvc is part of their "API" and had a <a href="http://viewvc.tigris.org/servlets/ReadMsg?list=dev&msgNo=2522">thorough discussion</a> on what changes could be made to the URL scheme before and after the 1.0 release! </p>
<p>Being in the middle tier, we seem to face more than our fair share of compatibility issues. First, the product is based on the specifications which are written in English. Each vendor is free to interpret it the way they want. Eventually this leads to customer queries like: "But this works in [plug the customer's current vendor name here]!" This results in new flags in the product configuration files. Over the years we have brought up such ambiguities in the expert groups and the newer versions of the specs clarify the interpretation.</p>
<p>The other category of issues arise from ensuring compatibility with the innumerable combinations of databases, drivers, operating systems and JVMs. JV talks about <a href="http://jroller.com/trackback/jvenu/Weblog/socket_not_connected">an issue we recently faced</a> wherein upgrading the VM from 1.4.2_10 to 1.4.2_11 breaks our product. JDK 1.4 introduced a new feature of disconnected sockets. The new implementation was supposed to be backward compatible. However, the implementation had a bug (<a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=2126509">2126509 </a>). In the process of fixing this bug in 1.4.2_11, (I believe) they introduced a new bug which breaks backward compatibility.</p>
<p>Such explicit problems are easier to manage than the unwritten contracts. While debugging I rely heavily on the exceptions raised. For example when you cast an object to a type, if there is a ClassCastException, the message generally has the class name of the object. So, in your code, if you are casting to java.util.List and the exception message is java.util.String, you know you are casting a String to a List. Also if you are casting to foo.bar.Klass and the message name is also foo.bar.Klass, then it is a class loading issue. The object you have loaded is of the same class but loaded from a different classloader. Looking at the exception message I could figure out whether it was a genuinely wrong cast or a ClassLoader issue. Unfortunately in JDK 1.4 ClassCastExceptions do not have a message. For a developer this is an annoyance, but is it worth logging a bug?</p>
<p>Here is a sample output with different jdks:
<pre class="cmd">
D:\code\41>java -cp PS30\tp\classes ClassCastTest
1.5.0_06
java.lang.ClassCastException: java.lang.String
at ClassCastTest.main(ClassCastTest.java:25)
D:\code\41>java -cp PS30\tp\classes ClassCastTest
1.4.2_10
java.lang.ClassCastException
at ClassCastTest.main(ClassCastTest.java:25)
D:\code\41>java -cp PS30\tp\classes ClassCastTest
1.3.1_16
java.lang.ClassCastException: java.lang.String
at ClassCastTest.main(ClassCastTest.java:25)
</pre>
Would you write unit tests for the output messages?</p><img src="http://feeds.feedburner.com/~r/cafefeed/~4/75773081"/> |
Source:
Feedburner Mon, 15 Jan 2007 20:34:02 -0600 |
| Enum and other Java 5 tricks ... |
| Deepak has finally started blogging at <a href="http://deepjava.wordpress.com/">Deep into Java</a>. He has been sharing some neat tricks like <a href="http://deepjava.wordpress.com/2006/12/08/bootstrapping-static-fields-within-enums/trackback/">Bootstrapping static fields within enums</a>.
Thanks for the tips buddy ... look forward to more of them.<img src="http://feeds.feedburner.com/~r/cafefeed/~4/74368929"/> |
Source:
Feedburner Fri, 12 Jan 2007 03:43:26 -0600 |
| Got Phished :( |
| <p>I booted my laptop early this morning to get my daily
dose of Google alerts. Navigating through the alerts I ended up at: <a href="http://momb.socio-kybernetics.net/">The Museum of
Modern Betas</a> and browsing through its entries I chanced upon
Google's firefox
extension for detecting phishing:
<a href="http://momb.socio-kybernetics.net/beta/google-safe-browsing-for-firefox">Safe
Browsing</a>. While I was going through their site,
I noticed the yahoo
notification window show "Deeps is now online" and I was thinking to
myself "What is this guy doing online so early in the morn?" (And may I
ask what are YOU doing online?!) Installing Google SafeBrowsing seems
to be fraught with its own problems. The SafeBrowsing home page says
that it can be installed as part of google toolbar only. Antitrust I
say! Some sites say the download is available only in US. Further
googling revealed the URL: <a href="http://dl.google.com/firefox/google-safebrowsing.xpi">http://dl.google.com/firefox/google-safebrowsing.xpi</a></p>
<p>While I
was installing the plugin (firefox waits for a couple of seconds before
enabling the install button ... i wonder why?!), I see a message from
deeps:
</p>
<q>Deeps: http://www.geocities.com/junebug585 <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/1.gif" alt=":)"></q>
<p>...and he logs out. I promptly clicked on the link which
showed
the page:</p>
<a href="http://www.me.umn.edu/%7Eshivane/blogs/cafefeed/resources/14-sept-2006/phishing-orig.png">
<img src="http://www.me.umn.edu/%7Eshivane/blogs/cafefeed/resources/14-sept-2006/phishing-small.png" alt="Click to enlarge"></a>
<p>"Hmmm ... password" I say. I ping deeps ..."Dood ... it's
asking for password". No response. Being a stickler for online security
(ask my wife on how i nag her into setting a different password for
each site and make sure she does not note down her passwords anywhere!)
I
think to myself... "Hey! This could be a phishing site!" (what with me
looking
at Google SafeBrowsing site just a few mins ago). "Very well", I tell
myself, "... the
url is Yahoo! Geocities, the logos and the layout looks ok ... Why
would deep try to phish my yahoo account details ... what the
hell .. let's try to login". Key in the user id pass nothing happens.
Back to Yahoo home page.
"D'oh! Have I been phished?!" with this nagging doubt go have a shower
... come back... notice deeps has replied to my message:</p>
<q>Deeps: what login?
<br>
Deeps: did u a get any message from me?
<br>
Deeps: i did not send it..
</q>
<p>"Oh God! I have been phished!! Change the password quickly."
Chirpy wifey: "Breakfast time!" "Oh God! Imagine after all my
taunts ... I've been phished ... how am I going to tell her this?! Have
I really been phished?!" So I decide to go back to the site and verify.
<a href="http://livehttpheaders.mozdev.org/">LiveHTTPHeaders</a>
shows:</p>
<pre>http://www2.fiberbit.net/form/mailto.cgi<br>POST /form/mailto.cgi HTTP/1.1<br>Host: www2.fiberbit.net<br>User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6<br>Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5<br>Accept-Language: en-us,en;q=0.5<br>Accept-Encoding: gzip,deflate<br>Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7<br>Keep-Alive: 300<br>Connection: keep-alive<br>Referer: http://www.geocities.com/junebug585/?200614<br>Content-Type: application/x-www-form-urlencoded<br>Content-Length: 138<br><b>Mail_From=GOD&Mail_To=jawsy1%40gmail.com&Mail_Subject=Gift&Next_Page=http%3A%2F%2Fwww.yahoo.com<br>&.pd=fpctx_ver%253d0&<span style="color: rgb(255, 0, 0);">login=asdf&passwd=asdf</span></b><br><br>HTTP/1.x 302 Moved Temporarily<br>Date: Thu, 14 Sep 2006 04:01:30 GMT<br>Server: Apache/1.3.26 (Unix) mod_perl/1.26<br>Location: http://www.yahoo.com<br>Content-Type: text/html; charset=iso-8859-1<br>X-Cache: MISS from downloads.pramati.com<br>X-Cache-Lookup: MISS from downloads.pramati.com:3128<br>Connection: close<br></pre>
<p>"Oh no! I really have been phished! <b>Bugger has
mailed my yahoo password to himself!!</b> Change the password ...
change the password ... change the password!". Wifey, annoyed after
waiting for me at the b'fast table:
"Wot'chu doin buster?!" ... where do I hide my face now?!</p>
<p>The phisher is not Deeps... some one phished his id and sent
me the message. Maybe it is not even junebug585 whose geocities site
was used to phish for my account details ... maybe that id was also
phished and misused. Maybe it is not even jawsy1@gmail.com where my
userid/pass have been mailed ... maybe that id/pass also have been
phished?! I wonder who all will receive a message from my id now and be
phished!</p>
<p>Imagine the coincidence, I am finicky abt internet security, I
was just checking out Google's SafeBrowsing and I got phished! "I took
a
chance typing my yahoo id, surely I wouldn't have taken a chance
if the site asked for my bank account-nos/user-ids" I rationalize.
But still ... what if the phisher downloaded all my password reminder
mails from my yahoo mailbox??!!</p>
<p>All the best dad!</p>
<p> ... now the painful part of reporting abuse to yahoo and gmail
... </p>
<hr>
<p><b>Update:</b> Looks like I am not the first! ... and looks like google pages are also being used for phishing. <a href="http://www.google.com/search?q=yahoo+geocities+phishing">Google: yahoo geocities phishing</a></p>
<hr>
<p><b>Update 1:</b> Yahoo!'s soln for phishing?! (via deeps):
<br>
<br>---------- Forwarded message ----------
<br>From: Kalyan K Kumar
<br>Date: Sep 14, 2006 11:04 AM
<br>Subject: phishing
<br>To: sammelan
<br>
<br>keep an eye on those yahoo login look alike geocities links. don't enter
<br>yahoo password anywhere
<br>other than login.yahoo.com
<br>you can setup a sign in seal to protect partly.
<br>
<br><a href="http://protect.login.yahoo.com/">http://protect.login.yahoo.com/</a>
</p><img src="http://feeds.feedburner.com/~r/cafefeed/~4/22127606"/> |
Source:
Feedburner Thu, 14 Sep 2006 02:18:16 -0500 |
| Why is finalize method protected? |
| <p>Rakesh sent me a mail the other day asking why the <code>finalize</code> method is <code>protected</code>.
Well, here's what I think:</p>
<p>The <code>finalize</code> method is invoked by the JVM/GarbageCollector on Objects which
are no longer referenced. So, if I were the guy who designed the <code>finalize</code> method, ideally I
would want it to be <code>private</code>. Just like why the writeObject method of the Serializable interface is
private. These methods are not meant to be called by other user objects,
these methods are invoked only by the JVM runtime classes only. So it would make
sense to make them private, and have special handling in the VM to invoke these
methods. This is ok in case of the writeObject method, however, making <code>finalize</code> method <code>private</code>
would have other implications. </p>
<p>Assume we had decided to go ahead and allow the <code>finalize</code> method to be private. Consider the following classes</p>
<pre class="jsccJAVA">public class SuperClass
{
private HeavyResource resource = new HeavyResource();
private void finalize()
throws Throwable
{
resource.shutdown();
}
}
public class SubClass
extends SuperClass
{
private AnotherResource another = new AnotherResource();
public SubClass(){
super(); //Added for clarity
}
private void finalize()
throws Throwable
{
another.shutdown();
}
}
</pre>
<p>Since SubClass extends the SuperClass, when we create an instance of SubClass,
we would also have created an instance of HeavyResource and an instance of
AnotherResource. However, when this instance of SubClass is being finalized, we
shutdown only the instance of AnotherResource. The shutdown method of
HeavyResource would not be called. </p>
<p>The recommended practice for <code>finalize</code> methods is that in the <code>finally</code> block of
the <code>finalize</code> method one should call the <code>finalize</code> method of the super class.
(That's right, in the constructor the first statement has to be the call to
super so for destructor/finalize the sequence should be reversed and super
should be called last). So
our SubClass would look something like: </p>
<pre class="jsccJAVA">public class SubClass
extends SuperClass
{
private AnotherResource another = new AnotherResource();
public SubClass(){
super(); //Added for clarity
}
private void finalize()
throws Throwable
{
try{
another.shutdown();
}finally{
super.finalize();//Compilation error here
}
}
}</pre>
<p>This would have worked, but unfortunately this won't even compile. You can
not call the private method of the super class. There are couple of ways I can
think of to solve this problem.</p>
<p>One solution of-course would be to relax our requirements and make the access modifier
of the <code>finalize</code> method protected and hope people are sensible enough not to call
it! </p>
<p>Another solution could be to allow calls to <code>super.finalize()</code>, even if the <code>finalize</code> method of
the super class has private access modifier, in the Java Language Specification
(JLS). </p>
<p>My preferred solution would be to have compilers automatically
add a try finally block and insert a call to <code>super.finalize()</code> method in the finally
block. (Modifying byte code to add a try finally block is a nightmare (as compared to adding a call to <code>super()</code>), but that's a separate discussion!)
This would be similar and consistent with the way compilers add the call to <code>super()</code> as the
first statement of a constructor if it does not already exist. (You can use
<code>javap -c ClassName</code> to look at the byte code generated by the compiler, but I
prefer to use <a href="http://http://www.ej-technologies.com/products/jclasslib/overview.html">JClasslib</a>.)</p>
<p>The <a href="http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.6">Java
language specification, (3rd ed, Section 12.6)</a> does mention that the call to <code>super.finalize</code> is not
injected automatically and provides a hint as to why:</p>
<blockquote><p>
The fact that class <code>Object</code> declares a <code>finalize</code>
method means that the <code>finalize</code> method for any class can always invoke the <code>finalize</code>
method for its superclass. This should always be done, unless it is the
programmer's intent to nullify the actions of the finalizer in the
superclass. (Unlike constructors, finalizers do not automatically
invoke the finalizer for the superclass; such an invocation must be
coded explicitly.)</p>
</blockquote>
<p>It appears this was done ``So that the programmer can nullify the actions of the finalizer in the
superclass.'' But thanks to this choice, developers today use
tools like <a href="http://pmd.sourceforge.net/rules/finalizers.html">PMD</a> which warn them about empty <code>finalize</code> methods and when the <code>finalize</code> does not call the same method of the super class.</p>
<p><b>Update (16 Jan 2007):</b> It appears that the designers of C# learnt from Java's mistakes and decided to make constructor and destructor symmetric. In C#, the destructor of the super-class is called whether the destructor of the sub-class was successfuly completed or not. From "Section 16.3: How exceptions are handled" of the <a href="http://download.microsoft.com/download/5/e/5/5e58be0a-b02b-41ac-a4a3-7a22286214ff/csharp%20language%20specification%20v1.2.doc">C# language specification 1.2</a>:</p>
<blockquote><p>
Exceptions that occur during destructor execution are worth special mention. If an exception occurs during destructor execution, and that exception is not caught, then the execution of that destructor is terminated and the destructor of the base class (if any) is called. If there is no base class (as in the case of the object type) or if there is no base class destructor, then the exception is discarded.</p></blockquote><img src="http://feeds.feedburner.com/~r/cafefeed/~4/76594560"/> |
Source:
Feedburner Sat, 17 Mar 2007 01:55:57 -0500 |
| Colorizing Java sources in a browser using JavaScript and CSS |
| <h3>[or JavaScript chorma-coding]</h3>
<p>While posting Java sources on this blog, I used to wish that the browsers could
take care of chroma-coding Java sources just the way they take care of chroma-coding
XML files. It would eliminate the hassle of exporting the sources in HTML
format. All one would have to do is paste the Java source in a <code>pre</code> block and
viola! you are done with it!</p>
<img src="http://www.me.umn.edu/~shivane/blogs/cafefeed/resources/26-oct-2004/pramati-j2ee-server.png" title="Screenshot of an XML file opened in IE. IE chroma-codes the XML file and creates a live tree structure of the XML using +/- toggle buttons"/>
<p>Inspired by the "live" pages on <a href="http://www.blogger.com">Blogger</a>, <a href="http://www.feedburner.com">Feed Burner</a> and <a href="http://gmail.google.com">GMail</a>, I decided to
experiment and see if JavaScript and CSS could be used to achieve this. After
couple of hours of struggling and about 200 lines of re-factored code, I managed to
get it to work! </p>
<p>Below is the HTML colorized version of <code>ClassParser.java</code> from
the BCEL sources. Check out the curly braces ... they are live! Clicking
on them will show or hide the enclosed block! Now for the surprise ... if you
look at the HTML source for the above part, you will see only plain java source.
All the colorization and parenthesis matching has been done in <code>jscc.js</code>, <code>jsccJAVA.js</code> and <code>jscc.css</code>
referred to in the head of the HTML file. Pretty neat huh?! </p>
<pre class="jsccJAVA">
package org.apache.bcel.classfile;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>;.
*/
import org.apache.bcel.Constants;
import java.io.*;
import java.util.zip.*;
/***
* Wrapper class that parses a given Java .class file. The method
* <A href ="#parse">parse</A> returns a <A href ="JavaClass.html">
* JavaClass</A> object on success. When an I/O error or an
* inconsistency occurs an appropiate exception is propagated back to
* the caller.
*
* The structure and the names comply, except for a few conveniences,
* exactly with the <A href="ftp://java.sun.com/docs/specs/vmspec.ps">
* JVM specification 1.0</a>. See this paper for
* further details about the structure of a bytecode file.
*
* @version $Id: ClassParser.java,v 1.5 2002/08/09 13:09:31 mdahm Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public final class ClassParser {
private DataInputStream file;
private ZipFile zip;
private String file_name;
private int class_name_index, superclass_name_index;
private int major, minor; // Compiler version
private int access_flags; // Access rights of parsed class
private int[] interfaces; // Names of implemented interfaces
private ConstantPool constant_pool; // collection of constants
private Field[] fields; // class fields, i.e., its variables
private Method[] methods; // methods defined in the class
private Attribute[] attributes; // attributes defined in the class
private boolean is_zip; // Loaded from zip file
private static final int BUFSIZE = 8192;
/***
* Parse class from the given stream.
*
* @param file Input stream
* @param file_name File name
*/
public ClassParser(InputStream file, String file_name) {
this.file_name = file_name;
String clazz = file.getClass().getName(); // Not a very clean solution ...
is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar.");
if(file instanceof DataInputStream) // Is already a data stream
this.file = (DataInputStream)file;
else
this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE));
}
/*** Parse class from given .class file.
*
* @param file_name file name
* @throws IOExcepti | | |
|
| | |