Village For DreamChasers....

블로그 이미지
by 건빵쥔곰
  • 13662Total hit
  • 1Today hit
  • 19Yesterday hit

'Idea Village/java'에 해당되는 글 5건

  1. 2008/07/29
    JAVA , Signal Number
  2. 2007/11/22
    Eclipse Hot Key
  3. 2007/11/08
    타 OS 간 TCP/IP 통신시 byte[] 배열...
  4. 2007/10/12
    String 을 Byte 단위로 자르는 함수
  5. 2007/07/04
    JAD - 자바디컴파일러

최근 서버운영중 OutOfMemory 가 발생
해서 javacore dump 가 떨어 지는데 해당 signal 의 분석이 필요해서 웹을 긁었다.

/**  JAVA Signal */
다음은 헤더에 정의 되어 있는 Java Signal이다.

예외적으로 JVM의 하위 버젼에서는 Out Of Memory의 경우, 0, -1을 출력하는 것으로 알려져 있다.

/* Signals.  */
#define SIGHUP      1   /* Hangup (POSIX).  */
#define SIGINT      2   /* Interrupt (ANSI).  */
#define SIGQUIT     3   /* Quit (POSIX).  */
#define SIGILL      4   /* Illegal instruction (ANSI).  */
#define SIGTRAP     5   /* Trace trap (POSIX).  */
#define SIGABRT     6   /* Abort (ANSI).  */
#define SIGIOT      6   /* IOT trap (4.2 BSD).  */
#define SIGBUS      7   /* BUS error (4.2 BSD).  */
#define SIGFPE      8   /* Floating-point exception (ANSI).  */
#define SIGKILL     9   /* Kill, unblockable (POSIX).  */
#define SIGUSR1     10  /* User-defined signal 1 (POSIX).  */
#define SIGSEGV     11  /* Segmentation violation (ANSI).  */
#define SIGUSR2     12  /* User-defined signal 2 (POSIX).  */
#define SIGPIPE     13  /* Broken pipe (POSIX).  */
#define SIGALRM     14  /* Alarm clock (POSIX).  */
#define SIGTERM     15  /* Termination (ANSI).  */
#define SIGSTKFLT   16  /* Stack fault.  */
#define SIGCLD      SIGCHLD /* Same as SIGCHLD (System V).  */
#define SIGCHLD     17  /* Child status has changed (POSIX).  */
#define SIGCONT     18  /* Continue (POSIX).  */
#define SIGSTOP     19  /* Stop, unblockable (POSIX).  */
#define SIGTSTP     20  /* Keyboard stop (POSIX).  */
#define SIGTTIN     21  /* Background read from tty (POSIX).  */
#define SIGTTOU     22  /* Background write to tty (POSIX).  */
#define SIGURG      23  /* Urgent condition on socket (4.2 BSD).  */
#define SIGXCPU     24  /* CPU limit exceeded (4.2 BSD).  */
#define SIGXFSZ     25  /* File size limit exceeded (4.2 BSD).  */
#define SIGVTALRM   26  /* Virtual alarm clock (4.2 BSD).  */
#define SIGPROF     27  /* Profiling alarm clock (4.2 BSD).  */
#define SIGWINCH    28  /* Window size change (4.3 BSD, Sun).  */
#define SIGPOLL     SIGIO   /* Pollable event occurred (System V).  */
#define SIGIO       29  /* I/O now possible (4.2 BSD).  */
#define SIGPWR      30  /* Power failure restart (System V).  */
#define SIGUNUSED   31

#define _NSIG       64  /* Biggest signal number + 1
                   (including real-time signals).  */

크리에이티브 커먼즈 라이선스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
TRACKBACK 0 AND COMMENT 0

이클립스 사용하면서 자주 쓰는 Hot Key
나머지는 사실 잘 쓰지도 않는다.. -ㅅ-

Ctrl + Space : 자동 완성, 힌트
Ctrl + Shift + O : Organize Import
Ctrl + Shift + F : Format
F3 : Open Declaration
F4 : hierarchy

Ctrl + Shift + space : 파라메터 힌트
Ctrl + / : // 코멘트(토글됨)
Ctrl + Shift + / : /* */ 코멘트
Ctrl + Shift +\ : /* */ 해제
Ctrl + 1 : Quick Fix
Alt  + Shift + O : 선택한 resource 찾기
Ctrl + o : overview..

크리에이티브 커먼즈 라이선스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
TRACKBACK 0 AND COMMENT 0
이번에 암호화 관련하여 개고생을 한 byte[] ..

byte[] tmp =  .....;
Strin strMsg = new String(tmp);

