Abstract class causes JNI GetByteArrayElements to crash

I'm having a problem with a subclass of an abstract class that is accessing a JNI function. I'm using Java 1.4.2.
I started out with a single class that reads data from a serial port (via a JNI call) and then parses the data. When I test this class, the read/parse works correctly.
Since I have to create multiple parsing protocols, I decided to create an abstract class that contained the reading functionality and a subclass that parses the data. When I did this, the 1st call to GetByteArrayElement never returns (nor do I get a stack dump trace).
I also tried making the super-class non-abstract and over-writing the prase method(s). I got a similar failure.
I can't imagine what the issue might be - why would splitting the original object into two (superclass/subclass) cause such a problem?
I've include relevent snippits of code.
Thanks for the help!
===== JNI Code =====
extern JNIEXPORT jint JNICALL Java_vp_jni_Serial_read (JNIEnv *env,
     jclass class, jint fd, jbyteArray buf, jint cnt, jint offset)
     jboolean     iscopy = JNI_FALSE;
     // FAILS ON CALL; NEVER RETURNS!!!!
     const jbyte *data = GetByteArrayElements (env, buf, &iscopy);
     const uchar     *b;
     int               num,
                    rc;
     b = (uchar *) &data[offset];
     num = cnt;
     do
          rc = read (fd, (char *) b, num);
          if (handleReadException (env, rc) != 0)
               (*env)->ReleaseByteArrayElements (env, buf, (jbyte *) data, 0);
               return rc;
          num -= rc;
          b += rc;
     } while (num > 0);
     (*env)->ReleaseByteArrayElements (env, buf, (jbyte *) data, 0);
     return cnt;
}==== Java Native Calls ====
public class Serial
     public int read (byte[] data, int length, int offset)
          throws IOException
          return read (fd, data, length, offset);
     private static native int read (int fd, byte[] buf, int cnt, int offset)
          throws IOException;
}==== Abstract super-class ====
package vp.parse;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.SyncFailedException;
import vp.jni.Serial;
import vp.jni.Exec;
import vp.data.ControlData;
public abstract class Parse extends Thread
     protected static final int     ERROR = -1;
     private static final int     LOC_TIMEOUT = 3000;
     private Serial          link;
     private int               port;
     private boolean          running = false;
     private int               baud = Serial.B9600;
     protected abstract void reset ();
     protected abstract void parse ();
     public Parse (int port, String id, int baud)
          this.port = port;
          this.baud = baud;
          start ();
          synchronized (this)
               try
                    wait (5000);
               } catch (Exception e)
                    System.out.println (id + " Thread failed to synchronize");
          System.out.println ("Done");
     public void run ()
          link = new Serial(port);
          try
               link.open();
               link.setBaud (baud);
               link.setTimeout (LOC_TIMEOUT);
          catch (Exception e )
               link = null;
               return;
          running = true;
          synchronized (this)
               notify ();
          while (running)
               parse ();
     protected int read (byte[] buf, int packetSize, int offset)
          if (offset >= packetSize)
               offset = 0;
          if (offset > 0)
               for (int i=0; i<packetSize - offset; i++)
                    buf[i] = buf[offset+i];
               offset = packetSize - offset;
          try
               int cnt = link.read (buf, packetSize - offset, offset);
               offset = 0;          // all data is good
          // ready to 'close down' executable
          catch (Exception exp)
               running = false;
               return ERROR;
          return offset;
}==== Sub-class to handle parsing ====
package vp.parse;
public class Eis extends Parse
     private static final int     PACKET_SIZE = 3 + 69 + 1;     // hdr, data, csum
     private byte[]          buffer = new byte[PACKET_SIZE];
     private int               offset = 0;
     public Eis (int port)
          super (port, "GR EIS", Serial.B9600);
     protected void reset ()
          offset = 0;
     protected void parse ()
          do
               offset = read (buffer, PACKET_SIZE, offset);
               if (offset == ERROR)
                    offset = 0;
                    return;
               // parse code here
          } while (parse failed);
     public static void main (String[] argv)
          Eis e = new Eis (3);
          try { Thread.sleep (10000); } catch (Exception x) {}
}

The issue was the following:
I had declared a buffer in the sub-class;
private byte[] buffer = new byte[PACKET_SIZE];
And the assumption would be that by the time it got used, it would be initialized. But that's not the case. Why?
The sub-class called the super class constructor. At this point in time, buffer[] is not valid.
The super class constructor spawns the child thread and waits for the spawned thread to finish initialization.
The spawned thread creates the serial port, informs the constructor it's 'done' and starts to parse incoming data.
The parse() code is the sub-class passes the uninitialized buffer to the JNI code and GetByteArrayElements crashes because id doesn't like a null pointer.
Since the parent thread doesn't regain control to finish the construction, buffer[] never gets initialized.
So much for synchronized thread spawning in a constructor...

