• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Netscape pickiness about string initialization

 
Don Arnett
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In investigating why an applet that I wrote works on some PCs and not others for my client (all running Win95, Netscape 4.75), I wrote the following simple applet:
import java.applet.*;
import java.awt.*;
public class ibLoginApplet40 extends Applet
{
TextField gtxtUserId;
public void init() {
gtxtUserId = new TextField("",10);
add(gtxtUserId);
}
}
This applet works on some PCs and not others, all of which are running Win95 and using Netscape Communicator 4.75. If I change the TextField constructor to TextField(" ",10), then it works on all of the PCs. On the PCs where if fails, the Java Console messages include:
java.lang.NullPointerException
at java.lang.StringBuffer.append(Compiled Code)
* at netscape.applet.DerivedAppletFrame$LoadAppletEvent.dispatch(Compiled Code)
at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled Code)
at java.awt.EventDispatchThread.run(Compiled Code)
at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled
Code)
# Applet ibLoginApplet20 can't init: NEW

My question, most likely for a Netscape guru, is 'what inside Netscape (or the PC) is most likely different that is causing the code to run differently on two similiar PCs?'
The Java Console for both reports 'Java 1.1.5'.
I'd like to know so that I can configure a PC here so I can duplicate the problem. The client is two states away and I can't find a PC here that this code will fail on.
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don,
I looked through the bug reports for +TextField +NullPointerException.
There were a number of issues about Java's handling of the constructor TextField( String text, int columns).
For example:

Bug Id
4122190
Votes
0
Synopsis
AWT TextField spec doesn't define behavior of a ctor for null input parameter
Category
java:doc
Reported Against
1.2beta3
Release Fixed
1.2fcs
State
Closed, fixed
Related Bugs

Submit Date
Mar 23, 1998
Description
The TextField(String text, int columns) constructor does not throw a
NullPointerException if null is provided for the text input parameter.
The TextField spec does not define the expected behavior of this
constructor in this situation.

Test
Workaround
None.
Evaluation
Proposed new doc comment being reviewed.
xxxxx@xxxxx 1998-08-03

Is it maybe possible that the NullPointerException is being thrown because the initial text argument is the empty String?
I was just wondering if avoiding the issue by using the constructor
TextField(int columns)
might solve your problem.

Just a suggestion.
Stephanie
 
Don Arnett
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. My original code used TextField(10). The only way that I can get it to work on some PCs is to add a non-empty string.
I suspect that the offending machines are using an older Java plugin. I'm waiting for responses from the users to verify this.
A question:
Where did you look up the bug reports?
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don,
You can go here: http://search.java.sun.com/
and select Bug Reports for the Area(s).
This site has been pretty useful for me.
Hope this helps.
Stephanie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic