| How do I finding the current static type? |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Using JMF to build rtsp serverHi, I'd like to know if it's possible to create a server application
that transmits a .rm file through rtsp. I've seen some examples using
AVI and other standard formats, but I'm not sure if this is possible.
Basically what I need is a server which waits for connections and
transmit a .rm file to it. Of course I could use Helix, but I need
something for free. In any case, is there any free alternative?
TIA.
- 1
- SimpleDateFormat problemHi, I'm beating my head against this with no avail.
Can someone tell me why this fails? The parsed date's getTime() has some
extra highorder bits set.
DateFormat df = new SimpleDateFormat("mm:ss:SSS");
String s = df.format(new Date(500));
assertTrue(df.parse(s).equals(new Date(500)));
Thanks!
- 1
- 3
- what did i install wrong?Ive been working on a space invaders game at school, i took it home today,
and tried installing jcreator, upon execution of my game class i got this
error.
http://www.geocities.com/xpirimint/cs3/error.JPG
any help would be apreciated
- 4
- 4
- a question about uploading files...I'm using jakarta.commons.FileUplaod to upload a file and it's working
fine (followed what I read in
http://www.onjava.com/pub/a/onjava/2003/06/25/commons.html?page=3)
only thing I would like to know is, is it possible to upload more than
one file at a time? (I mean is it possible to write code so in "choose
file" dialog you can select more than one file?)
I asked in jakarta.commons listserv (gmane.comp.jakarta.commons.user)
about two days ago, but well, still haven't gotten response (and am not
even sure whether this is strictly a jakarta.commons.FileUpload question
or a general java question..) thank you.. Frances
- 5
- questions about the implications of multiple JFrames using dispose() on closingHi
I've come up against some perplexing questions caused by the creation
of multiple instances of JFrame.
obj is referencing a JButton click. This then loads a FileDialog for
opening an image and displaying it in an extended JFrame called
'ResizeFrame'. JFrame then loads a panel which displays the Image. The
code as it stands allows multiple instances of ResizeFrame.
ResizeFrame basically does most of the work and calls methods to load
the Image - which has been opened in it - to be drawn in ResizePanel.
ResizeFrame is coded to 'dispose' on closing.
What I am trying to understand is what happens when a frame is opened,
then closed, and then a new frame is opened. Does the instance of
ResizeFrame (all named the same) that was initially opened, still
exist, or has it been over-written by the new version.
Am I making a mistake allowing several JFrames to be opened at once? I
know that when a frame is disposed that its claims on screen resourses
are freed up - but if it is still existing even after it has been
disposed it must still be using some memory resources?
Also, what are the implications of having several objects existing with
the same name?
Another thing I've noticed. My ResizeFrame has a method for loading a
panel and then is made visible within ResizeFrame. What I've noticed is
that if I load a ResizeFrame Image, then close it, then open up the
same image file - that the picture will appear much faster than if I
open up a different image. I'm not understanding how this is happening!
I could change my code so that it is only possible to have 1
ResizeFrame open at a time - however this would require a considerable
amount of simplification (i.e. beyond my hackish skills!). I would only
do it if I am convinced that the way I have done things is BAD with a
capital B (which it probably is - but then I am a very inexperienced
programmer).
Thanks for any advice.
Michael
//-----------------------------
if (obj == newdepth) {
File f = loadimage("depth\\", FileDialog.LOAD);
if (!(f == null)) {
File q = new File(f.getParent());
if (q.isDirectory()) {
String w = f.getPath();
p.LoadPic(w);
ResizeFrame jeff = new ResizeFrame((w + " - Depth Map"), new
Color(205, 219, 227), false);
jeff.LoadPic(w);
jeff.addpanel();
}
else {
status.setText("invalid directory");
}
}
}
//--------------------------------
//--I've included the full code for ResizeFrame and ResizePanel hoping
for constructive critism. Also, it might help to make my questions
clearer.
//-----------ResizeFrame----------
import java.awt.*;
import javax.swing.*;
import myroot.frames.*;
import java.awt.event.*;
import java.io.*;
import java.awt.image.*;
import osbaldeston.image.BMP;
public class ResizeFrame extends JFrame implements ImageObserver {
public Image myimage;
public ResizePanel mypanel;
public Color col;
public boolean resizing;
public void LoadPic(String inpic){
myimage = null;
int typepic = getTypePic(inpic);
if (typepic == 1) {
BMP dave = new BMP(new File(inpic));
myimage = dave.getImage();
}
if (typepic == 2) {
myimage = Toolkit.getDefaultToolkit().getImage ( inpic);
}
WaitImage(myimage);
}
public int getTypePic(String in) {
if (in.length() > 4) {
String test = in.substring(in.length() - 4, in.length());
test = test.toLowerCase();
if (test.equals(".bmp")) return 1;
if (test.equals(".gif")|| test.equals(".png") ||
test.equals(".jpg") || test.equals("jpeg")) return 2;
}
return 0;
}
public void WaitImage(Image im) {
boolean wait = true;
wait = ImageUtilities.waitForImage(im, this);
}
public void addpanel() {
if (resizing == true)
setExtendedState(Frame.MAXIMIZED_BOTH);
mypanel = new ResizePanel(myimage, col);
JScrollPane scroller = new JScrollPane(mypanel,
//JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroller.getVerticalScrollBar().setUnitIncrement( 16 );
getContentPane().add(scroller);
if (resizing == false) {
int w;
int h;
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
if ((myimage.getWidth(this) +40) > d.width)
w = d.width;
else
w = myimage.getWidth(this) + 40;
if ((myimage.getHeight(this) +60) > (d.height -30))
h = d.height -30;
else
h = myimage.getHeight(this) + 60;
setSize(w,h);
}
setVisible(true);
//mypanel.repaint();
}
public void setSize(){
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
setSize(d.width, d.height);
}
public ResizeFrame(String title, Color c, boolean res) {
super(title);
resizing = res;
col = c;
if (resizing == true) {
setSize();
}
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE );
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
}
});
}
}
//-------------------------
//---------ResizePanel--------
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
public class ResizePanel extends JPanel{
public Image myimage;
public Color col;
public ResizePanel(Image im, Color c) {
myimage = im;
col = c;
repaint();
}
public Dimension getPreferredSize(){
return (new Dimension(myimage.getWidth(this),
myimage.getHeight(this)));
}
public void paint(Graphics g) {
int h =0, v = 0;
h = (this.getWidth()-myimage.getWidth(this))/2;
v = (this.getHeight()-myimage.getHeight(this))/2;
if (h< 0)
h = 0;
if (v<0) v = 0;
g.setColor(col);
g.fillRect(0,0,this.getWidth(),this.getHeight());
g.drawImage(myimage, h,v, this);
}
}
//--------------------------
- 7
- newbie question: processing large database in chunks?
Hi,
When I
select * from XX
I'm geting an OutOfMemoryError. I'm using JDBC with Mysql,
and calls like:
ResultSet rs = dbc.executeQuery("select * from thetable");
My beginner's question: what's the right way to read and process the
table in chunks, to avoid running out of memory?
Is using LIMIT n1,n2 inside the query the right thing to do, giving
e.g. LIMIT 1,100 followed by another query using LIMIT 101,200, etc?
Is there a more efficient way?
I guess I'm surprised that it's even necessary. I would have thought
that the data would stay on the server until pulled to the client
by resultset.next() and a resultset.getXX(). But evidently
the whole table is being sent to the client??
- 12
- J2EE Log File Monitoring SolutionI would like to build/use a J2EE solution to run on WebLogic 8.1 that will
monitor certain log files, extract data based on certain rules, and to
display them on a webpage.
The solution would probably have a front-end (JSPs/servlet(s)) that
communicates with one or more Servlets to specify the what data needs to be
extracted, and then the front-end would format this.
For example, I may be monitoring the log file from my application server
which may contain Java stack traces, and I may be interested in a particular
exception that occurred. In this case, I would want the front-end to tell me
when the error occurred, and possibly allow me to drill down to see the
relevant section of the log file.
In another case, I would be monitoring an XML file, and I would want to
extract certain bits of information from it, but with the option to extend
the monitoring system to display more pieces of information. I.e. today, I
may be interested in XML elements X,Y and Z, but tomorrow, the format of the
XML may change, and I would want to be able to adjust my front-end to deal
with this.
There will probably be no more than 10 log files being monitored, each of
which will not be more than 50MB. Usually, they will be more around the
1-10MB size. As mentioned, the monitoring system will need to run on
WebLogic 8.1, so any J2EE 1.4 or WebLogic 8.1-specific libraries can be
used.
Can anyone suggest some architectural approaches that could be used to
achieve this? Pointers to tools, libraries etc. would also be useful.
Thanks.
C3
- 12
- pasting images from excel with transparency have a black backgroundHi There,
I've searched on this topic, but have only found an unanswered post
from 2003. Basically, if I copy a chart from excel (well, from a
number of vector based packages it seems) that has transparency, the
resulting image in java has had the transparency replaced with black.
However, if you paste the chart into word, select it and then copy it,
it will paste into java with no problems.
I've searched the java bug database, but have had not luck.
To repeat this, simply create a chart in excel, set it's background to
fill:none and copy the chart. Then run the class below and press the
button.
I am running Office 2002 and using Sun JDK 1.5.07
Any help much appreciated on this as it's driving me nuts.
Thanks,
Brian
=============================================================
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import javax.swing.*;
public class ClipboardTest
{
public static void main(String[] args)
{
try
{
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JLabel label = new JLabel();
label.setPreferredSize(new Dimension(200, 200));
frame.add(label, BorderLayout.CENTER);
JButton button = new JButton("Get Clipboard");
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
Transferable xfer =
Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
label.setIcon(new
ImageIcon((Image)xfer.getTransferData(DataFlavor.imageFlavor)));
}
catch (Exception ex) {}
}
});
frame.add(button, BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
}
catch (Exception e){}
}
}
- 13
- Interesting Java interview questionA friend of mine likes to ask this question when interviewing Java
developers. Thought I'd pass it along because it's sort of interesting.
Why does the following compile, and what does the output look like?
System.out.println(new Object(){{{}}}.toString());
He says he has asked this question of several dozen people, and almost
everyone just stares at it in shock. Only one has answered it
correctly. I wish I had his resume...
dleifker
- 14
- MIDP 1.0: Filled rectanglesHello!
I'm beginning to develop a 3D game for J2ME mobile phones. The obvious
problem is, how to draw filled triangles. I know that in MIDP 2.0 this
can be done easily, and Nokia has an extension to MIDP 1.0 which
allows to draw filled polygons. Now the problem is how to do it in
plain MIDP 1.0 (say, on a Motorola T720 or SonyEricsson T610). I
thought of two solutions:
* Use two or three fillArc() invocations. Each of them would paint an
arc which has a center in one triangle vertex. The arcs can be scaled
so that they cover the whole triangle and never paint outside the
triangle. Or perhaps even one arc can be used which approximates the
triangle well, especially when it's small.
* Divide the triangle into horizontal and vertical lines and draw them
using drawLine().
The second method requires (or at least appears to require) more code,
and uses much more drawing operations than the first, so it seems to
be slower. But on the other hands, perhaps scaling the arc and
painting it would be much time-consuming?
If you have any experience or insight about this problem, I'd be very
grateful.
Regards,
Michau.
- 14
- Including a folder's JAR files in CLASSPATHI have a folder C:\DevPrograms\Hibernate\lib which has 33 JAR files. I want
to include them in my CLASSPATH but not hardcoding the name of the jar
files; instead i want some thing like C:\DevPrograms\Hibernate\lib\*.jar so
that it can pick up all jar. I tried doing it but no success. What other
ways I can do it?
Thanks
- 15
- annoying eclipse automatisms (resource copying)I really like Eclipse as Java editing platform, but now I want to do
the following:
I have a directory with not only self-written Java sources but also
some non-Java source files (namely parser/lexer constructed in
CUP/JLex). From this, I generate Java sources which land in the same
directory. Now when I build this directory from Eclipse it persists in
copying my non-Java sources to the output directory. While this
doesn't exactly cause any malfunction, it does disturb my cleanly
nature ;)
What options would you suggest to keep the structure clean? I think
setting up yet another directory for the CUP/JLex sources would be
rather impractical.
Thanks,
Justin
- 16
- Controlling XML elements orderHi I'm returning an XML to my clients (SOAP). Now I want to order the
items in my XML (I dont want my clients to sort it) is there any API
in DOM that I can use for sorting the elements some way ? or simply
preserving the sort order of that that I added items to the DOM tree?
(I'm adding the items in a sorted way however when I look at the XML
generated its not sorted)
|
| Author |
Message |
benno.baumgartner

