| Differences between C++ and Java |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Component inside JList not painting; now resolvedI have set up a JList to work with its own ListModel and
ListCellRenderer. The symptom, my component does not
display any text. That is the list box is
completely blank. From the debugging, I saw it displayed the desired
text. And, we saw that the list box scrolled when there was more data
than can be displayed.
The problem turned out to be that I defined paint() rather than
paintComponent(). What was strange was that I was able to use other
classes extending Component that I wrote and return them
from the ListCellRenderer. These had the same mistake
of putting the display logic in paint() rather than paintComponent();
Yet those Components worked fine and this error in the class notes from
which
I taught our GUI course since 2001.
One of my students , Mr. Kevin Kraus,
elucidated the solution to this problem -- Thanks!
This was also discussed in this group in
relation to a post from John Creighton on September 2 2001.
Since, this is an easy error to make, it is worthwhile having the
reminder, here.
I did not see anything saying this in the FAQ but section 3.4
told our users not to use Component.getGraphics(). They were told
to override "paint()(AWT)" or "paintComponent()(Swing)"
I am sending a suggestion to Mr. Weidenfeller
of new wording to help people trouble shooting their
programs.
Here is my component definition:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class NumberComponent extends JComponent {
String FontName;
String ToDisplay;
int Size;
boolean Selected;
Font f;
void setSelected (boolean S){
Selected=S;
}
NumberComponent (String S) {
ToDisplay = S;
Size = 12;
FontName="Arial";
}
NumberComponent (String S, String F, int size) {
Size=size; FontName = F; ToDisplay = S;
}
public void paint (Graphics g) {
System.out.println ("font Name " + FontName + " Size " + Size);
if (!Selected) {
f = new Font (FontName,Font.PLAIN,Size);
}
else {
f = new Font (FontName,Font.BOLD,Size);
}
//g.setFont(f);
g.setColor(Color.black);
//g.fillRect(10,10,30,20);
g.drawString (ToDisplay,0,0);
System.out.println (" here " + ToDisplay + " hc " + hashCode());
}
public Dimension getMinimumSize() {
if (!Selected) {
f = new Font (FontName,Font.PLAIN,Size);
}
else {
f = new Font (FontName,Font.BOLD,Size);
}
int Width = getFontMetrics(f).stringWidth(ToDisplay);
int Height = getFontMetrics(f).getHeight();
System.out.println (" Width " + Width + "Height " + Height);
Dimension D = new Dimension (Width,Height);
return D;
}
public Dimension getPreferredSize() {
return getMinimumSize();
}
public Dimension getMaximumSize() {
return getMinimumSize();
}
}
Here is the output from the list box that is using it to display:
@toolman#/home/leffstudent/412/final1 >java LMX Numbers.xml
Number Text 33333333Font is Size NC 7754385
Width 64Height 15
Number Text 433333334Font is Size NC 3541984
Width 72Height 15
Number Text 233333332Font is Size NC 4565111
Width 72Height 15
Number Text 33333333Font is Size NC 16164678
font Name Arial Size 12
here 33333333 hc 16164678
Number Text 433333334Font is Size NC 16795905
font Name Arial Size 12
here 433333334 hc 16795905
Number Text 233333332Font is Size NC 28904249
font Name Arial Size 12
here 233333332 hc 28904249
@toolman#/home/leffstudent/412/final1 >exit
exit
Here is the ListCellRenderer I defined:
import javax.swing.*;
import java.awt.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
class NR implements ListCellRenderer {
public Component getListCellRendererComponent (
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
{
Element N = (Element)value;
NodeList NL = N.getChildNodes();
Node TextNode = NL.item(0);
String NumberText = TextNode.getNodeValue();
String Font = N.getAttribute("Font");
String SizeText = N.getAttribute("Size");
System.out.print ("Number Text " + NumberText + "Font is " + Font + "
Size " + SizeText);
NumberComponent NC;
if (Font != null && Font.length() != 0 && SizeText!=null &&
SizeText.length()!= 0) {
int Size = Integer.parseInt(SizeText);
NC = new NumberComponent(NumberText,Font,Size);
}
else {
NC = new NumberComponent(NumberText);
}
NC.setSelected(isSelected);
System.out.println ("NC " + NC.hashCode());
return NC;
}
}
- 5
- JSP <jsp:useBean ... /> tag: Difference between 'class' and 'type'Hello,
I'm trying to gain a better understanding of the included tag libraries
with JSP. The <jsp:useBean tag seems farily straightforward, in that it
sets a page variable from an object in any scope, with a variety of options.
I see examples listed that interchange the 'class' and 'type' attribute,
but to me it's not real clear as to their distinction. Can anyone
explain their difference?
One thing I have noticed is that if I don't yet have a variable declared
in the given scope, using the 'type' attribute causes an exception to be
thrown, whereas the 'class' attribute does not. It seems that when I
specify "class", it actually creates a new instance of the specified
variable / bean.
Thanks!!
-Sean
- 5
- Print via Command LineHello NG.
I'm trying to write a tool which is able to print a PostScript documents via
the command line. The call I'm making is the following:
String s = "copy /b " + filename + " lpt1:";
rt.exec(s);
This is commented by the interpreter as follows:
java.io.IOException: CreateProcess: copy /b
J:\Tmp\KyoceraMita\PostScript\Philipp.prn.tmp lpt1: error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:66)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at PrintPostScript.print(PrintPostScript.java:82)
at PrintPostScript.main(PrintPostScript.java:38)
Error = 2 means, that the file or something else is missing. The problem is:
The same command typed into my command line (I'm using W2k3) produces the
desired result. What am I doing wrong? Thanks in advance,
Philipp Ciechanowicz
- 7
- java e-booksPlease suggest a good e-book for a java beginner. Thanks.
- 8
- Java 5.0 Flood!Since J2SE 5.0 has just come out, I'd thought I'd post a some links and
highlights as written by the media around the internet.
---
** Sun ships Java upgrade, focuses on ease of use **
The next release is due out by early 2006
Highlights:
- "J2SE 5.0 is an important step for Java in its ongoing battle against
Microsoft Corp.'s .Net development environment", said Stephen O'Grady, an
analyst at RedMonk Inc. in Bath, Maine. "The streamlined start-up times and
a friendlier graphical user interface should be especially welcome additions
to Java users", he said.
"Particularly for Java applications on the client, it has taken a while for
them to start up," O'Grady said. "That has been a problem. Also, from a
user's perspective, [Sun] has updated the look and feel. It looks good. It's
cleaner, and it's more modern."
http://www.computerworld.com/developmenttopics/development/java/story/0,1080
1,96346,00.html?nas=APP-96346
---
** Sun Releases New Version of Java for Servers, Desktops **
Highlights:
- In addition, Austin said J2SE 5.0 will spark the creation of new tools for
developers, particularly new profiling and analysis tools. "We have a cool
technology called byte code insertion, so now you can profile in real-time."
J2SE 5.0 also enables developers to "pre-template" code, "so other analyzing
tools can read the metadata," he said.
http://www.eweek.com/article2/0,1759,1664580,00.asp
---
** A New Direction for Java **
Highlights:
- The result: "Java's beginning to wend its way into some pretty interesting
places," such as automobiles, said Schwartz. "I asked an automobile
manufacturer, 'What's the price at which, if you could sell online services
to the automobile, you could give away the automobile for free?' Without
batting an eye, that auto company's CFO said, '$220,'" Schwartz told his
JavaOne audience. "Now think about that. "Do you know a 17-year old who
would pay $5 to download a custom horn tone to his car? I do," he said.
- "It's not Sun thinking about putting services into an automobile, it's
Siemens and BMW," Schwartz said, returning to center stage after a
presentation in which a new BMW rolled out with an advanced Java-based
navigation and entertainment system.
http://www.eweek.com/article2/0,1759,1624150,00.asp
---
** Screenshots of J2SE 5.0 Look&Feels **
Windows XP File Chooser Dialog (from j5.0 beta)
http://java.sun.com/developer/technicalArticles/releases/j2se15/15art2.jpg
Redhat Linux File Open Dialog (from j5.0 beta)
http://java.sun.com/developer/technicalArticles/releases/j2se15/15art1.jpg
The new Ocean Theme
http://www.dubh.org/jdevimages/jdev_ocean_large.png
---
Comments on Synth
Synth is apparently a 'bare-bones' L&F designed specifically to allow
non-programmers to turn it into a custom L&F using simple XML. The article
"The Synth Look and Feel" in the next section gets more into the details.
An example XML file is also presented below. For an overview of the idea
behind Swing 5.0 see this article:
** Tiger on the Desktop **
http://weblogs.java.net/blog/chet/archive/2004/09/tiger_on_the_de_1.
** The Synth Look and Feel **
Highlights:
For the anxious, here's a quick example. The following XML code, taken from
example1.xml, defines a style named textfield and binds it to all text
fields in Synth. The result is that text fields look like the one in the
Motivation section.
<synth>
<style id="textfield">
<state>
<color value="white" type="BACKGROUND"/>
</state>
<imagePainter method="textFieldBorder" path="textfieldborder.png"
sourceInsets="5 6 6 7" paintCenter="false"/>
<insets top="5" left="6" bottom="6" right="7"/>
</style>
<bind style="textfield" type="region" key="TextField"/>
</synth>
Here's some code that loads the XML file into Synth and sets the current
look and feel to Synth:
SynthLookAndFeel laf = new SynthLookAndFeel();
laf.load(Example1.class.getResourceAsStream("example1.xml"),
Example1.class);
UIManager.setLookAndFeel(laf);
http://www.javadesktop.org/articles/synth/index.html )
---
l8r, Mike N. Christoff
- 11
- Packaging/version controlI'm developing a Swing program which I periodically update (change or
add classes or data files), weekly, to currently 2 people. The number of
people will eventually grow but the update frequency should decrease.
Currently, I'm putting the sources, classes, data files and a readme
file into a zip and sending it. The readme tells the users to either
compile or copy the classes over. There are ~25 .java files, ~75 .class
files and ~20 data files. This is time consuming, inconsistent and error
prone. I'm not using package statement or jars (currently). What are
people using and / or what would you recommend. - Thanks - Lou
- 12
- IBM Java 6 pre-release on LinuxFor those who are interested to try the new IBM Linux JDK 6 (pre-release),
here's a direct link:
https://www14.software.ibm.com/iwm/web/cc/earlyprograms/ibm/java6/
Haven't tried it on FreeBSD myself.
Cheers,
Ernst
- 12
- cglib/asm NoClassDefFoundErrorI'm having trouble running the cglib sample KeySample
http://cglib.sourceforge.net/xref/samples/KeySample.html. It compiles
fine, but when I try to run it, I get:
Exception in thread "main" java.lang.NoClassDefFoundError: org/
objectweb/asm/Type
at net.sf.cglib.core.TypeUtils.parseType(TypeUtils.java:180)
at net.sf.cglib.core.KeyFactory.<clinit>(KeyFactory.java:66)
at Test.main(Test.java:8)
To ensure asm.jar is definitely in the classpath, I'm running it as:
java -classpath .;$JAVA_HOME/lib;$CGLIB_LIB/cglib-2.1_3.jar;$CGLIB_LIB/
asm.jar;$CGLIB_LIB/aspectwerkz-core-0.10.RC1.jar;$CGLIB_LIB/ant.jar;
$CGLIB_LIB/asm-attrs.jar;$CGLIB_LIB/asm-util.jar;$CGLIB_LIB/jarjar.jar;
$CGLIB_LIB/junit.jar KeySample
The call in net.sf.cglib.core.KeyFactory which is triggering this is:
private static final Type KEY_FACTORY =
TypeUtils.parseType("net.sf.cglib.core.KeyFactory");
The call at net.sf.cglib.core.TypeUtils.parseType is:
public static Type parseType(String s) {
return Type.getType(map(s));
}
map is a private method which effectively transforms the input into
"L"+s.replace('.', '/'))+";" (i.e. "Lnet/sf/cglib/core/KeyFactory;").
I've traced through this with Eclipse, so I'm absolutely certain that
this is what's being passed to Type.getType. Based on the exception
and my trace, I don't think it's getting as far as calling
Type.getType, though.
If I add the lines:
org.objectweb.asm.Type t = Type.getType("Lnet/sf/cglib/core/
KeyFactory;");
System.out.println(t.getClassName());
to the sample code, those lines execute properly (i.e. it prints
"net.sf.cglib.core.KeyFactory"), but then it throws the exception
above.
The fun part is that I get the same result if I re-compile the
original sample code and run with the no-dependency version of cglib:
java -classpath .:$JAVA_HOME/lib:$CGLIB_LIB/cglib-nodep-2.1_3.jar
KeySample
I suspect that there's something truly screwed up with my environment,
but I haven't seen any other overt misbehavior like this. Any ideas?
- 14
- SWT&JFaceHi,
is there any method to add WizardDialog to windows taskbar?
In general, dialogs don't appear on taskbar, but maybe anyone knows
some trick.
yarecki
- 14
- native method performance puzzleJust to be clear, I'm afraid that I can't do more than sketch my problem out
here, since it's customer-specific, but I'm hoping for some direction.
I'm testing two implementations of a data-processing API, one in pure Java,
one in native methods (windows dll). The process I am testing is disk I/O
intensive.
Running the same performance test over and over again I've found that the
pure Java implementation gives very consistent results, while the native
method version gives results that steadily get better over about a dozen
runs, finally ending up about the same at the pure Java implementation
(probably ultimately limited by disk thruput).
For example, test 1 might look like:
pure Java method : 12 sec
native method: 20 sec
test 5 like:
pure Java method: 11 sec
native method: 15 sec
test 10 like:
pure Java method: 12 sec
native method: 10 sec
What could be going on here? It sure feels like something is being cached,
but I'm not sure what.
Thanks,
--arne
- 14
- [OT] eruditionOn 2008-02-12 03:12 +0100, Lew allegedly wrote:
> Daniele Futtorovic wrote:
>> confer:
>> "About Documents"
>> <http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#document>
>
> etc.
>
> That usage of "confer" is marvelous, simply delightful. I was just
> looking up that usage of the word the other day, coincidentally, in the
> context of the abbreviation "cf.". Sheer poetry to see it spelled out.
> Thank you.
>
You're most welcome.
- 16
- What is a type error?Marshall <email***@***.com> wrote:
+---------------
| Joachim Durchholz wrote:
| > Actually SQL has references - they are called "primary keys", but they
| > are references nevertheless.
|
| I strongly object; this is quite incorrect. I grant you that from the
| 50,000 foot level they appear identical, but they are not.
+---------------
Agreed. The only thing different about "primary" keys from any other
key is uniqueness -- a selection by primary key will return only one
record. Other than that constraint, many databases treat them exactly
the same as non-primary keys [e.g., can form indexes on them, etc.].
+---------------
| To qualify as a reference, there need to be reference and dereference
| operations on the reference datatype; there is no such operation is SQL.
+---------------
Not in "ANSI SQL92", say, but there might be in most SQL databases!
[See below re OIDs. Also, SQL:1999 had a "REF" type that was essentially
and OID.]
+---------------
| Would you say the relational algebra has references?
+---------------
Don't confuse "SQL" & "relational algebra"!! You'll get real
relational algebraists *way* bent out of shape if you do that!
+---------------
| > (Some SQL dialects also offer synthetic "ID" fields that are
| > guaranteed to remain stable over the lifetime of a record.
|
| Primary keys are updatable; there is nothing special about them.
+---------------
I think he's probably talking about "OIDs" (object IDs). Most
current SQL-based databases provide them, usually as a normally-
invisible "system column" that doesn't show up when you say
"SELECT * FROM", but that *does* appear if you say "SELECT oid, *",
and may be used as a "primary" key even on tables with no actual
primary key:
rpw3=# select * from toy limit 4;
c1 | c2 | c3 | upd
--------+-------+--------------------------------+-----
fall | tape | My Favorite Thanksgiving | 16
xmas | book | My Favorite Christmas | 2
xmas | video | The Grinch who Stole Christmas | 4
summer | book | Unusual 4ths of July | 17
(4 rows)
rpw3=# select oid, * from toy limit 4;
oid | c1 | c2 | c3 | upd
-------+--------+-------+--------------------------------+-----
19997 | fall | tape | My Favorite Thanksgiving | 16
19998 | xmas | book | My Favorite Christmas | 2
19999 | xmas | video | The Grinch who Stole Christmas | 4
20000 | summer | book | Unusual 4ths of July | 17
(4 rows)
rpw3=# select * from toy where oid = 19998;
c1 | c2 | c3 | upd
------+------+-----------------------+-----
xmas | book | My Favorite Christmas | 2
(1 row)
rpw3=# insert into toy values ('fall','book','Glory Road');
INSERT 32785 1
rpw3=# select oid, * from toy where oid = 32785;
oid | c1 | c2 | c3 | upd
-------+------+------+------------+-----
32785 | fall | book | Glory Road | 21
(1 row)
rpw3=#
See <http://www.postgresql.org/docs/8.1/static/datatype-oid.html>
for how PostgreSQL treats OIDs [including some critical limitations].
-Rob
-----
Rob Warnock <email***@***.com>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
- 16
- What's the proper way to use SocketChannel.finishConnect()?What's the proper way to use SocketChannel.finishConnect()?
I've read the documentation but couldn't comprehend what is written for it.
I've seen examples where it is placed:
1a) Right after SocketChannel.connect() (without while loop)
SocketChannel sc = SocketChannel.open();
sc.connect(...);
sc.finishConnect();
sc.configureBlocking(false);
sc.register(selector, SelectionKey.OP_READ);
1b) Right after SocketChannel.connect() (with while loop)
SocketChannel sc = SocketChannel.open();
sc.connect(...);
while (!sc.finishConnect()) {
}
sc.configureBlocking(false);
sc.register(selector, SelectionKey.OP_READ);
2a) When iterating the Selector.select() values (without while loop;
SocketChannel sc = SocketChannel.open();
sc.connect(...);
sc.configureBlocking(false);
sc.register(selector, SelectionKey.OP_CONNECT);
... {
if (sc.isConnectionPending()) {
sc.finishConnect();
}
sc.register(selector, SelectionKey.OP_READ);
}
...
2b) When iterating the Selector.select() values (with while loop)
SocketChannel sc = SocketChannel.open();
sc.connect(...);
sc.configureBlocking(false);
sc.register(selector, SelectionKey.OP_CONNECT);
... {
if (sc.isConnectionPending()) {
while (!sc.finishConnect()) {
}
}
sc.register(selector, SelectionKey.OP_READ);
}
...
- 16
- Printing Frames With JavascriptI apologize if this is the wrong group for this but I have looked for
an answer with no luck. I have the following frame setup on a site I
am working on:
http://img98.imageshack.us/img98/6238/frameprint1lr.jpg
I want to add a java print button in frame 3 that will then print
frames 3, 4, and 5 when clicked (preferably as laid out on screen in
landscape mode). Is something like this possible?
Thanks.
- 16
- [ANN] Luxor XUL Standard Widget Toolkit (SWT) Layout Pack Now LiveHi,
I've uploaded the Luxor *Standard* Widget Toolkit (SWT) Layout
package that shows you how to turn SWT layout managers such as
FillLayout, GridLayout and others into easy-to-use XUL tags that you
can use in addition to the built-in XUL box layout system.
This preview includes XUL tags for
* FillLayout
* RowLayout
* GridLayout
* SashForm
Here are some examples to see what's it all about:
FillLayout In Action
--------------------
The FillLayout is mapped to the <fillbox> tag and you can use it like
any other XUL box. Example:
<fillbox>
<label value="Instructions:" />
<label value="1. Fill in your name" />
<label value="2. Fill in your age" />
<label value="3. Fill in your gender" />
<label value="4. Check the box for employment" />
<label value="5. Click on OK" />
</fillbox>
GridLayout In Action
--------------------
The GridLayout is mapped to the <gridbag> tag and the GridData is
mapped to the <griddata> tag. Example:
<gridbag columns="3">
<button label="B1" />
<button label="Wide Button 2" />
<griddata rowspan="2" fill="MAX">
<button label="Button 3" />
</griddata>
<button label="B4" />
<button label="Button 5" />
</gridbag>
SashForm In Action
------------------
The SashForm is mapped to the <splitbox> tag. Example:
<splitbox id="splitbox3">
<button label="One" />
<button label="Two" />
<splitbox orient="vert">
<button label="One" />
<button label="Two" />
<button label="Three" />
</splitbox>
</splitbox>
and so on and so forth
You can grab a copy a the luxor-contrib site @
http://sourceforge.net/project/showfiles.php?group_id=64067 (look for
the swt-layout) package.
Enjoy.
- Gerald
PS: For more info check out the Luxor Website @
http://luxor-xul.sourceforge.net
If you want to discuss the Luxor SWT package please join the
luxor-xul-user mailinglist @
http://lists.sourceforge.net/lists/listinfo/luxor-xul-user
For more info about SWT (Standard Widget Toolkit) check out the
website @ http://www.eclipse.org/swt
|
| Author |
Message |
Roedy Green

