Javac / Eclipse compiler discrepancy: who's correct?

If you compile the following code using both javac and Eclipse 3.1, the results are different.
public class EclipseJavacDisagree
    public static <T> T method(Comparable<T> value)
        System.out.println("Method A");
        return null;
    public static <T extends Comparable<T>> T method(T value)
        System.out.println("Method B");
        return null;
    public static void main(String[] args)
        method("A Comparable String");
}The Eclipse output is "Method A" whilst javac's is "Method B".
Does anyone know which implementation is correct? I gather from JLS3 that both methods are applicable by subtyping, but I get lost in section 15.12.2.5 trying to figure out which of the two is most specific.
Thanks,
Alex.

I believe there is a typo in your post. Shouldn't the second definition be:
public static <T extends Comparable<T>> T method(T value)Should that even compile? I thought covariant return types were only for overloading. This is an example where the erased types method signatures are:
Object method(Comparable)
Comparable method(Comparable)
How does the compiler determine which one to use? Does it base it on what type the return value is cast to? What about the situation here where the return type is not used.
In any event, with Sun's compiler, I can't see how you can ever call the first method anyway. No matter whether you assigned the returned value in an Object or a String, it still calls version B. What does Eclispe do when the main method is:
    public static void main(String[] args)
        Object o = method("A Comparable String");
        String s = method("A Comparable String");
    }

