Excessive use of 'static' in Objects

Hello all,
I have inherited a code base which consists of around 90 objects seemingly randomly thrown together in a down and dirty effort to crank out working code as soon as possible. The original programmer has left the company and I've inherited his projects. While attempting to isolate some performance shortcomings I noticed that nearly every single class has a static method of some sort or another. My understanding is that this is clearly a bad idea as, if for no other reason, those objects, having a static method, will exist during the entire lifetime of the application and are not candidates to be GC'd. Furthermore these objects contain many String instances which, if the object that contains them isn't ever eliminated, will remain as huge memory hogs as well.
So, in essence, what are the general thoughts of the architects and developers on this board regarding the use of the 'static' keyword and it's effect on Object design and the implications for performance and memory? Any feedback would be greatly appreciated. I have looked through numerous books on OO design but nobody seems to speak directly to the implications and "best practices" of designing with the 'static' keyword, where, when and how it's most effectively used, etc.
Thanks!

Hi,
would you consider that the primary motivation for use of static, that the method in question use only class member variables?Often yes, but not always. The example given by jschell above is typical of a static method, but you can't always make methods static like this. If isDefined(String s) were specified by an interface (it couldn't be private in this case though), to implement different variants of what it means for a String to be 'defined', then you couldn't make the method static even if it did not depend on the object you are calling it on.
However I am still looking for a good "rule of thumb" that will help me to determine what the most appropriate use of the static keyword is/should be.For methods you should ask yourself "How will the method be called?" If it only makes sense to call it on an instance of the object then DON'T make it static, even if it could be. Static methods should only be called like this:
   ClassName.staticMethod();and not like this:
   instanceOfClass.staticMethod();as this second style of invocation is very misleading (and it really winds me up when I see it!).
As for fields - in my own code I tend to have private static final objects for constants or 'collections' that are used by many instances, or which are available through public static utility methods. Immutable static final fields I often make public. Pretty much everything else is non-static. I have no idea whether this is 'best practice' though.
You may also want to look at the java.util.Collections and java.util.Arrays classes. These cannot be instantiated and provide only static utility methods for manipulating other objects. It can sometimes help to split off the static 'utility' functions into another class like this, especially if common functions can be applied to an interface.
Ol.