|
Posted: 2005-12-2 3:36:00 |
Top |
java-programmer, Differences between C++ and Java
On 1 Dec 2005 10:25:38 -0800, "AndyRB" <email***@***.com> wrote,
quoted or indirectly quoted someone who said :
>The problem is many newbies (quite possibly
>Roedy's target audience) are ignorant of undefined behaviour and think
>that if their c++ code simply compiles then it must be valid c++.
That is not the issue. The issue is whether there are mechanisms to
detect the error or you simply get undefined results.
Think for example writing C code where you failed to initialise a
variable. This was legal. Most of the time it was initialised to 0.
But sometimes it was not, leading to a need for a timeout in a padded
cell. It STRONGLY matters if the compiler/run time can detect the
error.
It is almost irrelevant if the given code is technically legal.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Roedy Green

|
Posted: 2005-12-2 3:36:00 |
Top |
java-programmer >> Differences between C++ and Java
On 1 Dec 2005 10:25:38 -0800, "AndyRB" <email***@***.com> wrote,
quoted or indirectly quoted someone who said :
>The problem is many newbies (quite possibly
>Roedy's target audience) are ignorant of undefined behaviour and think
>that if their c++ code simply compiles then it must be valid c++.
That is not the issue. The issue is whether there are mechanisms to
detect the error or you simply get undefined results.
Think for example writing C code where you failed to initialise a
variable. This was legal. Most of the time it was initialised to 0.
But sometimes it was not, leading to a need for a timeout in a padded
cell. It STRONGLY matters if the compiler/run time can detect the
error.
It is almost irrelevant if the given code is technically legal.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Thomas G. Marshall

|
Posted: 2005-12-2 3:42:00 |
Top |
java-programmer >> Differences between C++ and Java
Thomas G. Marshall said something like:
> Dimitri Maziuk said something like:
>> Thomas G. Marshall sez:
>> ...
>>> Sorry to add to this so late, but even when I took the first tier
>>> programming course in my computer science degree in college in 1982,
>>> they tried to be very clear about this. That C, for example, is
>>> pass by value /only/. I didn't see why the term was defined as it
>>> is, mostly because I didn't care about it, until much later.
>>>
>>> As has been said in many different ways, particularly in these java
>>> forums, PbR means that modifying the formal parameter will result in
>>> a modification of the actual parameter. Java doesn't allow that and
>>> is .: PbV.
>>
>> Sheesh.
>>
>> void myfunc( MyObj o ) {
>> o.sefFoo( newfoo );
>> }
>>
>> How is that not modifying the actual instance of MyObj via "o"?
>
> Java /cannot/ and /is not/ modifying o
Well, a quick rephrase, of course to be consistent with the definition I've
already provided.
It /can/ alter the formal parameter o, but doing so cannot touch the actual
parameter.
The important point that needs to be driven home here is that the parameter
isn't technically an instance at all. It is a reference (pointer) to an
instance.
> which is the formal parameter.
> It is modifying the object that o points to.
...[rip]...
|
| |
|
| |
 |
Thomas G. Marshall

|
Posted: 2005-12-2 3:51:00 |
Top |
java-programmer >> Differences between C++ and Java
Roedy Green said something like:
> On Thu, 1 Dec 2005 17:35:55 +0000 (UTC), Dimitri Maziuk
> <email***@***.com> wrote, quoted or indirectly quoted someone who said :
>
>>
>> What Java doesn't allow is doing "o = otherobj;" and having
>> that stick after myfunc() returns. That's because "o" is
>> "object reference": a special data type that is similar, but
>> not quite the same as "reference" in "pass-by-reference".
>
> The point is words mean what people decide they mean. The Java
> community through consensus
Hardly. This wasn't a bunch of folks getting together over cards. You're
making this sound like an oddity in phrasing.
> came to define call by reference and call
> by value in such a way that Java always passes by value.
Not just the java community. Both my computer science programming 401
course in 1982, and my later compiler design course were insistant upon
this, using C as their example. I had to research this and iron this sucker
out when teaching other engineers java. Unfortunately, there are few "last
word authorities" on the subject, but I can tell you that the vast majority
of language/compiler design folks I've spoken to, perhaps 5 :) , all agree.
In java the parameter is a reference, and alterring that reference within
the method does not touch the actual parameter, and java is therefore PbV.
|
| |
|
| |
 |
AndyRB

|
Posted: 2005-12-2 5:57:00 |
Top |
java-programmer >> Differences between C++ and Java
Thomas G. Marshall wrote:
> AndyRB said something like:
> > Thomas G. Marshall wrote:
> >> AndyRB said something like:
>
> ...[rip]...
>
> > No, in c++ you cannot use pointer arithmetic to point to anywhere
> > within the address space, it is explicitly undefined behaviour
> > (consider a segmented memory model).
>
> Of course! But that happens /after/ the compiler accepts the attempt to set
> the pointer [anywhere] and when that part of the code is executed.
Who says that the compiler accepts the code and that the code even gets
executed.
It is undefined behaviour so technically you cannot assume anything
about what will happen or even what will be attempted.
|
| |
|
| |
 |
Oliver Wong

|
Posted: 2005-12-2 6:37:00 |
Top |
java-programmer >> Differences between C++ and Java
"AndyRB" <email***@***.com> wrote in message
news:email***@***.com...
>
> Thomas G. Marshall wrote:
>>
>> Of course! But that happens /after/ the compiler accepts the attempt to
>> set
>> the pointer [anywhere] and when that part of the code is executed.
>
> Who says that the compiler accepts the code and that the code even gets
> executed.
> It is undefined behaviour so technically you cannot assume anything
> about what will happen or even what will be attempted.
While I haven't read the C++ spec, based on my experience of reading
specifications for other languages, generally when they say "undefined
behaviour", they mean "undefined runtime behaviour". It is almost always
very well defined whether or not something will get accepted by the
compiler.
In other words, the "behaviour" they are referring to is the behaviour
of the program you're writing, not the behaviour of the compiler.
- Oliver
|
| |
|
| |
 |
Thomas G. Marshall

|
Posted: 2005-12-2 7:08:00 |
Top |
java-programmer >> Differences between C++ and Java
Bjorn Abelli said something like:
> "AndyRB" wrote...
>> Bjorn Abelli wrote:
>>
>>> If it really had been passed "by reference", you would also
>>> have had e.g. the possibility to change the original
>>> "reference-holder's" value for a reference to *another*
>>> object, much like you can do in C/C++ and the likes.
>>
>> References in c++ are not re-bindable, so you can't do what you
>> describe here and C doesn't have references.
>
> That's what you get for mixing up lingos for different contexts...
>
> In that sentence I didn't mean "reference" as the explicit C++ construct,
> but rather on a more general level as I tried to explain that it was
> *possible* to change something at the caller's side, in a way that you
> can't
> in Java.
>
>> Like java, C is pass by value, although you would usually
>> pass by pointer in order to simulate pass by reference.
>
> Well, I said somewhere else that it was many, many years since I
> programmed
> in C/C++... ;-)
>
> void bear::with(me *arg);
>
> If my memory serves me right I believe in C++ I sometimes even used
> "references to pointers"... ;-)
All manner of crap has been used in C++ that just boggles
the^H^H^Heveryone's mind.
--
Onedoctortoanother:"Ifthisismyrectalthermometer,wherethehell'smypen???"
|
| |
|
| |
 |