Similar Messages

  • Difference between javac and eclipse compiler

    I have the following code:
    public class Test {
         public static void main(String[] args) {          
              Integer i = 0;
              double d = 1.5d;
              i += d;
              System.out.println(i);
    }javac gives me the following error:
    Test.java:5: inconvertible types
    found   : double
    required: java.lang.Integer
                    i += d;
                         ^
    1 errorThe Eclipse compiler, however, gladly compiles and the JRE runs it, outputting "1".
    The question is: which compiler is correct?
    javac version 1.6.0_04
    java version "1.6.0_04"
    Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
    Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
    Eclipse JDT version 3.3.1.r332_v20080131

    Integer is probably 32-bit while Double is 64-bit.
    Your code is doing the following;
    - widening the original Integer to Double,
    - performing double-precision addition,
    - assigning the double-precision result to the original Integer.
    Without an explicit cast, your code is asking the compiler to implicitly narrow the double, potentially throwing away data.

  • "Error running javac.exe compiler" when using ant to compile Eclipse plugin

    Hi
    I encounter an error "Error running C:\jdk1.5.0_06\bin\javac.exe compiler" when building my project using ant1.7.
    My project has 10 eclipse plugins, and each plugin is compiled by invoking following ant target
    <!-- ===================================================================
    Compile specified plugin
         target parameters:
              param.plugin.dir: the plugin directory
              param.plugin.targetJarFile: the name of jar file for the given plugin
              param.plugin.src.dir: the folder name of source codes. Note: it is relative path name
              param.fork: indicate if another process is forked to run javac
    =================================================================== -->
    <target name="compilePlugin">
         <!-- Prepare compile environment -->
         <!-- Delete obsolete build folder -->
         <delete dir="${param.plugin.dir}/${build.dir}" quiet="true"/>
         <!-- Delete obsolete jar file -->
         <delete file="${param.plugin.dir}/${param.plugin.targetJarFile}" quiet="true"/>
         <mkdir dir="${param.plugin.dir}/${build.dir}"/>
         <!-- Compile source codes -->
         <javac      srcdir="${param.plugin.dir}/${param.plugin.src.dir}"
                   destdir="${param.plugin.dir}/${build.dir}"
                   failonerror="${javacFailOnError}"
                   verbose="${javacVerbose}"
                   debug="${javacDebugInfo}"
                   deprecation="${javacDeprecation}"
              optimize="${javacOptimize}"
                   source="${javacSource}"
                   target="${javacTarget}"     
                   fork="${param.fork}" memoryInitialSize="256m" memoryMaximumSize="512m">
              <classpath refid="compile.classpath" />
         </javac>
         <!-- Create plugin jar file -->
         <copy todir="${param.plugin.dir}/${build.dir}" failonerror="true">
              <fileset dir="${param.plugin.dir}/${param.plugin.src.dir}" excludes="**/*.java, **/package.htm*" />
         </copy>
         <jar jarfile="${param.plugin.dir}/${param.plugin.targetJarFile}" basedir="${param.plugin.dir}/${build.dir}"/>
         <delete dir="${param.plugin.dir}/${build.dir}" quiet="true"/>
    </target>
    Since each of first 9 plugins contains less than 500 java source files, we always set "param.fork" to false when invoking this ant target.
    For the 10th plugin, it has about 1000 source files. If we set "param.fork" to false, we will get the error "Error running javac.exe compiler". So we have to set "param.fork" to true when compiling it. This week, this plugin contains about 1250 files and we get the same error again when compiling it. I tried to increase the "memoryMaximumSize" to "768", but still couldn't get through it.
    BTW, There are about 150 jar files in our classpath for compiling plugins. Do many jar files cause this problem?
    Any help is highly appreciated.
    Many thanks
    Oceanman

    I encountered a very similar error and I was able to resolve it by removing the following parameters from the javac task:
    fork="${param.fork}"
    memoryInitialSize="256m"
    memoryMaximumSize="512m"My values were not the same as yours, before I removed them, the values were set to:
    fork="true"
    memoryInitialSize="256m"
    memoryMaximumSize="256m" Not sure why this fixed my problem but it did. I was using Ant 1.7 and Java 1.6_07 hope this helps.

  • OC4J infinity loop in javac.exe compiling JSP

    Hi,
    i have a very strange problem with OC4J 10.1.3.5.0 and one JSP page. It occurs under Windows/OC4J (dev environment) and under Linux/OAS (in production environment).
    I try to explain as best as possible.
    I have an application running OK in OC4J. In this application I have a simple JSP that contains very little java code, like this:
    <%@ include file="/wtn/gen/checkAccess.jsp" %>
    <%@page info="mySite.com"
            language="java"
            errorPage="/wtn/gen/error.jsp"
            import="java.util.Locale,
                    com.mySite.util.Util,
                    com.mySite.Const,
                    com.mySite.LoginBussines"%>
    <%
        boolean b1 = LoginBussines.isB1(request) ? true : false;
        String domain = LoginBussines.getDomain(request);
        String url = "";
        if (b1) {
           url = "/web/" + locale + "/home.html";
        } else {
           url = "/web/" + locale + "/index.html";
    %>
    <html>
      <head>
          <title>JSP Page</title>
          <% out.println("<meta http-equiv='REFRESH' content='0;url=http://" + domain + url + "' />"); %>
      </head>
      <body>
      </body>
    </html>Well, this JSP don't have any error and it works fine normally.
    Problem ocurred:
    When I delete the precompiled JSP from persistence/_pages for force .java generation and re-compilation, OC4J generate .java correctly and launch a javac.exe process for compile the servlet .java. This compilation through javac.exe don't finish, remain permanent running and the compilation of JSP does not finish.
    The web application remain sleep while javac.exe process perform ghost operations. Finally (after 5 minuts aprox.) the OC4J stop waiting and show blank page.
    The javac.exe remains alive in Operating System.
    *(strange) Cause:*
    I know the cause but I find no explanation :-(...
    The cause is the import of com.mySite.LoginBussines. This class is correctly (compiled by Eclipse and Ant) and run OK when is called from a servlet or another class running in OC4J. But when this class is imported in a JSP, the javac go crazy and remain try to compile permanently...
    *(very strange) Workaround:*
    When I delete any code line of this class (one or more, no matter), arbitrary line of any method in this Class, recompile class and try again, it's work fine!
    NOTE: the size of LoginBussines.class it's around 66.897 bytes. I don't know if it's relevant.
    Please, someone know what's going on? Someone has encountered this problem?
    Thank you so much!
    Edited by: 890752 on 11-oct-2011 4:40
    Edited by: 890752 on 11-oct-2011 6:08

    Robert,
    It appears that you have only installed the Java Runtime Environment (JRE). You need to install the Software Development Kit (SDK). Get version 1.4.2_05, since this is what your version of OC4J requires. Go to the following Web page
    http://java.sun.com/j2se/1.4.2/download.html
    And look for the "Download J2SE SDK" link -- which appears below the heading:
    J2SE v 1.4.2_05 SDK
    Good Luck,
    Avi.

  • Add jar for in-memory compilation by Eclipse Compiler

    Hi,
    I have a question regarding loading a jar file by the compiler to dynamically compile with a source file. I hope someone can probably offer me an idea on what has been missing or wrong with the source codes I have written for my application.
    I am using Eclipse compiler to dynamically compile a class. In the class, I want it to make a reference to a jar file for compilation dynamically.
    Here is the source of a test class I wrote:
    import javax.servlet.http.HttpServlet;
    class MyServlet extends HttpServlet {
    }The import statement refers to the class javax.servlet.http.HttpServlet from the jar file C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar placed in the local file system.
    In the method called compileClass (shown below), I used the path of the jar file to add to the option -classpath as suggested in another thread (http://forums.sun.com/thread.jspa?threadID=5306520&start=0&tstart=0).
    private static CompileClassResult compileClass(Writer out, String className, String classSource) {
              try {
                   JavaCompiler javac = new EclipseCompiler();
                   StandardJavaFileManager sjfm = javac.getStandardFileManager(null, null, null);
                   SpecialClassLoader scl = new SpecialClassLoader();
                   SpecialJavaFileManager fileManager = new SpecialJavaFileManager(sjfm, scl);
                   List<String> options = new ArrayList<String>();
                   options.addAll(Arrays.asList("-classpath", "C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar"));
                   List<MemorySource> compilationUnits = Arrays.asList(new MemorySource(className, classSource));
                   DiagnosticListener<JavaFileObject> diagnosticListener = null;
                   Iterable<String> classes = null;
                   if (out == null) {
                        out = new PrintWriter(System.err);
                   JavaCompiler.CompilationTask compile = javac.getTask(out, fileManager, diagnosticListener, options, classes, compilationUnits);
                   boolean res = compile.call();
                   if (res) {
                        //Need to modify the api to return an array of two elements - one classes and other bytecodes for all classes in the same class file.
                        return CompileClassResult.newInstance(scl.findClasses(), scl.findByteCodes());
              } catch (Exception e) {
                   e.printStackTrace();               
              return null;
         }I also extended the class ForwardingJavaFileManager as suggested in the thread mentioned above and have it delegated to the StandardJavaFileManager sent to the compiler mentioned in the method compileClass above. The extended class (called SpecialJavaFileManager) is as follows:
    public class SpecialJavaFileManager extends ForwardingJavaFileManager<StandardJavaFileManager> {
         private SpecialClassLoader xcl;
         public SpecialJavaFileManager(StandardJavaFileManager sjfm, SpecialClassLoader xcl) {
              super(sjfm);
              System.out.println("SpecialJavaFileManager");
              this.xcl = xcl;
         public JavaFileObject getJavaFileForOutput(Location location, String name, JavaFileObject.Kind kind, FileObject sibling) throws IOException {
              System.out.println("getJavaFileForOutput");
              MemoryByteCode mbc = new MemoryByteCode(name);
              xcl.addClass(name, mbc);
              return mbc;
         public Iterable<JavaFileObject> list(JavaFileManager.Location loc, String pkg, Set kinds, boolean recurse) throws IOException {
              System.out.println("list ");
            List<JavaFileObject> result = new ArrayList<JavaFileObject>();
            for (JavaFileObject f : super.list(loc, pkg, kinds, recurse)) {
                 System.out.println(f);
                result.add(f);
              return result;
    }I run the application and the result shows that it didn't load the jar file into the memory as expected. From the output (below) I got, it doesn't seem to invoke the method list(...) in the class SpecialJavaFileManager.
    SpecialJavaFileManager
    1. ERROR in \MyServlet.java (at line 1)
         import javax.servlet.http.*;
                ^^^^^^^^^^^^^
    The import javax.servlet cannot be resolved
    2. ERROR in \MyServlet.java (at line 3)
         class MyServlet extends HttpServlet {
                                 ^^^^^^^^^^^
    HttpServlet cannot be resolved to a typeDoes somebody know what I probably have missed or done wrong in the codes?
    Thanks.
    Jonathan

    Hi jschell,
    I read the thread referred to by the link you gave and tried to add the path using the setLocation method:
    JavaCompiler javac = new EclipseCompiler();
    StandardJavaFileManager sjfm = javac.getStandardFileManager(null, null, null);
    SpecialClassLoader scl = new SpecialClassLoader();
    List<File> path = Arrays.asList(new File("C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar"));
    sjfm.setLocation(StandardLocation.CLASS_PATH, path);
    SpecialJavaFileManager fileManager = new SpecialJavaFileManager(sjfm, scl);After I run the file with the change, I still didn't get the compiler to read the jar the file.
    Anyone knows how to solve this issue?
    Thank you.
    Jonathan

  • GeoKettle: Error running javac.exe compiler

    Hi,
    I am trying to use GeoKettle exactly as mentioned at
    http://209.85.229.132/search?q=cache:JHfrxCo7y0YJ:forge.osor.eu/docman/view.php/143/250/Kettle_Devel_guide_v0.odt+geokettle+spoon+java+api&cd=2&hl=en&ct=clnk&client=firefox-a
    But when I try to build it, i am getting the following error.
    [javac] Compiling 135 source files to D:\workspace\geokettle\classes-core
    BUILD FAILED
    D:\workspace\geokettle\build.xml:74: Error running javac.exe compiler
    Can anyone guide me please to resolve this problem.
    Best Regards
    Tabbasum

    most likely the javac executable is not on the system path. Try typing 'javac -version' in a command prompt and see what response you get.
    If it is something like 'javac is not a recognized...', locate where the JDK is installed and add its bin subdirectory to the PATH system variable. Restart any command prompt and type javac again.
    You DID have a JDK installed, didn't you?

  • [svn] 1038: Reverting Eclipse compiler projects to use 'flex-asc' project

    Revision: 1038
    Author: [email protected]
    Date: 2008-03-31 14:39:55 -0700 (Mon, 31 Mar 2008)
    Log Message:
    Reverting Eclipse compiler projects to use 'flex-asc' project
    * Now that we are using builds of asc from trunk/modules/asc, we can/should build/debug in Eclipse using the same sources.
    Modified Paths:
    flex/sdk/trunk/development/eclipse/java/flex-compiler/.classpath
    flex/sdk/trunk/development/eclipse/java/flex-jars/.classpath
    flex/sdk/trunk/development/eclipse/java/flex-swfutils/.classpath

    This is really becoming a pain since every time I get into FlexBuilder, I have to hit my project and set the required version back to 10.0.0. (It keeps reverting to 9.x) Since I am using the new FileReference enhancements in Flash10, this is mandatory to avoid compiler errors.
    I still have no way to automate the build process since there is nothing on the build machine to perform this action.
    Any help would be greatly appreciated

  • How do I set javac to compile for older versions of java?

    I need to compile a ".java" file for version 1.4.0 of java in order to run it on Nintendo DS. However, my version of java is 1.6.0.
    In resume, I need to set javac to compile for version 1.4.0, but I haven't had much success figuring it out myself, so if anyone knows this, please?

    WalterLaan wrote:
    Note that you want to compile against the 1.4 libraries (rt.jar) as well to avoid NoSuchClass/MethodsErrors with the [ -bootclasspath option|http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html#crosscomp-options]
    ++++ that.
    Using the -source/-target options are not a guarantee that the specified JRE will have the required classes, methods and attributes available. Those options only ensure the classes have a format that is 'reabable' by the target JRE.
    Using the -bootclasspath option guarantees the classes are not only readable, but that the VM will not throw 'NoSuchMethodError's or equivalent, at run-time.

  • Eclipse compiler & javac disprepency?

    Hi there,
    The following code compiles and runs under eclipse-3.1M6, but fails under javac:
    import java.lang.annotation.RetentionPolicy;
    public class Test
         public static void main(String[] args)
              Class<? extends Enum<?>> c = RetentionPolicy.class;
              System.out.println(Enum.valueOf(c, "CLASS"));
    }Javac reports the following error:
    Test.java:8: <T>valueOf(java.lang.Class<T>,java.lang.String) in java.lang.Enum cannot be applied to (java.lang.Class<capture of ? extends java.lang.Enum<?>>,java.lang.String)
                    System.out.println(Enum.valueOf(c, "CLASS"));
                                           ^
    1 errorAFAIK this should be legal code - does anyone know of any reason why it fails under javac?
    Cheers,
    Mark

    AFAIK this should be legal code - does anyone know of
    any reason why it fails under javac?It's not legal. The signature of valueOf is too strict:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6209030
    Here is a work around:
    Class<? extends Enum> c = RetentionPolicy.class;

  • Strange generic compilation behaviour - also javac/eclipse difference

    Hello!
    With my friends I've stumbled upon a problem in understanding how the compiler (and Java Language Specification too) treats a specific generic declaration.
    public class Main {
        public static void main(String args[]) {
            ArrayList<Integer> inParam2 = new ArrayList<Integer>();
            List<Number> returnValue2 = justDoIt(inParam2);
        public static <E extends Number> List<E> justDoIt(List<? super E> nums) {
            return null;
    }The code compiles fine with javac and throws compile error in eclipse. The latter, I believe, is the proper behaviour - what am I missing? The method justDoIt could be possibly resolved in two ways:
    public static List<Number> justDoIt(List<Number> nums)or
    public static List<Integer> justDoIt(List<Integer> nums)both will give reasonable and well-documented compile time errors. The first is because ArrayList<Integer> can't be passed to List<Number> (and even more - Integer is not a supertype of Number, therefore <? super Number> should fail). The latter is because List<Integer> value can't be assigned to List<Number> na main() for obvious reasons. I suppose from these two the compiler would resolve the mentioned static function as the one with Number throughout the declaration... but what really happens? How come the code compiles?
    I would be very grateful for any insights.
    Best regards,
    Mateusz

    maticomp wrote:
    The code compiles fine with javac and throws compile error in eclipse. Same here. Not even as much as a warning from javac with Xlint:all. Curious.
    I would be very grateful for any insights.&#42;cough&#42; I believe the relevant JLS section is this one: [15.12.2.7|http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#341287]. I'll readily admit I felt a bit too flabby today to read all of it.

  • Generic working in eclipse compiler but not through builds

    The following code snippet works fine in my eclipse development environment (1.6.0_06), but the build system running 1.6.0_06 throws exception:
    MyClass:343: incompatible types
    found : java.util.List<C>
    required: java.util.List<B>
    entries = createListFromSmartCopy(myAList, new B(), true);
    Types:
    A is an interface
    B is an interface of A
    C is an implementation of B
    List<A> aList = new ArrayList<A>();
    aList.add(new A());
    List<B> return = createListFromSmartCopy(aList, new C(), true);
        * <p>Creates a copy of a list where the source list could be an ancestor
        * type of the returned list. It also uses a reference object to actually
        * construct the objects that populate the return list.</p>
        * @param <T> - The ancestor type of the source list
        * @param <R> - The derived type of the destination list
        * @param <S> - The more derived type of the prototype object used to
        * construct the list of R's
        * @param sourceList - The source list
        * @param referenceObject - The object used to construct the return list
        * @param deepCopy - Deep copy serializable objects instead of just copying
        * the reference
        * @return a list of R's (as defined by the caller) of entries with the
        * object constructed as a copy of referenceObject with the properties of the
        * sourceList copyied in after construction
    public static <T extends Serializable, R extends T, S extends R> List<R> createListFromSmartCopy(
                List<T> sourceList, S referenceObject, boolean deepCopy)
          List<R> retr = new ArrayList<R>();
          for(int i = 0; i < sourceList.size(); i++)
             retr.add(copyOf(referenceObject));
             copyInto(sourceList.get(i), retr.get(i), deepCopy);
          return retr;
       }Any thoughts on either:
    1. How does this pass the compiler validation inside eclipse, even through 'R' has not been defined? I believe that the code is doing some sort of return type inference to return the exactly correct type of list as referred by the return result or else it is simply ignoring the invariant capture of R all together and silently dropping the error. The funny thing is that the code does work just fine in practice in my development system without an issue.
    or
    2. Why if the code is valid does the independent build system disallow this generic return type 'inference' to occur? Are there compiler flags I can use to withhold this special condition?

    Thanks for the response, I wasn't trying to show a full example but just my implementation's snippet. I'll list one now:
    package test;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;
    public class TestMe
        * <p>This method performs a deep copy of an object by serializing and
        * deserialzing the object in question.</p>
        * @param <T> - The type of data to copy
        * @param original - The original object to copy
        * @return The object who's state should be the same as the original. This
        * call uses serialization to guarantee this copy is fully separate from the
        * original, so all sub-object references are also deep copies of their
        * originals
       @SuppressWarnings("unchecked")
       public static <T extends Serializable> T clone(T original)
          T obj = null;
          try
             ByteArrayOutputStream bos = new ByteArrayOutputStream();
             ObjectOutputStream out = new ObjectOutputStream(bos);
             out.writeObject(original);
             out.flush();
             out.close();
             ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(
                      bos.toByteArray()));
             obj = (T)in.readObject();
          catch(IOException e)
             e.printStackTrace();
          catch(ClassNotFoundException cnfe)
             cnfe.printStackTrace();
          return obj;
        * <p>Copies the properties from one object to another. The destined object
        * in this method must be derived from the source object. This allows for a
        * faster and smoother transition.</p>
        * @param <T> The type of source
        * @param <R> The type of destination
        * @param source - The source object
        * @param destination - The destination object
        * @param deepCopy - Copies the reference objects instead of just passing
        * back the reference pointer reference
       public static <T, R extends T> void copyInto(T source, R destination,
                boolean deepCopy)
       // Stubbed because it links into a ton of unnecessary methods
        * <p>Copies the values of a list of an ancestor class into the values of
        * another list who's value is derived from the ancestor.</p>
        * @param <T> - The ancestor type of the source list
        * @param <R> - The derived type of the destination list
        * @param sourceList - The source list
        * @param destinationList - The destination list
        * @param deepCopy - Deep copy serializable objects instead of just copying
        * the reference
       public static <T, R extends T> void copyIntoList(List<T> sourceList,
                List<R> destinationList, boolean deepCopy)
          if(sourceList.size() > destinationList.size())
             throw new IllegalArgumentException(
                      "Cannot copy entire source set into destination list");
          for(int i = 0; i < sourceList.size(); i++)
             copyInto(sourceList.get(i), destinationList.get(i), deepCopy);
        * <p>Creates a copy of a list where the source list could be an ancestor
        * type of the returned list. It also uses a reference object to actually
        * construct the objects that populate the return list.</p>
        * @param <T> - The ancestor type of the source list
        * @param <R> - The derived type of the destination list
        * @param <S> - The more derived type of the prototype object used to
        * construct the list of R's
        * @param sourceList - The source list
        * @param referenceObject - The object used to construct the return list
        * @param deepCopy - Deep copy serializable objects instead of just copying
        * the reference
        * @return a list of R's (as defined by the caller) of entries with the
        * object constructed as a copy of referenceObject with the properties of the
        * sourceList copyied in after construction
       public static <T extends Serializable, R extends T, S extends R> List<R> createListFromSmartCopy(
                List<T> sourceList, S referenceObject, boolean deepCopy)
          List<R> retr = new ArrayList<R>();
          for(int i = 0; i < sourceList.size(); i++)
             retr.add(clone(referenceObject));
             copyInto(sourceList.get(i), retr.get(i), deepCopy);
          return retr;
       public static void main(String[] args)
          List<A> aList = new ArrayList<A>();
          aList.add(new AImpl());
          aList.add(new AImpl());
          List<B> bList = createListFromSmartCopy(aList, new C(), true);
          for(B bItem : bList)
             System.out.println("My String = "
                      + bItem.getString() + " and my number = " + bItem.getInt());
       public static interface A extends Serializable
          public void setString(String string);
          public String getString();
       public static class AImpl implements A
          private static final long serialVersionUID = 1L;
          @Override
          public void setString(String string)
          @Override
          public String getString()
             return null;
       public static interface B extends A
          public void setInt(int number);
          public String getInt();
       public static class C implements B
          private static final long serialVersionUID = 1L;
          public C()
          @Override
          public String getInt()
             return null;
          @Override
          public void setInt(int number)
          @Override
          public String getString()
             return null;
          @Override
          public void setString(String string)
    }In my eclipse (20090920-1017), this compiles and runs just fine. I stripped out the functional pieces that weren't pertinent to the discussion.

  • Sun ONE - compile OK, disaster follows; Eclipse - compile fails

    I hope Sylvia won't rap my knuckles with her ruler for posting an "it won't compile" message here, but this one is more than a bit strange.
    I was running Sun ONE Studio. It compiles my program w/o errors; then the application runs and crashes my Windows Me computer. Reliably; repeatedly. Hard to make progress when your development cycle is compile, try to test, reboot. What to do?
    Maybe the problem's in S1S! Try Eclipse. It won't compile the program. It says:
    java.lang.Error: Unresolved compilation problem:
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at jdb.FileViewer.main(FileViewer.java:120)
    Exception in thread "main"
    Come to think of it, that's really a compile error detected at run time, isn't it? Didn't know that was possible. Anyway, the offending line is:
      public static void main( String[] args ) {}(I simplified main() a bit trying to track this down.) If I remove main() altogether, it compiles and dies with the expected "can't find main()" error.
    Anybody can make any sense of this? (BTW, kudos to Eclipse. This beats trashing my machine. There's nothing but java here - no JNI - so trashing the OS isn't even possible, is it? So much for theory.)

    Maybe the problem's in S1S! Try Eclipse. It won't
    compile the program. It says:
    java.lang.Error: Unresolved compilation problem:
    (snipped)
    Exception in thread "main" Er... where exactly does Eclipse tell you this? Normally compilation diagnostics show up in the Task View. The above stack trace looks like nothing I have ever seen before when compiling. What Eclipse view is showing this message?
    Anybody can make any sense of this? (BTW, kudos to
    Eclipse. This beats trashing my machine. There's
    nothing but java here - no JNI - so trashing the OS
    isn't even possible, is it? So much for theory.)Eclipse uses SWT which is a native library. So theory is still valid, I guess.

  • Javac error, compiling

    I have never compiled a class file, and have just go this error,
    dose it mean that I stuffed up in my script or javac isnt workin properly.
    ________________________________________________dos_____________
    C:/j2sdk1.4.1_03\bin>javac AVIPviewer.java
    AVIPviewer.java:1414: cannot resolve symbol
    symbol : class JSObject
    location : class AVIPviewer
    private JSObject jswin;
    ^
    Note: AVIPviewer.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    2 errors
    thanxs
    simon

    sorry the second part of the error in the middle was:
    AVIPviewer.java:147:cannot resolve symbol
    symbol : variable JSObject
    loaction: class AVIPviewer
    jswin = JSObject.hetWindow(this);

  • How do I make 'javac' to compile all subdirectories?

    Is there any option of 'javac' command, so javac compiles all .java files in all subdirectories?

    Hi ,
    No recursive way of compiling. You can use packages which will
    be searched to be recomplied. Or if you do not want that, but the
    java files have different names then you can use a file composed of the java files and the @file name.
    ie
    foo1/TestJava1.java
    foo1/foo2/TestJava2.java
    put these two java files into a file say srcfile
    srcfile
    foo1/TestJava1.java
    foo1/foo2/TestJava2.java
    javac @srcfile
    Dave Nicholson Sun Developer Tech Support

  • FlushGraphics(x, y, w, h) clash, who is correct?

    when using GameCanvas.setFullScreenMode(), GameCanvas.flushGraphics(x, y, w, h) is not working as intended, or at least there are 2 different schools of behavior, depending on the emulator:
    Behavior #1, followed by:
    - Sun WTK21 / DefaultColorPhone
    - SonyEricson WTK2 / K700, Z1010 & co
    - Motorola SDK v4.1 / V300/400/500 & co
    Behavior #2, followed by:
    - Nokia Series 60 (e.g Series_60_MIDP_SDK_2_1_Beta)
    Surprisingly, the most "intuitive" behavior is #2, eventough behavior #1 is more popular!
    Following is a minimal test case, set by default to the counter-intuitive Behavior #1 (to switch to the other behavior, see the comments...)
    Any clues which school is correct?
    n.b. this one should be tested on models with bigger displays than 128x128...
    package simple_1;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.game.*;
    public class Simple_1 extends MIDlet
      static final int W = 128;
      static final int H = 128;
      int x = W / 2, y = H / 2;
      boolean running;
      MyCanvas canvas;
      public void startApp()
        if (canvas == null)
          canvas = new MyCanvas();
          Display.getDisplay(this).setCurrent(canvas);
          canvas.start();
      public void pauseApp()
      public void destroyApp(boolean unconditional)
        if (canvas != null)
          canvas.stop();
      class MyCanvas extends GameCanvas implements Runnable
        MyCanvas()
          super(true);
        public synchronized void start()
          setFullScreenMode(true);
        protected void sizeChanged(int width, int height)
          if (!running)
            running = true;
            new Thread(this).start();
        public void run()
          // without a pause, getHeight() is not correct on Nokia's Series_60 emulators
          try
            Thread.sleep(1000);
          catch (InterruptedException e)
          int w = getWidth();
          int h = getHeight();
          int dx = (w - H) / 2;
          int dy = (h - H) / 2;
          Graphics g = getGraphics();
          g.setColor(0x808080);
          g.fillRect(0, 0, w, h);
          flushGraphics();
          while (running)
            g.setColor(0xffffff);
            g.fillRect(0, 0, W, H);          // Behavior #1
            //g.fillRect(dx, dy, W, H);     // Behavior #2, TRY ME INSTEAD!
            x = (x + 1) % W;
            y = (y + 1) % H;
            g.setColor(0xff0000);
            g.fillRect(x, y, 4, 4);               // Behavior #1
            //g.fillRect(dx + x, dy + y, 4, 4);     // Behavior #2, TRY ME INSTEAD!
            flushGraphics(dx, dy, W, H);
            try
              Thread.sleep(10);
            catch (InterruptedException e)
        public void stop()
          running = false;
    }

    another hint, confirming the idea that Behavior #2 is problematic:
    with Sun WTK21/DefaultColorPhone, or with SonyEricsson K700, Z1010 emulators, when you pause the application (using the top menu), then when you resume: display is broken!

Maybe you are looking for

  • TS1440 iMac freezes, no choice but to hard shutdown, turn back on, white screen with folder and question mark appears

    Hi, so my iMac (it's not the most recent iMac if it makes any difference, and I'm running mountain lion 10.8.3) often freezes and I do a hard shutdown as I cannot force quit the applications or click on the apple in the top left to shut it down. When

  • Mirroring from IPAD to Samsung

    I have an ipad air, and a 2014 samsung smart tv. I have a wireless network, using Smartview 2 I have now connected the IPAD tv the television through the wireless router.  I can control the TV from the IPAD, but when I try to view Photos, Videos or M

  • About report preview

    Hi all when i press View Output (the report request's phase/status is completed/normal => OK ) the message of Browser is: http://x.xgames.org:2000/OA_CGI/FNDWRR.exe?temp_id=1808632377&login=APPLSYSPUB/PUB@PROD Content-type: text/plain Error connectin

  • Authorizing Audible over and over again

    I got a new iMac last week, and Migration Assistant seemed to work great to get me up and running from a Time Machine backup from my old iMac. I only have one issue - every time I sync my iPod, I get a message that not all my Audible files were copie

  • Runtime Error in CV04N

    Hi Experts, I am executing CV04N for displaying Document list.When I click on Thumbnails, it is showing thumnail view of the documents. But when I click on Table(Shift+F4),or back button, it is showing Run time Error. The description is mentioned bel