網頁

2011年2月21日 星期一

Is Sun's javac used in Eclipse?

NO. Eclipse has its own Java compiler.

http://www.eclipse.org/jdt/core/
JDT Core is the Java infrastructure of the Java IDE. It includes:
An incremental Java compiler. Implemented as an Eclipse builder, it is based on technology evolved from VisualAge for Java compiler. In particular, it allows to run and debug code which still contains unresolved errors.

Reference:
How to change to use SUN JAVAC compiler [message #112141]
sun vs eclipse autoboxing difference

2011年1月3日 星期一

JavaME Preverify

c:/Java_ME_platform_SDK_3.0/bin/preverify.exe
-classpath stubclasses.zip\;../client/preverified\;tmpclasses
-d classes
tmpclasses

Java Cross-Compilation

$JAVA_HOME/bin/javac
-bootclasspath stubclasses.zip
-source 1.3 -target 1.3
-d tmpclasses/
-classpath ../client/preverified
-sourcepath src/game/internal
src/game/internal/com/xyz/media/feature/function/track/GetStateTests.java
2>&1 | tee build4.log

2010年12月17日 星期五

Tricky initialization of a declaration in C

int main( void )
{
    int x = ( x = 10, x += x, x );

    printf("x=%d\n", x);

    return 0;
}

2010年6月10日 星期四

Linux 下的源程序查看工具

http://www.linuxsir.org/bbs/showthread.php?t=237551

我用下来的感觉是(在debian sid中)
(g)vim + ctags + taglist + cscope + cppcomplete + global

大型程序一定要global的参与,它的分析比较全面。

taglist 精干,需要ctags的支撑 ,直接可以在左边列出函数列表,全局参数列表。(可以排序)

cscope 比较强大,可以对函数以及部分类型定义进行跳转,但有些BUG,好像在某些条件下无法正确找到分析枚举的定义。

cppcomplete 需要ctags的支撑,可以补全类型或者函数名(可不是普通Ctrl+P/N的那种)

global 新版本可以嵌入vim使用,提供比较完整解析和类型索引,和cscope比,稍微差些的就是对类型引用的打印列表中没有标识这个引用在什么函数中进行的。

这些都在我平常的使用中,部分功能还在摸索中。

2010年5月20日 星期四

Java Anonymous Instance

對話框通常只會出現一下下, 用來提示使用者採取某些行動. 當使用者做完決定後, 這個對話框就會消失.

使用匿名類別顯示一個對話框, 亦即建立一個匿名的實體. 當運行完這個對話框後, 系統會自行回收這個匿名實體所佔用的記憶體空間, 從而讓程式在運行中不會佔到不必要的記憶體空間.

Java Nested Classes: this

http://mindprod.com/jgloss/this.html

"this" means the current object, the instance we are currently running a method on.

Beware, inside an (anonymous) inner class, "this" refers to the inner class, not the usual enclosing one. If the outer class were called MyOuter, you could get at its this with "MyOuter.this".

Example:

public class MyClass {
  private String outerClassField = "some value";
 
  public void outerClassMethod() {
    someObject.addMyListener(new MyListener() {
      public void processEvent(MyEvent e) {
        MyClass.this.outherClassField;
      }
    });
  }
}

2010年4月23日 星期五

useful command

  • $ find ../../../../MMI/UI_ESIM/porting/PL_Java -iname "*.c" -exec basename "{}" \; | sed -e 's/\.c/\.o/g' | xargs -r rm

  • $ find . -iname "iextutil.o" -o -iname "iamsengine.o" -o -iname "kjava_sys_ext.o" | xargs -r rm

  • $ svn status | grep -v '?' | cut -b 2- | sed -e 's,\\,/,g' | xargs -r cp --parents -t ../patch_0427_release_merge/

  • $ find . -maxdepth 1 ! -iname "pl_java*" | xargs -r rm -rf

  • $ find . -maxdepth 1 ! -iname "build*" -a ! -name '.' | xargs -r rm -rf

  • $ diff -u -r --ignore-matching-lines=".*\$Id.*" parts_simon/ parts_ting/ | tee diff4.patch

  • $ svn diff -c 80580 --diff-cmd diff -x '-u -w -B -t --tabsize=4' > svg_update_hi_diff.log

2010年4月20日 星期二

svn command

generate svn diff (unified) file:
  • svn diff -r PREV:COMMITTED $SVN_LINK > svn.patch
  • svn diff -c $REVISION_NUMBER $SVN_LINK > svn.patch
  • $ svn diff -c 80580 --diff-cmd diff -x '-u -w -B -t --tabsize=4' > svg_update_hi_diff.log


apply diff file:
  • patch --verbose --dry-run -p0 < svn.patch


copy local modified files
  • svn status | grep -v '?' | cut -b 2- | sed -e 's,\\,/,g' | xargs -r cp --parents -t ../patch_0427_release_merge/


retrieve modified files in a commit:
  • svn update -r PREV
  • svn update -r HEAD | sed 's,\\,/,g' | cut -b 2- | xargs -r cp --parents -t $DEST


show the latest n svn commit log:
  • svn log -l n -v

Nested Classes

Why Use Nested Classes?

There are several compelling reasons for using nested classes, among them:
  • It is a way of logically grouping classes that are only used in one place.
  • It increases encapsulation.
  • Nested classes can lead to more readable and maintainable code.



Java Gossip: 內部類別(Inner class)
  • 使用內部類別的好處在於可以直接存取外部類別的私用(private)成員,舉個例子來說,在視窗程式中,您可以使用內部類別來實作一個事件傾聽者類別,這個視窗傾聽者類別可以直接存取視窗元件,而不用透過參數傳遞。
  • 另一個好處是,當某個Slave類別完全只服務於一個Master類別時,我們可以將之設定為內部類別,如此使用Master類別的人就不用知道 Slave的存在。



So what are inner classes good for anyway?

The advantages of inner classes can be divided into three categories:
  • an object-oriented advantage,
  • an organizational advantage, and
  • a call-back advantage.