Thomas G. Marshall

|
Posted: 2005-12-2 7:12:00 |
Top |
java-programmer >> Differences between C++ and Java
AndyRB said something like:
> Thomas G. Marshall wrote:
>> AndyRB said something like:
>>> Thomas G. Marshall wrote:
>>>> AndyRB said something like:
>>
>> ...[rip]...
>>
>>> No, in c++ you cannot use pointer arithmetic to point to anywhere
>>> within the address space, it is explicitly undefined behaviour
>>> (consider a segmented memory model).
>>
>> Of course! But that happens /after/ the compiler accepts the attempt to
>> set
>> the pointer [anywhere] and when that part of the code is executed.
>
> Who says that the compiler accepts the code and that the code even gets
> executed.
> It is undefined behaviour so technically you cannot assume anything
> about what will happen or even what will be attempted.
We're going woefully astray here. But for yucks, I'll answer this part:
Undefined behavior is /always/ a definition of what happens at run time.
The compiler is in complete control of itself, and such a notion need not
exist at compile time. It is not, for example, ok for the compiler to spit
how "holy @#$% !!!" just because the behavior of an idiom/construct is
listed undefined in the specification.
--
Onedoctortoanother:"Ifthisismyrectalthermometer,wherethehell'smypen???"
|
| |
|
| |
 |
Chris Smith

|
Posted: 2005-12-2 7:28:00 |
Top |
java-programmer >> Differences between C++ and Java
Roedy Green <email***@***.com> wrote:
> The point is words mean what people decide they mean. The Java
> community through consensus came to define call by reference and call
> by value in such a way that Java always passes by value. Everything
> makes sense if you are consistent about this definition.
I'd modify that. The computer science field has come to define those
words in certain ways. Although there is a small step involved in apply
the definition to each individual language (namely, defining the term
"assignment operation" in the context of that language), the definition
is consistent and widely accepted at least among those who practice
language design and theory.
The Java community has come to understand that definition as it applies
to the Java programming language.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Thomas Hawtin

|
Posted: 2005-12-2 8:12:00 |
Top |
java-programmer >> Differences between C++ and Java
Thomas G. Marshall wrote:
>
> We're going woefully astray here. But for yucks, I'll answer this part:
> Undefined behavior is /always/ a definition of what happens at run time.
> The compiler is in complete control of itself, and such a notion need not
> exist at compile time. It is not, for example, ok for the compiler to spit
> how "holy @#$% !!!" just because the behavior of an idiom/construct is
> listed undefined in the specification.
So, are these features of C++ not undefined behaviour (if my memory serves):
o Platform dependent restrictions on the length of identifiers.
o Platform dependent restrictions on the depth of recursion of
template instantiation.
o Platform dependent #includes of one C++ standard header file from
another (not allowed for the C headers).
o Spitting out of platform dependent warnings.
Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
|
| |
|
| |
 |
AndyRB

