Inner classes generated by xmlbeans

I was given a library to use that most of it was created with the apache xmlbeans framework. The following code works within the eclipse java ide but JDeveloper does not find the inner factory class of the QueryEnterpriseAckDocument class. How does JDeveloper handle working with inner classes. This may be an issue that requires going back to eclipse as the ide.
     QueryEnterpriseAckDocument ackDoc = QueryEnterpriseAckDocument.Factory.newInstance();
     QueryEnterpriseAckDocument.QueryEnterpriseAck ack = ackDoc.addNewQueryEnterpriseAck();
thanks,
Jeremy Wilson
     

Is there some kind of meta-specification for JSR 269 that explains the design goals? Not really, only what is here http://jcp.org/en/jsr/detail?id=269
With such a document, it might also be easier to figure out how processors are supposed to work.JSR 269 is designed to permit solutions to various complex scenarios rather than provide solutions. Those scenarios and their intended solution are not often obvious from the API specs.
You might like to take a look at https://hickory.dev.java.net/ where I have a project to supply some tooling to assist annotation processor authors, and a wiki to document things. Allocating time to this is not easy, but the 3 packages in the API there are pretty robust. The test cases in source code for those have plenty of examples of some of the more complex design goals, such as the ability to write an annotation processor which works correctly in an incremental compile scenario, when the generated file derives from more than one source file, not all of which may be included in an incremental compile.
Other than that, if you have any particular questions, just ask in this forum, and Joe (JSR 269 spec lead) or myself should be able to answer them for you.
Bruce
Edited by: brucechapman on Feb 4, 2008 1:35 PM