Similar Messages

  • Is there a way to use a statically defined appearance stream in a dynamically created annotation?

    Hello,
    I want to create a document with cascading 'popups'.  Not the built-in text-only popup, but an annotation containing an appearance stream that defines text and images.  I'm currently using widget annotations based on a pushbutton field.
    Each page in my document has many citations that refer to other pages in the document.  When a user hovers over the citation, I want a 'popup' to appear containing a depiction of the destination.  However, as the destination will itself have citations, I also want the 'popup' to contain citations that the user can hover over, triggering another popup, etc.  In this way, a user could navigate throughout the document without leaving the page or even clicking the mouse.
    Obviously, with even a modest number of citations per page, pre-calculating and statically defining all of these widgets causes a combinatorial explosion, making the document sluggish and very large.
    Instead, I'd like to statically define appearance streams once per document, and then dynamically create annotations and assign the appropriate appearance stream using JS as the user navigates.
    So far I've created a named AP in the names dictionary, but I haven't been able to use it to dynamically set an appearance stream of a dynamically created widget annotation.
    Also, I've called Doc.getIcon(), passing in the named AP, which returns an Icon object.  However, after field.buttonSetIcon() and passing in the named AP, the button does not display the icon.
    Is there a way to use a statically defined appearance stream in a dynamically created annotation?
    Thank you,
    Dave

    Hi George, I've gotten named APs to work, and I expect hidden buttons will follow.  Thank you very much!
    Quick follow-up - I will have many documents embedded within the same pdf file, and some of these documents will contain identical popups.  However, I don't want to store identical icons in each document on account of file size.
    Instead, I'd like to store one instance of each icon for all documents in the file.
    Can I store all of the icons in a single document, and then access them by calling <DocName>.getField().getIcon() from any document in the file?
    Thank you again,
    Dave

  • How to use the static lib of berkeleydb in VC6?

    I know there is a libdb45s.lib. But when I try to link my project to it, VC6 reports many errors. Even the getting start examples cannot link correctly. The documents coming with berkeley db do not tell me how to link project to the lib, no matter static or dynamic.
    Could anyone tell me how to use the static lib libdb45s.lib and how to link it properly?
    OS: Windows XP pro SP2
    IDE: Virsual C++ 6.0 sp6
    BDB: 4.5.20
    Here is what I have done to link the libdb45s.lib:
    1.Add BDB related diretorys to VC6 link/lib dirs
    2.Add #include <db.c> to my .cpp file, I use the C API
    3.Change Project Options
    Link-> Libs/Objects-> add "libdb45s.lib"
    C/C++-> code generation-> Use Run Time Library-> MutiThreaded
    Link-> Ignore Library-> MSVCRT
    4.Build, here is the output, hope it would be some help:
    --------------------Configuration: wordseg - Win32
    Release--------------------
    Linking...
    LINK : warning LNK4049: locally defined symbol
    "_fflush" imported
    LINK : warning LNK4049: locally defined symbol "__iob"
    imported
    LINK : warning LNK4049: locally defined symbol
    "__errno" imported
    LINK : warning LNK4049: locally defined symbol
    "_malloc" imported
    LINK : warning LNK4049: locally defined symbol
    "_realloc" imported
    LINK : warning LNK4049: locally defined symbol "_free"
    imported
    LINK : warning LNK4049: locally defined symbol
    "_fclose" imported
    LINK : warning LNK4049: locally defined symbol
    "_fopen" imported
    LINK : warning LNK4049: locally defined symbol
    "__pctype" imported
    LINK : warning LNK4049: locally defined symbol
    "___mb_cur_max" imported
    LINK : warning LNK4049: locally defined symbol
    "__isctype" imported
    LINK : warning LNK4049: locally defined symbol
    "_strchr" imported
    LINK : warning LNK4049: locally defined symbol
    "_printf" imported
    LINK : warning LNK4049: locally defined symbol
    "_strncmp" imported
    LINK : warning LNK4049: locally defined symbol
    "_strncpy" imported
    LINK : warning LNK4049: locally defined symbol "_atol"
    imported
    LINK : warning LNK4049: locally defined symbol
    "_getenv" imported
    LINK : warning LNK4049: locally defined symbol
    "__open" imported
    LINK : warning LNK4049: locally defined symbol
    "__close" imported
    LINK : warning LNK4049: locally defined symbol
    "_strftime" imported
    LINK : warning LNK4049: locally defined symbol
    "_memmove" imported
    LINK : warning LNK4049: locally defined symbol
    "_strtoul" imported
    LINK : warning LNK4049: locally defined symbol
    "_fwrite" imported
    LINK : warning LNK4049: locally defined symbol
    "_fgetc" imported
    LINK : warning LNK4049: locally defined symbol
    "_strtol" imported
    libdb45s.lib(db_err.obj) : error LNK2001: unresolved
    external symbol __imp__strerror
    libdb45s.lib(db_getlong.obj) : error LNK2001:
    unresolved external symbol __imp__strerror
    libdb45s.lib(qam_verify.obj) : error LNK2001:
    unresolved external symbol __imp___snprintf
    libdb45s.lib(mp_mvcc.obj) : error LNK2001: unresolved
    external symbol __imp___snprintf
    libdb45s.lib(repmgr_util.obj) : error LNK2001:
    unresolved external symbol __imp___snprintf
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp___snprintf
    libdb45s.lib(env_region.obj) : error LNK2001:
    unresolved external symbol __imp___snprintf
    libdb45s.lib(log_put.obj) : error LNK2001: unresolved
    external symbol __imp___snprintf
    libdb45s.lib(qam_files.obj) : error LNK2001:
    unresolved external symbol __imp___snprintf
    libdb45s.lib(db.obj) : error LNK2001: unresolved
    external symbol __imp___snprintf
    libdb45s.lib(db_err.obj) : error LNK2001: unresolved
    external symbol __imp___snprintf
    libdb45s.lib(db_pr.obj) : error LNK2001: unresolved
    external symbol __imp___snprintf
    libdb45s.lib(env_failchk.obj) : error LNK2001:
    unresolved external symbol __imp___snprintf
    libdb45s.lib(env_register.obj) : error LNK2001:
    unresolved external symbol __imp___snprintf
    libdb45s.lib(db_err.obj) : error LNK2001: unresolved
    external symbol __imp___vsnprintf
    libdb45s.lib(log_debug.obj) : error LNK2001:
    unresolved external symbol __imp___vsnprintf
    libdb45s.lib(db_err.obj) : error LNK2001: unresolved
    external symbol __imp__vfprintf
    libdb45s.lib(db_err.obj) : error LNK2001: unresolved
    external symbol __imp__fprintf
    libdb45s.lib(db_pr.obj) : error LNK2001: unresolved
    external symbol __imp__fprintf
    libdb45s.lib(db_getlong.obj) : error LNK2001:
    unresolved external symbol __imp__fprintf
    libdb45s.lib(os_errno.obj) : error LNK2001: unresolved
    external symbol __imp__WSASetLastError@4
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp__WSAGetLastError@0
    libdb45s.lib(os_errno.obj) : error LNK2001: unresolved
    external symbol __imp__WSAGetLastError@0
    libdb45s.lib(repmgr_method.obj) : error LNK2001:
    unresolved external symbol __imp__WSAGetLastError@0
    libdb45s.lib(repmgr_windows.obj) : error LNK2001:
    unresolved external symbol __imp__WSAGetLastError@0
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__WSAGetLastError@0
    libdb45s.lib(env_open.obj) : error LNK2001: unresolved
    external symbol __imp__strncat
    libdb45s.lib(mut_win32.obj) : error LNK2001:
    unresolved external symbol __imp___getpid
    libdb45s.lib(os_pid.obj) : error LNK2001: unresolved
    external symbol __imp___getpid
    libdb45s.lib(txn_chkpt.obj) : error LNK2001:
    unresolved external symbol __imp__time
    libdb45s.lib(env_stat.obj) : error LNK2001: unresolved
    external symbol __imp__time
    libdb45s.lib(rep_record.obj) : error LNK2001:
    unresolved external symbol __imp__time
    libdb45s.lib(rep_backup.obj) : error LNK2001:
    unresolved external symbol __imp__time
    libdb45s.lib(env_recover.obj) : error LNK2001:
    unresolved external symbol __imp__time
    libdb45s.lib(txn_region.obj) : error LNK2001:
    unresolved external symbol __imp__time
    libdb45s.lib(log.obj) : error LNK2001: unresolved
    external symbol __imp__time
    libdb45s.lib(rep_region.obj) : error LNK2001:
    unresolved external symbol __imp__time
    libdb45s.lib(db_stati.obj) : error LNK2001: unresolved
    external symbol __imp__time
    libdb45s.lib(rep_util.obj) : error LNK2001: unresolved
    external symbol __imp__time
    libdb45s.lib(env_region.obj) : error LNK2001:
    unresolved external symbol __imp__time
    libdb45s.lib(txn.obj) : error LNK2001: unresolved
    external symbol __imp__time
    libdb45s.lib(db_idspace.obj) : error LNK2001:
    unresolved external symbol __imp__qsort
    libdb45s.lib(log_archive.obj) : error LNK2001:
    unresolved external symbol __imp__qsort
    libdb45s.lib(db_join.obj) : error LNK2001: unresolved
    external symbol __imp__qsort
    libdb45s.lib(mp_mvcc.obj) : error LNK2001: unresolved
    external symbol __imp__qsort
    libdb45s.lib(db_meta.obj) : error LNK2001: unresolved
    external symbol __imp__qsort
    libdb45s.lib(lock_list.obj) : error LNK2001:
    unresolved external symbol __imp__qsort
    libdb45s.lib(mp_sync.obj) : error LNK2001: unresolved
    external symbol __imp__qsort
    libdb45s.lib(txn_stat.obj) : error LNK2001: unresolved
    external symbol __imp__qsort
    libdb45s.lib(rep_record.obj) : error LNK2001:
    unresolved external symbol __imp__qsort
    libdb45s.lib(os_config.obj) : error LNK2001:
    unresolved external symbol __imp__wcscmp
    libdb45s.lib(env_config.obj) : error LNK2001:
    unresolved external symbol __imp__fgets
    libdb45s.lib(repmgr_method.obj) : error LNK2001:
    unresolved external symbol __imp__gethostname@8
    libdb45s.lib(os_open.obj) : error LNK2001: unresolved
    external symbol __imp___snwprintf
    libdb45s.lib(os_map.obj) : error LNK2001: unresolved
    external symbol __imp___snwprintf
    libdb45s.lib(os_unlink.obj) : error LNK2001:
    unresolved external symbol __imp___snwprintf
    libdb45s.lib(os_dir.obj) : error LNK2001: unresolved
    external symbol __imp___snwprintf
    libdb45s.lib(os_map.obj) : error LNK2001: unresolved
    external symbol __imp__wcsrchr
    libdb45s.lib(log_archive.obj) : error LNK2001:
    unresolved external symbol __imp___getcwd
    libdb45s.lib(lock_stat.obj) : error LNK2001:
    unresolved external symbol __imp__localtime
    libdb45s.lib(qam_files.obj) : error LNK2001:
    unresolved external symbol __imp__strrchr
    libdb45s.lib(ctime.obj) : error LNK2001: unresolved
    external symbol __imp__ctime
    libdb45s.lib(os_clock.obj) : error LNK2001: unresolved
    external symbol __imp___ftime
    libdb45s.lib(os_uid.obj) : error LNK2001: unresolved
    external symbol __imp__rand
    libdb45s.lib(os_uid.obj) : error LNK2001: unresolved
    external symbol __imp__srand
    libdb45s.lib(repmgr_msg.obj) : error LNK2001:
    unresolved external symbol __imp__ntohs@4
    libdb45s.lib(repmgr_windows.obj) : error LNK2001:
    unresolved external symbol __imp__ioctlsocket@12
    libdb45s.lib(repmgr_windows.obj) : error LNK2001:
    unresolved external symbol __imp__WSACleanup@0
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp__WSACleanup@0
    libdb45s.lib(repmgr_windows.obj) : error LNK2001:
    unresolved external symbol __imp__WSAStartup@8
    libdb45s.lib(repmgr_windows.obj) : error LNK2001:
    unresolved external symbol __imp__WSASend@28
    libdb45s.lib(repmgr_windows.obj) : error LNK2001:
    unresolved external symbol __imp__WSARecv@28
    libdb45s.lib(repmgr_windows.obj) : error LNK2001:
    unresolved external symbol
    __imp__WSAEnumNetworkEvents@12
    libdb45s.lib(repmgr_windows.obj) : error LNK2001:
    unresolved external symbol
    __imp__WSAWaitForMultipleEvents@20
    libdb45s.lib(repmgr_windows.obj) : error LNK2001:
    unresolved external symbol __imp__WSAEventSelect@12
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__WSAEventSelect@12
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp__WSAEventSelect@12
    libdb45s.lib(repmgr_windows.obj) : error LNK2001:
    unresolved external symbol __imp__WSACreateEvent@0
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__WSACreateEvent@0
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__WSACloseEvent@4
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp__WSACloseEvent@4
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__closesocket@4
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp__closesocket@4
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__accept@12
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__connect@12
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__socket@12
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp__socket@12
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__htonl@4
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp__htonl@4
    libdb45s.lib(getaddrinfo.obj) : error LNK2001:
    unresolved external symbol __imp__htonl@4
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__ntohl@4
    libdb45s.lib(repmgr_sel.obj) : error LNK2001:
    unresolved external symbol __imp__send@16
    libdb45s.lib(repmgr_util.obj) : error LNK2001:
    unresolved external symbol __imp__htons@4
    libdb45s.lib(getaddrinfo.obj) : error LNK2001:
    unresolved external symbol __imp__htons@4
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp__listen@8
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp__bind@12
    libdb45s.lib(repmgr_net.obj) : error LNK2001:
    unresolved external symbol __imp__setsockopt@20
    libdb45s.lib(getaddrinfo.obj) : error LNK2001:
    unresolved external symbol __imp__gethostbyname@4
    libdb45s.lib(getaddrinfo.obj) : error LNK2001:
    unresolved external symbol __imp__inet_addr@4
    Release/wordseg.exe : fatal error LNK1120: 47
    unresolved externals
    Error executing link.exe.
    wordseg.exe - 100 error(s), 25 warning(s)

    After adding MsWSock.Lib, WSock32.Lib, build returns following errors:
    (error count reduced from 100 to 71)
    --------------------Configuration: wordsegzjp - Win32 Release--------------------
    Compiling...
    main.cpp
    Linking...
    LINK : warning LNK4049: locally defined symbol "_fflush" imported
    LINK : warning LNK4049: locally defined symbol "__iob" imported
    LINK : warning LNK4049: locally defined symbol "_malloc" imported
    LINK : warning LNK4049: locally defined symbol "_realloc" imported
    LINK : warning LNK4049: locally defined symbol "_free" imported
    LINK : warning LNK4049: locally defined symbol "_fclose" imported
    LINK : warning LNK4049: locally defined symbol "_fopen" imported
    LINK : warning LNK4049: locally defined symbol "__pctype" imported
    LINK : warning LNK4049: locally defined symbol "___mb_cur_max" imported
    LINK : warning LNK4049: locally defined symbol "__isctype" imported
    LINK : warning LNK4049: locally defined symbol "_strchr" imported
    LINK : warning LNK4049: locally defined symbol "_printf" imported
    LINK : warning LNK4049: locally defined symbol "_strncmp" imported
    LINK : warning LNK4049: locally defined symbol "_strncpy" imported
    LINK : warning LNK4049: locally defined symbol "_atol" imported
    LINK : warning LNK4049: locally defined symbol "_getenv" imported
    LINK : warning LNK4049: locally defined symbol "__open" imported
    LINK : warning LNK4049: locally defined symbol "__close" imported
    LINK : warning LNK4049: locally defined symbol "_strftime" imported
    LINK : warning LNK4049: locally defined symbol "_memmove" imported
    LINK : warning LNK4049: locally defined symbol "_strtoul" imported
    LINK : warning LNK4049: locally defined symbol "_fwrite" imported
    LINK : warning LNK4049: locally defined symbol "_fgetc" imported
    LINK : warning LNK4049: locally defined symbol "_strtol" imported
    libdb45s.lib(db_err.obj) : error LNK2001: unresolved external symbol __imp__strerror
    libdb45s.lib(db_getlong.obj) : error LNK2001: unresolved external symbol __imp__strerror
    libdb45s.lib(qam_verify.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(mp_mvcc.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(repmgr_util.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(repmgr_net.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(env_region.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(log_put.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(qam_files.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(db.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(db_err.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(db_pr.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(env_failchk.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(env_register.obj) : error LNK2001: unresolved external symbol __imp___snprintf
    libdb45s.lib(db_err.obj) : error LNK2001: unresolved external symbol __imp___vsnprintf
    libdb45s.lib(log_debug.obj) : error LNK2001: unresolved external symbol __imp___vsnprintf
    libdb45s.lib(db_err.obj) : error LNK2001: unresolved external symbol __imp__vfprintf
    libdb45s.lib(db_err.obj) : error LNK2001: unresolved external symbol __imp__fprintf
    libdb45s.lib(db_pr.obj) : error LNK2001: unresolved external symbol __imp__fprintf
    libdb45s.lib(db_getlong.obj) : error LNK2001: unresolved external symbol __imp__fprintf
    libdb45s.lib(os_errno.obj) : error LNK2001: unresolved external symbol __imp___errno
    libdb45s.lib(env_open.obj) : error LNK2001: unresolved external symbol __imp__strncat
    libdb45s.lib(mut_win32.obj) : error LNK2001: unresolved external symbol __imp___getpid
    libdb45s.lib(os_pid.obj) : error LNK2001: unresolved external symbol __imp___getpid
    libdb45s.lib(txn_chkpt.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(env_stat.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(rep_record.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(rep_backup.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(env_recover.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(txn_region.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(log.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(rep_region.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(db_stati.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(rep_util.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(env_region.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(txn.obj) : error LNK2001: unresolved external symbol __imp__time
    libdb45s.lib(db_idspace.obj) : error LNK2001: unresolved external symbol __imp__qsort
    libdb45s.lib(log_archive.obj) : error LNK2001: unresolved external symbol __imp__qsort
    libdb45s.lib(db_join.obj) : error LNK2001: unresolved external symbol __imp__qsort
    libdb45s.lib(mp_mvcc.obj) : error LNK2001: unresolved external symbol __imp__qsort
    libdb45s.lib(db_meta.obj) : error LNK2001: unresolved external symbol __imp__qsort
    libdb45s.lib(lock_list.obj) : error LNK2001: unresolved external symbol __imp__qsort
    libdb45s.lib(mp_sync.obj) : error LNK2001: unresolved external symbol __imp__qsort
    libdb45s.lib(txn_stat.obj) : error LNK2001: unresolved external symbol __imp__qsort
    libdb45s.lib(rep_record.obj) : error LNK2001: unresolved external symbol __imp__qsort
    libdb45s.lib(os_config.obj) : error LNK2001: unresolved external symbol __imp__wcscmp
    libdb45s.lib(env_config.obj) : error LNK2001: unresolved external symbol __imp__fgets
    libdb45s.lib(os_open.obj) : error LNK2001: unresolved external symbol __imp___snwprintf
    libdb45s.lib(os_map.obj) : error LNK2001: unresolved external symbol __imp___snwprintf
    libdb45s.lib(os_unlink.obj) : error LNK2001: unresolved external symbol __imp___snwprintf
    libdb45s.lib(os_dir.obj) : error LNK2001: unresolved external symbol __imp___snwprintf
    libdb45s.lib(os_map.obj) : error LNK2001: unresolved external symbol __imp__wcsrchr
    libdb45s.lib(log_archive.obj) : error LNK2001: unresolved external symbol __imp___getcwd
    libdb45s.lib(lock_stat.obj) : error LNK2001: unresolved external symbol __imp__localtime
    libdb45s.lib(qam_files.obj) : error LNK2001: unresolved external symbol __imp__strrchr
    libdb45s.lib(ctime.obj) : error LNK2001: unresolved external symbol __imp__ctime
    libdb45s.lib(os_clock.obj) : error LNK2001: unresolved external symbol __imp___ftime
    libdb45s.lib(os_uid.obj) : error LNK2001: unresolved external symbol __imp__rand
    libdb45s.lib(os_uid.obj) : error LNK2001: unresolved external symbol __imp__srand
    libdb45s.lib(repmgr_windows.obj) : error LNK2001: unresolved external symbol __imp__WSASend@28
    libdb45s.lib(repmgr_windows.obj) : error LNK2001: unresolved external symbol __imp__WSARecv@28
    libdb45s.lib(repmgr_windows.obj) : error LNK2001: unresolved external symbol __imp__WSAEnumNetworkEvents@12
    libdb45s.lib(repmgr_windows.obj) : error LNK2001: unresolved external symbol __imp__WSAWaitForMultipleEvents@20
    libdb45s.lib(repmgr_windows.obj) : error LNK2001: unresolved external symbol __imp__WSAEventSelect@12
    libdb45s.lib(repmgr_sel.obj) : error LNK2001: unresolved external symbol __imp__WSAEventSelect@12
    libdb45s.lib(repmgr_net.obj) : error LNK2001: unresolved external symbol __imp__WSAEventSelect@12
    libdb45s.lib(repmgr_windows.obj) : error LNK2001: unresolved external symbol __imp__WSACreateEvent@0
    libdb45s.lib(repmgr_sel.obj) : error LNK2001: unresolved external symbol __imp__WSACreateEvent@0
    libdb45s.lib(repmgr_sel.obj) : error LNK2001: unresolved external symbol __imp__WSACloseEvent@4
    libdb45s.lib(repmgr_net.obj) : error LNK2001: unresolved external symbol __imp__WSACloseEvent@4
    Release/wordsegzjp.exe : fatal error LNK1120: 28 unresolved externals
    Error executing link.exe.
    wordsegzjp.exe - 71 error(s), 24 warning(s)

  • Should I use a static method or an instance method?

    Just a simple function to look at a HashMap and tell how many non-null entries.
    This will be common code that will run on a multi-threaded weblogic app server and potentially serve many apps running at once.
    Does this have to be an instance method? Or is it perfectly fine to use a static method?
    public static int countNonNullEntries(HashMap hm){
    if(hm==null)return 0;
    int count=0;
    for(int i=0; i<hm.size(); i++) {
    if(hm.get(i)!=null)
    { count++;}
    return count;
    OR
    public int countNonNullEntries(HashMap hm){
    if(hm==null)return 0;
    int count=0;
    for(int i=0; i<hm.size(); i++) {
    if(hm.get(i)!=null)
    { count++;}
    return count;
    }

    TPD Opitz-Consulting com wrote:
    The question is the other way around: Is there a good reason to make the method static?
    Ususally the answer is: no.The question is: does this method need state? Yes -> method of a class with that state. No -> static.
    The good thing of having this method statig is that it meight decrese memory foot pring but unless you're facing memory related problem you should not think about that.I doubt there is any difference between the memory foot print of a static or not method.
    I'm not shure if this method beeing static maks problems in multithreaded environments like the one you're aiming at. But I do know that an immutable object is always thread save.Does the method use shared state (data)? No -> no multi threaded problems.
    Can the parameters be modified by different threads? Yes, if multiple threads modified the parameter map, but nothing you can do about it here (no way to force the calling thread to lock on whatever you lock on).
    So my answer to your question is: yes, it should be non static.The method should be static since it uses no state.
    It is thread-safe when only the calling thread can modify the passed map (using a synchronized or ConcurrentHashMap is not enough, since you don't call a single atomic method on the map).
    // Better use Map instead of HashMap
    // We don't care about the generic type, but that does not mean we should use a raw type
    public static int countNonNullEntries(Map<?, ?> map) {
      // whether to accept null map or not, no need for explicit exception
      // since next statement throw NPE anyway
      Collection<?> values = map.values();
      // note your method is called countNonNull, not countNull!
      // (original code it would need to by if(null != mapValue) notNullsCounter++;
      return values.size() - java.util.Collections.frequency(values, null);
    }

  • To use a static variable in another class,but report NullPointerException

    when TableMain is running,I run testRecord so that let TableMain add a occur informatin and
    happened time in a row in TableMain,but when I run testRecord,java report a NullPointerException and I dont know how to solve this problem,thanks for helping me to check my code;(error report info is in end)
    import java.awt.event.*;
    import javax.swing.table.*;
    import java.io.*;
    public class TableMain extends JFrame{
    JTable table;
    static OwnModel model;
    String[] columnHeader={"occur","time"};
    class OwnModel extends DefaultTableModel{
    public OwnModel(Object[] columnNames,int numRows){
    super(columnNames,numRows);
    public boolean isCellEditable(int row,int column){
    return false;
    public TableMain(){
    model=new OwnModel(columnHeader,0);
    table=new JTable(model);
    JScrollPane scroll=new JScrollPane(table);
    JButton save=new JButton("save record");
    JButton delete=new JButton("delete record");
    JPanel buttons=new JPanel();
    buttons.add(save);
    buttons.add(delete);
    JLabel sign=new JLabel("occur record");
    Container cp=getContentPane();
    cp.add(BorderLayout.NORTH,sign);
    cp.add(BorderLayout.CENTER,scroll);
    cp.add(BorderLayout.SOUTH,buttons);
    this.setSize(300,500);
    this.setVisible(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    public static void main(String[] args){
    new TableMain();
    import java.util.Vector;
    import java.util.Calendar;
    import java.text.SimpleDateFormat;
    public class testRecord{
    public static void main(String[] args){
    SimpleDateFormat simpledf=new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
    String tableName="friends";
    Calendar occurtime=Calendar.getInstance();
    Vector record=new Vector();
    record.add("send 'desc' sql, "+"operated table is :"+tableName);
    record.add(simpledf.format(occurtime.getTime()));
    System.out.println("model is "+Guide.model);
    System.out.println("record is "+record);
    Guide.model.addRow(record);
    error report:
    model is null
    record is [send 'desc' sql,operated table is :friends, 2004/05/26 11:39:03]
    Exception in thread "main" java.lang.NullPointerException
    at testRecord.main(testRecord.java:14)

    but I just use this constructor once,never use twice
    with same jvm;I thinks my idea is not too very badIt's a public constructor (if I'm looking in the right
    place) - it could be called from anywhere. To
    intialize a static variable outside the declaration,
    use a static initializer:private static String whatever;static {
    whatever = "whatever";
    }Or simply (in this case):private static String whatever = "whatever";

  • Threaded Queries from Single static Connection object - Good approach?

    Hi,
    I need to generate a report where I need to query count(1) from over one hundred tables from oracle 10g database. I am not updating or deleting any record.
    My approach is to use a single static connection object and create one thread for each table and capture the result back into a static hashtable.
    But still, I am not getting any substantial performance improvement. Earlier, my report took 40 minutes, when it was non-threaded and now it takes 30 minutes.
    Is there anything more I can do to make my report get the counts faster? Will a connection pool help?

    Tolls wrote:
    jschell wrote:
    I was told by the DBA that count(1) works faster than count(*)....that's why....Unlikely. Certainly not true in current versions of Oracle if that is the source.Not unlikely, actually not true. Beneath the hood Oracle turns a count(1) into a count(*) in order to deal with this. Why? Because count(1) is turned into count(*) in order to avoid it being slower (Oracle 7 was the last time count(1) was different). And the reason generally given is because so many people were mistakenly using count(1) thinking it performed better that they decided to put in the "conversion" to fix the silly queries.
    I think this it the [Ask Tom|http://asktom.oracle.com/pls/asktom/f?p=100:11:109792721681931::::P11_QUESTION_ID:1156159920245] link I used last time this came up here.
    I knew all that, but I missed that the OP had specified the database vendor and version.

  • Non-static method/object cannot be referenced from a static context...?????

    What does this mean. I know about static, but I don't understand why I get this so many times.
    I try to do something pretty normal and this is what I get a lot of times. I mean: the main() method should be static right? Then what good is the main() method if you cannot let it do stuff for you like this:
    public class Test extends JFrame
        public Test
            setSize( 100, 100 );
            show();
    public static main( String args[] )
        Test window = new Test();
        draw();
    public void draw()
        blablabla whatever I want to do, a lot of times I can't.....
    }Why is this, what is the reason for Java to forbid this and what can I do about it?

    Your draw() method, since it isn't defined as static is considered by Java to be part of your Test object; hence, it can only be invoked in the context of an existing instance of your object. In other words, any Java program that wanted to use your draw() method would have to create an instance of your Test class using something likemyTest = new Test()Your main method, however, is something different. Since you want to execute your class as a program, the Java run-time environment needs to have standard starting point. This starting point is the main method. The problem is that the main method must be static, because the run-time environment cannot be expected to know beforehand the correct way to create an instance of your class so that non-static methods can be invoked. The drawback is that your main method can only directly access methods that are defined as static.
    There are two possible solutions to this problem, and which of the two you want to use depends on the object-oriented nature of your program.
    On the one hand, if your draw() method is closely tied to the object itself, if the draw() method is actually drawing your object or a part of it, it should be left as an instance method, and you should simpy use the instance of the object you created in your main method:public static main( String args[] )
        Test window = new Test();
        // maybe some code to generate something to draw???
        window.draw();
    }This is what I think you are trying to do.
    On the other hand, if your draw() method was some kind of universal method that didn't depend in any way on the current configuration of your instance, you could simply define draw() as static at which point your main method (or a method in an external class) could invoke it directly, without a corresponding instance. But if you did that, the draw() method itself would only be able to access static variables and methods.
    Doug

  • Using Arrays in custom objects

    All,
    I have searched for an answer to this but have not been able to find out so I'll post the issue and see what happens.
    I am creating a service and client for use with a JavaCard system. We have a pre-existing domain class called CardMetaData wich holds information about a card such as it's type, it's name, and an array of strings representing the static keys required to create a secure channel to the card. Essentially it looks like this:
    public class CardMetaData implements Serializable
            String[] cardStaticKeys = {"key1","key2","key3");
            String name;
            String type;
            ///getters and setters..
            //plus
            public String getStaticKey(int keyType)
              return this.cardStaticKeys[keyType];
         public void setCardStaticKey(String keyValue, int keyType)
              //Validation of input may be added later or put in an Aspect
              this.cardStaticKeys[keyType]=keyValue;
    }This is a datat transfer object.
    It is served up by a service with the following interface:
    public interface JCTemplateService extends Remote
         public CardMetaData getTemplate(String ATR) throws java.rmi.RemoteException;
    }Everything compiles and deploys find. The WSDL is:
    <definitions name="JCCardTemplateService" targetNamespace="urn:JCCardTemplateService">
         <types>
         <schema targetNamespace="urn:JCCardTemplateService">
    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
         <complexType name="CardTemplate">
         <sequence>
    <element name="cardStaticKeys" type="tns:ArrayOfstring"/>
    <element name="description" type="string"/>
    <element name="name" type="string"/>
    </sequence>
    </complexType>
         <complexType name="ArrayOfstring">
         <complexContent>
         <restriction base="soap11-enc:Array">
    <attribute ref="soap11-enc:arrayType" wsdl:arrayType="string[]"/>
    </restriction>
    </complexContent>
    </complexType>
    </schema>
    </types>
         <message name="JCTemplateService_getTemplate">
    <part name="String_1" type="xsd:string"/>
    </message>
         <message name="JCTemplateService_getTemplateResponse">
    <part name="result" type="tns:CardTemplate"/>
    </message>
         <portType name="JCTemplateService">
         <operation name="getTemplate" parameterOrder="String_1">
    <input message="tns:JCTemplateService_getTemplate"/>
    <output message="tns:JCTemplateService_getTemplateResponse"/>
    </operation>
    </portType>
         <binding name="JCTemplateServiceBinding" type="tns:JCTemplateService">
         <operation name="getTemplate">
         <input>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:JCCardTemplateService"/>
    </input>
         <output>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:JCCardTemplateService"/>
    </output>
    <soap:operation soapAction=""/>
    </operation>
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
    </binding>
         <service name="JCCardTemplateService">
         <port name="JCTemplateServicePort" binding="tns:JCTemplateServiceBinding">
    <soap:address location="http://localhost:8080/jcaa/templateService"/>
    </port>
    </service>
    </definitions>When I use a dynamic proxy to access this service like this:
    public static void main(String[] args) throws Exception
              URL urlWsdl =
                   new URL("http://localhost:8080/jcaa/templateService?WSDL");
              String nameSpaceUri = "urn:JCCardTemplateService";
              String serviceName = "JCCardTemplateService";
              String portName = "JCTemplateServicePort";
              ServiceFactory serviceFactory = ServiceFactory.newInstance();
              Service service =
                   serviceFactory.createService(
                        urlWsdl,
                        new QName(nameSpaceUri, serviceName));
               JCTemplateService myProxy =
                   (JCTemplateService) service.getPort(
                        new QName(nameSpaceUri, portName),
              JCTemplateService.class);
         ->    CardMetaData ct=myProxy.getTemplate("123456");
              System.out.println("CardTemplate from WS is "+ct.getDescription());
              System.out.println("key 1 from WS is "+ct.getKeyENC());
              System.out.println("key 2 from WS is "+ct.getKeyMAC());
              System.out.println("key 3 from WS is "+ct.getKeyKEK());
              System.out.println("Name is "+ct.getName());
         }It fails with a 'deserializzation error incomplete object' error at the line indicated above. If I remove the String[] from the value object and replace it with 3 separate string variables it works.
    Any idea's?
    Mike

    Does this mean, if you need the Dynamic Proxy client approach (and cannot use the Static Stub client, since it's J2EE implementation specific as I've learned from you, Kathy), today you cannot expect String arrays to work in J2EE web services?
    I have got a datatype Foo with an ArrayList containing String Arrays. In webMethods GLUE my server and client understand each other, it works pretty well. But I found that the WSDL is way to complex/not correctly understood by other SOAP client implementations like MS SOAP Toolkit or Mozilla Web Service Implementation.
    So my idea was to switch from GLUE to J2EE. Ok, this leads me to a WS Basic Profile I compliant WSDL and all. But now it seems this works only for really simple java types.
    I really need the ArrayList with the String Array elements. But I think in my web service (WSDL) I have to use a wrapper type which is the String representation of my (serialized by hand) Foo type and I have on the client side to create the Foo type from the string. That would not be nice, my hope was that J2EE supports more in this area. :-) Anyway, at the end it's important for me to have a portable (interoperable!) way to create and use a web service.
    So, to ask the question short and to the point:
    Today, if I want my client to work with different J2EE implementations using the Dynamic Proxy client approach and other clients, like MS SOAP Toolkit, can I offer on the J2EE web service server side a datatype with an ArrayList containing String arrays in a portable and interoperable way without the need of custom deserializers on client side?
    Merten

  • Pojo used by many other objects

    Hello all,
    In my application I have got a complex entity containing lists and maps filled with data by the persistence tier and that entity is to be used by many other objects in my application, including many controllers. I am trying to find a way to access that pojo in the most practical way. For that I could use a kind of factory such as:
    public final class MyPojoFactory
        private static MyPojo instance;
        public static MyPojo getInstance(){
        if(instance == null){
           instance = new MyPojo();
           return instance;
    }and then access my pojo using the MyPojoSingleton.getInstance() method throughout the client part of my application. However, I am bit concerned about the thread safety of this implementation since instance is a static variable and that its state could be altered indeterministically.
    What I've thought of is having a parent abstract class extended by all the classes that would need this pojo. But sometimes these classes hierarchy gets really deep and I end up with things like myClass.getParentClass().getParentClass().getMyPojo() if you see what I mean, which I would like to avoid.
    Any solution or design pattern or simpler implementation I should have a look into?
    Thanks a bunch,
    Jimmy

    Well thanks for this tip! But I've got another similar case where the service needs an id as parameter as such:
    public final class MyPojoFactory
        private static MyPojo instance;
        public static MyPojo getInstance(long primaryKey){
        if(instance == null){
           instance = service.getData(primaryKey);
           return instance;
    }In that case I don't think I could use my PojoFactory because the instance object has a global scope, doesn't it? How could I handle such a case?
    Thanks again,
    Jimmy

  • What is the advantage of using methods to return objects?

    Hello there,
    What is the advantage of using static methods to return
    objects? Isnt this a Factory Pattern ?
    What is the real advantage of using methods to return objects
    rather than using public constructors to create objects ?
    Can some one please explain
    Regards

    I think there were two questions. The first (why
    static) is well answered but I hope somebody can
    answer the general question - why whatever =
    createSomething(); as opposed to whatever
    = new Something(); - because inquiring minds
    want to know.I thought I answered that question. Perhaps I need to be more specific.
    For the Singleton pattern, you don't want a new instance (except possibly the first time, if you're using lazy instantiation).
    For the Factory pattern, you might not always want an instance of the actual class containing the static methods, so new won't work.
    If, on the other hand, neither of the above holds, there is no reason not to use new (unless, of course, anyone can come up with another use of static creators).
    RObin

  • Expression logic using LOV (static VO)

    Hi! I have a problem to create my form in JDev 11g. I created Static VO with two columns. Then in my form object "APases" I used this static VO to create LOV choices for two attributes. How can I do that, if I choose value in first attribute then I see some, not all values, in the second attribute using Static VO? Can You give me ideas and best examples what to do?
    Best regards!

    Sorry for multiple posts, but I want to all see my topic, because I need Your opinion!
    Best regards!

  • Use of static{};

    I would like to ask a dummy Question.
    class A{
    static{
    //something
    in this program, the "static{};" is use for what?
    THX

    How is that different from a constructor?Because it's performed only once for the whole class, not for each instance you create (and even if you never create an instance). Consequently it can access only static variables and methods.
    The java compiler creates two secret methods per class. <clinit> for class initialisation and <init> for instance intialisation. <clinit> is formed by gluing together all initialization of static fields, plus static blocks in the order they occur. Likewise <init> is formed by gluing together all the instance field initializers and any "instance initializer" blocks. You'll sometimes see these method names on stack traces. <clinit> is called automatically the first time you try to use the class, either creating and instance or accessing a static field or method. When the class is first loaded all fields are set to zero so any non-zero initial values are set at this point.
    My favourite use for static {} is preloading static Map objects.

  • Use of static refrence of interface

    Hi friends,
    One of my program i have got a doubt. I just want to know that what is the use of static refernce of interface. I am just giving sample code. any body could tell me how is it possible?
    public interface X{
    public void m1();
    public void m2();
    I don't know where this interface has been implemented. I taken the assumption that inteface has been implemented by the Class Y.
    Now in other class I am just creating static reference of the interface as below.
    Class B{
    static X x1;
    x1.m1(); // is valid code?
    if i is valid code, what is the purpose of this? If call method x1.m1() which method will collected?
    I am in the troble? any help would apriciated.
    Thanks in advance.
    regards & thanks.
    vijaysekhar.vn

    [ code ] [ / code ]
    public interface X{
    public void m1();
    public void m2();>
    Class B{
    static X x1;
    x1.m1(); // is valid code?
    if i is valid code, Static has nothing to do with it. As for whether it is valid code, what does your compiler tell you?
    what is the purpose of this?To have class B use functionality without depending on knowing the concrete type implementing interface X.
    If
    call method x1.m1() which method will collected?Be called, you mean? The m1 in the concrete implementing class of the object x1 is pointing to. Say you have two implementations of interface X: Y and Z. If x1 was initialized with a new Y(), Y's m1. If x1 was initialized with a new Z(), Z's m1.
    I am in the troble? Does it feel like you are? :-)

  • When I try to open an embedded PDF file I get an error "The program used to create this object is AcroExch.exe.

    When I try to open an embedded PDF file (Word doc) I get an error "The program used to create this object is AcroExch.exe. That program is either not installed on your computer, or is corrupt..."  I've tried  about everything from unchecking
    protected mode at startup to removing & reinstalling Adobe.  Nothing seems to fix this issue.  Any other ideas?
    This is happening on Adobe reader 9, 10 & 11 with MS Word 2010 & 2013.  I've uninstalled, cleaned & reinstalled Reader 9, 10 & 11, as well as Acrobat 10 Pro & 11 Standard.  Removed "Protected mode at startup, and changed
    the default program for viewing from reader to Acrobat.  This will not go away.  It is affecting production at our company.

    " Help > Troubleshooting Information > Profile Directory: Open Containing Folder" . i can't find open containing folder in profile directory. it does give me the option to open the places.sqlite file using graphic converter. when i try that, graphic converter gives me a window saying that it can't be opened because it is corrupted or is not a file type supported by graphic converter.
    i appreciate your help with a workaround to get the old bookmarks. that works. however, the problem has morphed from that concern to why adobe reader [the default app.] won't open firefox .sqlite files. is the problem in adobe reader or firefox? also, how can i tell if the places.sqlite file is corrupt?
    i'm getting in over my head here and do appreciate your help.

  • How to use two activex class objects in same vi

    HI
    I am using labview to read ECU data from INCA software .INCA providing COMTOOL API(incacom.dll). I am using ACTIVEX for  communication between INCA & Labview. My problem is If I have used single activex class object  I am able to read Inca version, getting the database path etc. If I have used two activex class in same vi (one to open Inca & other one is to read the folder structure) I am not getting output.I have attached snapshot for referance
    Attachments:
    activex1.JPG ‏114 KB
    activex2.JPG ‏107 KB

    It wasnt in the first two images you posted, or I couldnt see it anyway! That was the only reason.
    Did you try the database block on its own, just to confirm that it is working?
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

Maybe you are looking for

  • Building mod_jk module on Solaris 10 (Intel Platform)

    Hi, I am trying to build a mod_jk module on a Sun Blade 1500 (Solaris 10 Intel Platform). I downloaded the most recent tomcat connector I could find (jakarta-tomcat-connectors-current-src.tar.gz) and have attempted to build it, but I have received th

  • Service Module Report - tracing field origin

    I have a Crystal report, "Service Call Ticket" which reference the folloiwing table and fields. ServiceCallTicket is the table  name. The fields aree ItemNo, Quantity, Price, LineTotal. I cannot trace this back to the originating table. Doed anyone k

  • Mail stalls after refreshing Envelope Index

    I have refreshed the Envelope Index and now my Mail.app freezes as soon as I point on a message. Restoring the previous Envelope Index file doesn't help either. Any ideas? Or is there any way to reinstall only the Mail.app without reinstalling the wh

  • ORDERS05-To-File Mapping the qualifiers

    Hi,    I have a scenario of mapping idoc orders05 to file.    Can anybody tell me how to map the qualifiers in the target file structure for any one qualifier.    If any body has mapping program for orders05 to flat file mapping can u send the info.

  • Oracle database software on Intel based Solaris

    Hi all, Any idea regarding Oracle 8i/9i software on Intel based Solaris. Can I use Oracle 8i Sparc Software for Intel based Solaris? Thanks