|
Posted: 2005-12-2 17:59:00 |
Top |
java-programmer >> Differences between C++ and Java
Thomas G. Marshall wrote:
> AndyRB said something like:
> > Thomas G. Marshall wrote:
> >> AndyRB said something like:
> >>> Thomas G. Marshall wrote:
> >>>> AndyRB said something like:
> >>
> >> ...[rip]...
> >>
> >>> No, in c++ you cannot use pointer arithmetic to point to anywhere
> >>> within the address space, it is explicitly undefined behaviour
> >>> (consider a segmented memory model).
> >>
> >> Of course! But that happens /after/ the compiler accepts the attempt to
> >> set
> >> the pointer [anywhere] and when that part of the code is executed.
> >
> > Who says that the compiler accepts the code and that the code even gets
> > executed.
> > It is undefined behaviour so technically you cannot assume anything
> > about what will happen or even what will be attempted.
>
>
> We're going woefully astray here. But for yucks, I'll answer this part:
> Undefined behavior is /always/ a definition of what happens at run time.
> The compiler is in complete control of itself, and such a notion need not
> exist at compile time. It is not, for example, ok for the compiler to spit
> how "holy @#$% !!!" just because the behavior of an idiom/construct is
> listed undefined in the specification.
Undefined behaviour does not have to be diagnosed at compile-time, but
it is very much OK for a conforming compiler to spit out "holy @#$%
!!!" if it encounters a construct that is undefined behaviour.
>From the c++ standard definition...
"[Note: permissible
undefined behavior ranges from ignoring the situation completely with
unpredictable results, to
behaving during translation or program execution in a documented manner
characteristic of the environment
(with or without the issuance of a diagnostic message), to terminating
a translation or execution
(with the issuance of a diagnostic message)."
Note the explicit references made to translation in the above
definition.
>
>
>
> --
> Onedoctortoanother:"Ifthisismyrectalthermometer,wherethehell'smypen???"
|
| |
|
| |
 |
AndyRB

|
Posted: 2005-12-2 18:03:00 |
Top |
java-programmer >> Differences between C++ and Java
Oliver Wong wrote:
> "AndyRB" <email***@***.com> wrote in message
> news:email***@***.com...
> >
> > Thomas G. Marshall wrote:
> >>
> >> Of course! But that happens /after/ the compiler accepts the attempt to
> >> set
> >> the pointer [anywhere] and when that part of the code is executed.
> >
> > Who says that the compiler accepts the code and that the code even gets
> > executed.
> > It is undefined behaviour so technically you cannot assume anything
> > about what will happen or even what will be attempted.
>
> While I haven't read the C++ spec, based on my experience of reading
> specifications for other languages, generally when they say "undefined
> behaviour", they mean "undefined runtime behaviour". It is almost always
> very well defined whether or not something will get accepted by the
> compiler.
So you are making assumptions about c++ based on the specifications of
entirely different languages?
>
> In other words, the "behaviour" they are referring to is the behaviour
> of the program you're writing, not the behaviour of the compiler.
>From the /C++/ standard definition...
"[Note: permissible
undefined behavior ranges from ignoring the situation completely with
unpredictable results, to
behaving during translation or program execution in a documented manner
characteristic of the environment
(with or without the issuance of a diagnostic message), to terminating
a translation or execution
(with the issuance of a diagnostic message)."
Note the explicit references made to translation in the definition
above.
>
> - Oliver
|
| |
|
| |
 |
AndyRB

|
Posted: 2005-12-2 18:59:00 |
Top |
java-programmer >> Differences between C++ and Java
Roedy Green wrote:
> On 1 Dec 2005 10:25:38 -0800, "AndyRB" <email***@***.com> wrote,
> quoted or indirectly quoted someone who said :
>
> >The problem is many newbies (quite possibly
> >Roedy's target audience) are ignorant of undefined behaviour and think
> >that if their c++ code simply compiles then it must be valid c++.
>
> That is not the issue. The issue is whether there are mechanisms to
> detect the error or you simply get undefined results.
>
> Think for example writing C code where you failed to initialise a
> variable. This was legal. Most of the time it was initialised to 0.
> But sometimes it was not, leading to a need for a timeout in a padded
> cell.
and what sounds like undefined behaviour. Uninitialised variables are
legal, using uninitialised variables is undefined...however, I don't
think this affects the point I think you are trying to make.
>It STRONGLY matters if the compiler/run time can detect the
> error.
I don't think I have ever said anything to the contrary?
>
> It is almost irrelevant if the given code is technically legal.
It is irrelevant as far as erroneous code is erroneous, but that was
not the point I was making.
The point I am trying to make is that you can't attach expectations to
undefined behaviour, so what I am saying is that a statement along the
following lines is incorrect:
In c++ you can write <replace with some code that is undefined
behaviour> in order to <replace with some expected output>.
If the code is undefined behaviour you can say absolutely nothing about
what the code should do. It is on that basis that I said some of your
statements (e.g. pointer arithmetic)were incorrect.
> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Oliver Wong

|
Posted: 2005-12-2 23:54:00 |
Top |
java-programmer >> Differences between C++ and Java
"AndyRB" <email***@***.com> wrote in message
news:email***@***.com...
> Oliver Wong wrote:
>> While I haven't read the C++ spec, based on my experience of reading
>> specifications for other languages, generally when they say "undefined
>> behaviour", they mean "undefined runtime behaviour". It is almost always
>> very well defined whether or not something will get accepted by the
>> compiler.
> So you are making assumptions about c++ based on the specifications of
> entirely different languages?
Yes. Sort of like when I encounter a new programming language and see
the statement "x = y + z;", I assume that the + is an operator (and not,
say, a variable name) that does something semantically equivalent to
"addition" on the "y" and "z", which I assume are variable names (and not,
say, operators). This interpretation is so widespread, it almost seems like
a defacto standard, and from a utilitarian perspective, it is MORE useful to
just make that assumption, and then correct yourself when you find out that
you are wrong, than to sort of be blocked from proceeding further and
acknowledging that you don't actually really know what the statement means.
>>
>> In other words, the "behaviour" they are referring to is the
>> behaviour
>> of the program you're writing, not the behaviour of the compiler.
>
>>From the /C++/ standard definition...
> "[Note: permissible
> undefined behavior ranges from ignoring the situation completely with
> unpredictable results, to
> behaving during translation or program execution in a documented manner
> characteristic of the environment
> (with or without the issuance of a diagnostic message), to terminating
> a translation or execution
> (with the issuance of a diagnostic message)."
>
> Note the explicit references made to translation in the definition
> above.
Noted. I'm very surprised that this is the stance on what is accepted
when something is said to have "undefined behaviour", but if that's what it
says, so be it. I stand corrected.
- Oliver
|
| |
|
| |
 |
Alvin Ryder

|
Posted: 2005-12-3 2:29:00 |
Top |
java-programmer >> Differences between C++ and Java
Roedy Green wrote:
> A link to an essay on the differences between C++ and Java in the Java
> glossary has died, so I concocted this little essay to replace it at
> http://mindprod.com/jgloss/cpp.html
>
> In Java, the sizes of int, long etc. are rigidly defined in terms of
> bits. In C++ they are platform-dependent.
>
> In Java, the JVM behaves at if it were big endian, even if internally
> it is actually little-endian. In C++, the endianness is platform
> dependent.
>
> In Java, garbage collection of unreferenced objects is automatic. In
> C++, you manually manage memory.
>
> In Java, references are constrained to point only to the beginnings of
> objects. In C++, you can do arithmetic on pointers and make pointers
> point anywhere in the address space.
>
> In Java you cannot overload operators. In C++, you can.
>
> In Java, by default methods are virtual (overrideable). In C++, by
> default, methods are non-virtual.
>
> Java object code (class files containing JVM byte codes) will run
> unmodified on any platform. C++ object code must be first linked to
> produce an executable containing platform-specific machine
> instructions. It will run only on one platform.
>
> Java checks all subscripts that they are in bounds and all casts for
> validity. C++ does not.
>
> Java requires a JVM to execute. C++ programs are usually freestanding.
> Java does not use a preprocessor. C++ makes extensive use of a macro
> preprocessor.
>
> Anything else important to say?
>
> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Java custom programming, consulting and coaching.
Hi,
You've covered many good points, in addition most of my points aren't
language related per se but they are certainly important and an
inevitable part of using each language.
Culture.
Java has a culture of "let's make it easy and cool to use" while C++'s
culture is "hey if you can't hang with the big boys, that's your
problem (... try VB)".
Java: "You need an API, yea, we'll build it, you can have it ... for
free" ;-)
C++: "You need an API, great go build it yourself ... or buy it" ;-|
Growth.
JCP - moves pretty quickly. New JDK every year.
ANSI C++ - moves slowly, to "gc" or "not to gc"... meantime the world
has moved on.
Support.
Sun makes huge effort to sign everyone up for Java support (remember
those days).
C++ leaves participation open to happen-stance.
JDBC is just one fruit of that almost unanimous and uniform support,
while in C++ talking to databases is still on a case by case basis.
Enterprise integration. Java has J2EE, C++ say's "that's your problem
not ours".
C++: A case of a language and a compiler, *all* the rest is up to you.
Java: We'll make all the pieces of the jigsaw puzzle and we'll make
them fit, you only need to make the app.
Style.
Java encourages "ease" thus clarity thus verbosity, happyTyingFolks (
).
C++ is terse. htf ( ). (Of course that's only a cultural tendency not
an intrinsic language feature..)
Java: A class must be in a file of the same name. File location must
match package structure.
C++: Put it where you want, name it how you want (=mess).
Cheers.
|
| |
|
| |
 |
Thomas G. Marshall

|
Posted: 2005-12-3 14:16:00 |
Top |
java-programmer >> Differences between C++ and Java
AndyRB said something like:
> Thomas G. Marshall wrote:
>> AndyRB said something like:
>>> Thomas G. Marshall wrote:
>>>> AndyRB said something like:
>>>>> Thomas G. Marshall wrote:
>>>>>> AndyRB said something like:
>>>>
>>>> ...[rip]...
>>>>
>>>>> No, in c++ you cannot use pointer arithmetic to point to anywhere
>>>>> within the address space, it is explicitly undefined behaviour
>>>>> (consider a segmented memory model).
>>>>
>>>> Of course! But that happens /after/ the compiler accepts the attempt
>>>> to
>>>> set
>>>> the pointer [anywhere] and when that part of the code is executed.
>>>
>>> Who says that the compiler accepts the code and that the code even gets
>>> executed.
>>> It is undefined behaviour so technically you cannot assume anything
>>> about what will happen or even what will be attempted.
>>
>>
>> We're going woefully astray here. But for yucks, I'll answer this part:
>> Undefined behavior is /always/ a definition of what happens at run time.
>> The compiler is in complete control of itself, and such a notion need not
>> exist at compile time. It is not, for example, ok for the compiler to
>> spit
>> how "holy @#$% !!!" just because the behavior of an idiom/construct is
>> listed undefined in the specification.
>
> Undefined behaviour does not have to be diagnosed at compile-time, but
> it is very much OK for a conforming compiler to spit out "holy @#$%
> !!!" if it encounters a construct that is undefined behaviour.
>
>> From the c++ standard definition...
> "[Note: permissible
> undefined behavior ranges from ignoring the situation completely with
> unpredictable results, to
> behaving during translation or program execution in a documented manner
> characteristic of the environment
> (with or without the issuance of a diagnostic message), to terminating
> a translation or execution
> (with the issuance of a diagnostic message)."
>
> Note the explicit references made to translation in the above
> definition.
Hmmm ok, thanks. I'll have to ponder on this---IMO there's a nuance to this
that /still/ doesn't seem quite right in this thread's context. But in any
case, Chris Uppal rephrased it properly already.
--
Whyowhydidn'tsunmakejavarequireanuppercaselettertostartclassnames....
|
| |
|
| |
 |
Dimitri Maziuk

|
Posted: 2005-12-4 3:42:00 |
Top |
java-programmer >> Differences between C++ and Java
Roedy Green sez:
...
> Please at least read the JVM spec and also study how parameters are
> passed in various language
I have, and I much prefer Delphi language guide that says object
references are "pointers that are automatically dereferenced" in
the "objects" section and that if you wnat to, you can var any
formal parameter
procedure myfunc( var o:Myobj )
(in the "methods" section).
JLS says that there are three "reference types" and that reference types
are *not* primitive types. It says that "reference values" are pointers
to objects. Then you trace down the three "reference types" and work out
that in the end they're all instantiated as objects, so "reference values"
is what you're interested in.
In 2.10 JLS says that for every parameter, a new variable is created and
initialized when method is invoked. Thankfully, I know enough about
stack-based languages to understand what they mean by that.
So it's the same as Delphi sans var parameters and clarity of documentation.
> ... before you
> continue with your crusade.
What crusade? -- I'm just keepin' up a polite conversation. Prompted
by your statement that "Java references point to the beginnings of
objects, in C++ you can do pointer arithmetics..." It's bad, OK?
Because
1. Java "reference values (often just _references_)" are pointers
to objects and there are only two things you can do with them: point
one to an object and access object's members via it (basically; there's
also comparisons which may or may not be done by object's members,
instanceof and string concatenation). They don't point to "the beginnings
of objects" -- that's simply meaningless in Java context -- they point
to objects.
2. Unlike Java reference values, C pointers are just memory addresses.
Modern compilers give you syntactic icing on top, like remembering the
type of data poined to and various cast operations, but you're pretty
much free to discard all that sugar and do whatever you want with them
(e.g. work out the address of the second byte in the third field of the
fifth element of an array of records. Sorry, structs.).
C++ also has references, in addition to pointers. C++ references are
nothing at all like Java reference values. They are more like references
in Comp. Sci. definition. You cannot re-point a reference and whatever
you do to the reference you're doing to underlying data.
Both pointers and refences in C++ can point to/reference any data
type (including pointers), not just objects.
Dima
--
We're part of that admittedly-too-small group that is trying to save
the human race from itself. With any luck, we'll fail abjectly and
the cockroaches will win out.
-- Mike Andrews
|
| |
|
| |
 |
