Compile-time checking for Serializable

Hi,
For an object to be Serialized it must implement the Serializable interface. If any of the objects it stores as instance variables do not implement this interface then run-time exceptions will be thrown. Why can't there be a compile-time check for this? It seems fairly simple to me... Also, why don't the writeObject methods only accept objects that are Serializable? Just changing the method signature to public void writeObject(Serializable obj) throws... should be enough if compile-time checking were available.
Am I being really stupid or are Sun?
Dan.

It would be impossible to reasonably check at compile time, because what if you had a variable of type Object? At runtime it might work because anything could be in there, but if you check at compile time, it would have to fail, because the compiler can't gurantee that the value will be serializable. Also, a non-serializable field wouldn't cause a problem at runtime if it's null, which is another condition the compiler cannot check.

Similar Messages

  • Compiling error: "checking for mtc_init in -lmatc... no"

    Hello
    I'm trying to compile the elmer fem from svn via a selfmade PKBUILD.
    I've got an error message:
    "checking whether we are using the Microsoft C compiler... no
    checking for mtc_init in -lmatc... no
    configure: error: libmatc
    ==> FEHLER: Ein Fehler geschah in build().
        Breche ab ..."
    Is here a dependency missing? Does anyone know which?
    Thanks.

    I'm having the same problem, albeit 18 months later. I am working with a tutorial from apress, which seems very high on Glassfish as a AppServer environment for learning EJB 3.0. I have the same error when I try to run the client application in the Sun Platform 9.0 Application Server's AppClient Module container , "... Error checking for persistence unit annotations in the main class..." and I think it has something to do with the fact that the AppClient is expecting "something" in the MANIFEST.MF file that actually isn't there... ( sigh ). " so close, and yet so far away.... "
    --- andyj748

  • Compile time errors for large code in try-catch blocks

    Hi, Has anyone ever faced this problem of a compile time error, where the Java compiler returns with the following error that Code is too large for try block.
    I have about 5000 thousand lines in my try-catch block and am facing this problem. Please suggest possible solutions

    1) Are you sure that your try/catch blocks contain 5 million lines?! I seriously don't believe this.Sounds like generated code. The generator needs to be a bit cleverer. In particular, it seems to be generating repeated blocks of code that ought to be stuffed into methods somewhere.

  • What about compile time support for String.intern()

    Then we could use it in switch statements...

    Then we could use it in switch statements...Huh? The switch statement syntax would still require a 'type' and that type would have to be String. And the JMS doesn't support String in the byte codes so the JLS and the JMS would have to change.
    Since this is a rather simple problem if you use code generation it wouldn't seem like a great addition to me.

  • Compile-time business rules

    using apt i have embedded compile-time checks for particular relationships, e.g. AnnotationA exists (only) on ClassB, AnnotationC exists on subclass of ClassD, ClassE has 0..n refs to ClassF, ClassG declares AnnotationH, ClassI has 0..n fields/methods annotated (by), etc.
    with a declarative programming approach, knowing what functionality a particular annotation declares, the absence/existence of this metadata can tell us about business relationships
    with apt business rules can be enforced at compile-time
    this approach provides an alternative to another thread posting
    http://forum.java.sun.com/thread.jspa?threadID=5180602&tstart=0
    and is available without spec change
    i am interested in hearing if others are doing this
    additional relationship
    Message was edited by:
    developer_jbs

    Declarative programing has all but gone the way of
    the doe doe because...
    1: It is not flexible (It is extremely difficult to
    change a complex system in a predetermined way)isn't this the "expert system" model?
    2: It lengthens the development cycle (see item 1)
    3: It normally forces the developer to add many
    things to there code to get things to work, that have
    nothing to do with the intent of the code.more things? the declarations or the declaration processing?
    In its defense (I like a declarative model but, do
    not like being forced into one)...not advocating a forced change in Java
    1: It increases code safety.
    2: It can shorten the development cycle, in certain
    circumstances (especially if it is not overused),
    because it can greatly increase the readability of
    code.
    3: It follows many best practices (although this is
    also possible in a Non-Declarative model).as for best practices what I'd like to see are declarative design patterns, Adapter, Singleton, Factory, Delegate, Strategy, Interpreter, Proxy, Visitor
    too often the design intent is lost in an implementation or design details can only be deduced by class/field/method names, comments, and accompanying docs
    So, if everyone had unlimited time, and an unlimited
    budget, yes declaritive is the way to go. Since that
    is not the case, we filtered out 99% of what it gave
    us, made sure the stuff that was getting in the way
    was removed, and what do you have???
    You guessed it OOA&D.
    Now having said that should we be more declarative? I
    think so, but I will tell you now, REQUIRING
    declarative elements in code is a sure fire way to
    get the majority of development groups to drop the
    language (and I think Java as it stands currently CAN
    be declarative, so if you have one of those unlimited
    budgets, go for it!).no need to require it
    I believe given good (reusable) declarative options, on top of OOP, will become the chosen approach
    reusable design declarations would lessen overall cost and increase readability

  • Question about compile-time legality rules for cast conversion

    Hi, In the rules which explain compile-time legality for cast conversion, it is often mentioned the following scenario in the cast conversion of a compile-time type S to a compile-time type T:
    if S is a class type then:
    if T is a class type then either |S| <: |T| or |T| <: |S| or a compile time error occurs. Furthermore, if there exist a supertype X of T and a supertype Y of S such that X and Y are provably distinct parameterized types and that the erasures of X and Y are the same, a compile-time error occurs.
    As regards the quote in bold, I imagine the following scenario:
    1) S <: T and extends Y
    2) Y<T1...Tn>
    3) X<T1..Tn>
    4) T extends X
    Does the above represents a supertype X of T and a supertype Y of S such that X and Y are provenly distinct parameterized types? If that holds, what does it mean that the erasure of X and Y is the same?

    Declarative programing has all but gone the way of
    the doe doe because...
    1: It is not flexible (It is extremely difficult to
    change a complex system in a predetermined way)isn't this the "expert system" model?
    2: It lengthens the development cycle (see item 1)
    3: It normally forces the developer to add many
    things to there code to get things to work, that have
    nothing to do with the intent of the code.more things? the declarations or the declaration processing?
    In its defense (I like a declarative model but, do
    not like being forced into one)...not advocating a forced change in Java
    1: It increases code safety.
    2: It can shorten the development cycle, in certain
    circumstances (especially if it is not overused),
    because it can greatly increase the readability of
    code.
    3: It follows many best practices (although this is
    also possible in a Non-Declarative model).as for best practices what I'd like to see are declarative design patterns, Adapter, Singleton, Factory, Delegate, Strategy, Interpreter, Proxy, Visitor
    too often the design intent is lost in an implementation or design details can only be deduced by class/field/method names, comments, and accompanying docs
    So, if everyone had unlimited time, and an unlimited
    budget, yes declaritive is the way to go. Since that
    is not the case, we filtered out 99% of what it gave
    us, made sure the stuff that was getting in the way
    was removed, and what do you have???
    You guessed it OOA&D.
    Now having said that should we be more declarative? I
    think so, but I will tell you now, REQUIRING
    declarative elements in code is a sure fire way to
    get the majority of development groups to drop the
    language (and I think Java as it stands currently CAN
    be declarative, so if you have one of those unlimited
    budgets, go for it!).no need to require it
    I believe given good (reusable) declarative options, on top of OOP, will become the chosen approach
    reusable design declarations would lessen overall cost and increase readability

  • Java compiler should check if wait() and notify()

    wait(), notify(), and notifyAll() methods should be called within a critical section, but the Java compiler does not check for this. It is usually during running that an Exception is thrown when the methods was not called within a critical section.
    To me, it seems that the compiler should check and enforce that wait(), notify() and notifyAll() be called within a critical section.

    I think I mis-understood you.
    Yes, you are right to say that because callNotify() was called within a critical section at some time, and may be called from other non-critical sections, so the compiler does not have means to keep trace of the calling stack.
    How about this:
    Because critical sections are always marked by the synchronized keyword, the compiler can actually keep count of the synchronized word and its corresponding braces, then when a wait(), or notify(), or notifyAll() call is made at certain point, the compiler just check for the nested synchronized cunt number, if it is non-zero, it will be syntaxically correct.
    Take the example of your code, I see that the proper point for
    public class Test {
      Object lock = new Object();
      public void lockObject() {
        synchronized (lock) {
          callNotify();                     // here the synchronized brace count is 1, so it is OK!
      private void callNotify() {
        lock.notify();               // here the synchronized brace count is 0,
                                            // but because it is a stand alone function, the compiler
                                            // can deliver warning information.
      public void dumbMethod() {
        callNotify();              // should deliver warning
      public static void main(String[] args) {
        Test t = new Test();
        t.lockObject();
        t.callNotify();                   // but here, the synchronized brace count is 0, so failure!
    }

  • Compile-time arithmetics

    Hi!
    Could anybody explain me pls what is compiler optimization in regard to the code below. Why compile-time error is not thrown?
    class Compiler
         final static int i1 = 10;
         final static int i2 = 0;
         final static int i3 = i1/i2;
         final static int i4 = 10/0;
         public static void main (String args[])
              System.out.println(i3+" "+i4);
    }

    Actually, the compiler will check for constant expressions, and compute the value during compilation instead of at runtime. When it is the case that the computation would result in an ArithmeticException, the compiler will skip the optimization and insert the actual code. Dividing by zero is not a syntactical error, so while it prevents optimizations, it should not prevent a class from compiling.

  • Boxee-source compilation "checking for main in -ldl... no"

    Hello Guys and Girls,
    I'm trying to get Boxee to run on my laptop so that I can setup up on a small homebuild HTPC running a naked Arch Linux Installation in the future.
    I have tried the versions that are in the AUR and got them to install after linking some header files, downgrading glew etc. but they are very old and
    are teaming with bugs. The repo found in the Wiki https://wiki.archlinux.org/index.php/Boxee-source is outdated as well. The current Version is 1.5
    and it is downloading 0.9.8.something from the repo.
    There are 32 and 64 bit *.deb's for Ubuntu available on boxee.tv/download, but Ubuntu is way to bloated and I don't know how to work with it
    when it comes to more advanced configuration (booting straight into X11 and starting boxee trough .xinitrc which worked fine with xbmc).
    Made me realize what a great learning tool Arch Linux is.
    So I downloaded the Sorce Code and extracted it and opened the README.ubuntu to find some building instructions.
    TOC
    1. Introduction
    2. Installing the required Ubuntu packages
    3. How to compile
    4. Create Installer
    1. Introduction
    We currently recommend Ubuntu 11.10.
    NOTE TO NEW LINUX USERS: All lines that are prefixed with the '#'
    character are commands that need to be typed into a terminal window /
    console (similar to the command prompt for Windows). Note that the '#'
    character itself should NOT be typed as part of the command.
    2. Installing the required Ubuntu packages
    # sudo apt-get install make g++ gcc gawk pmount nasm automake cmake bison libsdl1.2-dev libsdl-image1.2-dev libfribidi-dev liblzo2-dev libfreetype6-dev libsqlite3-dev libogg-dev libasound2-dev python-sqlite libglew1.5-dev libcurl4-openssl-dev libmad0-dev libogg-dev libvorbis-dev libsmbclient-dev libmysqlclient-dev libpcre3-dev libdbus-1-dev libjasper-dev libfontconfig1-dev libbz2-dev libboost-dev libfaac-dev libenca-dev libpng12-dev libjpeg62-dev libcdio-dev libsamplerate0-dev libmms-dev libmpeg3-dev libfaad-dev libflac-dev doxygen php5 swig libssl-dev libgdbm-dev libvdpau-dev libxmu-dev libxtst-dev libxinerama-dev libhal-dev libhal-storage-dev gperf libtool
    3. How to compile
    # ./bootstrap
    # ./configure --enable-optimizations --disable-debug
    # make -j4
    # make -C tools/TexturePacker -f Makefile.host
    # rm skin/boxee/media/Textures.xbt
    # make -C skin/boxee/media
    4. Create installer
    # cd debian
    # sudo ./make_debian.sh
    ./bootstrap wored fine.
    With ./configure I ran into problems a few times but managed to fix them on my own ( installed libmms, lz02, mysql-clients etc. when check failed)
    but now I'm stuck at: "checking for main in -ldl... no" and I have no clue how to fix it. What am I missing?
    Once I get this to compile and run I want to contribute my first package to the AUR. Would be a good opportunity to get familiar with ABS, PKGBUILDs and all
    that.
    Regards,
    blackout23
    Last edited by blackout23 (2011-12-30 22:42:21)

    Looks like a linking issue?
    http://phaseit.net/claird/comp.unix.programmer/linking-unix.html wrote:
    Linux's dl library
    There are at least two distinct problem symptoms with dynamic-linking that Linux users frequently report: that
        the configure for Tcl and/or derivatives think that dynamic linking is not possible; and
        a makefile which attempts dynamic linking fails for not resolving "... -ldl ..." adequately.
    To the best of my knowledge, all instances of the former problem have been traced back to an inconsistency between configure and other sources, typically the result of incomplete application of a patch, mis-installation of a compiler and its ancillary libraries, or some sort of cross-OS contamination. As far as I know, correcting any compiler problems and doing a "make distclean" to sanitize the Tcl source directory has always been enough to cure the situation.
    Some installations (Slackware 2.1? 3.1? others? Red Hat before 4.0?) are reputed to have a missing symbolic link between /lib/libdl.so.1 and /lib/libdl.so. Any application which employs dynamic linking, and which therefore links with "... -ldl ..." under Linux, apparently will fail until one completes the installation by commanding
               ln -s /lib/libdl.so.1 /lib/libdl.so
    That's the whole story that I know. However, those unfamiliar with Unix deserve a warning: the previous paragraph used "link" in three distinct senses. If these matters are new to you, you might feel more comfortable substituting
               cp /lib/libdl.so.1 /lib/libdl.so
    for the "ln ..." command above. When I'm able to make time, I'll return to explain these matters more fully.
    Why isn't there a /lib/libdl.a? That's an involved topic, one that I aim to document later in spring '97.
    ldconfig is sometimes an issue for Linux. I'll document it once I understand it better.

  • I have installed itunes 10.7 several times.  All goes well.  After reboot, I go into itunes and check for updates and it says I need to download the update 10.7! (And so cant sync with my Iphone)

    I have installed itunes 10.7 several times, all goes well. After reeboot, I go to check for updates and it still wants to update to version 10.7! I cant sync to my iphone4 because I get an error message saying I need version 10.6.3 or later. Help

    Thank you for getting me started on the track by mentioning "Revo" Uninstaller.  The results of "Revo" spoke volumns on why a successful install of ITunes is so difficult to achieve.  It is the evil "BONJOUR".
    I then tripped upon the following site by Apple and the detailed directions (I read, printed, re-read and followed the instructions.  It was intense) brought a successful ITunes, Quick Time and the lovely Bonjour home.  Thank you for the start JD42.
    http://support.apple.com/kb/HT1923

  • How can I set iTunes to check for new podcasts at a specific time of day?

    Hi guys,
    Anybody know a work around for this? I thought it was just a matter of clicking the refresh button at the time I want iTunes to look for new podcasts, but it doesn't seem to be the case...
    I want iTunes to look for new podcasts at 2 am every day. So, at 2 am, I clicked the refresh button in the Podcasts section in iTunes. It would then say, in the settings, that iTunes last checked for podcasts at 2 am and will look again at 2 am the next day. Awesome, not. Every single time I try this, iTunes always resets itself and decides to look for podcasts at 2:49 pm. I can't work it out.
    So, if anyone has a solution, I would love to hear it! I'm on the latest version. 9.0.2. Thanks for reading.
    Regards,
    Daniel

    I'm looking for the solution to this issue too. Once or twice, a full system restart has seemed to solve the problem temporarily but it slips back to an afternoon refresh after a few days.
    Seems like it would be simple for Apple to allow us to specify a time of day for refreshes in the preferences section.

  • Trying to dynamically load CSS for project at compile time via config XML file to select CSS file.

    I'm using the same code base to compile different versions of a project. Each project has different base fonts. I've created multiple css files that use the same style names. The idea being that in the code I reference the style names, then the loaded CSS determines which font (and size, color, etc) is used for each style name.
    The CSS files are compiling to SWFs, and those SWFs are referenced in config.xml files. Before compiling, I select the config file to use.
    I am loading the CSS SWF files via the StyleManager in the Application.mxml, like so:
      styleManager.loadStyleDeclarations( _contentData.elements( 'cssPath' ).@path )
    The path traces out correctly as:
    assets_embed/styles/project2.swf
    For some reasone I must include an fx:Style line in the Application.mxml file or no fonts are recognized. Example:
      <fx:Style source="assets_embed/styles/project1.css"/>
    If I reference the css for project one (as done above) then most, but not all, styles work. Some styles reference the fonts from the project 1 css, others properly use fonts from project 2 swf. If I point to the CSS for the project I'm compiling in the <fx:Style > tag then all fonts work, but that defeats the goal of using XML rather than code to identify the styles.
    So, why do I need the fx:Style line if the css is being loaded via StyleManager?
    Why is there "cross talk" between style definitions?
    Is there a better way to select styles at compile time?

    I read this quickly so I might have missed a detail.  I think your describing an issue with recent Flex releases that is described in the fine print somewhere.  If you don't have any fonts embedded in the main app and are only bringing in fonts embedded in CSS SWFs, you have to force-link the EmbeddedFontRegistry by adding something like this to the main app's script block.
    import mx.core.EmbeddedFontRegistry; EmbeddedFontRegistry;
    (Yes, "EmbeddedFontRegistry" is in there twice, once to define the fully qualified name, the other to create a class dependency to force the linking).

  • I cannot do a software update, I get as far as System Updates then when I choose it a message appears say  "Check for update is not available at this time"  but I have not had a system update for a good while now.  I am on System version 6.16.211.XT912.Ve

    I cannot do a software update, I get as far as System Updates then when I choose it a message appears say  "Check for update is not available at this time"  but I have not had a system update for a good while now.  I am on System version 6.16.211.XT912.Verizon,en,US

    Which phone model?

  • I cannot access any of my old purchases. Movies, mainly. It has nothing to do with authorized accounts, I've checked for available downloads a thousands times over. They simply do not exist any longer.

    Well, this has been going on for a long time and I've had my absolute fill of it tonight.
    I have purchased a large collection of movies from iTunes that for mainly the reason that I have a new computer, my old films no longer exist as downloaded iTunes videos. That being said, I know I should be able to download purchased films as long as they're still on the iTunes store. I cannot download any of them. Tonight I decided to buy a collection that should have allowed me to download all three films (which I had previously owned, but got sick of trying to find a solution to why I cannot redownload them). So tonight, I purchase this collection of three films, downloads the frst one. Theres absolutely no sign of the second or third film and when I select Check for available purchases it says all available purchases have been downloaded.
    If this was true, 25+ movies would be available to download, least to say the two missing from tonights purchase (which I have purchased in the past as well).
    My account is authorized, everything is alright with my account and I have tried multiple suggestions and am completely lost. Apple support is giving me the run-around.
    What do I do?

    Nevermind. I finally found a third party answer and will post it for anyone else with my problem.
    >Go to the iTunes store.
    >Halfway down the page, right hand side, says account
    >Under account it says purchaced, select that
    >Wa-la

  • How to stop Firefox from checking for add-on compatibility every time it opens?

    How to stop Firefox from checking for add-on compatibility every time it opens?

    That can be a problem with the compatibility.ini file in the Firefox profile folder.
    Try to rename (or delete) the compatibility.ini file in the Firefox profile folder to see if that helps.
    You can use this button to go to the currently used Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Show Folder (Linux: Open Directory; Mac: Show in Finder)
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    You can also check for problems with preferences.
    Delete possible user.js and numbered prefs-##.js files and rename (or delete) the prefs.js file to reset all prefs to the default value including prefs set via user.js and prefs that are no longer supported in the current Firefox release.
    *http://kb.mozillazine.org/Preferences_not_saved
    *http://kb.mozillazine.org/Resetting_preferences

Maybe you are looking for

  • MSI P67/H67/H61 Socket 1155 Series Mainboards B2 or B3

    When making posts concerning 6 series chipset mainboards here in the forum, it will be of great help to those of us providing assistance if it is mentioned exactly which stepping it is, B2 or B3, & BIOS version the board was shipped with or currently

  • Can I make an aperture slideshow and use it in iweb?

    I need to know if I can make an aperture slideshow and use it in iweb (not making it a quicktime movie)? I don't want to use I photo (I know how to make one in Iphoto and put it in Iweb and I dont want to do this). (dont want a .mac gallery either) P

  • How do I set up gnubox/bluetooth on my e71?

    I don't have access to wifi in my office and would like to share our internet over bluetooth or USB cable to enable net access on my e71.  I have tried to follow the instructions on http://xan.dnsalias.org/gnubox/ but none of these seem to be relevan

  • QuickEdit Lookup Column Sort

    Hello,  I have the following issue and i would like to understand why it has happened in my enviroment and the solution if its possible. About enviroment: Currently running SharePoint 2013 but it was upgraded from SharePoint 2010. Deployed in a 2 ser

  • FRM-40039 cannot attach the libray C:\ORA902\forms90\webutil

    I have this mistake, when try to run my forms, I compile de forms is OK. This forms try user the library Webutil, is the first time I try use. I use the forms version 9.0.2.10. and webutil version 1.0.6. I use the manual Oracle Forms Developer Webuti