Reflection problem with private class

I am trying to write a junit on private class and I am stuck not knowing how to access private class.
Here is the structure of my code:
public abstract class cars extends auto{
private class model{
String name;
String year;
String make;
private model getInfo(name, year, make{
Model mod = new Model();
mod.name = "Echo";
mod.year = "1992";
mod.make = "Toyota";
return mod;
}Basically how do I use reflection so I can write assert such as
assertEquals(getInfo.year, "1992");Thanks in advance!

You don't. Private methods, members, and classes are considered implementation details and should not be directly tested with your unit tests.

Similar Messages

  • Getting problem with DOMImplementation classes method getFeature() method

    hi
    getting problem with DOMImplementation classes method getFeature() method
    Error is cannot find symbol getFeature()
    code snippet is like...
    private void saveXml(Document document, String path) throws IOException {
    DOMImplementation implementation = document.getImplementation();
    DOMImplementationLS implementationLS = (DOMImplementationLS) (implementation.getFeature("LS", "3.0"));
    LSSerializer serializer = implementationLS.createLSSerializer();
    LSOutput output = implementationLS.createLSOutput();
    FileOutputStream stream = new FileOutputStream(path);
    output.setByteStream(stream);
    serializer.write(document, output);
    stream.close();
    problem with getFeature() method

    You are probably using an implementation of DOM which does not implement DOM level-3.

  • Problems with inner classes in JasminXT

    I hava problems with inner classes in JasminXT.
    I wrote:
    ;This is outer class
    .source Outer.j
    .class Outer
    .super SomeSuperClass
    .method public createrInnerClass()V
         .limit stack 10
         .limit locals 10
         ;create a Inner object
         new Outer$Inner
         dup
         invokenonvirtual Outer$Inner/<init>(LOuter;)V
         ;test function must print a Outer class name
         invokevirtual Outer$Inner/testFunction ()V
    .end method
    ;This is inner class
    .source Outer$Inner.j
    .class Outer$Inner
    .super java/lang/Object
    .field final this$0 LOuter;
    ;contructor
    .method pubilc <init>(LOuter;)V
         .limit stack 10
         .limit locals 10
         aload_0
         invokenonvirtual Object/<init>()V
         aload_0
         aload_1
         putfield Inner$Outer/this$0 LOuter;
         return
    .end method
    ;test
    .method public testFunction ()V
         .limit stack 10
         .limit locals 10
         ;get out object
         getstatic java/io/PrintStream/out  java/io/PrintStream;
         aload_0
         invokevirtual java/lang/Object/getClass()java/lang/Class;
         ;now in stack Outer$Inner class
         invokevirtual java/Class/getDeclaringClass()java/lang/Class;
         ;but now in stack null
         invokevirtual java/io/PrintStream/print (Ljava/lang/Object;)V
    .end methodI used dejasmin. Code was equal.
    What I have to do? Why getDeclatingClass () returns null, but in dejasmin code
    it returns Outer class?

    Outer$Inner naming convention is not used by JVM to get declaring class.
    You need to have proper InnerClasses attribute (refer to http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#79996)
    in the generated classes. Did you check using jclasslib or another class file viewer and verified that your .class files have proper InnerClasses attribute?

  • Problems with String[] Class Object

    Hi guys,
    I'm writing a web server who should invoke a method of a class when asked by a client.
    My problem is that if the method that should be invoked has a String[] parameter the web server is unable to invoke it and throws a java.lang.IllegalArgumentException: argument type mismatch.
    Useful pieces of code to understand are the following:
    //create the Class[] to pass as parameter to the getMethod method
    Class[] paramType = {String[].class};
    //find the class "className" and create a new instance
    Class c = Class.forName(className);
    Object obj = c.newInstance();
    //the getMethod should find in the class c the method called nameMeth
    // having paramType (i.e. String[]) as parameter type...
    Method theMethod = c.getMethod(nameMeth, paramType);
    //here's the problematic call!!
    theMethod.invoke(obj, params);I've noted that System.out.println(theMethod); prints the signature of the method with the parameter type java.lang.String[].
    System.out.println(paramType[0]); instead prints [Ljava.lang.String;
    I know that [L means that it is an array, so why do you think that I'm having an argument type mismatch?
    Thank you                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    I had no problems making that work.import java.lang.reflect.Method;
    public final class StringArray {
        public static final String CLASSNAME = "StringArray";
        public static final String METHODNAME = "myMethod";
        public static final String[] sa = { "a", "b"};
        // automatic no-args constructor
        public final void myMethod(String[] sa) {
            for(int i=0;i<sa.length;++i) {
                System.out.println(sa);
    public static final void main(String[] arg) throws Exception {
    //create the Class[] to pass as parameter to the getMethod method
    Object[] params = { sa };
    Class[] paramType = {sa.getClass()};
    //find the class "className" and create a new instance
    Class c = Class.forName(CLASSNAME);
    Object obj = c.newInstance();
    //the getMethod should find in the class c the method called nameMeth
    // having paramType (i.e. String[]) as parameter type...
    Method theMethod = c.getMethod(METHODNAME, paramType);
    //here's the problematic call!!
    theMethod.invoke(obj, params);

  • Reflection problems with null pointer exception

    I am having a problem with reflection. I keep getting a NullPointerException and can't figure out why.
    It is happening when I call this:
    ResponseObject result = (ResponseObject)method.invoke(classInstance, argArray);
    I can't figure out what the problem is. I had this reflection working, and then I made some changes to how the argument array was created. In the end, the argarray is the same.
    Any ideas?

    Also, the API for the method class says that a
    NullPointerException is thrown if the object in the
    first argument is null. I have tested for this, and
    it is not null.does it? read again, because giving 'null' as the first argument is perfectly legal. how else would you reflectively invoke a static method, since you might not have an actual instance of the class to pass

  • Problem with JFrame class.

    To risolve my problem i need for few diferent frame
    ( for esample in one i put JTextFild that take the user input, in a nother one i need for program output ) . But, th problem is, all my frames using the same object.
    If i construct diferent JFrame window class i have problem that i don't acess in the same object from all the window. And if i dont use a object, i have static acess .
    I risolve the problem with 1 JFrame class with diferent constructors, but i wont a diferent way to risolve my problem, because there are few windows.
    Help me.....

    Make the class that extends JFrame an inner class of the the main class. You can then access all members of the outer class.

  • Problems with importing classes in Java

    Hello,
    i have some problems with a simple project.
    The structure is like this:
    web-inf/classes/databeans/loginexistinguserform.java
    web-inf/classes/formactions/loginexistinguseraction.java
    loginexistinguserform.java :
    package databeans;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionMapping;
    import javax.servlet.http.HttpServletRequest;
    public class LoginExistingUserForm extends ActionForm
         String userid;
         String password;
         public String getUserid(){return userid;}
         public void setUserid(String newUserid){userid=newUserid;}
         public String getPassword(){return password;}
         public void setPassword(String newPassword) {password=newPassword;}
         public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
              ActionErrors errors=new ActionErrors();
              if(this.userid==null||this.userid.equals(""))
                   errors.add("user",new ActionError("error.userid.required"));
              if(this.password==null||this.password.equals(""))
                   errors.add("pass",new ActionError("error.password.required"));
              return errors;
    }loginexistinguseraction.java
    package formactions;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import databeans.LoginExistingUserForm;
    public class LoginExistingUserAction extends Action
         public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException
              LoginExistingUserForm loginData=(LoginExistingUserForm)form;
              if(loginData.getUserid().equals("Admin")&&loginData.getPassword().equals("Parola"))
                   return mapping.findForward("successLogin");
              else
                   return mapping.findForward("failureLogin");
    }I can complie succesfully loginexisitinguserform.java but problems appears when i want to compile the second file, loginexistinguseraction.java with command: javac loginexistinguseraction.java
    C:\ApacheGroup\Tomcat\webapps\PersonalWeb\WEB-INF\classes\formactions>javac loginexistinguseraction.java
    loginexistinguseraction.java:10: package databeans does not exist
    import databeans.LoginExistingUserForm;
    ^
    loginexistinguseraction.java:17: cannot find symbol
    symbol : class LoginExistingUserForm
    location: class formactions.LoginExistingUserAction
    LoginExistingUserForm loginData=(LoginExistingUserForm)form;
    ^
    loginexistinguseraction.java:17: cannot find symbol
    symbol : class LoginExistingUserForm
    location: class formactions.LoginExistingUserAction
    LoginExistingUserForm loginData=(LoginExistingUserForm)form;
    ^
    3 errors
    I have the CLASSPATH variable setup tu C:/Sun/Appserver/lib/j2ee.jar
    Can someone help me ? Thank you in advance !

    Thank you very much ! It worked. I'm really new in Jav a programming.
    Now i have encoutered another problem. When i want to login, and enter user name and password i am redirected to a login.do page, instead of Welcome.jsp
    Here is Login.jsp:
    <%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@page contentType="text/html; charset=ISO-8859-1"%>
    <html>
    <head><title>Login Form</title></head>
    <body>
    <html:errors/>
    <html:form action="/login">
    <table border="0" width="200">
    <tr>
         <td>User Name:</td>
         <td><html:text property="userid" maxlength="13"/></td>
    </tr>
    <tr>
         <td>Password:</td>
         <td><html:password property="password" maxlength="13"/></td>
    </tr>
    </table>
    <br />
    <html:submit value="Login"/>
    </html:form>
    </body>
    </html>and here is struts-config.xml :
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
              "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
    <struts-config>
    <!--========================beans for HTML form data=======================-->
    <form-beans>
         <form-bean name="loginBean" type="databeans.LoginExistingUserForm"/>
    </form-beans>
    <!--========================Action Mappings================================-->
    <action-mappings>
         <action path="/login" type="formactions.LoginExistingUserAction" name="loginBean" input="/Login.jsp" scope="session">
              <forward name="succesLogin" path="/pages/Welcome.jsp" redirect="true"/>
              <forward name="failureLogin" path="/pages/Diverse.jsp" redirect="true"/>
         </action>
    </action-mappings>
        <message-resources parameter="MessageResources" />
    </struts-config>

  • Problems with loading Classes from a Directory of a jar file.

    Hi Guys,
    i have a problem with my programm. It works greatly in my eclipse platform. but there are all classes in my default folder. I want to add a plugin function now. My Abstract classes are in in my default folder and my doughter classes are in my plugin-folder called plugin.
    I look what is in the pluginfolder -> all my doughter classes. but i every time get a Class Cast Exception and an ClassNotFoundException.
    How can i do that ? Current i do it with Class.forName(frames.substring(0,frames[i].indexOf(".class")));
    best regards flo

    http://java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html

  • Inheritance problem with parent class calling child class

    I have a problem with inheritance with a parent class calling a child class method. Below is the example pseudocode code and my problem:
    public abstract class A {
        protected void function1 ( ) { }
        protected void function2 () {
             //calls function1();
             function1();
    public abstract class B extends A {
        protected void function1 ()  {
             // do stuff
    public class C extends B {
        protected void function1 ()  {
            // do stuff
            super.function1 ();
    }I have an object instance of class C created and its function2() is invoked.
    My problem is, while in function2(), which belongs to abstract class A and the method call to function 1() is called, the call invokes the function1() of class B. Shouldn't the call invoke function 1() of class C instead? And then function1() of class B will be called after due to the super.function1(). It's not behaving like I thought it would.
    Edited by: crono77 on Jan 10, 2008 8:13 PM

    Nevermind, i found my error :)

  • Problem with loading classes!!!

    I am loading classes using
    // Open File
    InputStream jarFile = new BufferedInputStream(new FileInputStream(
    pluginPath));
    // Get Manifest and properties
    Attributes attrs = new JarInputStream(jarFile).getManifest().
    getMainAttributes();
    jarFile.close();
    // Read Main Class
    String mainClass = attrs.getValue("Protocol-Class");
    // Load all classes from jar file without giving classpath
    URL url = new URL("jar:file:" + pluginPath + "!/");
    JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
    URL[] urls = new URL[] {
    url};
    ClassLoader classLoader = new URLClassLoader(urls);
    // Create new instance of protocol
    Protocol protocol = (Protocol) classLoader.loadClass(mainClass).
    newInstance();
    I am loading classes one by one say a order A, B, C. In my case class c extends class A. So I am loading class A first and later B and finally C. But I am getting exceptions when loading class C that Class A is unknown.The following exception is thrown
    java.lang.NoClassDefFoundError: com/a/A at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
    Please give me a solution to make it run.

    You create a new class loader for each class. The class loaders are independent, and so the class hierarchies they load are independent. Class A loader by classLoaderOne doesn't see class B loader by classLoaderTwo - they are loaded into their own sandboxes.
    Either load everything with one class loader or create the class loaders in a hierarchy. To create a hierarchy use the class loader constructor that takes a parent class loader as a parameter. One class loader may be easier because then you don't need to worry about loading order.

  • Problem with local class, static private attribute and public method

    Hello SDN,
    Consider the following situation:
    1) I have defined a LOCAL class airplane.
    2) This class has a private static attribute "type table of ref to" airplane (array of airplanes)
    3) A public method should return the private static table attribute
    Problems:
    a) The table cannot be given as an EXPORTING parameter in the method because TYPE TABLE OF... is not supported and I get syntax errors. I also cannot define a dictionary table type because it is a local class.
    b) The table cannot be given as a TABLES parameter in the method because TABLES is not supported in the OO context.
    c) The table cannot be given as an EXPORTING parameter in the method defined as LIKE myStaticAttribute because my method is PUBLIC and my attribute is PRIVATE. ABAP syntax requires that all PUBLIC statements are defined before PRIVATE ones, therefore it cannot find the attribute to reference to with LIKE.
    I see only 2 solutions:
    a) Never ever use local classes and always use global classes so that I might define a dictionary table type of my class which I can then use in my class.
    b) Make the attribute public, but this goes against OO principles, and isn't really an option.
    Am I missing anything here, or is this simply overlooked so far?

    Hello Niels
    Since your class is local and, thus, only know to the "surrounding" application is does not really make sense to make it public to any other application.
    However, if you require to store instances of your local classes in internal tables simply use the most generic reference type possible, i.e. <b>OBJECT</b>.
    The following sample report shows how to do that. Furthermore, I believe it also shows that there are <u><b>no </b></u>serious inconsistency in the ABAP language.
    *& Report  ZUS_SDN_LOCAL_CLASS
    REPORT  zus_sdn_local_class.
    " NOTE: SWF_UTL_OBJECT_TAB is a table type having reference type OBJECT
    *       CLASS lcl_airplane DEFINITION
    CLASS lcl_airplane DEFINITION.
      PUBLIC SECTION.
        DATA:    md_counter(3)             TYPE n.
        METHODS: constructor,
                 get_instances
                   RETURNING
                     value(rt_instances)   TYPE swf_utl_object_tab.
      PRIVATE SECTION.
        CLASS-DATA: mt_instances    TYPE swf_utl_object_tab.
    ENDCLASS.                    "lcl_airplane DEFINITION
    *       CLASS lcl_airplane IMPLEMENTATION
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
        APPEND me TO mt_instances.
        DESCRIBE TABLE mt_instances.
        md_counter = syst-tfill.
      ENDMETHOD.                    "constructor
      METHOD get_instances.
        rt_instances = mt_instances.
      ENDMETHOD.                    "get_instance
    ENDCLASS.                    "lcl_airplane IMPLEMENTATION
    DATA:
      gt_instances      TYPE swf_utl_object_tab,
      go_object         TYPE REF TO object,
      go_airplane       TYPE REF TO lcl_airplane.
    START-OF-SELECTION.
      " Create a few airplane instance
      DO 5 TIMES.
        CREATE OBJECT go_airplane.
      ENDDO.
      gt_instances = go_airplane->get_instances( ).
      CLEAR: go_airplane.
      LOOP AT gt_instances INTO go_object.
        go_airplane ?= go_object.
        WRITE: / 'Airplane =', go_airplane->md_counter.
      ENDLOOP.
    END-OF-SELECTION.
    Regards
      Uwe<u></u>

  • Splitting 1GB Files // Problem with FileStream class

    Hi, in my Air (2 beta) app i'm splitting large files to upload them in  smaller chunks.
    Everything works fine, until i choose files larger  than 1GB?
    This might be the Problem:
    var  newFile:File =  File.desktopDirectory.resolvePath(filename);                        
    trace(newFile.size);
    //  8632723886  (About 8GB correct file size)
    BUT if i use the FileStream Class instead:
    var stream:FileStream = new  FileStream();
    stream.open(new File(filename), FileMode.READ);
    trace(stream.bytesAvailable)
    //  42789294 ("wrong" file size?)
    If i run the same code with files smaller  than 1GB stream.bytesAvailable returns the same result as newFile.size.
    Is there a  limitation in the FileStream class or is my code wrong?
    Thanks!

    use asynchronous file handling method. i.e use (filestream object).openAsync(file,filemode.read). here is the implementation :
    private var fileCounter:int = 0;
    private var bytesLoaded:int = 0;
    private var filePath:String = "D:\\folder\\";
    private var fileName:String = "huge_file";               
    private var fileExtension:String = ".mkv";
    private var file:File = new File(filePath+fileName+fileExtension);
    //split size = 1 GB
    private var splitSize:int = 1024*1024*1024;
    private var fs:FileStream = new FileStream();
    private var newfs:FileStream = new FileStream();
    private var byteArray:ByteArray = new ByteArray();
    private function init():void{
         fs.addEventListener(Event.COMPLETE,onFsComplete);
         fs.addEventListener(ProgressEvent.PROGRESS,onFsProgress);
         newfs.open(new File(filePath+fileName+fileCounter+fileExtension),FileMode.WRITE);
         fs.openAsync(new File(filePath+fileName+fileExtension),FileMode.READ);
    private function onFsComplete(e:Event=null):void{                    
         fs.readBytes(byteArray,0,fs.bytesAvailable);                    
         newfs.writeBytes(byteArray,0,Math.min(splitSize-bytesLoaded,fs.bytesAvailable));
         for(var i:int = 0; i < byteArray.length; i+=splitSize){
              newfs.close();
              newfs.open(new File(filePath+fileName+fileCounter+fileExtension),FileMode.WRITE);
              newfs.writeBytes(byteArray,i,Math.min(splitSize,byteArray.length-i));
              fileCounter++;
              trace("Part " + fileCounter + " Complete");
    private function onFsProgress(e:ProgressEvent):void{
         if((bytesLoaded+fs.bytesAvailable)==file.size){
              onFsComplete();                         
         else if((bytesLoaded + fs.bytesAvailable)>=splitSize){
              fs.readBytes(byteArray,0,splitSize-bytesLoaded);
              newfs.writeBytes(byteArray,0,byteArray.length);
              newfs.close();
              bytesLoaded = fs.bytesAvailable;
              fs.readBytes(byteArray,0,bytesLoaded);
              fileCounter++;
              newfs.open(new File(filePath+fileName+fileCounter+fileExtension),FileMode.WRITE);                         
              newfs.writeBytes(byteArray,0,byteArray.length);
              byteArray.clear();
              trace("Part " + fileCounter + " Complete");
         else{
              bytesLoaded+=fs.bytesAvailable;
              fs.readBytes(byteArray,0,fs.bytesAvailable);
              newfs.writeBytes(byteArray,0,byteArray.length);
              byteArray.clear();     
    cheers!

  • Help - problems with mixin class and recursion

    I'm trying to set up functionality which will allow me to track gui node nesting.
    Basically, I'd like to have an optional name for each node and be able to generate a string which uses these to track descent. So, e.g., if I have "panel1" as my top scene, "control1" as a node within that scene and "image1" as a node within control1, I'd like to be able to produce the string "panel1.control1.image1" with a call to the image1 node.
    I am attempting to do this with a mixin class, as it seems precisely the sort of situation suited to mixins. So I have:
    import java.lang*;
    public mixin class Descent {
        public-init var objName:String = getClass().toString();
        public function getObjDescent():String;
    }When an object is created, it can be assigned a name - or, if there's no assignment, it gets given its class name. When I want the full "descent name" of the object, I'll call getObjDescent(). So far so good.
    But now it gets trickier. The idea is to track descent within javafx nodes. If I don't want to assume everything is set up properly, I've got to cover a few cases:
    (a) the class into which this object is mixed - the mixee - is not a javafx node
    (b) the mixee is a javafx node, but its parent is not
    (c) the mixee is a javafx node and descends from a javafx node
    Thus:
        public function getObjDescent():String
            var build:String="";
            // get parent's name, if it has it
            try {
                var nodeClass:Class[] = [javafx.scene.Node.class];
                var checkIsNode = this.getClass().getMethod("getNodeMaxHeight",nodeClass);
                if ((this as Node).parent != null) {
                    var parentDescentFn = (this as Node).parent.getClass().getMethod("getObjDescent",(null as Class[])) ;
                    build = ((this as Node).parent as Descent).getObjDescent();
                    build = build.concat(".");
            catch (e:NoSuchMethodException)
                build = "";
            build.concat(this.objName);
        };First I have to check if the mixee is a javafx Node. I can't do this by member checking because javafx doesn't support that. So I have to check by methods. I use one of the Node methods - getNodeMaxHeight - if it is defined for the mixee, the mixee is a node. If not, I'll get an error and can abort down to the catch section.
    If this mixee is a node, then it will have a parent node. If that parent also has descent info, I have to prefix that parent's descent name. So now I need to figure out if I can recursively call getObjDescent() on the parent.
    So I do the same getMethod() approach on the parent (if any) to see if it has a name I have to prefix. If not then, again, we abort out to the NoSuchMethodException error catch.
    Now I should be sure that this is a node and its parent has the Descent fields. So I should be safe to call the parent for its info.
    Here I've done this as
    ((this as Node).parent as Descent).getObjDescent().Though that gives me no errors, I'm not sure if that's the right way to cast things - will it look at the wrong portion of the object to find the method call? Better would be to call the function using the parentDescentFn variable, which I've gotten in checking to see if the parent has the Descent class mixed in, but I can't figure out how to go from a java.lang.reflect.Method variable to generating an actual call of that method. So there's a first question.
    However I get to that recursive call, I will get back the parent's descent name. I add my descent separator, '.', and then append the objName of this particular class. Voila - the full descent name.
    Though the above throws no warnings in the editor, it generates two compile errors.
    First, it tells me it cannot find the symbol:
    symbol  : method get$class()
    location: class javafx.scene.Node
                var nodeClass:Class[] = [javafx.scene.Node.class];I need to construct a Class[] containing Node for my call to getMethod in the next line. Is this not the right way to specify the Node class?
    The next error is:
    non-static variable this cannot be referenced from a static context
                var checkIsNode = this.getClass().getMethod("getNodeMaxHeight",nodeClass);I still find what javafx treats as "static" and what non-static to be mystifying. I'm fairly sure I've seen mixin classes which use "this" to grab the mixee object, and I certainly need to do so in this case to check if the mixee is a javafx Node and, subsequently, to get its parent Node.
    So... three problems:
    - Using "this" in a mixin class ... what's messing that up?
    - constructing the Class[] sequence for the first call to getMethod
    - (possibly) properly generating a call to the parent mixee's getObjDescent() method.
    urg.

    RE static vs non-static of this:
    I'm not sure, but I think it's a little less straightforward:
    e.g. if I type:
    var dummy = this; no problem. (This is analogous to what you did.)
    But if I type:
    var dummy = this.getClass();I get the static/non-static error. I take this to reflect the fact that getClass() is not defined by the mixin class, even if it is defined for any object which might use that class. (Perhaps, down deep in the code, "this" has been redirected to point just to that block of memory which gives the implementation of the mixin information?)
    Yet if I type
    var dummy = getClass();it works fine, and returns the class which is implementing the mixin.
    My guess is that "this" is being treated specially with a mixin class - I think, at compile time, if it just says "this" it is ignored by the "mixin" handling and passed along to the regular class compiling to process, but if it is this.method() or this.member, then the mixin class handles it and will throw that error if it gets any methods or members which it did not itself define.
    I haven't had any trouble using the Class objects in javafx, though I don't think I can easily make them do what I, here, specificly want to do. But getClass() seems to work just fine (as long as I don't say this.getClass() !!), as do calls to get or invoke members - I got that one of the 3 problems solved.
    I discovered that javafx seems to flatten its classes out to the single implementation of FXObject - when I attempted to parse the interfaces of the mixee class to see if "Node" was a member (which it should be, conceptually), I only got 2 interfaces: FXObject and my mixin class. So I can't use the Class commands to find out of the mixee class object implements Node or not.
    I also discovered that, given how javafx seems to compile itself into java, I could actually check for members as well as methods: getMethod("loc$parent") would actually return the parent member, if present. So getMethod can be used to check for the presence of both members and methods in javafx classes. I could not figure out, however, how to get from that reference to the value of the object itself - while invoke() works properly for methods, I couldn't get it to work for the members it retrieved. Though I didn't try too terribly hard.
    The getMethod() Class function did allow me to check if a class had my mixin class present - or, at least, if it contained a method with the same name as one defined in that class.
    Ultimately, though, I'm still stuck with trying to answer the questions, given a generic javafx class (implicit in this, which I could get by getClass()):
    - does this mixee class implement Node?
    - if so, what is the value of its "parent" member ((this as Node).parent didn't seem to work within the mixin class' code. Or so it seemed.)
    I've gotten around that problem by adding a Node member to the class, so that, rather than trying to deduce it from "this" or the Class functions, it simply uses its variable. Less elegant and more memory-using, but quicker and, actually, more flexible. That approach solves my immediate problem, though it does leave unanswered the more basic questions raised by the exercise.
    thanks for the feedback!

  • Problems with Adler32 class in JDK 1.5 (not tried 1.6)

    When I use the java.util.zip.Adler32-class for generating Adler32-checksums, I found a couple of strange problems. When the total filesize (generating checksums of several files with the same checksum-object, using reset() in between) is 31999 bytes or greater, it gives pseudorandom output for the first file that exceeds the 31999 bytes. By running the test-program several times in a row, it seems like the output changes every second, as if random data was generated with the second counter as a seed. All the other checksums seem correct, and they do not change. A workaround that works for a series of only small files is to create a new Adler32-object for every file that needs its checksum generated, but that proves itself insufficient when a single file exceeds 31998 bytes of size (31999 or above).
    I've tried different inputstreams and various methods of using the update(xx)-functions of the Adler32, but I always get the same results. Is this a known bug (Note: JDK 1.5, not 1.6)? Or am I doing something obviously wrong? Example source code can be provided if necessary.

    R,
    I'm disappointed to see that you haven't received any replies to this. I am experiencing a very similar problem. What I have noticed is that the problem occurs when the combo-box is forced to be heavy-weight (meaning it has to draw itself outside the bounds of the window). In those cases, I can never pick a different value from the combo-box in the table. The exact same app run under 1.3.1 does not have any problems. Further, combo-boxes not in table views do not seem to have any problems even when they are heavy-weight.
    Paul

  • Problems with Embedded classes mapping

    Hi,
    I'm experiencing problems for table generation with the following case:
    a class declares two fields; one of them typed as a subclass of the other; both fields annotated with @Embedded; the subclass uses the annotation @AttributeOverride to avoid column names duplication.
    When the tables are generated, one of the field (the most specialized one) is simply omitted by the JPA implementation...
    To illustrate my problem, here is an example:
    @Entity
    public class Bar implements Serializable {
         @Embedded
         protected Foo foo = null;
         @Id
         @GeneratedValue(strategy=GenerationType.SEQUENCE)
         protected long id = -1;
         @Embedded
         protected SubFoo subFoo = null;
         public Bar() {
                    super();
            // getters & setters
    @Embeddable
    public class Foo implements Serializable {
         @Column
         protected String bar = null;
         @Column
         protected String foo = null;
         public Foo() {
              super();
            // getters & setters
    @Embeddable
    @AttributeOverrides({
         @AttributeOverride(name="bar", column=@Column(name="subbar")),
         @AttributeOverride(name="foo", column=@Column(name="subfoo"))
    public class SubFoo extends Foo {
         public SubFoo() {
                    super();
    }The generated table BAR contains only 3 columns: ID, FOO, BAR...
    ...and what I expect is two additionnal columns named SUBFOO & SUBBAR!
    Can someone tell me: if I definitely need to go back to school (I'm obviously not an EJB expert), or how to make it work as I expect...?
    Thanks
    -Jerome

    I found the note in the EJB specs that clearly states that my issue has no solution at this time:
    "Support for collections of embedded objects and for the polymorphism and inheritance of embeddable classes will be required in a future release of this specification."
    EJB 3.0 specs - final release - persistence, page 23, note 10 in section 2.1.5

Maybe you are looking for

  • New to Logic 9, Questions about mixing with summing box.

    Hello - glad to be aboard. I just picked up Logic9 last week.. I have been on DP...well since it was P (I guess 20yrs,) Been contemplating the move for quite some time, but as I too, pay the bills with music, I've got to stay on DP until I and Logic

  • Compressor / Deinterlacing

    Hello - I have a few files to encode for the web, and I need some advice on compressor and deinterlacing. I exported the video from FCP to Compressor to be encoded @ 640 x 480 with H.624 (2k kbps). I chose the deinterlacing filter, with the sharp alg

  • Upload new phrases in the system

    Hi, We are currently upgrading from 46c to ECC604. In 46C we use a very small functionality of the dangerous goods master. Just some info for entering UN numbers, hazardous substances and user defined texts (5x). We have our own forms and print some

  • What is project systems are related to fico

    hi sap gurus anybody clesrly tell me about  project systems are related to fico   ,  and what are the relations to these sap fico and ps? regards venkatareddy

  • How many songs needed to create a Genius playlist?

    I was wondering if there is any rule of thumb about how many songs I would need on my iphone to create a Genius playlist. I currently have 1566 songs, but I ususally get the same old message about not having enough songs to create a list. I have many