Roedy Green

|
Posted: 2005-12-4 4:56:00 |
Top |
java-programmer >> Differences between C++ and Java
On Sat, 3 Dec 2005 19:41:51 +0000 (UTC), Dimitri Maziuk
<email***@***.com> wrote, quoted or indirectly quoted someone who said :
>> ... before you
>> continue with your crusade.
>
>What crusade?
your crusade to change Java's definition of call by value.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Thomas G. Marshall

|
Posted: 2005-12-4 5:26:00 |
Top |
java-programmer >> Differences between C++ and Java
Dimitri Maziuk said something like:
...[rip]...
> 1. Java "reference values (often just _references_)" are pointers
> to objects and there are only two things you can do with them: point
> one to an object and access object's members via it (basically; there's
> also comparisons which may or may not be done by object's members,
> instanceof and string concatenation). They don't point to "the beginnings
> of objects" -- that's simply meaningless in Java context -- they point
> to objects.
While this is obviously correct, I believe that the layman explanation of
references pointing to solely the beginnings of objects is not a terrible
one. In C, for example, when you have a pointer to a struct, you have a
pointer to it's first location in memory. So it's an understood programming
idiom.
In java, you cannot take the address of, say, the third int in an object.
Hmmm, I'm guessing here, but a C99 purist might be able to argue that the C
pointer to a struct is not to the first location of a struct but to the
struct itself, because you cannot do anything legal but dereference the
entire struct or sub components of it with "->". You can *obviously* do
much more, but it all would require modifying the pointer by casting it to
something else. {shrug}. If so, I don't see much the point in pedantically
pointing it out.
On the flip side of all this, I don't believe that the point of C and Java's
PbV is a pedantic one, but this reopens a (hopefully) dead issue in this
thread.
...[rip]...
> C++ also has references, in addition to pointers. C++ references are
> nothing at all like Java reference values.
No one is contesting that. Even the JLS refers to the reference as a
pointer.
...[rip]...
--
"I don't want FOP, God dammit! I'm a DAPPER DAN MAN!"
|
| |
|
| |
 |
Chris Smith

|
Posted: 2005-12-4 5:32:00 |
Top |
java-programmer >> Differences between C++ and Java
Dimitri Maziuk <email***@***.com> wrote:
> I have, and I much prefer Delphi language guide that says object
> references are "pointers that are automatically dereferenced"
And that's Delphi. It doesn't make sense to say that in Java. In Java,
a reference is only dereferenced if you apply an operation that
dereferences it. Those operations include the "." and "[]" symbols, and
Java 1.5's unboxing conversions. Otherwise, there is no dereferencing
that takes place.
> JLS says that there are three "reference types" and that reference types
> are *not* primitive types. It says that "reference values" are pointers
> to objects.
Well, to be precise, it says that a reference value is either a pointer
to an object, or null.
> Then you trace down the three "reference types" and work out
> that in the end they're all instantiated as objects, so "reference values"
> is what you're interested in.
I'm a little lost by your use of words here. References are just
values. Creating a reference doesn't necessarily imply instantiating an
object. You seem to be talking about something that you call
instantiating a reference type... for which I can't find any logical
meaning. In any case, it's not normal Java terminology.
> In 2.10 JLS says that for every parameter, a new variable is created and
> initialized when method is invoked. Thankfully, I know enough about
> stack-based languages to understand what they mean by that.
I see that language in 4.12.3 in the JLS 3rd edition, and 4.5.3 in the
JLS 2nd edition. Are you sure you're reading the same JLS as the rest
of us?
In any case, I don't know whether you understand this or not. In any
case, this language in the spec doesn't imply a stack. It may or may
not be implemented with the CPU stack (though it obviously is most of
the time for performance reasons). It is similar to, but not quite, an
implementation of the generic computer science concept of stacks --
differing only in that local variables within the current stack frame
may be accessed in any order.
It means just what it says. Every time a method is called, the actual
parameters are copied into the formal parameters, which function as
separate variables. This is pretty close to exactly the definition of
pass by value, as it turns out.
> So it's the same as Delphi sans var parameters and clarity of
> documentation.
I don't know much about Delphi, but the language above about references
being automatically dereferenced suggests that it's not exactly the
same. If use of a reference as an lvalue in Delphi modifies the object
and not the reference, then it is different in precisely the way that is
needed in order to make Delphi qualify as pass by reference in a way
that Java does not.
Incidentally, if you're look for documentation that makes intuitive
sense to you, then the language spec may not be the place the look.
There are good books on Java, including for example Bruce Eckel's which
is free online. However, if you're looking for precise definition of
language behavior, the spec is the place to look.
> What crusade? -- I'm just keepin' up a polite conversation. Prompted
> by your statement that "Java references point to the beginnings of
> objects, in C++ you can do pointer arithmetics..." It's bad, OK?
I agree that the statement you're quoting is a poor description. It
mixes implementation with specification (in much the same way as the
stack comment above).
> 2. Unlike Java reference values, C pointers are just memory addresses.
> Modern compilers give you syntactic icing on top, like remembering the
> type of data poined to and various cast operations, but you're pretty
> much free to discard all that sugar and do whatever you want with them
> (e.g. work out the address of the second byte in the third field of the
> fifth element of an array of records. Sorry, structs.).
I'm sure someone will jump in and point out that the above is only true
if you're willing to achieve undefined behavior according to the C
standard. Nevertheless, your point remains true.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Dimitri Maziuk