|
Posted: 2005-3-30 20:27:00 |
Top |
java-programmer, How do I finding the current static type?
Dear Java Gurus,
I need to find out what the static type (a.k.a. compile time type) of
a given object is at runtime[1]. What I want to achieve is this:
public interface ClassA { public void f(); }
public interface ClassB extends ClassA {}
ClassA classA;
ClassB classB = new ClassBImpl();
classA = classB;
classB.f(); // does something
classA.f(); // does something else
classB and classA are referencing the exact same object and on this
object f() is called but they should not do the same since the static
types are different (ClassA for classA and ClassB for classB).
So, ClassBImpl should look something like:
public class ClassBImpl implements ClassB {
public void f() {
if (
static type in caller of this
is proper subtype of ClassA
) {
//do something
} else {
//do something else
}
}
}
I'm sure you're wondering now why the heck he wants to do something
stupid like that. The reason is that I'm working on a Eiffel to Java
compiler at the moment and there are situations where the f() from
ClassA denotes a completely different method as the f() in ClassB,
they just have the same signature. I can't convince Java that they are
not the same and Java does therefore always bind dynamically to the
most recent implementation which may be the wrong one in some cases.
I'm thinking about this problem like for two weeks now and I'm
completely stuck. You'll make my month if you have any idea how to
solve it no matter how far fetched the idea may be.
Thanks for your time,
Benno
[1] I know, objects do not have a static type, what I mean is the type
of the last variable that was referencing that object.
|
| |
|
| |
 |