Similar Messages

  • JSP Inner class generates IllegalAccess Error

    I created an inner class inside of a JSP file. Unfortunately, Weblogic 5.1.0
              compiles the inner class as private. So I got an IllegalAccessError. Is
              there a way to use inner classes in JSP files?
              Thank you.
              - Remington
              Here is my code:
              <%
              Object obj = new Object()
              public int hashCode()
              return 100;
              out.println( "obj: " + obj.hashCode() );
              %>
              Error messages:
              Wed Jan 31 17:23:38 PST 2001:<E> <ServletContext-General> Servlet failed
              with Exception
              java.lang.IllegalAccessError: try to access class
              jsp_servlet/_test/_test01$1 from class jsp_servlet/_test/_test01
              at jsp_servlet._test._test01._jspService(_test01.java:66)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              :105)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java:742)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java:686)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
              Manager.java:247)
              at
              weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
              at
              weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
              Code)
              

    Works ok with sp8.
              Remington Li <[email protected]> wrote:
              > I created an inner class inside of a JSP file. Unfortunately, Weblogic 5.1.0
              > compiles the inner class as private. So I got an IllegalAccessError. Is
              > there a way to use inner classes in JSP files?
              > Thank you.
              > - Remington
              > Here is my code:
              > <%
              > Object obj = new Object()
              > {
              > public int hashCode()
              > {
              > return 100;
              > }
              > };
              > out.println( "obj: " + obj.hashCode() );
              > %>
              > Error messages:
              > Wed Jan 31 17:23:38 PST 2001:<E> <ServletContext-General> Servlet failed
              > with Exception
              > java.lang.IllegalAccessError: try to access class
              > jsp_servlet/_test/_test01$1 from class jsp_servlet/_test/_test01
              > at jsp_servlet._test._test01._jspService(_test01.java:66)
              > at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              > at
              > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              > :105)
              > at
              > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              > l.java:742)
              > at
              > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              > l.java:686)
              > at
              > weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
              > Manager.java:247)
              > at
              > weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
              > at
              > weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
              > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
              > Code)
              Dimitri
              

  • Inner class vs. imported class

    Hi everyone,
    I have entitiy beans created for a client's web app I'd like to use in the
    web service using WebLogic Workshop 7.0. Say the classes are imported like
    this in the services:
    import com.hoike.clientname.ap.bean.Invoice
    import com.hoike.clientname.ap.bean.Vendor
    Instances of these classes are used in callback methods and some of the
    service methods.
    When I generate the CTRL file, it actually adds those imported classes as
    inner class of the service defined.
    The problem is that when I try to used these services from another service,
    I cannot use the imported classes (as Invoice or Vendor), but instead I have
    to use the inner class (InvoiceService.Invoice or VendorService.Vendor)
    Does WebLogic Workshop 7.0 only allow you to use inner classes? Is there a
    way to use custom classes as method parameters?
    Thanks in advance!
    Makoto

    how do you declare your inner class?
    Is it (public)
    public static class MyInnerClassor (private)
    private static class MyInnerClassor (package)
    static class MyInnerClassor (protected)
    protected static class MyInnerClassTry to change the way you declare the inner class. Use protected or package or public instead.

  • Inner Classes Changing Access Rights Of Parent  Members

    I read that if you access a parent class's private memebers or methods from within an inner class, those members of methods will automatically and silently be converted to having package access. This seems dangerous and I'd like to know how I could design around it.
    Here is my current dilemma. I have an EventHandler class whose handleEvent() method changes with the object's state. I've implemented this using the Strategy Pattern, where the Strategy objects are inner classes of EventHandler. The problem is that these Strategy objects need access to certain private members and methods of their parent. There is no reason, however, to give package access to these members and methods. What can I do? Or does this suggest that I need a design change? Other than this issue, though, I'm quite happy with the design.
    Thanks for any thoughts,
    John

    When inner classes access private fields or methods, the compiler generates new package-private methods
    with names like "access$000":
    import java.lang.reflect.*;
    public class X {
        private void x() {}
        class Y {
            public void y() {
                x();
        public static void main(String[] args) {
            Method[] methods = X.class.getDeclaredMethods();
            for(int i=0; i<methods.length; ++i)
                System.out.println(methods.getName());
    So it's not correct that the access to fields or methods is changed, just that additional methods are added.
    Unless you're in the habit of writing method names that contain '$', I think it's unlikely that you'll directly call
    these new methods, and if you do, it should be easy to spot!

  • Inner classes should appear in jar?

    At first thanks for answering my question: I did resolve the problem of excluding files, so the .java and .html are not present anymore�.. but the problem stays: I do see the applet in the applet viewer but not on the safari (mac Version 3.0.4) browser. The tag, I think is ok:
    <applet code="Slides.class" width="500" height="500" archive="slides.jar"></applet>
    A second question related to this problem might be, that the two inner class files that show up in the build/class file are not present in the jar. The application consists of just one single class (I already moved some initialization stuff from the constructor to the init). The class is called Slides.class and the compiler generates the Slides$1, Slides$xxx and Slides$yyyy. Should they all be included in the jar I only so the main class.
    Thanks a lot
    willemjav
    The (still dirty) code is here (you need a folder with images files called xxxx#img01 etc.) and a first image called firstpic.jpg
    * Slides
    * Created on February 3, 2008, 10:25 PM
    * The application does an applet slide show
    * of a list of images files set in the folder
    * Imagestore each 7 seconds changes the picture
    * see DURATION
    * still to do an image list check on file extentions
    * and a fade in/ out
    * @author wdragstra
    import java.awt.*;
    import java.awt.Image;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.net.URL;
    import java.io.*;
    import java.awt.image.BufferedImage;
    public class Slides2 extends JPanel implements ActionListener {
    private int count, maxcount, x, y, duration,
    textposx, textposy, imgwidth, imgheight;
    static int framew, frameh;
    private boolean intro;
    private static final int LOAD = 7000, PAUSE=4000; // animation duration
    private static final String FILE_NAME="Imagestore"; // the image file name in work directory
    private File directory; // File object referring to the directory.
    private String[] picfilenames; // Array of file names in the directory.
    private JOptionPane infoPane;
    private JPanel picttextPanel;
    private JLabel textLabel;
    private Timer load, timer, pause;
    private Image firstpic;
    private BufferedImage OSC;
    public Slides2() { // construtor
    framew = 350; // frame size to be set
    frameh = 390;
    textposx = 130; // text position to be set
    textposy = 20;
    duration = 9000; // image duration to be set
    count=0; // image and textstring counters
    maxcount = 0;
    load = new Timer(LOAD, this); // the three animation timers
    readImageFilelist(FILE_NAME); // get the content of the image folder
    firstpic = downloadImage("firstpic.jpg");
    orderImages();
    timer = new Timer(duration, this);
    infoPane = new JOptionPane(); // containing the 1) firstpic.jpg the
    picttextPanel = new JPanel(); // first picture or only picture
    textLabel = new JLabel(" INFO ", JLabel.CENTER); // 2) the parameter file called
    this.setLayout(null); // imageanimater.txt 3) the imgefiles
    textLabel.setBounds(textposy,textposx, 300 , 50); // with name xxxxx#img01 - 99
    add(textLabel);
    intro = true;
    load.start();
    public void actionPerformed(ActionEvent evt) { // timer listner
    if (evt.getSource() == load) { // first timer only ones for first picture
    // second timer for image duration
    load.stop();
    timer.start();
    intro=false;
    repaint();
    if (evt.getSource() == timer) {
    if (count == maxcount)
    count = 0;
    repaint();
    count++;
    void readImageFilelist(String dirname) { // gets the list of images
    directory = new File(dirname); // of folder imagestore
    if (directory.isDirectory() == false) { // in work directory
    if (directory.exists() == false)
    JOptionPane.showMessageDialog(infoPane,
    " there is no directory called " + directory);
    else
    JOptionPane.showMessageDialog(infoPane, directory +
    " is not a directory. ");
    else {
    picfilenames = directory.list(); // stores the list of file names
    for (int i = 0; i < picfilenames.length; i++) {
    if (imageNamecheck(picfilenames)) { // check correct file extension #img
    picfilenamesmaxcount = picfilenames; // eliminate the incorrect ones
    maxcount++;
    if (maxcount == 0)
    JOptionPane.showMessageDialog(infoPane,
    "no valid files present ");
    private boolean imageNamecheck(String st) {
    int pos = st.indexOf("#img");
    if (pos == -1)
    return false;
    else return true;
    private int imagePos(String st) {
    int posnmb=0; // convert string-number into int
    int pos = st.indexOf("#img"); // when no image present returns -1
    if (pos==-1) {
    JOptionPane.showMessageDialog(infoPane,
    "The file has�t the correct format #img01-#img99 ");
    return 0;
    else
    return pos+4;
    private void orderImages() { // sort de file list of images 00-99
    int lastarray = maxcount-1;
    int trynmb=0, maxnmb=0, index=0, pos=0;
    String tempfl="";
    while(lastarray != 0) {
    index = 0;
    pos = imagePos(picfilenames[0]);
    try { maxnmb = Integer.parseInt(picfilenames[0].substring(pos, pos+2));
    catch ( NumberFormatException e ) {
    JOptionPane.showMessageDialog(infoPane,
    "File format: #img01-#img99 " + e);
    for (int i = 1; i <= lastarray; i++) {
    pos = imagePos(picfilenames);
    try { trynmb = Integer.parseInt(picfilenames.substring(pos, pos+2));
    catch ( NumberFormatException e ) {
    JOptionPane.showMessageDialog(infoPane,
    "File format: #img01-#img99 " + e);
    if (trynmb>maxnmb) {
    maxnmb = trynmb;
    index=i;
    tempfl = picfilenameslastarray;
    picfilenameslastarray = picfilenamesindex;
    picfilenamesindex = tempfl;
    lastarray--;
    // for (int i = 0; i < maxcount; i++) {
    //JOptionPane.showMessageDialog(infoPane,
    // "last array " + i + " filename " + picfilenames);
    private Image scaleImage(BufferedImage bimg) { // scale buffered image into image fill
    try {
    imgwidth = bimg.getWidth(this);
    catch (Exception e) {
    JOptionPane.showMessageDialog(infoPane, "can not get image width " + e);
    try {
    imgheight = bimg.getHeight(this);
    catch (Exception e) {
    JOptionPane.showMessageDialog(infoPane, "can not get image height " + e);
    double scalerate = calcScale(imgwidth, imgheight); // calls the actual scaling method
    imgwidth = (int)(imgwidth * scalerate);
    imgheight = (int)(imgheight * scalerate);
    x = (int)(framew - imgwidth)/2;
    y = (int)(frameh - imgheight)/2;
    DecimalFormat myFormatter = new DecimalFormat("######.##");
    String xx = myFormatter.format(scalerate);
    String yy = myFormatter.format(scalerate);
    //JOptionPane.showMessageDialog(infoPane,
    // "image size " + imgwidth + " / " + imgheight + " new size " + newidth + " / " + newheight + " scalerate " + xx
    // + " insets " + insetw + " / " + inseth );
    try {
    Image img = bimg.getScaledInstance(imgwidth, imgheight, bimg.SCALE_FAST); // the actual scaling
    return img;
    catch (IllegalArgumentException e) {
    JOptionPane.showMessageDialog(infoPane, " can not scale the image " + bimg + " " + e);
    return null;
    private double calcScale(int imgwidth, int imgheight) {
    double sc=0, x=0;
    if ((double)framew-imgwidth < frameh-imgheight) { // gets the smallest side of the picture
    sc = (double)framew/imgwidth; // to scale to frame size (sc)
    else {
    sc = (double)frameh/imgheight;
    return sc;
    private Image downloadImage(String filename) { //downloads image and call the scaling
    BufferedImage bufimg=null;
    Image img=null;
    ClassLoader cl = Slides2.class.getClassLoader();
    URL imageURL = cl.getResource(filename);
    try {
    bufimg = ImageIO.read(imageURL);
    img=scaleImage(bufimg);
    catch (Exception e){
    JOptionPane.showMessageDialog(infoPane, " can not download " + filename + " " + e);
    return img;
    private void displayText(int cnt) {
    textLabel.setFont(new Font("Serif", Font.BOLD, 18));
    textLabel.setForeground(Color.RED);
    textLabel.setText("xcount maxcount " + count + " / " + maxcount);
    public void paintComponent(Graphics g) { // the timer calls the component
    // to draw the pictures
    if (intro) { // the first pic and its display time
    g.drawImage(firstpic,0, 0, imgwidth, imgheight, this);
    else {
    //g.drawImage(img, dest_x1, dest_y1, dest_x2, dest_y2,
    // source_x1, source_y1, source_x2, source_y2, imageObserver); x=width y=height
    g.setColor(Color.WHITE);
    g.fillRect(0, 0, framew+10, frameh+10);
    g.drawImage(downloadImage(picfilenamescount),x, y, imgwidth, imgheight,this);
    //g.drawImage(firstpic,0, 0, imgwidth, imgheight, this);
    displayText(7);
    }

    If the application is expecting to find an inner class in the jar - then yes, it must be there.
    Put it in there and see what happens - it is probably needed there.

  • Problems with inner classes

    I ran into the following problems when I tried to read into an inner class:
    This is my .jdo file
    <?xml version="1.0"?>
    <jdo>
    <package name="com.globalrefund.jdo.mna">
    <class name="Parameter$Syspar" objectid-class="SysparId">
    <extension vendor-name="kodo" key="table" value="syspar"/>
    <extension vendor-name="kodo" key="lock-column" value="none"/>
    <extension vendor-name="kodo" key="class-column" value="none"/>
    <field name="landescode" primary-key="true">
    <extension vendor-name="kodo" key="data-column"
    value="landescode"/>
    </field>
    <field name="waehrungscode">
    <extension vendor-name="kodo" key="data-column"
    value="waehrungscode"/>
    </field>
    </class>
    </package>
    </jdo>
    1.) appidtool does not work for this inner class, I get this stack trace
    C:\users\Bernhard\jbProject\refundManual>appidtool
    src\com\globalrefund\jdo\mna\Parameter$Syspar.jdo
    Generating an application id for type "class
    com.globalrefund.jdo.mna.Parameter$Syspar"...
    Exception in thread "main" java.lang.NullPointerException
    at com.solarmetric.kodo.enhance.ApplicationIdTool.getFile(Unknown
    Source)
    at
    com.solarmetric.kodo.enhance.ApplicationIdTool.writeApplicationId(Unknown
    Source)
    at
    com.solarmetric.kodo.enhance.ApplicationIdTool.writeApplicationId(Unknown
    Source)
    at com.solarmetric.kodo.enhance.ApplicationIdTool.main(Unknown
    Source)
    2.) I tried to use a hand coded inner class as ID class, but id did not work
    (is this not possible ?)
    Exception in thread "main" java.lang.NoSuchMethodError:
    com.globalrefund.jdo.mna.Parameter$SysparId: method <init>()V not found
    at
    com.globalrefund.jdo.mna.Parameter$Syspar.jdoNewObjectIdInstance(Parameter.j
    ava)
    at
    javax.jdo.spi.JDOImplHelper.newObjectIdInstance(JDOImplHelper.java:166)
    at com.solarmetric.kodo.util.ObjectIds.fromPKValues(Unknown Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.createFromResultSet(
    Unknown Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager$2.getResultObject(Un
    known Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.instantiateRow(Unknown
    Source)
    at com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.get(Unknown
    Source)
    at java.util.AbstractList$Itr.next(AbstractList.java:416)
    at com.solarmetric.kodo.runtime.ResultListIterator.next(Unknown
    Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.ResultListFactory.createResultList(Un
    known Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(Unknown
    Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(Unknown
    Source)
    at com.solarmetric.kodo.query.QueryImpl.executeWithMap(Unknown
    Source)
    at com.solarmetric.kodo.query.QueryImpl.execute(Unknown Source)
    at
    com.solarmetric.kodo.query.QueryImpl$SynchronizedQuery.execute(Unknown
    Source)
    at com.globalrefund.jdo.mna.Parameter.<init>(Parameter.java:71)
    3.) It worked after I moved the ID class into a separate class
    Regards,
    Bernhard

    1.) appidtool does not work for this inner class, I get this stack traceThis is a bug. It will be corrected in the final release of 2.3, due out
    Real Soon Now. Thanks for catching this!
    2.) I tried to use a hand coded inner class as ID class, but id did not work
    (is this not possible ?)
    Exception in thread "main" java.lang.NoSuchMethodError:
    com.globalrefund.jdo.mna.Parameter$SysparId: method <init>()V not foundThis exception is saying that your application ID class does not have a
    no-args constructor. Make sure the id class is a static inner class;
    otherwise Java transparently adds a parent object parameter to each
    constructor, and so the application id class will violoate the JDO constraint
    of having a no-args constructor.

  • How to reference an inner class with @link?

    Hi,
    Let's assume we have a class Test with an inner class namned InnerTest. If I want to put a @link to a method in InnerTest in another java-file, what do I write?
    To reference a method in Test, I write:
    {@link com.company.Test#method}
    My first thought when referencing the inner class' method was to just write:
    {@link com.company.Test.InnerTest#method}
    but this doesn't seem to be the correct way.
    Any help is greatly appreciated! Thank you in advance.

    You're calling the method in the inner class the right way.
    You're probably experiencing bugs with links.
    I don't know what version you're using, but 1.4.0 and
    1.4.1 have some severe bugs. Please see another
    thread in this forum entitled:
    "Some {@link} tags do not seem to generate hyperlinks"
    -Doug Kramer
    Javadoc team

  • Inner Classes doubts

    Hi All,
    I am trying to learn Inner classes in Java. I am referring to the book Core Java by Horstmann and Cornell.
    I know that there are various types of inner classes namely:
    - Nested Inner classes
    - Local Inner classes
    - Annonymous Inner classes
    - static inner classes
    First I am on with Nested Inner classes :
    Following is the code which I am executing :
    package com.example.innerclass;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Date;
    import javax.swing.JOptionPane;
    import javax.swing.Timer;
    public class InnerClassTest {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              TalkingClock clock = new TalkingClock(1000,true);
              clock.start();
    //          JOptionPane.showMessageDialog(null,"Quit Program");
    //          System.exit(0);
    class TalkingClock
         private int interval;
         private boolean beep;
         public TalkingClock(int interval, boolean beep){
              this.interval = interval;
              this.beep = beep;          
         public void start(){
              ActionListener listener = new TimePrinter();
              Timer t = new Timer(interval,listener);
              t.start();
         private class TimePrinter implements ActionListener{
              public void actionPerformed(ActionEvent event){
                   Date now = new Date();
                   System.out.println("At the tone time is : "+now);
                   if(beep)
                        Toolkit.getDefaultToolkit().beep();
    }Following are my doubts :
    1. Why do we need to give the line
    JOptionPane.showMessageDialog(null,"Quit Program");
    System.exit(0);without this line the program doesn't show any output.
    2. I didn't understand this syntax.
    You can write inner object constructor more explicitly using the syntax. :
    outerObject.new InnerClass(construction parameters)
    For e.g.
    ActionListener listener = this.new TimePrinter();
    Here the outer class reference of the newly constructed TimePrinter object is set to this reference of the method that creates the inner class object. the this. qualifier is redundant. However, it is also possible to set the outer class reference to another object by explicilty naming it. For e.g if TimePrinter were a public inner class, you could construct a TimePrinter for any talking clock.
    TalkingClock jabberer = new TalkingClock(1000,true);
    TalkingClock.TimePrinter listener = jabberer.new TimePrinter();
    Please do help me understand this concept.
    Thanks
    Siddharth

    I have understood that this explanation :
    i) assuming that TimePrinter is an inner class of TalkingClock, that you'd need an instance of the later in order to create an instance of the former.Yes.
    Being a non-static inner class, it can not be instantiated out of context ... which context is the outer class.No. See my reply 11. The "context" is an instance of the outer class - it bears repeating.
    ii) jabberer is the outer instance that you are providing.Yes (more accurately it's a reference to an instance of the outer class, but that would be nit-picking).
    The left side is identifying the class, the right side is identifying the instanceNo.
    I'm not sure what you're calling left side and right side.
    If you're talking about both sides of the equals sign, then no, it's completely wrong.
    If you're talking about both sides of the "point" sign, then it's wrong too, just a bit less wrong.
    Let's revise this step by step (good thought process).
    1. in first line we are getting an outer class reference with this code
    TalkingClock jabberer = new TalkingClock(1000,true);
    this line is very natural and easily understood. Yes. The correct wording would be merely "we are getting a reference to an instance of the outer class". Sorry to insist densely.
    2. Now when we come to the second line, i.e. where we try to instantiate an inner class with this line of code
    TalkingClock.TimePrinter listener = jabberer.new TimePrinter();
    - I do understand the concept that we need an instance of outer class in order to create an instance of inner class as inner class is visible only to outer class.No. We need an instance of the outer class as the inner class is non-static, and by definition needs an instance of the outer class. That has nothing to do with visibility (public vs private vs...). Again, some words have special meanings in the Java world.
    - I also do understand that it cant be instantiated out of context. I see you like this expression, but it is too vague and misleads you. Please forget about it for a moment (no offense to otherwise helpful and knowledgeable abillconsl).
    - I also do understand that left side is identifying the class and right side is identifying the instance. ANDAgain I'm afraid of which "sides" you're talking about.
    - that in this line TalkingClock.TimePrinter listener = new TalkingClock().new TimePrinter();
    the outer class is anonymous (new TalkingClock()) as we don't require its name here Poor choice of words again. Anonymous classes do exist in Java, but are a totally different concept, that is not related to this line.
    - Also in this line TalkingClock.TimePrinter listener = jabberer.new TimePrinter();
    I understood the left side part i.e. TalkingClock.TimePrinter listener =
    We are attaching the outer class reference with the inner class that's absolutely understandable. Not at all!
    This just declares a variable listener, whose type is TalkingClock.TimePrinter (or more accurately com.example.innerclass.TalkingClock.TimePrinter).
    Then follows an assignment:
    WHAT I don't understand is the right hand side, i.e., the statement jabberer.new TimePrinter();
    1. I am unable to digest the fact that we can do something like anobject.new
    new is an operator that is used to instantiate an instance of an object. I am unable to digest that we can do x.new?See my previous reply. This is short-hand syntax Sun chose to pass a reference to an instance of the outer class (here, jabberer) to the constructor of the inner class. They could have chosen something else. Again, bear with it.
    I only know that we can do is new SomeClass(); AND NOT instance.new SomeClass();
    Now you know better:
    The second form is valid - only if SomeClass is a non-static inner class defined in a class of which instance is an instance.
    2. Is there something to this conceptually OR this is only a syntax and that I should learn it.
    I want to understand and grasp if there is some concept behind it rather than just learn and mug up. See my previous reply. Each instance of a non-static inner class stores a reference to an instance of the outer class. There must be a way (a syntax) to specify which instance (of the outer class) should be stored in the instance (of the inner class).
    This particular syntax is just a syntax, the "concept" is that the instance of the inner class stores a (unmodifiable) reference to the instance of the outer class that was specified when the instance of the inner class was created.
    I don't know if that deserves to be called a concept, but that's an interesting thing to keep in mind (there are some not-so-obvious implications in terms of, e.g. garbage collection).
    Best regards.
    J.

  • Inner classes use

    what is the main goal behind using inner classes in java design

    The best thing about inner classes in Java (something they missed in the C++ spec) is that a non-static inner class has direct access to everything in the containing class without the need to maintain an explicit reference.
    That makes inner class instances ideal as a kind of "delegate" from the main object into another context, e.g. to generate several ActionListener objects to be added to various gadgets, or as an Iterator which moves through some child elements.

  • 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?

  • Event handling and inner classes

    Hi everyone,
    When assigning an actionlistener object to a swing component, is making the encapsulating component implement actionlistener better performance-wise than using inner classes? I ask this because my application is pretty slow to start-up, and I'm using lots of inner classes.
    I don't want to go ahead and change the event-handling unless I'm sure it will do any good, because the time restriction is too tight for wasting. Does using addActionListener(this) just pass a reference to itself or is an object generated for each call?
    Thanks in advance,
    Richard

    Passing this only passes a reference. But you won't get a big improvement over inner classes. (If you use one listener object instance and pass that instance to the event sources. Do you?)
    Kurta

  • Compiling inner classes

    Hi,
    I have an applet with inner classes (the applet is contained in a single .java file). When I compile the applet, a number of *$*.class files are created for the inner classes. However, a friend of mine compiles the same .java file and he gets a single .class file. He can't see any files corresponding to the inner classes. My compiler is version 1.4.0, his is 1.4.2. Can you suggest how my friend can generate the *$*.class files corresponding to the inner classes?
    Thanks for your help.
    Miguel
    PS If the .jar file does not contain the *$*.class files, then appletviewer can't find the inner classes.

    Let me try again. My friend gets a single .class file.
    If he invokes the applet like this:
    <APPLet CODE="myapplet.class" WIDTH=100 HEIGHT=100>
    he has no problems at all.Because all the necessary files are there. Including the inner class files. Why he doesn't see them is another problem.
    However, if he puts his class file in myjar.jar and
    invokes the applet like this:
    <APPLet CODE="myapplet.class"
    ARCHIVE="myjar.jar"
    WIDTH=100 HEIGHT=100>
    then his inner classes are not found by appletviewer.Because he didn't put the inner class files in the jar. Why he didn't put them is another problem.
    There is abosolutely no other explanation I can see.

  • How to use inner class in axis2 in java?

    Hi,
    Iam very new in axis2. My language is java. What iam trying to do is, i need to create a xml format for the clients to send data to server using axis2 service.
    My demo xml format is,
    <test1>
    <test2>
    <test3>
    <test4></test4>
    <test5></test5>
    </test3>
    <test3>
    <test4></test4>
    <test5></test5>
    </test3>
    </test2>
    </test1>
    Iam trying to use nested inner class to generate this xml. Below is my demo java class. But unfortunately, or may be lac of knowledge, iam unable to create sub trees.
    public class EchoService{
    public MyInnerClass retMyInnerClass(MyInnerClass test1) {
    return test1;
    public class MyInnerClass {
    private String test2;
    public MyInnerClass() { }
    public void setTest2(String test2) {
    this.test2 = test2;
    public String getTest2() {
    return this.test2;
    Please help me to generate the web service for client.
    Thanks in advance.

    847897 wrote:
    well, i apologies for that fault. But i need the answer. It is urgent.That's your problem, not ours. However, I don't see the connection between your inner class and producing XML subtrees. Perhaps if you explained the problem, rather than your solution...
    [url http://sscce.org/]This page is usually a good place to start; otherwise [url http://www.catb.org/~esr/faqs/smart-questions.html]this one.
    Winston

  • Possible have the an inner class named the same as an outer class?

    Is there some workaround for this issue? I have some code generated by JAXB that won't compile because of a situation like this.
    public class Class1 {
        public Class1() { }
        public static class Quantity {
            public Quantity() { }
            public static class Year {
                public Year() { }
                public static class Quantity {
                    public Quantity() { }
    }When I remove the inner-most Quantity class, the compiler creates:
    Class1.class
    Class1$Quantity.class
    Class1$Quantity.Year.class

    Try a different name for the inner class. I'm sure there is no dearth of names.

  • OJC error w/ assert & inner class

    The following code generates an error:
    public class Foo {
    public class Bar {}
    public Foo() {}
    public static void main(String[] args) {
    assert false == true:"Foo Bar";
    ojc Foo.java -source 1.4 -classpath c:\j2sdk1.4.1\jre\lib\rt.jar -verbose
    [jdk location retrieved from JAVA_HOME environment variable: c:\j2sdk1.4.1]
    [classpath: c:\j2sdk1.4.1\lib\rt.jar;c:\j2sdk1.4.1\lib\i18n.jar;c:\j2sdk1.4.1\li
    b\sunrsasign.jar;c:\j2sdk1.4.1\lib\jsse.jar;c:\j2sdk1.4.1\lib\jce.jar;c:\j2sdk1.
    4.1\lib\charsets.jar;c:\j2sdk1.4.1\classes;c:\j2sdk1.4.1\jre\lib\rt.jar]
    [sourcepath: c:\j2sdk1.4.1\jre\lib\rt.jar]
    [encoding: default]
    makeLevel = 1
    [parsing C:\temp\Foo.java [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\AssertionError.class 50ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Error.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Throwable.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Object.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\io\Serializable.class 0ms]
    60ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Class.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\String.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Comparable.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\CharSequence.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\RuntimeException.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Exception.class 0ms]
    [flattening class Foo]
    [flattening class Foo$Bar]
    C:\temp\Foo.java:8: error #300: constructor AssertionError(<anything>) not found
    in class java.lang.AssertionError
    assert false == true:"Foo Bar";
    ^
    Total build elapsed time = 70ms
    [10 lines compiled in 70ms from 1 files, generating 0 classes]
    1 error
    The same code compiles fine with Sun's JDK 1.4.1 compiler. Removing the inner class allows the code to compile fine with OJC.
    Is this a known OJC bug?
    TIA,
    David

    It is a known bug that has been fixed in 9.0.4. We don't plan to ship 9.0.4
    anytime soon. If you are using 9.0.3, send me an email to
    [email protected] and I will send you a workaround. In your email
    specify the JDev build number that you are using (please, see
    about box).
    Regards,
    Michel

Maybe you are looking for

  • Crackling noises in Audacity and Rezound, but not in players

    I have a new Asus W5A laptop with an intel hda sound card. I have compiled the 2.6.13-git6 kernel with support for this card, and it works quite well. But when I play a sound file in Audacity I get a crackling sound almost like an old vinyl record, t

  • Device plays not updating Last Played field

    I see that this was an issue two years ago -- cannot believe that it has not been fixed. Issue: Match updates play count/Last Played field from iTunes computer installs, but not via device plays. Three iPhones, an iPad, and an Apple TV all show this

  • Iphone stuck in headphone mode

    Hi, I have seen that I'am not the only one with this issue. I'am quite sure that this is not a hardware issue on my iphone 5, because my workaround is to turn the phone off/on. Then it works fine until I connect headphone again. Quite annoying.. This

  • What does the I phone 4s newest update the 6.1 do for the I phone 4s??

    What does the I phone newest update the 6.1 do for the I phone 4s

  • Songs stay on iPhone after Match

    After syncing with iMatch in iTunes, the songs are still on the phone.  9GB out of 16GB are audio files.  When connected in iTunes under Music, it says iTunes Match is on, and my iphone can access music in iCloud.  I'm not synching music, but the mus