|
Posted: 2005-12-5 3:23:00 |
Top |
java-programmer >> Differences between C++ and Java
Chris Smith sez:
> Dimitri Maziuk <email***@***.com> wrote:
>> I have, and I much prefer Delphi language guide that says object
>> references are "pointers that are automatically dereferenced"
>
> And that's Delphi. It doesn't make sense to say that in Java. In Java,
> a reference is only dereferenced if you apply an operation that
> dereferences it. Those operations include the "." and "[]" symbols, and
> Java 1.5's unboxing conversions. Otherwise, there is no dereferencing
> that takes place.
What they mean by "automatically dereferenced" is you don't write
(using C syntax as it's probably more familiar) myobj->myfunc(),
you write myobj.myfunc(). It doesn't make sense in Java because
there is no "->" in Java, yet if reference values are pointers
(as per JLS) "." must involve dereferencing behind the scenes.
> I see that language in 4.12.3 in the JLS 3rd edition, and 4.5.3 in the
> JLS 2nd edition. Are you sure you're reading the same JLS as the rest
> of us?
Sun's website, 1.5 docs, JLS 3rd edition, #4.3 "reference types and
values" and #8.4 "formal parameters".
> I don't know much about Delphi, but the language above about references
> being automatically dereferenced suggests that it's not exactly the
> same. If use of a reference as an lvalue in Delphi modifies the object
> and not the reference, then it is different in precisely the way that is
> needed in order to make Delphi qualify as pass by reference in a way
> that Java does not.
No, it's just that Delphi documentation is written for people who are
used to regular meaning of certain terms -- as opposed to Java meaning.
In Delphi "by reference" means "var parameter". The default is by
value and language guide explains that "by value" involves making
a copy of the variable. Like in Java, assignment to a "class type
variable" (Java "reference value") re-points the pointer. You can't
change that because like Java Delphi does not allow operator
overloading. (I'm assuming by "lvalue" you mean "can be assigned to").
What makes the comparison interesting is that both languages were
developed at the same time and both teams came up with the same
way of handling objects.
Dima
--
Relativity, Uncertainty, Incompleteness, Undecidability: choose any four
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Grouphow do i join this group of programmers
- 2
- database content as objectsI wonder what is so appealing in mapping of database content to
predefined Java (or some other language) objects.
There is a problem with joins in he first place. There is lot of coding
and processing overhead.
I found it more elgant to store data in HashMaps. If I need an object,
I could always provide a class with a constructor that takes HashMap as
parameter.
Reporting can be much easier that way, too. I used it in a couple of
projects, and find it very handy.
DG
- 3
- Beware of disabled ActionHi !
just a note to warn you about some javax.swing.AbstractAction problem
My GUI dispays a JButton.
depending on the user's state, I do a setAction(AAction)
or a setAction(BAction).
AAction and BAction each extend AbstractAction and possess their own icon
(ImageIcon).
Here is a sample scenario :
1) button.setAction(AAction)
2) AAction.setEnabled(false)
3) button.setAction(BAction)
4) BAction.setEnabled(false)
the result of this is : the Action linked to the button is BAction as
expected, and the icon is...AAction's disabled icon (original icon greyed).
The only workaround I've found is to do button.setDisabledIcon(null) before
any new setAction()
It seems that an AbstractAction doesn't possess a disabled icon on its own,
and relies on the JComponent's one.
The first time, 1) and 2) have the consequence of creating a disabled icon
for my button , which doesn't have any at the beginning.
Then, 3) and 4) won't change this disabled icon, because the button now has
one
Regards,
Arnaud
- 4
- jtextarea and htmlHi,
Is it possible for me to setup up jtextarea such that
it renders html.
Suppose I create a but "interpret html" which when clicked
goes through the text in jtextarea and
adds styles
for example if I have something like
<b>bold text here</b>
then this should be bold. Furthermore, it should hide these html
tags but not delete them, that way when i save the text, i save the html
tags as well.
thanks for any advice
- 5
- ZoneView: does it work?I'm going to repeat a question that i've asked in javalobby to no
avail.
Did anyone ever got zoneview working for a JEditorPane and if so how?
I'm using a custom stylededitorkit that implements view factory and my
factory code looks like this:
public View create(Element elem) {
String name = elem.getName();
if (name != null) {
if (name.equals(AbstractDocument.ContentElementName)) {
return new LabelView(elem);
} else if (name.equals(AbstractDocument.ParagraphElementName)) {
return new CountingParagraphView(elem,observer);
} else if (name.equals(AbstractDocument.SectionElementName)) {
return new ZoneView(elem, View.Y_AXIS);
} else if (name.equals(StyleConstants.ComponentElementName)) {
return new ComponentView(elem);
}else if (name.equals(StyleConstants.IconElementName)) {
return new IconView(elem);
}
}
return new LabelView(elem);
}
Ignore the contngparagraph view, its just something i did to be able to
tell the amount of text visible.
Using zoneview here gives an nullpointerexception in the guts of swing,
in AsyncBoxView i think.
I'm just looking for a way not to load to the views the entire text at
a time (That is sloooow). And getting an indicator of the index of
text. I'm going to append my editor kit and textpaintobserver if you
want to see how it works (to make it work, just replace zoneview with
boxview in the method above).
/**
*
*/
package ui;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Shape;
import javax.swing.SwingUtilities;
import javax.swing.text.AbstractDocument;
import javax.swing.text.BoxView;
import javax.swing.text.ComponentView;
import javax.swing.text.Element;
import javax.swing.text.IconView;
import javax.swing.text.JTextComponent;
import javax.swing.text.LabelView;
import javax.swing.text.ParagraphView;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledEditorKit;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
class TextCountingEditorKit extends StyledEditorKit implements
ViewFactory{
/**
* Observer given in the constructor.
*/
private final TextPaintObserver observer;
private static final long serialVersionUID = -7828351555750309111L;
public TextCountingEditorKit(TextPaintObserver observer) {
super();
this.observer = observer;
}
public ViewFactory getViewFactory()
{
return this;
}
public View create(Element elem) {
String name = elem.getName();
if (name != null) {
if (name.equals(AbstractDocument.ContentElementName)) {
return new LabelView(elem);
} else if (name.equals(AbstractDocument.ParagraphElementName)) {
return new CountingParagraphView(elem,observer);
} else if (name.equals(AbstractDocument.SectionElementName)) {
return new ZoneView(elem, View.Y_AXIS);
} else if (name.equals(StyleConstants.ComponentElementName)) {
return new ComponentView(elem);
}else if (name.equals(StyleConstants.IconElementName)) {
return new IconView(elem);
}
}
return new LabelView(elem);
}
/**
* Counting paragraph view
*/
class CountingParagraphView extends ParagraphView {
private Rectangle line;
private Rectangle win;
private TextPaintObserver observer;
public CountingParagraphView(Element elem, TextPaintObserver
observer){
super(elem);
//strategy = new MyFlowStrategy(); TODO
line = new Rectangle();
win = new Rectangle();
this.observer = observer;
}
/**
* Overrides the normal paint method for eliminating
* cut lines at the top and bottom of the viewport
* and for counting the number of visible chars from
* the model (without added \n from line-wrap,or tabs)
* the visible chars are derivated by subtracting
* two variables of the class, first and last,
* who this method updates, and who is the responsability
* of the component that wants to know them to rest afterwards
* @param g
* @param a
*/
public void paint(Graphics g, Shape a) {
Rectangle box = (a instanceof Rectangle) ? (Rectangle)a :
a.getBounds();
SwingUtilities.calculateInnerArea((JTextComponent)getContainer(), win);
int n = getViewCount();
int x = box.x;
int y = box.y;
for (int i = 0; i < n; i++) {
line.x = x + getOffset(X_AXIS, i);
line.y = y + getOffset(Y_AXIS, i);
line.width = getSpan(X_AXIS, i);
line.height = getSpan(Y_AXIS, i);
View view = getView(i);
//g.draw3DRect(line.x,line.y,line.width,line.height,true);
if ( win.contains(line) ) {
int startOffSet = view.getStartOffset();
//Lame document default behavior workaround (see
AbstractDocument)
int endOffSet = (view.getEndOffset() >
getDocument().getLength() ) ? view.getEndOffset()-1:
view.getEndOffset();
if( startOffSet < observer.getFirst()){
observer.setFirst(startOffSet);
}
if( endOffSet > observer.getLast()){
observer.setLast(endOffSet);
}
paintChild(g, line, i);
}
}
}
}
}
package ui;
import java.lang.reflect.InvocationTargetException;
import javax.swing.SwingUtilities;
import javax.swing.text.JTextComponent;
public class TextPaintObserver {
private int first;
private int last;
private JTextComponent text;
public TextPaintObserver(JTextComponent text) {
reset();
this.text = text;
}
public void setFirst(int in) {
this.first = in;
}
public void setLast(int in) {
this.last = in;
}
public int getFirst() {
return (this.first == Integer.MAX_VALUE) ? 0 : first;
}
public int getLast() {
return (this.last == Integer.MIN_VALUE) ? 0 : last;
}
/**
* Resets the state of the observed values
*/
private void reset(){
first = Integer.MAX_VALUE;
last = Integer.MIN_VALUE;
}
/**
* Gets the visible length
*/
public int getInterval(){
resetState();
return getLast() - getFirst();
}
/**
* Causes the state of the visible length to
* be updated
*
*/
private void resetState(){
reset();
if(SwingUtilities.isEventDispatchThread()){
text.paintImmediately(text.getBounds());
}
else{
try {
SwingUtilities.invokeAndWait(
new Runnable(){
public void run(){
text.paintImmediately(text.getBounds());
}
}
);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
- 6
- Fashion Footwear Industrial Co.,Ltd(Fujian,CHINA) www.fashion-sky.comDear my friend
It is our pleasure to meet you here.
we are wholesaler sport shoes,clothing,electrons in Fujian of China.
our website: http://www.fashion-sky.com
We are professional and honest wholesaler of all kinds of brand
sneaks and apparel.the products
our company supply are as follows:
1).Nike Jordans
Jordan 1 jordan 1.5 jordan 2 jordan 3 jordan 3.5 jordan 4 jordan 5
jordan 5.5 jordan 6 jordan 6.5 jordan 7 jordan 8 jordan 9 jordan 9.5
jordan 10 jordan 11 jordan 12 jordan 13 jordan 13.5 jordan 14 jordan
15 jordan 16 jordan 17 jordan 18 jordan 18.5 jordan 19 jordan 20
jordan 21 jordan 21.5 jordan 22 jordan King jordan Dub Zero Jordan 23
Jordan 7.5
2).Air Force One Air Force one (low) Air Force one (High) Air Force
one (Mid) Air Force one (clear) Air Force One 25 year
3).SHOX Shox R3 Shox R4 Shox R5 Shox TL1 Shox TL2 Shox TL3 Shox NZ
Shox OZ Shox Turbo Show GO Shox CL Shox Coqnescenti Shox Energia Shox
Explodine Shox Monster Shox Rhythmic Shox Warrior
4).Bape Shoes Bape Bape (transparent)
5).Air max AirMax 90 AirMax 95 AirMax 97 AirMax 2003 AirMax 2004
AirMax 2005 Air Max 2006 AirMax 180 AirMax LTD AirMax TN AirMax solas
AirMax 87 AirMax Rift
6).Puma Puma Rpt2 Puma SK6 Puma Jayfi Puma Cir Puma Speed Puma Repli
Puma Future Cat Puma Mostro Puma Lifestyle
7).Dunk SB Dunk High Dunk Low
8).Timberland Timberland High Timberland Low
9).Adidas Adidas 35 Adicolor Country city sense Adidas NBA
11).Prada & Gucci Prada Gucci
12).Footballer Shoes Footballer
13).Locaste
14).converse & Reebok converse Reebok
15).D&G shoes
16).Dsquared2 shoes
17).James shoes
18).Nike King
9).Children shoes Jordan Shox
20).Women shoes Women Jordans Women Shox R3 Women Shox R4 Women AirMax
95&97 Women AirMax 03&06 Women Dunk Women Shox NZ Women AF1
21).sandal & baboosh Nike Puma Gucci Prada
CLOTHES 1).Bape 2).ED Hardy 3).BBC 4).CLH 5).LRG 6).Artful Dodger
Hoodies 7).GINO GREEN GLOBAL 8).10 Deep 9).A&F Coat 11).Jersey NBA
Jersey Football Jersey 12).Juicy Bikini 13).Adidas Coat 14).F1 Coat
15).D&G Coat 16).Superman Coat 17).NBA Coat
JEAN 1).E&D Jeans 2).BBC Jeans 3).BAPE Jeans 4).D&G Jeans 5).EVSIU
Jeans 6).Red monkey 7).COOGI Jeans
T-shirt 1).POLO 2007 polo(women) 2007 POLO IIII(Men) POLO (stripe)
polo (small )
2).Lacoste Lacoste (LONG) Lacoste (SHORT) 3).Name Brand shirt D&G
Shirt Giorgio Armani TN Shirt 4).BBC T-shirt 5).LRG & gina green
glalal 6).Triumvir 7).ED handy 8).Evsiu 9).R.M.B 10).CLOT
Burse & Handbag 1).LV Bag 2).Gucci Bag 3).Dior Bag 4).Chanel Bag
5).Fendi Bag 6).Coach Bag 7).Burberrys Bag 8).Prada Bag 9).Man Leisure
Bag 11).D&G bag 12).nike bag 13).Wallet 14).Suitcase
Electronics 1).Vertu Mobile 2).New iphone Mobile 3).Nokia Mobile
4).moto Mobile 5).PSP Game & memory card 6).Sony Mobile 7).Samsung
Mobile 8).Ipod nano 9).Sony PS3 10).Laptops IBM laptops DELL laptops
Sony laptops ASUS laptops
CAP 1).ED Hardy Cap 2).New Bape & NY Cap 3).RMC Cap 4).New era NBA
5).F1 6).Chanel 7).D&G 8).gucci 9).LV 10).Prada 11).PUMA 12).wool
WATCH 1).Rolex 2).Omega 3).Cartier 4).Chanel 5).Piaget 6).Breitling
7).Bvlgari 8).Corum
Sunglasses 1).Gucci Sunglasses 2).D&G Sunglasses 3).Dior Sunglasses
4).LV Sunglasses 5).Chanel Sunglasses 6).Prada Sunglasses 7).Versace
Sunglasses 8).Giorgio Armani
Strap 1).Bape Strap 2).D&G Strap 3).Gucci Strap 4).LV Strap 5).Scarf
Other 1).Lighter
size chart
Men Size:
US: 7 8 8.5 9 9.5 10 10.5 11 11.5 12 13 14 15
UK: 6 7 7.5 8 8.5 9 9.5 10 10.5 11 12 13 14
EUR: 40 41 42 42.5 43 44 44.5 45 45.5 46 47.5 48 49
Women Size:
US: 5 5.5 6 6.5 7 7.5 8 8.5
UK: 2.5 3 3.5 4 4.5 5 5.5 6
EUR: 35.5 36 36.5 37.5 38 38.5 39 40
Kid's
US: 1 2 3 4 5 6 7 7.5 8 8.5 9 9.5 10 10.5 11 11.5 12 12.5 13 13.5
UK: 13 1 2 3 4 5 6 6.5 7 7.5 8 8.5 9 9.5 10 10.5 11 11.5 12 12.5
EUR:17 18 19 20 21 22 23 24 24.5 25 25.5 26 26.5 27 27.5 28 29 30 30.5
31
Clothing Size:
S M L XL XXL XXXL XXXXL XXXXXL
7.because the space of the website is limited,we can also supply many
other products which be not showed out in our site. if you have the
photos of the products you need , we are pleasure to supply for your
orders.
And our company can supply for our customers ,as follow:
1. top quality.all our products have top quality.
2. most rational price. we offer the most competitive price to you to
open your market. So today most of our products have sold well in the
America, Europe, Middle East, Southeast Asia etc..
3. safe and fast shipment. As different country you are in, we will
deliver the products to you by different ways and pledge to arrive to
your address 100%.and we will send the products to you within 24h
after we get your payment.
4.many products in stock. We have many products in stock and kinds of
size you need , also include kid's.
5.our credit. If the products can be not delivered to your address as
our reason, we will refund the money you paid.
Hope sincerely to have glad and long term business relationship with
you.
If you are interested in our products and have any problem, welcome
to
contact us.
Please trust us , we will be your best choice !!!
Website : http://www.fashion-sky.com
MSN and E-mail: email***@***.com
Yahoo ID:email***@***.com
Michael
Fashion Footwear Industrial Co.,Ltd.(Fujian,CHINA)
- 7
- What means %10.7f?Hi,
My code has:
System.out.printf("%10.7f", aDouble);
My intention is to print out the value of a double variable following
the rule: a)the maximum space is 10; b)have 7 digits after the decimal
point.
But there is a bug here, I found. If aDouble < 100, it is fine; If
aDouble >= 100, it will take 11 spaces, instead of 10 spaces. So I have
to manually change 10.7f to 10.6f. What a pain!
Could you help me out? Thank you.
- 8
- [OT] Re: Viewing and Changing Settings"news" <email***@***.com> wrote in message
news:ezLCb.1561$email***@***.com...
>
> I want to see my settings for java. How do I see the settings
> using set on DOS screen??
>
Type:
set
and press <ENTER>; you should find a number of items displayed:
PATH=...
CLASSPATH=...
>
> My problem is when I type in set and nothing shows.
> I go to the directly where java.exe is located and type
> set and nothing.
>
I find this a highly unusual situation. Ordinarily, you would have at least
a couple of environment variables displayed.
>
> How do I change the settings like CLASSPATH
>
To create a CLASSPATH enviorment variable where none exists, do:
set CLASSPATH=C:\XYZ;D:\ABC
and press <ENTER>.
To add information to an existing CLASSPATH [you can choose whether to place
it before or after existing data] do:
:: Before existing data
set CLASSPATH=%classpath%;C:\XYZ;D:\ABC
or:
:: After existing data
set CLASSPATH=C:\XYZ;D:\ABC;%classpath%
and press <ENTER>.
Note, though, this changes the settings for the current console window [i.e.
DOS Window] only - the settings are lost once you close it. For a more
permanent solution:
* Edit 'autoexec.bat' file to include the above statements - this
applies to older Windows versions
* Use the System applet in the Control Panel to edit Enviromnent
Variables [for W2K, and XP]
I hope this helps.
Anthony Borla
- 9
- Executing a jar fileI have the following code
/*
WinTest.java
*/
import java.io.*;
public class WinTest {
public static void main (String args[]) {
String line;
Process backgroundProcess;
try {
// Start the other process
backgroundProcess = Runtime.getRuntime().exec
("d:\\program files\\cprog.exe");
}
catch (Exception e) {
System.out.println(e);
}
}
}
If I execute the class file from a cmd windown I get the start up
screen from the cprog.exe, however as I would like to dispense with
the dos window I packaged the class into a jar file
First creating a text file called WinTest.txt containin the single
line
Main-Class: WinTest
Then create the jar file
jar cmf WinTest app.jar WinTest.class
I associated the jar file with the java.exe in the SDK lib
But when I double click to execute the jar file a dos window pops up
disappears but no start screen from the cprog.exe is shown
I'm sure it is a severe user error must I have to admit to being
stumped and help would be nuch appreciated
- 10
- help with my first project on first job, how to read a strange file, thanks a lot!!!!!!!the OS is mainly windows. i doubt windows has powerful tool to do the
job automatically.
i need to open and close the file frequently because another process
is writing to the file. then Java create a new object each time I open
the file. in this case, can the program remeber the position I set
last time?
if yes, can i do the same thing with BufferedReader class instead of
RandomAccessFile. i am not sure whether RandomAccessFile can easily
allow me to keep the new line characters and white space among the
valid text. i need these chars in the application. The length() can
not help me a lot, since the file size does not change when new text
is written into the file. the new text write over the whitespace but
do not change the file size.
thanks again!
Alex Kizub <email***@***.com> wrote in message news:<email***@***.com>...
> You didn't mention OS. Probably it could be solved only by OS tools.
> For example for UNIX like it could be grep, tail -f, awk... |, >
>
> Java has other features, but since you can't change application and should
> only change the file (which is not good solution itself) here are some
> solutions for you.
>
> Use java.io.RandomAccessFile.
> So you can set position which you alreadu reached with method seek, you
> can know length of new open file with method
> length().
> Then, I suggest, read file with method read(byte[] b) copy none white
> spaces to another array and write it to the new file.
> Pretty easy.
>
> BTW. With java.io.File you can understand last modification time and
> decide do you need reread file again.
>
> Good luck in your new job.
> Alex Kizub.
> matt wrote:
>
> > Java guys:
> > this is my first project at my first job. so pls help if you could.
> > i am working with a text file with strange format. The file has a lot
> > of white space between the last line of valid text and the end of
> > file character. And the file is update frequently. New valid text is
> > appended behind the original valid text and overwrite some whitespace.
> > I need to feed this file as an input to an application. but this
> > application only take files without such whitespace. The application
> > need to read the file frequently to see whether new text is appended.
> > if there is, get the appended text.
> > My initial solution is to convert the original file into a new file in
> > which the whitespace is truncated. then the application can read the
> > new file.
> > possibility 1:
> > loop
> > read 1 line of text of original file
> > write this line to new file
> > until read the long line of white space
> > close both file
> >
> > in this case, what class and method should i use, especially in
> > examing the white spaces?
> >
> > possibility 2:
> > the previous one is not smart because the same text is read and write
> > each time when the file is read. so is there a way i can just each
> > time check whether update happens to the file and then just write the
> > update to the new file? such as in C, a file pointer know the position
> > of last read. can i do the same in Java or C#? or other ways to do it?
> > possibility 3:
> > very unlikely but smarter,
> > read the file in a stream, truncate the whitespace inside the
> > stream, then feed the stream directly into the application. but it is
> > unlikely because i can not change the souce code the application.
> >
> > any other possibilies to solve this problem?
> > for all the possibilities, pls tell me what class and method should i
> > use, sample code and website is extremely helpful.
> > thanks a lot!!!!!
- 11
- eclipse doesn't build?
Eclipse doesn't build right now, these seems to be gnome related...
Script started on Thu Apr 14 06:23:31 2005
bsd# make
===> Vulnerability check disabled, database not found
===> Extracting for eclipse-3.0.1_4
=> Checksum OK for eclipse/eclipse-sourceBuild-srcIncluded-3.0.1.zip.
===> eclipse-3.0.1_4 depends on executable: unzip - found
===> Patching for eclipse-3.0.1_4
===> Applying FreeBSD patches for eclipse-3.0.1_4
===> eclipse-3.0.1_4 depends on executable: ant - found
===> eclipse-3.0.1_4 depends on executable: zip - found
===> eclipse-3.0.1_4 depends on executable: unzip - found
===> eclipse-3.0.1_4 depends on executable: mozilla - found
===> eclipse-3.0.1_4 depends on file: /usr/local/jdk1.4.2/bin/java - found
===> eclipse-3.0.1_4 depends on executable: gmake - found
===> eclipse-3.0.1_4 depends on file: /usr/local/bin/intltool-extract - found
===> eclipse-3.0.1_4 depends on file: /usr/X11R6/libdata/pkgconfig/gnome-mime-data-2.0.pc - found
===> eclipse-3.0.1_4 depends on executable: pkg-config - found
===> eclipse-3.0.1_4 depends on shared library: esd.2 - found
===> eclipse-3.0.1_4 depends on shared library: atk-1.0.901 - found
===> eclipse-3.0.1_4 depends on shared library: gconf-2.5 - found
===> eclipse-3.0.1_4 depends on shared library: glib-2.0.600 - found
===> eclipse-3.0.1_4 depends on shared library: gnomevfs-2.1000 - found
===> eclipse-3.0.1_4 depends on shared library: gtk-x11-2.0.600 - found
===> eclipse-3.0.1_4 depends on shared library: art_lgpl_2.5 - found
===> eclipse-3.0.1_4 depends on shared library: bonobo-2.0 - found
===> eclipse-3.0.1_4 depends on shared library: bonoboui-2.0 - found
===> eclipse-3.0.1_4 depends on shared library: glade-2.0.0 - found
===> eclipse-3.0.1_4 depends on shared library: gnome-2.1000 - found
===> eclipse-3.0.1_4 depends on shared library: gnomecanvas-2.1000 - found
===> eclipse-3.0.1_4 depends on shared library: gnomeui-2.1000 - found
===> eclipse-3.0.1_4 depends on shared library: IDL-2.0 - found
===> eclipse-3.0.1_4 depends on shared library: xml2.5 - found
===> eclipse-3.0.1_4 depends on shared library: xslt.2 - found
===> eclipse-3.0.1_4 depends on shared library: linc.1 - found
===> eclipse-3.0.1_4 depends on shared library: ORBit-2.0 - found
===> eclipse-3.0.1_4 depends on shared library: pango-1.0.800 - found
===> Configuring for eclipse-3.0.1_4
Copying plugins/org.eclipse.jface/src/org/eclipse/jface/resource/jfacefonts_linux.properties into plugins/org.eclipse.jface/src/org/eclipse/jface/resource/jfacefonts_freebsd.properties
Copying plugins/org.eclipse.jface/src/org/eclipse/jface/resource/jfacefonts_linux_gtk.properties into plugins/org.eclipse.jface/src/org/eclipse/jface/resource/jfacefonts_freebsd_gtk.properties
Copying plugins/platform-launcher/library/motif/make_linux.mak into plugins/platform-launcher/library/motif/make_freebsd.mak
Copying assemble.org.eclipse.sdk.linux.motif.x86.xml into assemble.org.eclipse.sdk.freebsd.motif.x86.xml
Copying assemble.org.eclipse.sdk.linux.gtk.x86.xml into assemble.org.eclipse.sdk.freebsd.gtk.x86.xml
Copying plugins/org.eclipse.pde.source.linux.gtk.x86 into plugins/org.eclipse.pde.source.freebsd.gtk.x86
Copying plugins/org.eclipse.pde.source.linux.motif.x86 into plugins/org.eclipse.pde.source.freebsd.motif.x86
Copying plugins/org.eclipse.platform.source.linux.motif.x86 into plugins/org.eclipse.platform.source.freebsd.motif.x86
Copying plugins/org.eclipse.swt.motif/os/linux into plugins/org.eclipse.swt.motif/os/freebsd
Copying plugins/org.eclipse.jdt.source.linux.motif.x86 into plugins/org.eclipse.jdt.source.freebsd.motif.x86
Copying plugins/org.eclipse.platform.source.linux.gtk.x86 into plugins/org.eclipse.platform.source.freebsd.gtk.x86
Copying plugins/org.eclipse.jdt.source.linux.gtk.x86 into plugins/org.eclipse.jdt.source.freebsd.gtk.x86
Copying plugins/org.eclipse.update.core.linux into plugins/org.eclipse.update.core.freebsd
Copying plugins/org.eclipse.update.core.linux/os/linux into plugins/org.eclipse.update.core.freebsd/os/freebsd
Copying plugins/org.eclipse.core.resources.linux into plugins/org.eclipse.core.resources.freebsd
Copying plugins/org.eclipse.core.resources.linux/os/linux into plugins/org.eclipse.core.resources.freebsd/os/freebsd
Copying plugins/org.eclipse.swt.gtk/os/linux into plugins/org.eclipse.swt.gtk/os/freebsd
Copying plugins/platform-launcher/bin/linux into plugins/platform-launcher/bin/freebsd
Copying features/org.eclipse.platform/linux.motif into features/org.eclipse.platform/freebsd.motif
===> Building for eclipse-3.0.1_4
===> Building libswt.
cd "plugins/org.eclipse.swt/Eclipse SWT PI/gtk/library" && \
/bin/sh ./build.sh && \
/bin/cp *.so ../../../../org.eclipse.swt.gtk/os/freebsd/x86/
gmake[1]: Entering directory `/usr/ports/java/eclipse/work/plugins/org.eclipse.swt/Eclipse SWT PI/gtk/library'
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic -c swt.c
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic -c callback.c
cc -shared -fpic -o libswt-gtk-3063.so swt.o callback.o
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags gtk+-2.0` -c os.c
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags gtk+-2.0` -c os_structs.c
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags gtk+-2.0` -c os_custom.c
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags gtk+-2.0` -c os_stats.c
cc -shared -fpic `pkg-config --libs gtk+-2.0 gthread-2.0` -L/usr/X11R6/lib -lXtst -o libswt-pi-gtk-3063.so swt.o os.o os_structs.o os_custom.o os_stats.o
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags atk gtk+-2.0` -c atk.c
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags atk gtk+-2.0` -c atk_structs.c
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags atk gtk+-2.0` -c atk_custom.c
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags atk gtk+-2.0` -c atk_stats.c
cc -shared -fpic `pkg-config --libs atk gtk+-2.0` -o libswt-atk-gtk-3063.so swt.o atk.o atk_structs.o atk_custom.o atk_stats.o
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0` -c gnome.c
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0` -c gnome_structs.c
cc -O -Wall -DSWT_VERSION=3063 -DFREEBSD -DGTK -I/usr/local/jdk1.4.2/include -I/usr/local/jdk1.4.2/include/bsd -I/usr/local/jdk1.4.2/include/freebsd -I../../../Eclipse_SWT/common/library -I../../../Eclipse_SWT_PI/gtk/library -I/usr/X11R6/include -fpic `pkg-config --cflags gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0` -c gnome_stats.c
cc -shared -fpic `pkg-config --libs gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0` -o libswt-gnome-gtk-3063.so swt.o gnome.o gnome_structs.o gnome_stats.o
/usr/bin/ld: cannot find -lpopt
gmake[1]: *** [libswt-gnome-gtk-3063.so] Error 1
gmake[1]: Leaving directory `/usr/ports/java/eclipse/work/plugins/org.eclipse.swt/Eclipse SWT PI/gtk/library'
gmake: *** [libswt] Error 2
*** Error code 2
Stop in /usr/ports/java/eclipse.
- 12
- layouts layouts layouts..Andrew Thompson wrote:
> On Fri, 02 Sep 2005 12:09:47 -0400, Frances wrote:
>
> ..
>
>>>- Your button should occupate SOUTH (Looks like you want button to
>>>occupate all available place)
>>
>>no I don't!! that's just how it's coming out, can't figure out how to
>>control size for it (as I said, setSize() is being ignored..
>
>
> 'size' is often ignored, while prefered/minimum/maximum
> are more likely to be honored. Some layouts will ignore
> even the latter in some circumstances, especially like
> BorderLayout.CENTER.
>
>
>>..(I have been wondering, though, about BorderLayout, I
>>don't see WEST in yr post, I've been wondering if it's ok to use
>>BorderLayout if you don't fill all five "corners".. (NORTH, SOUTH,
>>CENTER, EAST, WEST..)
>
>
> Yes. BorderLayout allows 5 components, but can accept less.
great.. thank you Andrew, I really had been wondering about this...
again many thanks Andrew, to you and to all who responded... I got lots
to chew on here for the weekend now...
:)
- 13
- [ANN] Excelsior JET 6.0 (AOT compiler) Supports Java SE 6Excelsior JET (http://www.excelsior-usa.com/jet.html) is a complete
Java SE 6 implementation enhanced with an Ahead-Of-Time (AOT)
compiler. It is certified Java Compatible on a number of Windows and
Linux platforms, including Windows Vista and RHEL 5.
http://www.excelsior-usa.com/jetlatest.html provides full information
on new features and improvements.
http://www.excelsior-usa.com/jetdleval.html has free trial downloads
available (registration is optional.)
http://www.excelsior-usa.com/jetfree.html offers a free license
to authors of non-commercial Java software.
- 14
- developing web browser and email clientHi people...
I am planning to develop a webbrowser and e-mail client..but i haven't
done this work before.
Can you please tell me which language is the best to go ahead with it
? And what are the prerequisites that i need to learn ?
I'll be thankful
Regards
Anupam
I am planning to create a s/w package that'll install both of these..
- 15
- a common yet hard-to-resolved problem for Java GUI size!The Java application GUI (setPreferSize to some hardcoded dimension)
gets smaller when it comes to wide screen (Dell 16:9 laptop), and the
users have to resize the GUI every time they are launched (so as to see
the action buttons). This problem seems to happen only for 16:9 wide
screen so far.
Question:
1. What are the factors deciding the swing (awt) GUI size, besides
resolution and font? Is wide screen really an individual factor?
2. How to formulate a universal good GUI size? Or any examples to
define different sizes for different display-cases?
Thought the following functions might be needed, although I heard that
Toolkit.getScreenResolution() cannot really detect screen resolution.
Toolkit.getScreenResolution(), Toolkit.getScreenSize(), getFontSize()
Any example or information will be highly appreciated!
|
|
|