여기서 byte[] 배열을 String 으로 변환하는 new String(byte[]) 생성자에 대해
JDK 1.4 Doc  에 있는 설명을 보면..
 
The behavior of this constructor when the given bytes are not valid
in the default charset is unspecified.

 /**
     * Constructs a new <tt>String</tt> by decoding the specified subarray of
     * bytes using the platform's default charset.  The length of the new
     * <tt>String</tt> is a function of the charset, and hence may not be equal
     * to the length of the subarray.
     *
     * <p> The behavior of this constructor when the given bytes are not valid
     * in the default charset is unspecified.  The {@link
     * java.nio.charset.CharsetDecoder} class should be used when more control
     * over the decoding process is required.
     *
     * @param  bytes   the bytes to be decoded into characters
     * @param  offset  the index of the first byte to decode
     * @param  length  the number of bytes to decode
     * @throws IndexOutOfBoundsException
     *         if the <code>offset</code> and the <code>length</code>
     *         arguments index characters outside the bounds of the
     *         <code>bytes</code> array
     * @throws NullPointerException
     *         if <code>bytes</code> array is <code>null</code>
     * @since  JDK1.1
     */

결국 위 메소드 수행결과는 JDK 버전에 따라 , 플랫폼 별 JDK 에 따라 , 인코딩에 따라 return 되는
결과값에 대해 자바 규약에는 없댄다.. 젠 -_ㅜ

암튼 글의 요지는 byte[] 를 String 으로 변환할때 개조심 하지 않으면 데이타 손실및
통신을 제대로 하고도 데이타를 제대로 구현하지 못한다는 것이다..

아래는 www.javaservice.net 에서 친절하게도 테스트 해준 결과값..
(진작에 찾아 봤으면 개고생 안해도 될텐데 .... 이틀을 삽질하고 찾아보고나선
얼마나 좌절을 했는지.. ㅠ_ㅠ)

==========================================================================================

Big5:false
Big5-HKSCS:false
EUC-CN:false
EUC-JP:false
euc-jp-linux:false
EUC-KR:false
EUC-TW:error
GB18030:false
GBK:false
ISCII91:error
ISO-2022-CN-CNS:error
ISO-2022-CN-GB:error
ISO-2022-KR:error
ISO-8859-1:true
ISO-8859-13:true
ISO-8859-15:true
ISO-8859-2:true
ISO-8859-3:false
ISO-8859-4:true
ISO-8859-5:true
ISO-8859-6:false
ISO-8859-7:false
ISO-8859-8:false
ISO-8859-9:true
JIS0201:false
JIS0208:false
JIS0212:false
Johab:false
KOI8-R:true
Shift_JIS:false
TIS-620:false
US-ASCII:false
UTF-16:false
UTF-16BE:false
UTF-16LE:false
UTF-8:false
windows-1250:false
windows-1251:false
windows-1252:false
windows-1253:false
windows-1254:false
windows-1255:false
windows-1256:true
windows-1257:false
windows-1258:false
windows-936:false
windows-949:false
windows-950:false

==========================================================================================

크리에이티브 커먼즈 라이선스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
TRACKBACK 0 AND COMMENT 0
소켓통신이나 전문 처리를 할때  String 을 subString 으로 자르기보다 Byte  단위로 잘라서
통신을 송/수신 하기도 한다.

다음의 함수가 유용할듯  

/**
     * String 을 BYTE 단위로 자르는 함수
     * @ author 박동규
     * @ param startIndex, length
     * @ return String 잘려진 문자열
     */
   
    public String cutStringToByte (String str, int startIndex , int length) {
       
        byte[] b1 = null;
        byte[] b2 = null;
        try{
           
            if(str == null ) {
                return "";
            }
           
            b1 = str.getBytes();
            b2 = new byte[length] ;
           
            if( length > (b1.length - startIndex) ) {
                length = b1.length - startIndex;               
            }
           
            System.arraycopy(b1,startIndex,b2,0,length);
           
        } catch (Exception e) {
            e.printStackTrace();
        }
           
        return new String(b2);
    }
크리에이티브 커먼즈 라이선스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
TRACKBACK 0 AND COMMENT 0

말그대로 디컴파일러

있으면 잘 안쓰고 없으면 불편한 ㅋㅋㅋ
크리에이티브 커먼즈 라이선스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
TRACKBACK 0 AND COMMENT 0

ARTICLE CATEGORY

분류 전체보기 (35)
Stroy Village (6)
Daily Village (9)
Idea Village (20)

RECENT TRACKBACK

CALENDAR

«   2008/08   »
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            

ARCHIVE