Marcin Grunwald

|
Posted: 2005-3-30 21:14:00 |
Top |
java-programmer >> How do I finding the current static type?
Benno wrote:
> Dear Java Gurus,
>
> I need to find out what the static type (a.k.a. compile time type) of
> a given object is at runtime[1]. What I want to achieve is this:
>
> public interface ClassA { public void f(); }
> public interface ClassB extends ClassA {}
>
> ClassA classA;
> ClassB classB = new ClassBImpl();
> classA = classB;
> classB.f(); // does something
> classA.f(); // does something else
>
> classB and classA are referencing the exact same object and on this
> object f() is called but they should not do the same since the static
> types are different (ClassA for classA and ClassB for classB).
> So, ClassBImpl should look something like:
>
> public class ClassBImpl implements ClassB {
>
> public void f() {
> if (
> static type in caller of this
> is proper subtype of ClassA
> ) {
> //do something
> } else {
> //do something else
> }
> }
> }
>
> I'm sure you're wondering now why the heck he wants to do something
> stupid like that. The reason is that I'm working on a Eiffel to Java
> compiler at the moment and there are situations where the f() from
> ClassA denotes a completely different method as the f() in ClassB,
> they just have the same signature. I can't convince Java that they are
> not the same and Java does therefore always bind dynamically to the
> most recent implementation which may be the wrong one in some cases.
> I'm thinking about this problem like for two weeks now and I'm
> completely stuck. You'll make my month if you have any idea how to
> solve it no matter how far fetched the idea may be.
>
> Thanks for your time,
> Benno
>
> [1] I know, objects do not have a static type, what I mean is the type
> of the last variable that was referencing that object.
You can't do something like that. You call method on object, type of
reference to that object doesn't matter.
I assume that you generate Java code from Eiffel so maybe try to generate
something little different:
public class ClassA { public static void f(ClassA obj) {} }
public class ClassB extends ClassA { public static void f(ClassB obj) {} }
ClassB classB = new ClassB();
ClassB.f(classB); // does something
ClassA.f(classB); // does something else
The same object (classB) and 2 different methods (ClassB.f(), ClassA.f()).
Cheers
grundig
|
| |
|
| |
 |
Patricia Shanahan

|
Posted: 2005-3-30 21:55:00 |
Top |
java-programmer >> How do I finding the current static type?
Benno wrote:
> I'm sure you're wondering now why the heck he wants to do
> something stupid like that. The reason is that I'm
> working on a Eiffel to Java compiler at the moment and
> there are situations where the f() from ClassA denotes a
> completely different method as the f() in ClassB, they
> just have the same signature. I can't convince Java that
> they are not the same and Java does therefore always bind
> dynamically to the most recent implementation which may
> be the wrong one in some cases. I'm thinking about this
> problem like for two weeks now and I'm completely stuck.
> You'll make my month if you have any idea how to solve it
> no matter how far fetched the idea may be.
The usual approach to this type of problem is to encode the
distinction in the method's identifier. That was, for
example, how C++ to C translators dealt with overloaded
function names in C++.
Patricia
|
| |
|
| |
 |
John C. Bollinger

|
Posted: 2005-3-30 22:51:00 |
Top |
java-programmer >> How do I finding the current static type?
Benno wrote:
> Dear Java Gurus,
>
> I need to find out what the static type (a.k.a. compile time type) of
> a given object is at runtime[1].
[moved up from later in the original post:]
> [1] I know, objects do not have a static type, what I mean is the type
> of the last variable that was referencing that object.
That is not an adequate definition of the property you want. There may
be multiple copies of the reference stored in variables of different
declared types at the same time.
> What I want to achieve is this:
>
> public interface ClassA { public void f(); }
> public interface ClassB extends ClassA {}
>
> ClassA classA;
> ClassB classB = new ClassBImpl();
> classA = classB;
> classB.f(); // does something
> classA.f(); // does something else
>
> classB and classA are referencing the exact same object and on this
> object f() is called but they should not do the same since the static
> types are different (ClassA for classA and ClassB for classB).
It looks like what you really want is to choose a method to invoke based
on the type of a reference-type expression. You cannot achieve this
with virtual methods -- that's the whole point of them -- and all
non-static, non-private methods in Java are virtual.
[...]
> I'm sure you're wondering now why the heck he wants to do something
> stupid like that.
Yes, as a matter of fact I do.
> The reason is that I'm working on a Eiffel to Java
> compiler at the moment and there are situations where the f() from
> ClassA denotes a completely different method as the f() in ClassB,
> they just have the same signature. I can't convince Java that they are
> not the same and Java does therefore always bind dynamically to the
> most recent implementation which may be the wrong one in some cases.
It sounds like you are trying to convert Eiffel code into equivalent
Java code. I'd call software that performed that feat a "translator"
rather than a "compiler", but no matter. I know as much about Eiffel as
I was able to glean from ten minutes' study of this introduction:
http://archive.eiffel.com/doc/online/eiffel50/intro/language/invitation-00.html.
Nevertheless, I observe that Eiffel has static typing and dynamic
binding, just like Java. My only guess, then, as to why you want to do
what you asked is Eiffel's "feature renaming" ... err ... feature. But
this is not the only problem you have to overcome with class definition
and method dispatch, because Eiffel supports multiple inheritance of
implementation, whereas Java does not.
> I'm thinking about this problem like for two weeks now and I'm
> completely stuck. You'll make my month if you have any idea how to
> solve it no matter how far fetched the idea may be.
You could use Java's static selection of method signatures to your
advantage here. Here's an example:
class ClassA { ... }
class ClassB extends ClassA {...}
class Foo {
void doSomething(ClassA arg) {
}
void doSomething(ClassB arg) {
}
void doIt() {
ClassB thingB = new ClassB();
ClassA thingA = thingB;
doSomething(thingB); // uses doSomething(ClassB)
doSomething(thingA); // uses doSomething(ClassA)
}
}
I don't think that gets you anywhere near where you need to be, however.
Given the inheritance and method name issues that present themselves,
I think you're going to need to provide your own method dispatch
mechanism, and possibly your own Java metaclass to represent Eiffel
classes. You are unlikely to be successful in an attempt to convert
arbitrary Eiffel classes directly into Java classes.
--
John Bollinger
email***@***.com
|
| |
|
| |
 |
