Re: A basic question about constants. A final field that is not final?



Hello,

1. Thanks for all your answers. Actually, final has been removed in the source code in src.zip but it is not removed in the online javadoc at http://java.sun.com/j2se/1.5.0/docs/api/index.html, and, worse, the field of the binary version (for Windows) is final yet (see the following compilation). I have submited a bug report to Sun.

2. I have another problem with CachedRowSetImpl (implementation of CachedRowSet by Sun). Do you know if I can get the source code of this implementation of CachedRowSet? It is not in src.zip.

* My java version:

java -version
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)

* An example that does not compile and shows that the constant is final:

import javax.sql.rowset.CachedRowSet;

public abstract class AClass2 implements CachedRowSet {
  static {
    COMMIT_ON_ACCEPT_CHANGES = false;
  }

  public static boolean getConstant() {
    return COMMIT_ON_ACCEPT_CHANGES;
  }
}

class Main {
  public static void main(String[] args) {
    System.out.println(AClass2.getConstant());
  }
}

javac AClass2.java
AClass2.java:5: cannot assign a value to final variable COMMIT_ON_ACCEPT_CHANGES
COMMIT_ON_ACCEPT_CHANGES = false;
^
1 error



Regards,

Richard

Sebastian Scheid a écrit :
"Richard" <grin@xxxxxxxx> schrieb im Newsbeitrag news:42e1fbdb$0$29943$636a15ce@xxxxxxxxxxxxxxx

Hello,

An extract from the javadoc of javax.sql.rowset.CachedRowSet (an interface):
---
COMMIT_ON_ACCEPT_CHANGES


static final boolean COMMIT_ON_ACCEPT_CHANGES

Causes the CachedRowSet object's SyncProvider to commit the changes when acceptChanges() is called. If set to false, the changes will not be committed until one of the CachedRowSet interface transaction methods is called.

See Also:
  commit(), rollback(), Constant Field Values
---

My basic question is: how is it possible to change the value of a constant defined in an interface?


The interface is in the SDK since 5.0 I think. And in 5.0 the field is not final in the sources as well as in the api-doc. What lib with the interface are you using?

Regards
Sebastian



.



Relevant Pages

  • Re: how to limit access to source code...
    ... > interface and also additional code for some calculations. ... > to limit access to the source code for the gui itself. ... implementing Calc, compiles it, puts the class file to the classpath. ...
    (comp.lang.java.programmer)
  • Re: C# Plugin system - same interface in two different assemblies...
    ... Yes - the source code for the interface is present twice. ... they only have to reference the assemblies they *do* use. ... Duplicating source code just makes that worse, ... If there's a bug in an SDK client helper ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: COM... is it the best model so far?
    ... prevents you from using source code reuse as this sidesteps ... each component only specifies "required interface" and "provide ... there should be a glue component or container component that are ...
    (microsoft.public.vc.atl)
  • Re: MSIDL to C#
    ... and it will give you the C# source code. ... >> Can anyone tell me if it is possible to generate C# from IDL/MSIDL ... ... I guess he's talking about the COM interface ... definition language - or a typo;-) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A basic question about constants
    ... Causes the CachedRowSet object's SyncProvider to commit the changes when acceptChanges() is called. ... the changes will not be committed until one of the CachedRowSet interface transaction methods is called. ...
    (comp.lang.java.help)