Similar Messages

  • Adding a variable to a class causes a WinRT originate error.

    I have a Clock class which causes my game to crash after I add the following line
    public:
    int FrameTimeTicks; // this line will cause the crash
    the error message reads:
    First-chance exception at 0x74B24598 (KernelBase.dll) in HH.exe: 0x40080201: WinRT originate error (parameters: 0x80000013, 0x0000001D, 0x02C3D5E0).
    First-chance exception at 0x74B24598 in HH.exe: Microsoft C++ exception: Platform::ObjectDisposedException ^ at memory location 0x02C3DA80. HRESULT:0x80000013 The object has been closed.
    WinRT information: The object has been closed.
    The program '[8200] HH.exe' has exited with code 0 (0x0).
    This is completely meaningless to me. It's a strange problem.
    Edit: When i step through the program, a breakpoint on the first line of MainPage() isn't reached before the exception is thrown. I can put a breakpoint in Clock constructor which looks like this:
    Clock::Clock()
    QueryPerformanceFrequency(&frequency);
    QueryPerformanceCounter(&pCountAppStart);
    //FrameTimeTicks = {};
    And it will be hit, when i step through from there, execution reaches the end of Clock(), goes to MainPage() open brace, but before it hits the first line I get "Source not available - Source information is missing from the debug information for this
    module ..."
    So has MainPage been disposed ?
    Here is the Clock.h file:
    #pragma once
    #include <Windows.h>
    #include <map>
    #include "Debug.h"
    using namespace std;
    using namespace Platform;
    using namespace Platform::Collections;
    class Clock
    public:
    Clock();
    int64 MarkIn();
    int64 MarkOut();
    //int FrameTimeTicks; // can't add these
    //int FrameTimeMS = 0;
    private:
    LARGE_INTEGER frequency = {};
    LARGE_INTEGER pCountAppStart = {};
    LARGE_INTEGER pCountStt = {};
    LARGE_INTEGER pCountEnd = {};
    //int frameTimeTicks; // can't add these either
    //int frameTimeMS;

    So I think I have found the problem here, and I came to a fix by using Analyze > Run code analysis on solution. Something I've never used before. When i ran it, it gave me 3 issues, one of the issues was that I was using a byte* to pixel data after a
    failed call to
    IBufferByteAccess->Buffer(&pixels);
    I don't know why the call is failing as I call it immediately after creating the WriteableBitmap, and then later in ClearBitmap. Also, the call result never returns a failure. But, nevertheless, by checking for the HRESULT and returning NULL if it fails,
    then checking for NULL in the calling functions. The issue seems to have been resolved and I can add variables to my clock class.
    I guess something weird was happening with memory.

  • Java applet causes IE6.0 to crash

    Both 1.4 and 1.5 versions cause internet explorer to crash. This is only happening on 1 out of 5 machines and its driving me crazy.
    Here are the system stats
    Windows XP Pro(it happens on sp1 and sp2)
    AMD 2200+ processor on a PCCHips MB
    512 MB ram
    Asus FX5200 graphics card 128 mb ram(also happened on an ati radeon 9000)
    30 gb seagate barracuda 7200 rpm
    10x DVD
    3 1/4 floppy
    Dlink DWL 520 Air Card (PCI) 802.11b
    onboard ac97 sound
    If any one has any idea how I can stop this or what is causing it, please let me know. I have tried everything except replacing the Processor and motherboard. I even tried different brand of ddr memory.
    CrashnBurnin,
    Please help,
    Harry

    Here is a copy of the error report that ended up on the desktop.
    # An unexpected error has been detected by HotSpot Virtual Machine:
    # EXCEPTION_PRIV_INSTRUCTION (0xc0000096) at pc=0x044224b1, pid=1828, tid=664
    # Java VM: Java HotSpot(TM) Client VM (1.5.0_02-b09 mixed mode, sharing)
    # Problematic frame:
    # j sun.awt.GlobalCursorManager._updateCursor(Z)V+87
    --------------- T H R E A D ---------------
    Current thread (0x0698cda0): JavaThread "AWT-EventQueue-2" [_thread_in_Java, id=664]
    siginfo: ExceptionCode=0xc0000096
    Registers:
    EAX=0xffffffff, EBX=0x000000b6, ECX=0x01c04fd8, EDX=0x00000000
    ESP=0x07def748, EBP=0x07def7a0, ESI=0x2ab5baa2, EDI=0x07def7bc
    EIP=0x044224b1, EFLAGS=0x00010212
    Top of Stack: (sp=0x07def748)
    0x07def748: 07def7bc 2ab5baa2 07def7a0 07def768
    0x07def758: 000000b6 000000e8 20dfb440 00000047
    0x07def768: 044224ab 6d7820c0 0000027d 216c1a28
    0x07def778: 21230950 00000001 00000000 07def77c
    0x07def788: 2ab5ba87 07def7bc 2b3fb0a0 00000000
    0x07def798: 2b3fae90 07def7b8 07def7e4 04422923
    0x07def7a8: 00000000 216c1a28 20dfb440 20dfb450
    0x07def7b8: 00000000 21230950 00000001 00000000
    Instructions: (pc=0x044224b1)
    0x044224a1: 68 c0 20 78 6d e8 00 00 00 00 60 e8 0a 7b 22 69
    0x044224b1: f4 90 90 00 00 00 00 00 00 00 00 00 00 00 00 80
    Stack: [0x07cf0000,0x07df0000), sp=0x07def748, free space=1021k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    j sun.awt.GlobalCursorManager._updateCursor(Z)V+87
    j sun.awt.GlobalCursorManager.updateCursorImmediately()V+27
    j sun.awt.windows.WComponentPeer.updateCursorImmediately()V+3
    j java.awt.Component.updateCursorImmediately()V+49
    j java.awt.LightweightDispatcher.dispatchEvent(Ljava/awt/AWTEvent;)Z+68
    j java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V+12
    J java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V
    J java.awt.EventDispatchThread.pumpOneEventForHierarchy(ILjava/awt/Component;)Z
    v ~RuntimeStub::alignment_frame_return Runtime1 stub
    j java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+26
    j java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4
    j java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3
    j java.awt.EventDispatchThread.run()V+9
    v ~StubRoutines::call_stub
    V [jvm.dll+0x818e8]
    V [jvm.dll+0xd4989]
    V [jvm.dll+0x817b9]
    V [jvm.dll+0x81516]
    V [jvm.dll+0x9c1d6]
    V [jvm.dll+0xfeeab]
    V [jvm.dll+0xfee79]
    C [msvcrt.dll+0x27fb8]
    C [kernel32.dll+0x1d33b]
    --------------- P R O C E S S ---------------
    Java Threads: ( => current thread )
    0x0764a4c8 JavaThread "Thread-12" daemon [_thread_blocked, id=432]
    0x01ca47a0 JavaThread "Thread-11" daemon [_thread_blocked, id=808]
    0x06a1d358 JavaThread "Thread-10" daemon [_thread_blocked, id=1324]
    0x01c10c30 JavaThread "Thread-8" daemon [_thread_in_native, id=860]
    0x0696c848 JavaThread "Thread-6" daemon [_thread_blocked, id=564]
    =>0x0698cda0 JavaThread "AWT-EventQueue-2" [_thread_in_Java, id=664]
    0x069e8d28 JavaThread "TimerQueue" daemon [_thread_blocked, id=1428]
    0x01cc65b0 JavaThread "AWT-EventQueue-1" [_thread_blocked, id=1816]
    0x01cef448 JavaThread "TimerQueue" daemon [_thread_blocked, id=1656]
    0x06963cd0 JavaThread "thread applet-loader.class" [_thread_blocked, id=1268]
    0x06944e08 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=1232]
    0x069552e0 JavaThread "AWT-Shutdown" [_thread_blocked, id=1184]
    0x01cffe48 JavaThread "traceMsgQueueThread" daemon [_thread_blocked, id=1084]
    0x01cfc4e8 JavaThread "AWT-Windows" daemon [_thread_in_native, id=336]
    0x069447a8 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=344]
    0x0003c390 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=408]
    0x01c348d8 JavaThread "CompilerThread0" daemon [_thread_blocked, id=296]
    0x01c33b28 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=404]
    0x0003e078 JavaThread "Finalizer" daemon [_thread_blocked, id=400]
    0x01c2ab98 JavaThread "Reference Handler" daemon [_thread_blocked, id=396]
    0x01c24008 JavaThread "main" [_thread_in_native, id=1832]
    Other Threads:
    0x01c06338 VMThread [id=392]
    0x01c11808 WatcherThread [id=112]
    VM state:not at safepoint (normal execution)
    VM Mutex/Monitor currently owned by a thread: None
    Heap
    def new generation total 4992K, used 3697K [0x20a60000, 0x20fc0000, 0x211c0000)
    eden space 4480K, 82% used [0x20a60000, 0x20dfc728, 0x20ec0000)
    from space 512K, 0% used [0x20ec0000, 0x20ec0000, 0x20f40000)
    to space 512K, 0% used [0x20f40000, 0x20f40000, 0x20fc0000)
    tenured generation total 65656K, used 39392K [0x211c0000, 0x251de000, 0x26a60000)
    the space 65656K, 59% used [0x211c0000, 0x23838178, 0x23838200, 0x251de000)
    compacting perm gen total 8192K, used 2491K [0x26a60000, 0x27260000, 0x2aa60000)
    the space 8192K, 30% used [0x26a60000, 0x26cced48, 0x26ccee00, 0x27260000)
    ro space 8192K, 62% used [0x2aa60000, 0x2af68018, 0x2af68200, 0x2b260000)
    rw space 12288K, 46% used [0x2b260000, 0x2b7ec620, 0x2b7ec800, 0x2be60000)
    Dynamic libraries:
    0x00400000 - 0x00419000      C:\Program Files\Internet Explorer\iexplore.exe
    0x77f50000 - 0x77ff7000      C:\WINDOWS\System32\ntdll.dll
    0x77e60000 - 0x77f46000      C:\WINDOWS\system32\kernel32.dll
    0x77c10000 - 0x77c63000      C:\WINDOWS\system32\msvcrt.dll
    0x77d40000 - 0x77dcd000      C:\WINDOWS\system32\USER32.dll
    0x7e090000 - 0x7e0d1000      C:\WINDOWS\system32\GDI32.dll
    0x77dd0000 - 0x77e5d000      C:\WINDOWS\system32\ADVAPI32.dll
    0x78000000 - 0x78087000      C:\WINDOWS\system32\RPCRT4.dll
    0x70a70000 - 0x70ad6000      C:\WINDOWS\system32\SHLWAPI.dll
    0x71700000 - 0x71849000      C:\WINDOWS\System32\SHDOCVW.dll
    0x71950000 - 0x71a35000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.1643_x-ww_7c3a9bc6\comctl32.dll
    0x7cd00000 - 0x7d4fa000      C:\WINDOWS\system32\SHELL32.dll
    0x77340000 - 0x773cb000      C:\WINDOWS\system32\comctl32.dll
    0x4fec0000 - 0x4fff6000      C:\WINDOWS\system32\ole32.dll
    0x5ad70000 - 0x5ada4000      C:\WINDOWS\System32\uxtheme.dll
    0x71500000 - 0x715fc000      C:\WINDOWS\System32\BROWSEUI.dll
    0x72430000 - 0x72442000      C:\WINDOWS\System32\browselc.dll
    0x75f40000 - 0x75f5f000      C:\WINDOWS\system32\appHelp.dll
    0x7c890000 - 0x7c911000      C:\WINDOWS\System32\CLBCATQ.DLL
    0x77120000 - 0x771ab000      C:\WINDOWS\system32\OLEAUT32.dll
    0x77050000 - 0x77115000      C:\WINDOWS\System32\COMRes.dll
    0x77c00000 - 0x77c07000      C:\WINDOWS\system32\VERSION.dll
    0x76620000 - 0x7666e000      C:\WINDOWS\System32\cscui.dll
    0x76600000 - 0x7661c000      C:\WINDOWS\System32\CSCDLL.dll
    0x76670000 - 0x76757000      C:\WINDOWS\System32\SETUPAPI.dll
    0x1a400000 - 0x1a47d000      C:\WINDOWS\system32\urlmon.dll
    0x63000000 - 0x63096000      C:\WINDOWS\system32\WININET.dll
    0x762c0000 - 0x76348000      C:\WINDOWS\system32\CRYPT32.dll
    0x762a0000 - 0x762b0000      C:\WINDOWS\system32\MSASN1.dll
    0x76f90000 - 0x76fa0000      C:\WINDOWS\System32\Secur32.dll
    0x00d20000 - 0x00da8000      C:\WINDOWS\System32\shdoclc.dll
    0x74770000 - 0x747ff000      C:\WINDOWS\System32\mlang.dll
    0x71ad0000 - 0x71ad8000      C:\WINDOWS\System32\wsock32.dll
    0x71ab0000 - 0x71ac5000      C:\WINDOWS\System32\WS2_32.dll
    0x71aa0000 - 0x71aa8000      C:\WINDOWS\System32\WS2HELP.dll
    0x71a50000 - 0x71a8b000      C:\WINDOWS\system32\mswsock.dll
    0x71a90000 - 0x71a98000      C:\WINDOWS\System32\wshtcpip.dll
    0x76ee0000 - 0x76f17000      C:\WINDOWS\System32\RASAPI32.DLL
    0x76e90000 - 0x76ea1000      C:\WINDOWS\System32\rasman.dll
    0x71c20000 - 0x71c6e000      C:\WINDOWS\System32\NETAPI32.dll
    0x76eb0000 - 0x76edb000      C:\WINDOWS\System32\TAPI32.dll
    0x76e80000 - 0x76e8d000      C:\WINDOWS\System32\rtutils.dll
    0x76b40000 - 0x76b6c000      C:\WINDOWS\System32\WINMM.dll
    0x75e90000 - 0x75f3d000      C:\WINDOWS\System32\SXS.DLL
    0x75a70000 - 0x75b15000      C:\WINDOWS\system32\USERENV.dll
    0x76f20000 - 0x76f45000      C:\WINDOWS\System32\DNSAPI.dll
    0x76fb0000 - 0x76fb7000      C:\WINDOWS\System32\winrnr.dll
    0x76f60000 - 0x76f8c000      C:\WINDOWS\system32\WLDAP32.dll
    0x76fc0000 - 0x76fc5000      C:\WINDOWS\System32\rasadhlp.dll
    0x63580000 - 0x63834000      C:\WINDOWS\System32\mshtml.dll
    0x746f0000 - 0x74716000      C:\WINDOWS\System32\msimtf.dll
    0x74720000 - 0x74764000      C:\WINDOWS\System32\MSCTF.dll
    0x76390000 - 0x763ac000      C:\WINDOWS\System32\IMM32.DLL
    0x75c50000 - 0x75ce1000      C:\WINDOWS\System32\jscript.dll
    0x01f20000 - 0x01f5c000      C:\WINDOWS\System32\iepeers.dll
    0x73000000 - 0x73023000      C:\WINDOWS\System32\WINSPOOL.DRV
    0x746c0000 - 0x746e7000      C:\WINDOWS\System32\MSLS31.DLL
    0x73300000 - 0x73375000      C:\WINDOWS\System32\vbscript.dll
    0x10000000 - 0x101a7000      C:\WINDOWS\System32\macromed\flash\Flash.ocx
    0x763b0000 - 0x763f5000      C:\WINDOWS\system32\comdlg32.dll
    0x72d20000 - 0x72d29000      C:\WINDOWS\System32\wdmaud.drv
    0x72d10000 - 0x72d18000      C:\WINDOWS\System32\msacm32.drv
    0x77be0000 - 0x77bf4000      C:\WINDOWS\System32\MSACM32.dll
    0x77bd0000 - 0x77bd7000      C:\WINDOWS\System32\midimap.dll
    0x6bdd0000 - 0x6be03000      C:\WINDOWS\System32\dxtrans.dll
    0x76b20000 - 0x76b35000      C:\WINDOWS\System32\ATL.DLL
    0x65000000 - 0x65009000      C:\WINDOWS\System32\ddrawex.dll
    0x51000000 - 0x51049000      C:\WINDOWS\System32\DDRAW.dll
    0x73bc0000 - 0x73bc6000      C:\WINDOWS\System32\DCIMAN32.dll
    0x6be10000 - 0x6be65000      C:\WINDOWS\System32\dxtmsft.dll
    0x74cb0000 - 0x74d1f000      C:\WINDOWS\System32\mshtmled.dll
    0x66880000 - 0x6688a000      C:\WINDOWS\System32\imgutil.dll
    0x722b0000 - 0x722b5000      C:\WINDOWS\System32\sensapi.dll
    0x6d590000 - 0x6d5a1000      C:\Program Files\Java\jre1.5.0_02\bin\npjpi150_02.dll
    0x5edd0000 - 0x5edea000      C:\WINDOWS\System32\OLEPRO32.DLL
    0x6d400000 - 0x6d417000      C:\Program Files\Java\jre1.5.0_02\bin\jpiexp32.dll
    0x6d450000 - 0x6d468000      C:\Program Files\Java\jre1.5.0_02\bin\jpishare.dll
    0x6d640000 - 0x6d7c5000      C:\PROGRA~1\Java\JRE15~1.0_0\bin\client\jvm.dll
    0x6d280000 - 0x6d288000      C:\PROGRA~1\Java\JRE15~1.0_0\bin\hpi.dll
    0x76bf0000 - 0x76bfb000      C:\WINDOWS\System32\PSAPI.DLL
    0x6d610000 - 0x6d61c000      C:\PROGRA~1\Java\JRE15~1.0_0\bin\verify.dll
    0x6d300000 - 0x6d31d000      C:\PROGRA~1\Java\JRE15~1.0_0\bin\java.dll
    0x6d630000 - 0x6d63f000      C:\PROGRA~1\Java\JRE15~1.0_0\bin\zip.dll
    0x6d000000 - 0x6d166000      C:\Program Files\Java\jre1.5.0_02\bin\awt.dll
    0x6d240000 - 0x6d27d000      C:\Program Files\Java\jre1.5.0_02\bin\fontmanager.dll
    0x6d1f0000 - 0x6d203000      C:\Program Files\Java\jre1.5.0_02\bin\deploy.dll
    0x6d5d0000 - 0x6d5ed000      C:\Program Files\Java\jre1.5.0_02\bin\RegUtils.dll
    0x07020000 - 0x072e6000      C:\WINDOWS\System32\msi.dll
    0x6d3e0000 - 0x6d3f4000      C:\Program Files\Java\jre1.5.0_02\bin\jpicom32.dll
    0x6d4c0000 - 0x6d4d3000      C:\Program Files\Java\jre1.5.0_02\bin\net.dll
    0x71d40000 - 0x71d5b000      C:\WINDOWS\System32\actxprxy.dll
    0x6cc60000 - 0x6cc6b000      C:\WINDOWS\System32\dispex.dll
    0x6d1c0000 - 0x6d1e3000      C:\Program Files\Java\jre1.5.0_02\bin\dcpr.dll
    0x6d4e0000 - 0x6d4e9000      C:\Program Files\Java\jre1.5.0_02\bin\nio.dll
    0x6d3c0000 - 0x6d3df000      C:\Program Files\Java\jre1.5.0_02\bin\jpeg.dll
    VM Arguments:
    jvm_args: -Xbootclasspath/a:C:\PROGRA~1\Java\JRE15~1.0_0\lib\deploy.jar;C:\PROGRA~1\Java\JRE15~1.0_0\lib\plugin.jar -Xmx96m -Djavaplugin.maxHeapSize=96m -Xverify:remote -Djavaplugin.version=1.5.0_02 -Djavaplugin.nodotversion=150_02 -Dbrowser=sun.plugin -DtrustProxy=true -Dapplication.home=C:\PROGRA~1\Java\JRE15~1.0_0 -Djava.protocol.handler.pkgs=sun.plugin.net.protocol -Djavaplugin.vm.options=-Djava.class.path=C:\PROGRA~1\Java\JRE15~1.0_0\classes -Xbootclasspath/a:C:\PROGRA~1\Java\JRE15~1.0_0\lib\deploy.jar;C:\PROGRA~1\Java\JRE15~1.0_0\lib\plugin.jar -Xmx96m -Djavaplugin.maxHeapSize=96m -Xverify:remote -Djavaplugin.version=1.5.0_02 -Djavaplugin.nodotversion=150_02 -Dbrowser=sun.plugin -DtrustProxy=true -Dapplication.home=C:\PROGRA~1\Java\JRE15~1.0_0 -Djava.protocol.handler.pkgs=sun.plugin.net.protocol vfprintf
    java_command: <unknown>
    Environment Variables:
    PATH=C:\PROGRA~1\Java\JRE15~1.0_0\bin;C:\Program Files\Internet Explorer;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;.
    USERNAME=Christofor
    OS=Windows_NT
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 8 Stepping 1, AuthenticAMD
    --------------- S Y S T E M ---------------
    OS: Windows XP Build 2600 Service Pack 1
    CPU:total 1 family 6, cmov, cx8, fxsr, mmx, sse
    Memory: 4k page, physical 523760k(313452k free), swap 1280972k(1076168k free)
    vm_info: Java HotSpot(TM) Client VM (1.5.0_02-b09) for windows-x86, built on Mar 4 2005 01:53:53 by "java_re" with MS VC++ 6.0

  • No instances can be created from abstract classes

    Dear SAPGurus,
    I have developed a oData Service in my backend system & able to register the service in the gateway hub system. When i try to execute the metadata of the service from gateway system i am able to see the metadata with list of entity types availble in the data model.
    But when i try to execute with entity set i am getting the following error.
    "The class 'ZCL_ZGRC_DATA_MODEL_DPC' is abstract. No instances can be created from abstract classes."
    Where my data model provider class name is  'ZCL_ZGRC_DATA_MODEL_DPC'
    Kindly help me.
    Thanks & Regards,
    Rumeshbabu S

    Hello Rumesh,
    I do not think the error which u are getting is because of System Alias setting in SPRO.
    Its something else which is really strange.
    However the below is the setting to be maintained in GW SPRO system alias when u have a environment setup like u have now.
    I mean the way u have created service and registered -
    In ECC system u have created service using builder.
    In GW system u have registered it and trying to access now via an RFC destination.
    We have the same setup like u have now and we do not have any issues. We have also maintained the System Alias like i have shared in screen shot.
    Check your System Alias config once in SPRO. But i dont think this is causing problem in your case. Still check once.
    As per my understanding, from GW its trying to hit the DPC class and hence i feel system alias setting is correct in your case.
    Problem is something else which is really strange.
    Check error logs and see if it can. Share the error log please.
    Regards,
    Ashwin

  • Abstract class implements Cloneable... How?

    I have an abstract class that is inherited by many many subclasses. I wish to make this abstract class a cloneable.
    Most of the subclasses are using the protected fields inherited from the abstract one, they almost never add any extra field. So it would make a lot of sense to implement the clone() method at the abstract level. And not doing so would cost me a lot of time.
    But that causes me trouble, because you can't write something like this :
    public abstract class MyAbstractClass implements Cloneable {
        protected Source source; // the two fields the subclasses are satisfied with, most the time
        protected Vectro<Target> targets;
        public Effect clone() {
            return new Effect(source , targets);  // when a subclass has extra fields, I plan to overwrite clone()
    }Because you can't instantiate an abstract class, of course. Anyway, I'd rather instatiate a class of the appropriate concrete class.
    I feel there is a way to hack this. I feel there is a way to avoid having to write the same clone() method in every subclass.
    Anyone?
    Thanks.

    jverd wrote:
    bestam wrote:
    Most of the subclasses are using the protected fields inherited from the abstract one, Bad idea. Make the fields private and provide protected get/set methods.Is this a general recommendation or only in the context described by the OP?
    Because API classes don't do this in many cases. Just looked at a random one: AbstractButton.

  • Abstract class hierarchy - compilation error

    I coded an abstract class and couple of concrete classes. When I am compiling the concrete classes, I see the error message: cannot find symbol abstract class. For diagnosing I coded very simple programs AbstractClass1.java and ConcreteClass.java. Again I am facing the same compilation error. Code is given below:
    abstract class AbstractClass1 {
    protected AbstractClass1() {
    System.out.println("AbstractClass1 constructor called");
    public abstract void distinct_method();
    public void common_method() {
    System.out.println("common method called");
    distinct_method();
    class ConcreteClass extends AbstractClass1 {
    public void distinct_method() {
    System.out.println("distinct_method called");
    I can't figure out what's causing the compilation error.
    Edited by: ague on Nov 9, 2008 5:52 PM

    Yes. AbstractClass1 is defined in AbstractClass1.java. I know it is compiling fine for others. I am unable to figure out the problem at my end because the problem was first encountered with a different (and bigger) program. I then started using new simpler classes to zero in on the problem area. I copied the code from java forum so I know it can't be a problem with code. You and one more person confirmed it. In my first post I was focusing on abstract class because the problem started when I began coding a hierarchy with an abstract class at the top. Other programs are working fine. Thanks anyway.

  • Casting to an abstract class from a different classloader

    I have a class Special that extends an abstract class Base. In my code I use a URLClassLoader to load the class Special and I then want to cast Special to Base. If I do this I get a ClassCastException because the classes are loaded from different classloaders. I can't have the URLClassLoader and the class that performs the cast extend a parent ClassLoader that knows about the Base class. What I want to be able to do is something like this:
    URLClassLoader loader = new URLClassLoader(codebase, null);
    Class baseClass = loader.loadClass(className);
    Base baseObj = (Base)baseClass.newInstance();
    I have seen some post that suggest I can achieve this using Reflection but I am not sure how to go about this. Any help would be appreciated.
    Thanks
    Jim.

    Thanks for your help so far but I still can't do the casting, consider this example:
    //Base.java
    package classTest;
    public interface Base
         public abstract void execute();
    //ConcBase.java
    package classTest;
    public class ConcBase implements Base
         public void execute()
              System.out.println("execute in ConcBase called");
    I compile these files and jar them into work.jar
    I now have my application:
    //Test.java
    import java.net.*;
    import java.io.*;
    import classTest.*;
    public class Test
    public static void main(String[] args)
              Test t = new Test();
              t.test();
         public void test()
              try
                   File file = new File("D:/Projects/classloadTest/work.jar");
                   URL[] codebase = {file.toURL()};
                   ClassLoader ccl = getClass().getClassLoader();
                   ccl.loadClass("classTest.Base");
                   URLClassLoader ucl = new URLClassLoader(codebase,ccl);
                   Class conClass = ucl.loadClass("classTest.ConcBase");
                   classTest.Base b = (classTest.Base)conClass.newInstance();
                   b.execute();
              catch(Exception t)
                   System.out.println("thowable caught");
                   t.printStackTrace(System.out);
    I compile this and run it with this command:
    java -classpath D:\Projects\classloadTest\work.jar;. Test
    This runs as I would expect, however I have set the parent class loader of my custom URLClassLoader to the one that does the cast, this means that Base and ConcBase are both being picked up by the application class loader as my custom class loader delegates to its parent. This is the current behaviour I have in my proper application and it is causing problems, I don't want the class that implements Base to delegate to any class on the main applications classpath. If I change the line:
    URLClassLoader ucl = new URLClassLoader(codebase,ccl);
    In Test.java to:
    URLClassLoader ucl = new URLClassLoader(codebase,null);
    I get a ClassCastException, this is because the class that does the cast (Test) loads Base from it's classpath and ConcBase is loaded from the URLClassLoader. After spending more time looking at this problem I don't think there is anyway to resolve but if anyone thinks there is please tell me.
    Many thanks
    Jim.

  • Abstract class/ method calls

    Hi, in an
    abstract class Report
    private int mat
    private string add
    private int mat
    private double creduced = 0.125;
    private double sreduced = 0.25;
    public Property(String location, int material)
    add = location;
    mat = material;
    public double getActualPrice()
    double base = getPrice();
    double money = base;
    if (mat == 1)
    money -= base * creduced;
    return money;
    etc and two abstract classes called getPrice() , and getInsurance()- which i have both coded in the extended class
    in a class called "class Info extends Report" I want to use the getActualPrice() method since it will anyway cause of inheritence but i want to add a new if line to it. How do I do this and code it in the extended class?
    Can i super call the instance variables and local variables ? I have tried super calls on the instance variables but since none of them are included in any of the constructors it wont work.

    public double getActualPrice()
    double actual=super.getActuelPrice();
    if ( something )
       actual=dosomethingwith(actual){
    return actual;
    }

  • Abstract class method polymorphically using constructors?

    how can i have a method defined in an abstract superclass call a constructor of the actual class running the method?
    abstract class A {
    public List getMultple() {
    List l = new ArrayList();
    for (short i=0;i<4;i++) {
    l.add(this());//<obviously this breaks
    return l
    or something like that. A won't run this method, but its children will...and they can call their constructors, but what do i put here to do that?
    i've tried a call back. an abstract method getOne() in the superclass forces each child to define that method and in each of those i return the results of a constructor. that works fine.
    the problem is i want to abstract this method out of each of these children classes cause its the exact same in each one, just using a different constructor to get multiple of each in a list. so if i use this callback method, then i am not saving the number of methods in each class, so why bother at all?
    any ideas?

    I still say you are coming at it from the wrong angle. A super class is not the way to go. What you are doing sounds like something very similar to something I did not too long ago.
    My requirement was that I had tab delimited text files filed with data that I had to parse. Each line would be used to instantiate one object, so a particular file could be used to instantiate, for example, a thousand objects of the same class. There were different types of files corresponding to different classes to instantiate instances of.
    Here is the design I ended up using.
    An object of class DataTextFileReader is instantiated to parse the text file and generate objects. It includes code for going line by line, handling bad lines and generating objects and reports. The constructor:
    public DataTextFileReader(File inputFile, LineParser<T> theLineParser)LineParser is an interface with one method:
    public T read(String line);When you call a load() method of the DataTextFileReader, it does its thing with the aid of the LineParser's read method, to which each line is passed, and stores the generated objects in an ArrayList. This can be returned by using another method. There are other methods for getting the reports, etc.
    Obviously, the LineParser chosen needs to have code appropriate for parsing the lines in question, so you have to choose and instantiate the right one.
    I find this design to work well. I arrived at it after spending hours giving myself headaches trying to come up with a design where there was a superclass roughly equivalent to the DataTextFileReader mentioned above, and classes extending this that fulfilled the duty of the LineParsers mentioned above... rather like what you are trying to do now.
    I did not care for the solution at first because it did not give me the "Ah, I am clever!" sensation I was expecting when I finally cracked the problem using inheritance, but I quickly came to think that it was much better OOD anyway.
    The LineParsers mentioned above are essentially embodiments of the Factory pattern, and I would recommend you do something similar in your case. Obviously your "constructors" all have to be different, so you should make a separate class for each of those. Then you can put the code that performs the query and loops to create loads of objects in another class called something like DatabaseDepopulator, using appropriate generics as in my example. Really it is the same problem, now that I look at it.
    This will also result in better separation of concepts, if you ask me. Why should the class constructor know how to parse a database result query, much less perform the query? It has nothing to do with databases (I presume). That is the job of an interpreter object.
    As a final note, remember... 95% of the time you feel like the language won't let you do what you want, it is because you shouldn't anyway.
    Drake

  • Can not locate Java class using JNI within C++ DLL

    I am using trying to use JNI to call a Java class from C++. The Java class uses JMS to send messages to a JMS message queue. At first I coded the C++ in a console application that created the JavaVM and used JNI to access the Java class. All worked fine. Then I called the Java class using JNI from threads and ran into the problem of the Java class not able to locate the JMS related classes. This was solved by placing the following line in the constructor of the Java class.
    Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
    Then I moved the JNI code from a console application to a DLL in specific an extension DLL that is called by SQL Server or Oracle server. The DLL will use JNI to call the Java class and send messages to a JMS message queue.
    The problem I am having now when the DLL code is called by SQL Server the call to
    JNI_CreateJavaVM
    appears to work correctly but the call to find the Java class using
    jvmEnv->FindClass(pName)
    fails. It appears the is a class loading problem which occurs due to the fact JNI is called from a DLL. When the VM is created I pass the class path information using the statement
    -Djava.class.path=
    And as I stated before it all works when running from a console application. I am new to JNI and really need help in the form of some sample code that will solve this problem. I believe I need to somehow load the classpath information from the DLL but I can not find examples on how to do this using JNI. I have tried several ways using URLClassLoader and getSystemClassLoader from JNI and either it does not work or it crashes very badly.
    I used the following code to determine what the existing class path is and the string returns empty.
    jcls = jvmEnv->FindClass("java/lang/System");
    jmid = jvmEnv->GetStaticMethodID(jcls, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
    jstrClassPath = jvmEnv->NewStringUTF("java.class.path");
    jstr = (jstring)jvmEnv->CallStaticObjectMethod(jcls, jmid, jstrClassPath);
    m_jstr = (jstring)jvmEnv->NewGlobalRef(jstr);
    pstr = jvmEnv->GetStringUTFChars(m_jstr, 0);
    Can anyone please help with example code that will solve this problem. Thanks in advance for any help.
    Charles�

    I have determined the problem occurs when the application/component is compiled using VC 6.0. The test application was compiled using VC 7.1 and works correctly by locating the class path information. If the test application is compiled using VC 6.0 it has the same problem.
    The jvm.dll I am using is version 1.4.2.80. Currently this is not an option to compile all the applications that use JNI using VC 7.1 so can someone please tell me how to solve this problem.

  • Difference between abstract class and interface

    Hi everyone,
    CAn anyone explain why the following happen????
    Abstract class can have a constructor, Interface cannot.
    Abstract class can have static methods, Interface cannot.

    What are the advantages of defining constant
    variables in Interfaces?Not many.
    Effective Java - Joshua Bloch, Chapter 4, Item #17: Use interfaces only to define types.
    The constant interface pattern is a poor use of interfaces. That a class uses some constants internally is an implementation detail. Implementing a constant interface causes this implementation detail to leak into the class's exported API. It is of no consequence to the users of a class that the class implements a constant interface. In fact, it may even confuse them. Worse, it represents a commitment: if in a future release the class is modified so that it no longer needs to use the constants, it still must implement the interface to ensure binary compatibility. If a nonfinal class implements a constant interface, all of its subclasses will have their namespaces polluted by the constants in the interface.
    In summary, interfaces should only be used to define types. They should not be used to export constants.

  • Defining inherited classes in JNI

    I have to use JNI in order to inherit a concrete class from an abstract one (java.util.TimerTask) and, then, instantiate it.
    I have to re-define the abstract method "run" of "TimerTask". In Java it's a trivial problem but I have to do it in C++!
    I hope I explained my problem. How do I work this?

    Well, it's not entirely clear. My assumption is that you want to derive a concrete class from an abstract class, and you want the concrete class to implemenet "run()").
    1. Define your concrete class (in java). Give it a run method, but deine the run method as native.
    2. Run jnih and generate a .h file (C header file) for the native method.
    3. Write a library (dll on Windows) that implements the subroutine as declared in the .h file.

  • What is the diff b/w Abstract class and an interface ?

    Hey
    I am always confused as with this issue : diff b/w Abstract class and an interface ?
    Which is more powerful in what situation.
    Regards
    Vinay

    Hi, Don't worry I am teach you
    Abstract class and Interface
    An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.
    Edited by SASIKUMARA
    SIT INNOVATIONS- Chennai
    Message was edited by:
    sasikumara
    Message was edited by:
    sasikumara

  • Abstract class with set and get methods

    hi
    how to write set and get methods(plain methods) in an abstartc class
    ex: setUsername(String)
    String getUsername()
    and one class is extending this abstract class and same methods existing in that sub class also..... how to write......plz provide some ideas
    am new to programming....
    asap
    thnx in advance

    yes... as i told u.... i am new to coding......
    and my problem is ..... i have 2 classes one is abstract class without abstract methods.. and another class is extending abstract class.....
    in abstract class i have 2 methods...one is setusername(string) and getusername() ..... how to write these two methods.... in abstract class i have private variables username...... when user logins ..... i need to catch the user name and i need to validate with my oracle database and i need to identify the role of that user and based on role of that user i need to direct him to appropriate jsp page.......
    for that now i am writing business process classes..... the above mentioned two classes are from business process.....
    could u help me now
    thnx in advance

  • RH8 causing other apps to crash?

    Hello -
    I have a colleague (working in another office, so I can't really see this problem first hand) who is trying to install RH8 on a Win7/32 machine (new install, not an upgrade). A member of her IT dept is performing the install.
    After the installation of the app and patches is finished, RH seems to work more or less normally (she's new to RH, so her sense of "normal" is rather limited at this stage).  The problem is that other applications lock up and crash (she mentioned MS Office apps in particular, but that could be because those are the ones she tends to use the most).
    After un-installing RH, the other apps no longer crash.
    I've recommended re-installing but skipping the "RoboHelp for Word" piece, but I can't think of anything else.
    I'm just wondering if anyone else has seen a similar situation? I've found other threads that deal with RH crashing or the RH install failing, but I couldn't find any in which RH caused other apps to crash.
    Thanks,
    Dave

    Hmm...I posted a reply via email, but it isn't showing up, so I'm pasting it in.
    Hi, Rick -
    Thanks for the suggestions. Like some of the other threads I've found, these seem to deal mainly with RH crashes rather than other apps. But your first link possibly has some overlap as the menu issue it describes also pops up in a thread I found:
    "RoboHelp 8 crashes on Windows 7"
    http://forums.adobe.com/message/2955493#2955493
    This thread includes a scenario in which Outlook and other apps are failing. Additionally, some users were having RH crashes related to the menu bug. Some users found relief by uninstalling source control, others did not. Finally, An Adobe employee posted a fix that corrects issues related to Oleacc.dll which helped some users.
    To be thorough, I'll mention that the problems are occurring on a laptop (another thread traced RH crashes to a BioMetric service running on their laptop). And my colleague has the FoxIt PDF utility installed (I don't think this should be the issue here, but perhaps worth a mention.)
    I'm going to suggest that they try:
    1a. Check the registry to ensure traces of the previous RH install are gone.
    1b. Reinstall but omit source control and RH for Word (I think you can skip these during install?  I'm no longer allowed to to perform my own installs, so I'm less familiar with the process than I once was.)
    2. Ensure patches are installed (version should be 8.02.208)
    3. If that doesn't work, try the Oleacc.dll fix.
    4. If that doesn't work, try another Win7/32 machine (preferably non-laptop).
    5. If all is well on the other machine, I guess it is time to start looking at which non-essential services might be causing a conflict.
    Regards,
    Dave

Maybe you are looking for

  • Any way to transcode more than one file at a time?

    I've noticed that Final Cut Pro X, when doing transcoding (for Optimizing or creative Proxy media) only processes a single file at a time (whereas it can handle processing up to 5 audio files at once), and is only using about 70% of my processor(s) -

  • Can no longer connect to SMB server after upgrading to Lion

    We have a MacBook Pro that was running 10.6.8. The user upgraded to Lion, and can no longer connect to a Windows 2008 file server. (We have two offices connected through a hardware tunnel, but i do not think this is the issue.) We have tried to conne

  • How to adjust R/W rules to display images inline?

    Hi all, out of the box, when I insert an image in a paragraph (DITA 1.2) then FrameMaker 12 uses the "below line" display setting. I need to display it inline, at the insertion point. When I adjust the settings of the anchored frame then the inline s

  • Overloading the Firewire Bus?

    I am having troubles with having a Canon GL2 video camera being plugged into my iMac G5 via Firewire and a LaCie 250 GB external harddrive being plugged into my iMac G5 via Firewire at the same time. If they are both plugged in via Firewire at the sa

  • Power adapter - not from apple.

    I recently purchased an iPod power adapter + dock from Value City I think it was. I don't use the dock, but I do use the power adapter that I plug my iPod into using the cord that came with my iPod. the box for the adapter says that it's compatible w