P.Hill

|
Posted: 2005-3-31 4:05:00 |
Top |
java-programmer >> How do I finding the current static type?
Benno wrote:
> public class ClassBImpl implements ClassB {
>
> public void f() {
> if (
> static type in caller of this
> is proper subtype of ClassA
> ) {
> //do something
> } else {
> //do something else
> }
Say what? This doesn't seem to match the verbal description
above. In Java since it is strongly typed, the reference in
the caller is always some subtype of ClassA "do something" is the only
path possible.
-Paul
|
| |
|
| |
 |
P.Hill

|
Posted: 2005-3-31 6:36:00 |
Top |
java-programmer >> How do I finding the current static type?
Benno wrote:
> Dear Java Gurus,
> there are situations where the f() from
> ClassA denotes a completely different method as the f() in ClassB,
> they just have the same signature. I can't convince Java that they are
> not the same and Java does therefore always bind dynamically to the
> most recent implementation which may be the wrong one in some cases.
So, if the static analysis can determine the special situation where
you DONT want polymorphism and Java only has polymorphism, then you need
to munge the code to provide a different entry point for that special
case and use that different entry point when your code analysis says
you should.
So I have done the following:
1. Leave interfaces A and B the same (but dropping the "Class" from an
interface, that is just confusing, give it up!)
2. provided an implementation hook in the implementation of
AImpl and BImpl to get to each implementation:
a. used Patricia's suggestion of some type of name mangling
AND alternatively
b. used John's suggestion of
"use Java's static selection of method signatures"
then I can implement the following class which
public class OneThingAnother {
public static void main(String[] args) {
A a;
B b = new BImpl();
a = b;
((BImpl)b).fFromB(); // does something
((AImpl)a).fFromA(); // does something else
BImpl.f( b ); // does something
AImpl.f( a ); // does something else
}
}
Produces:
does something
does something else
does something
does something else
So I have invented two ways to do the same thing,
both of which contain a cast. Both are trivially
automatable transformations of the original code.
The trick is that all of these 'side door' methods
must have unique names in each Impl class, so they
don't get overwritten and these new methods need to be
able to get to the actual body regardless of overloaded
behavior, therefore, the real f() method and all of these special side
door methods all call a _private_ instance method fImpl(). We can't just
make fImpl public and call it, because it would become polymorphically
overridden at each level leaving us back in the same place we were
before if we had placed our implementation in f() and overrode it.
So if we want:
1. f() to be polymorhic and overridable
2. be able to insert some trick code to get a caller
to one particular implementation of f(),
3. A (super) doesn't know about B (Sub) in any of the interfaces or
classes.
My code uses classes of the form:
public class BImpl extends AImpl implements B {
/**
* Choice 1: Static entry to get to the implementation of f()
*/
public static void f( B b ) {
((BImpl)b).fImplB();
}
/**
* Choice 2: Dynamic name mangled entry to get to the implemenation
of f();
*
*/
public void fFromB() {
fImplB();
}
/**
* User entry point to f()
*/
public void f() {
fImplB();
}
/**
* The actual working body of f()
*/
private void fImplB() {
System.out.println( "does something");
}
}
The AImpl:
public class AImpl implements A {
public static void f( A a ) {
((AImpl)a).fImplA();
}
public void fFromA() {
fImplA();
}
public void f() {
fImplA();
}
private void fImplA() {
System.out.println( "does something else");
}
}
I'm assuming any class caste exceptions can be eliminated
at code analysis time of the calling class.
I'd be interested in what the Eiffel rules are
that cause some code to pick the none polymorphic
behavior.
Does anyone have any comments about the might be
the development impact, if I dropped the private method
and put the body in fFromA (and simply called it fA())?
Also, from the little I know AspectJ, this static analysis and
insertion sounds like a perfect job for AspectJ, but it
relies on specifying the right 'cut' when the
non-polymorphic should happen and I assume I can
move (rename?) an existing F() body to another method,
fImpl using AspectJ, but maybe that's a fantasy.
-Paul
|
| |
|
| |
 |
benno.baumgartner

|
Posted: 2005-3-31 22:44:00 |
Top |
java-programmer >> How do I finding the current static type?
"P.Hill" <email***@***.com> wrote in message news:<d2f9kr$hfe$email***@***.com>...
> Benno wrote:
> > Dear Java Gurus,
>
> > there are situations where the f() from
> > ClassA denotes a completely different method as the f() in ClassB,
> > they just have the same signature. I can't convince Java that they are
> > not the same and Java does therefore always bind dynamically to the
> > most recent implementation which may be the wrong one in some cases.
>
> So, if the static analysis can determine the special situation where
> you DONT want polymorphism and Java only has polymorphism, then you need
> to munge the code to provide a different entry point for that special
> case and use that different entry point when your code analysis says
> you should.
> So I have done the following:
> 1. Leave interfaces A and B the same (but dropping the "Class" from an
> interface, that is just confusing, give it up!)
> 2. provided an implementation hook in the implementation of
> AImpl and BImpl to get to each implementation:
> a. used Patricia's suggestion of some type of name mangling
> AND alternatively
> b. used John's suggestion of
> "use Java's static selection of method signatures"
> then I can implement the following class which
>
> public class OneThingAnother {
> public static void main(String[] args) {
> A a;
> B b = new BImpl();
> a = b;
>
> ((BImpl)b).fFromB(); // does something
> ((AImpl)a).fFromA(); // does something else
>
> BImpl.f( b ); // does something
> AImpl.f( a ); // does something else
> }
> }
>
> Produces:
> does something
> does something else
> does something
> does something else
>
> So I have invented two ways to do the same thing,
> both of which contain a cast. Both are trivially
> automatable transformations of the original code.
>
> The trick is that all of these 'side door' methods
> must have unique names in each Impl class, so they
> don't get overwritten and these new methods need to be
> able to get to the actual body regardless of overloaded
> behavior, therefore, the real f() method and all of these special side
> door methods all call a _private_ instance method fImpl(). We can't just
> make fImpl public and call it, because it would become polymorphically
> overridden at each level leaving us back in the same place we were
> before if we had placed our implementation in f() and overrode it.
I can't inherit from AImpl in BImpl since I want to model multiple
inheritance. But of course name mangeling is a solution, but not a
nice one. Because the user of the generated Classes has to decide
which name denotes the right implementation in his situation, and in
Eiffel he does not have to think about that, the runtime chooses the
right implementation.
>
> So if we want:
> 1. f() to be polymorhic and overridable
> 2. be able to insert some trick code to get a caller
> to one particular implementation of f(),
> 3. A (super) doesn't know about B (Sub) in any of the interfaces or
> classes.
>
> My code uses classes of the form:
>
> public class BImpl extends AImpl implements B {
> /**
> * Choice 1: Static entry to get to the implementation of f()
> */
> public static void f( B b ) {
> ((BImpl)b).fImplB();
> }
>
> /**
> * Choice 2: Dynamic name mangled entry to get to the implemenation
> of f();
> *
> */
> public void fFromB() {
> fImplB();
> }
>
> /**
> * User entry point to f()
> */
> public void f() {
> fImplB();
> }
>
> /**
> * The actual working body of f()
> */
> private void fImplB() {
> System.out.println( "does something");
> }
> }
>
>
> The AImpl:
>
> public class AImpl implements A {
> public static void f( A a ) {
> ((AImpl)a).fImplA();
> }
>
> public void fFromA() {
> fImplA();
> }
>
> public void f() {
> fImplA();
> }
>
> private void fImplA() {
> System.out.println( "does something else");
> }
> }
>
> I'm assuming any class caste exceptions can be eliminated
> at code analysis time of the calling class.
>
> I'd be interested in what the Eiffel rules are
> that cause some code to pick the none polymorphic
> behavior.
See:
http://n.ethz.ch/student/bebaumga/secours/cowboy.pdf
for an example. If this example can be translated to Java (without
name mangling and the use of static) then I'll be fine. But I guess it
is realy not possible.
So as I see it I can either:
1. Use name mangling (maybe in combination with the static approach to
make it a bit more usable)
2. Extend the Java runtime and compile to a non standart JVM (belive
me: I will not do that)
>
> Does anyone have any comments about the might be
> the development impact, if I dropped the private method
> and put the body in fFromA (and simply called it fA())?
>
> Also, from the little I know AspectJ, this static analysis and
> insertion sounds like a perfect job for AspectJ, but it
> relies on specifying the right 'cut' when the
> non-polymorphic should happen and I assume I can
> move (rename?) an existing F() body to another method,
> fImpl using AspectJ, but maybe that's a fantasy.
I had a quick look at the introduction at:
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/progguide/starting-aspectj.html
And it sounds promising. One can do something like multible
subclassing with AspectJ. I will investigate that further and keep you
informed if I find something usefull.
Benno
>
> -Paul
|
| |
|
| |
 |
P.Hill

|
Posted: 2005-4-1 3:36:00 |
Top |
java-programmer >> How do I finding the current static type?
> See:
> http://n.ethz.ch/student/bebaumga/secours/cowboy.pdf
> for an example. If this example can be translated to Java (without
> name mangling and the use of static) then I'll be fine. But I guess it
> is realy not possible.
Sorry, but since you have the change something. After all you are going
from one language to another, I'm not sure I understand your concern
about introducing new methods.
p i c t u r e s : LINKED LIST[PICTURE]
p i c t u r e s . extend ( a cowboy )
So what implementation of Picture is this supposed to be placed
in pictures when all you are providing is a Cowboy?
If the null arg constructor is sufficient then here is my solution:
1. generate an Eiffel-like substitute for a caste on multiple inherited
methods with rename using composite objects.
2. generate appropriate code for "rename draw as draw weapon"
public interface Cowboy {
void draw();
}
public class CowboyImpl extends EiffelObject implements Cowboy {
public void draw() {
System.out.println( "Draw Weapon");
}
}
where EiffelObject is:
class EiffelObject {
EiffelObject caste(Class clazz) {
// maybe this eactly right, since we might be dealing with
// subclass of Clazz
if ( this.getClass() == clazz ) {
return this;
}
throw new ClassCastException();
}
}
SIMILARLY FOR Picture and PictureImpl
Okay, so far all we've introduced is EiffelObject.
So here is the definition of CowboyPicture and its Impl
public interface CowboyPicture extends Picture {
void drawGun(); // Eiffel: rename draw as draw weapon
}
public class CowboyPictureImpl extends PictureImpl implements
CowboyPicture, Picture {
Cowboy c;
Picture p;
CowboyPictureImpl( Cowboy ac, Picture ap ) {
this.c = ac;
this.p = ap;
}
CowboyPictureImpl( Cowboy ac ) {
this( ac, new PictureImpl() );
}
CowboyPictureImpl( PictureImpl ap ) {
this( new CowboyImpl(), ap );
}
CowboyPictureImpl() {
this( new CowboyImpl(), new PictureImpl() );
}
// Eiffel: rename draw as draw weapon
public void drawGun() {
c.draw();
}
EiffelObject caste( Class clazz ) {
if ( clazz == Cowboy.class ) {
return (EiffelObject)c;
} if ( clazz == Picture.class ) {
return (EiffelObject)p;
}
throw new ClassCastException();
}
}
And now the code the is equivalent to
http://n.ethz.ch/student/bebaumga/secours/cowboy.pdf
page 23
public class Try {
public static void main(String[] args) {
CowboyPicture a_cowboy = new CowboyPictureImpl();
a_cowboy.draw();
// I'm not going to implement the generics version, so let's
try old fashion
// untyped with casts
LinkedList cowboys = new LinkedList();
LinkedList pictures = new LinkedList();
cowboys.add( a_cowboy );
Cowboy c = (Cowboy)((EiffelObject)(cowboys.get( 0 ))).caste(
Cowboy.class );
c.draw();
pictures.add( a_cowboy );
Picture p = (Picture)((EiffelObject)(pictures.get( 0 ))).caste(
Picture.class );
p.draw();
}
}
Using 1.5 Generics with our own Collection we could clean up the get
and make it,
Picture p = pictures.get( 0 );
but the operation would be equivalent down the replacement get method.
but I don't currently have a 1.5 installed.
-Paul
|
| |
|
| |
 |
P.Hill

|
Posted: 2005-4-1 3:40:00 |
Top |
java-programmer >> How do I finding the current static type?
P.Hill wrote:
>
But instead of using my delegation solution, you might want to
consider Mjava which was recently mentioned in this same newsgroup.
http://music.dsi.unifi.it/abstracts/multipinh-abs.html
-Paul
|
| |
|
| |
 |
benno.baumgartner

|
Posted: 2005-4-4 17:45:00 |
Top |
java-programmer >> How do I finding the current static type?
"P.Hill" <email***@***.com> wrote in message news:<d2hjfs$6k7$email***@***.com>...
> > See:
> > http://n.ethz.ch/student/bebaumga/secours/cowboy.pdf
> > for an example. If this example can be translated to Java (without
> > name mangling and the use of static) then I'll be fine. But I guess it
> > is realy not possible.
>
>
> Sorry, but since you have the change something. After all you are going
> from one language to another, I'm not sure I understand your concern
> about introducing new methods.
I want to make it as easy to use as possible for the user. If the user
sees routines in a class like Af(), Bf(), Cf(), DCf()... which one
should he call? Which one is the right one in his situation? He has to
think realy hard about it each time he calls a routine.
>
> p i c t u r e s : LINKED LIST[PICTURE]
> p i c t u r e s . extend ( a cowboy )
>
> So what implementation of Picture is this supposed to be placed
> in pictures when all you are providing is a Cowboy?
>
> If the null arg constructor is sufficient then here is my solution:
> 1. generate an Eiffel-like substitute for a caste on multiple inherited
> methods with rename using composite objects.
> 2. generate appropriate code for "rename draw as draw weapon"
>
> public interface Cowboy {
> void draw();
> }
> public class CowboyImpl extends EiffelObject implements Cowboy {
> public void draw() {
> System.out.println( "Draw Weapon");
> }
> }
> where EiffelObject is:
> class EiffelObject {
> EiffelObject caste(Class clazz) {
> // maybe this eactly right, since we might be dealing with
> // subclass of Clazz
> if ( this.getClass() == clazz ) {
> return this;
> }
> throw new ClassCastException();
> }
>
> }
> SIMILARLY FOR Picture and PictureImpl
>
> Okay, so far all we've introduced is EiffelObject.
>
> So here is the definition of CowboyPicture and its Impl
> public interface CowboyPicture extends Picture {
> void drawGun(); // Eiffel: rename draw as draw weapon
> }
>
> public class CowboyPictureImpl extends PictureImpl implements
> CowboyPicture, Picture {
> Cowboy c;
> Picture p;
>
> CowboyPictureImpl( Cowboy ac, Picture ap ) {
> this.c = ac;
> this.p = ap;
> }
>
> CowboyPictureImpl( Cowboy ac ) {
> this( ac, new PictureImpl() );
> }
>
> CowboyPictureImpl( PictureImpl ap ) {
> this( new CowboyImpl(), ap );
> }
>
> CowboyPictureImpl() {
> this( new CowboyImpl(), new PictureImpl() );
> }
>
> // Eiffel: rename draw as draw weapon
> public void drawGun() {
> c.draw();
> }
>
> EiffelObject caste( Class clazz ) {
> if ( clazz == Cowboy.class ) {
> return (EiffelObject)c;
> } if ( clazz == Picture.class ) {
> return (EiffelObject)p;
> }
> throw new ClassCastException();
> }
> }
>
> And now the code the is equivalent to
> http://n.ethz.ch/student/bebaumga/secours/cowboy.pdf
> page 23
>
> public class Try {
> public static void main(String[] args) {
>
>
> CowboyPicture a_cowboy = new CowboyPictureImpl();
>
> a_cowboy.draw();
>
> // I'm not going to implement the generics version, so let's
> try old fashion
> // untyped with casts
>
> LinkedList cowboys = new LinkedList();
> LinkedList pictures = new LinkedList();
> cowboys.add( a_cowboy );
> Cowboy c = (Cowboy)((EiffelObject)(cowboys.get( 0 ))).caste(
> Cowboy.class );
> c.draw();
>
> pictures.add( a_cowboy );
> Picture p = (Picture)((EiffelObject)(pictures.get( 0 ))).caste(
> Picture.class );
> p.draw();
> }
> }
>
>
> Using 1.5 Generics with our own Collection we could clean up the get
> and make it,
>
> Picture p = pictures.get( 0 );
>
> but the operation would be equivalent down the replacement get method.
>
> but I don't currently have a 1.5 installed.
>
> -Paul
"Casting" to the implementation object is a very interesting idea.
What do you think about something like:
public interface A {
public void f();
public Object downcast();
}
public class AImpl implements A {
private Object child;
public AImpl(Object child) {this.child = child;}
public void f() {System.out.println("Af");}
public Object downcast() {return child;}
}
public interface B extends A {
//rename f as g
//defines new f
public void g();
//"Casts"
public A asA();
}
public class BImpl implements B {
private AImpl aDelegate = new AImpl(this);
public void g() {aDelegate.f();}
public void f() {System.out.println("Bf");}
//"Casts"
public A asA() {return aDelegate;}
public Object downcast() {return null;}
}
And then use it like:
public static void main(String[] args) {
A a;
B b = new BImpl();
a = b.asA();
//a = b; valid but incorrect code
b.f(); //Bf
a.f(); //Af
b = (B) a.downcast();
b.f(); //Bf
}
If the user does the assignment right then it will work.
Benno
|
| |
|
| |
 |
P.Hill

|
Posted: 2005-4-5 1:38:00 |
Top |
java-programmer >> How do I finding the current static type?
Benno wrote:
> "P.Hill" <email***@***.com> wrote in message news:<d2hjfs$6k7$email***@***.com>...
> I want to make it as easy to use as possible for the user. If the user
> sees routines in a class like Af(), Bf(), Cf(), DCf()... which one
> should he call? Which one is the right one in his situation? He has to
> think realy hard about it each time he calls a routine.
No he just calls f() (or draw in our case).
I am confised by your excessively generic naming.
> "Casting" to the implementation object is a very interesting idea.
> What do you think about something like:
It looks very simliar to my solution using delegation.
> public interface B extends A {
> //rename f as g
> //defines new f
> public void g();
>
> //"Casts"
> public A asA();
> }
>
> public class BImpl implements B {
>
> private AImpl aDelegate = new AImpl(this);
>
> public void g() {aDelegate.f();}
> public void f() {System.out.println("Bf");}
>
> //"Casts"
> public A asA() {return aDelegate;}
> public Object downcast() {return null;}
> }
>
> And then use it like:
>
> public static void main(String[] args) {
> A a;
> B b = new BImpl();
> a = b.asA();
> //a = b; valid but incorrect code
It seems to me that you have confused yourself with overly
generic names. If A is a icture and B is a Cowboy
then
a = b
a.draw() get you picture.draw(), which is what I want if
I saw:
Picture a = b;
> b.f(); //Bf
> a.f(); //Af
>
> b = (B) a.downcast();
> b.f(); //Bf
> }
>
> If the user does the assignment right then it will work.
Yes, including in the case you were worried about.
-Paul
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- How to load a resource from an external jarIf a jar file exists in the classpath, how can I load a resource from
that external jar? Is it different from
"this.getClass().getClassLoader().getResource"?
Thanks in advance!
- 2
- Trouble with the driver and classes that work with the driver.this first part is the driver. need help with getting them both to work
with each other.
import java.util.Scanner;
public class AbbreviationsandStates
{
public static void main(String[] args)
{
String abbreIn;
String abbreOut;
String theResult;
EnterState es = new EnterState();
System.out.println("Enter Abbreviation the for the State : ");
Scanner in = new Scanner(System.in); //Instantiate Scanner
abbreIn = in.nextLine();
abbreOut = es.getAbbre(abbreIn);
theResult = es.getResult(abbreIn, abbreOut);
System.out.println(theResult);
}
}
this part is the class not sure what I am doing wrong but I do know that I
can not have an int for a string in the driver.
public class EnterState
{
public String getAbbre(String userInput)
{
userInput = userInput;
return userInput;
}
public int getResults(int abbre1, int abbre2)
{
String theResult;
switch (abbre1)
{
case 'A': case 'a':
switch (abbre2)
{
case 'L': case 'l':
System.out.print("Alabama");
break;
case 'K': case 'k':
System.out.print("Alaska");
break;
case 'Z': case 'z':
System.out.print("Arizona");
break;
case 'R': case 'r':
System.out.print("Arkansas");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'C': case 'c':
switch (abbre2)
{
case 'A': case 'a':
System.out.print("California");
break;
case 'O': case 'o':
System.out.print("Colorado");
break;
case 'T': case 't':
System.out.print("Connecticut");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'D': case 'd':
switch (abbre2)
{
case 'E': case 'e':
System.out.print("Delaware");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'F': case 'f':
switch (abbre2)
{
case 'L': case 'l':
System.out.print("Florida");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'G': case 'g':
switch (abbre2)
{
case 'A': case 'a':
System.out.print("Georgia");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'H': case 'h':
switch (abbre2)
{
case 'I': case 'i':
System.out.print("Hawaii");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'I': case 'i':
switch (abbre2)
{
case 'D': case'd':
System.out.print("Idaho");
break;
case 'L': case 'l':
System.out.print("Illinois");
break;
case 'N': case 'n':
System.out.print("Indiana");
break;
case 'A': case 'a':
System.out.print("Iowa");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'K': case 'k':
switch (abbre2)
{
case 'S': case 's':
System.out.print("Kansas");
break;
case 'Y': case 'y':
System.out.print("Kentucky");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'L': case 'l':
switch (abbre2)
{
case 'A': case 'a':
System.out.print("Louisiana");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'M':
switch (abbre2)
{
case 'E':
System.out.print("Maine");
break;
case 'D':
System.out.print("Maryland");
break;
case 'A':
System.out.print("Massachusetts");
break;
case 'I':
System.out.print("Michigan");
break;
case 'N':
System.out.print("Minnesota");
break;
case 'S':
System.out.print("Mississippi");
break;
case 'O':
System.out.print("Missouri");
break;
case 'T':
System.out.print("Montana");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'N':
switch (abbre2)
{
case 'E':
System.out.print ("Nebraska");
break;
case 'V':
System.out.print("Nevada");
break;
case 'H':
System.out.print("New Hampshire");
break;
case 'J':
System.out.print("New Jersey");
break;
case 'M':
System.out.print("New Mexico");
break;
case 'Y':
System.out.print("New York");
break;
case 'C':
System.out.print("North Carolina");
break;
case 'D':
System.out.print("North Dakota");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'O':
switch (abbre2)
{
case 'H':
System.out.print("Ohio");
break;
case 'K':
System.out.print("Oklahoma");
break;
case 'R':
System.out.print("Oregon");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'P':
switch (abbre2)
{
case 'A':
System.out.print("Pennsylvania");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'R':
switch (abbre2)
{
case 'I':
System.out.print("Rhode Island");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'S':
switch (abbre2)
{
case 'C':
System.out.print("South Carolina");
break;
case 'D':
System.out.print("South Dakota");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'T':
switch (abbre2)
{
case 'N':
System.out.print("Tennessee");
break;
case 'X':
System.out.print("Texas");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'U':
switch (abbre2)
{
case 'T':
System.out.print("Utah");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'V':
switch (abbre2)
{
case 'T':
System.out.print("Vermont");
break;
case 'A':
System.out.print("Virginia");
break;
default:
System.out.print("Invalid");
break;
}
break;
case 'W':
switch (abbre2)
{
case 'A':
System.out.print("Washington");
break;
case 'V':
System.out.print("West Virginia");
break;
case 'I':
System.out.print("Wisconsin");
break;
case 'Y':
System.out.print("Wyoming");
break;
default:
System.out.print("Invalid");
break;
}
break;
default:
System.out.print("Invalid");
break;
}
theResult = abbre1 + abbre2 + " The State is" ;
return theResult;
}
}
- 3
- Eclipse - background processes?Hi,
When I use Eclipse, there seem to be a lot of java.exe background
processes that are created when I run programs from the compiler. But
these background processes are not stopped when the programs are
stopped. Would anyone know how to stop these background processes?
Thanks,
Gil
- 4
- Export HTML table inside JSP to Excel using JavaWhen I generate this table inside this JSP page, it will offer a
button for user to click if he/she decides to export the HTML table
into an Excel sheet (which get displayed directly back in the
browser), then user can save his/her this Excel spreadsheet into his/
her local file system.
Can someone help me on how I can convert this HTML table to Excel
using XSLT? Sample code would really help also, if there's any URL to
refer me to.
Is it a good idea to generate the Excel file (as temporary file which
to be sent back to browser later if user click the button) at the same
time when the HTML table get generated? Then remove this temporary
Excel file later.
Any comments? Thanks,
Jimmy
- 5
- objects (newbie)I learnt to program in the top down procedural system (assembly). Knowing
when to create a new function was easy. If you kept repeating the same task
then you needed to put it in a subroutine. But I'm a bit confused by all
these classes in Java. What criteria should I use to decide to create a new
class instead of just add a method to my existing class. I can see me
writting code thats basically one big class with lots of methods. I know I
should break it up into smaller classes but cant tell what criteria to use.
Can anyone recommend a book or url for an object orientated approach to
programming?
Thanks in advance
- 6
- help my first java programThis is my first attempt at java
here it is
public class Welcome {
public static void main(String[] args){
System.out.println("Welcome to java");
}
}
however when i compile it i get this error
C:\Java>javac Test.java
Test.java:3: package system does not exist
system.out.println("This is a test");
^
1 error
what am i doing wrong
- 7
- Unable to start tomcat serverHi All,
I'm doing tomcat configuration for the first time. I'm unable to start
tomat server.
What are the mandatory configuration steps.
It populated following error
EmbededTomcat: error creating module
org.apache.tomcat.modules.config.PathSetter
java.lang.ClassNotFoundException:
org.apache.tomcat.modules.config.PathSetter
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at
java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:575)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at
org.apache.tomcat.startup.EmbededTomcat.createModule(EmbededTomcat.java:
1062)
at
org.apache.tomcat.startup.EmbededTomcat.addModule(EmbededTomcat.java:
391)
at
org.apache.tomcat.startup.EmbededTomcat.addServerXmlModules(EmbededTomcat.java:
434)
at
org.apache.tomcat.startup.EmbededTomcat.addDefaultModules(EmbededTomcat.java:
455)
at
org.apache.tomcat.startup.EmbededTomcat.initContextManager(EmbededTomcat.java:
598)
at
org.apache.tomcat.startup.EmbededTomcat.execute1(EmbededTomcat.java:
791)
at org.apache.tomcat.startup.EmbededTomcat
$1.run(EmbededTomcat.java:775)
at org.apache.tomcat.util.compat.Jdk12Support
$PrivilegedProxy.run(Jdk12Support.java:166)
at java.security.AccessController.doPrivileged(Native Method)
at
org.apache.tomcat.util.compat.Jdk12Support.doPrivileged(Jdk12Support.java:
76)
at
org.apache.tomcat.startup.EmbededTomcat.execute(EmbededTomcat.java:
773)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.tomcat.util.IntrospectionUtils.execute(IntrospectionUtils.java:
52)
at org.apache.tomcat.startup.Main.execute(Main.java:272)
at org.apache.tomcat.startup.Main.main(Main.java:98)
EmbededTomcat: exception initializing ContextManager
Thanks in advance
Regards,
Jagadeesh Tata
- 8
- video lectures on C, C++, Java and other programming and Computer science.Hi Friends,
Check here http://freevideolectures.com/computerscience.html for
video lectures on Programming languages like C, C++, Java, COBOL
etc.., OS, Algorithms, Data Structures, RDBMS,
Web designing, etc..........
It also has amazing collection of video lectures and animations on all
Engineering and Medical Sciences. I am sure you will be surprised to
see such great collection.
Do you like it???
- 9
- Working with JFrameI Have The Following code to measure how far the mouse has move I can get it
to work for JApplet But not for JFrame how can I get it to work for JFrame?
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Odometer extends JApplet implements MouseMotionListener,
ActionListener
{
private int td=0;
private int last_x=0;
private int last_y=0;
private Graphics g;
private JPanel extra=new JPanel();
private JButton btn=new JButton("Reset");
private JLabel lbl=new JLabel("");
private JTextField txt=new JTextField(10);
private Container c = getContentPane();
public void init()
{
btn.addActionListener(this);
extra.add(btn);
extra.add(txt);
extra.add(lbl);
c.add(extra);
this.addMouseMotionListener(this);
}
public void mouseMoved(MouseEvent e)
{
double ld=0;
String str;
int x;
int y;
x=e.getX();
y=e.getY();
ld=Math.sqrt((Math.pow(x-last_x,2))+(Math.pow(y-last_y,2)));
str=Double.toString(ld);
td=td+Double.valueOf(str).intValue();
txt.setText(Integer.toString(td));
last_x=x;
last_y=y;
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn)
{
td=0;
txt.setText(Integer.toString(td));
}
}
public void mouseDragged(MouseEvent e){}
}
- 10
- set vm-parameter when converting to jar?!Hello,
I have an application in jbuilder and want to make it into jar file.
my application as an vm-parameter and appearently when i make this jar file
the settings are not set in the jar. how can i do this (in jbuilder)?
thank you very much!!!
Stefan
- 11
- Hibernate: @SecondaryTable causes ORA-00918I have to tables 'first' and 'second':
CREATE TABLE first (
first_id int IDENTITY NOT NULL,
first_value INT NOT NULL,
PRIMARY KEY (first_id)
)
CREATE TABLE second (
second_id int IDENTITY NOT NULL,
first_id int NOT NULL,
second_value INT NOT NULL,
PRIMARY KEY (second_id)
)
I want to join these two tables into one entity using @SecondaryTable.
The columns that are used for joining are named the same in both
tables ('first_id'). Hibernate creates a query like this:
SELECT f_.first_value as first_value_,
s_.secondValue as second_value_
FROM first f_,
second s_
WHERE f_.first_id=s_.first_id(+)
and first_id=?
In the last line Hibernate "forgets" to add a qualifier to 'first_id',
so I get an "ORA-00918: column ambiguously defined" error.
Any ideas?
Thanks,
Ralpe
- 12
- ports/116082: java/linux-sun-jdk16 jconsole is unable toSynopsis: java/linux-sun-jdk16 jconsole is unable to connect to a local process
Responsible-Changed-From-To: freebsd-ports-bugs->java
Responsible-Changed-By: edwin
Responsible-Changed-When: Tue Sep 4 14:20:07 UTC 2007
Responsible-Changed-Why:
Over to maintainer
http://www.freebsd.org/cgi/query-pr.cgi?pr=116082
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 13
- Hiding methods from a public APIWe publish a library. Some of the methods in the public classes are
intended for consumption by our customers, but others are just for
internal use. Ok, fine, declare those methods protected.
A difficultly arises when we want to access one of these internal-use
methods from a class in another package. Example:
com.mydomain.foo.MyFoo wants to access a method in
com.mydomain.bar.MyBar
So the method has to be made public, which makes it available to our
customers. Not good.
How do people generally handle this? I've been putting a "Do not use,
for internal use only" in the Javadoc for the method, but that's not ideal.
- 14
- mouse button 2 is always meta-modified?I have a program in which I wanted to allow the user
to use either Alt or Meta to indicate the same
modification of a mouse click. When I look at what's
returned by getModifiersEx(), I am surprised to
discover that an unmodified Button2 event produces a
value of 256, which also happens to be the value of
MouseEvent.META_DOWN_MASK. The result is that a plain
Button2 event looks like a Meta-modified one. This
cannot be right; and there is no analogous problem
with Button1, which produces 0 for an unmodified
event. In fact, if I hold down any combination of
Shift, Control, and Alt when clicking Button2, then the
256 bit is _not_ set but the appropriate combination
of others is set. I am on a PC and I do not actually
have a Meta key; but I wanted folks who do have one to
be able to use it in preference to Alt. What's going
on here? Is there a solution to this problem? (In
the meantime, I have just removed my Meta-modifier
option so that I can successfully detect that a Button2
event is unmodified.)
I am using SDK 1.4 under Windows 98.
Regards,
David V.
- 15
- float vs double : speed on P4 machineI'm writing some real-time numerical code which needs to be pretty
nippy. Should I be using float or doubles for my calculations? I
know my P4 is a 32bit processor, but I don't know if the JVM will end
up putting the 32bits of the floats into the 32bits of my processor,
or if it does something else. In C the 64double would take much
longer to run on a 32bit processor -- is this still the case with the
virtual machine?
|
|
|