Know/Java

[err] ['.' expected]Compilation error in jdk 1.4 later..

Marine™ 2006. 4. 6. 16:00
반응형
[출처: http://okjsp.pe.kr/bbs?act=VIEW&seq=25996&bbs=bbs4&pg=0 ]

간만에.. 왔다가..

밑에..

. 이 필요한 에러가 보이길래.. 적습니다.

저도 얼마전 운영 중인 사이트의 jvm을 1.4.1로 업글 하던 중 이상 증상을 발견하여.

java.sun.com의 버그 퍼레이드에 글을 올렸더니 답변이 왔더라구요..

답변의 내용은 일반적인 상용 제품에서는 패키지를 사용한다면..

항상 네임 스페이가 필요하다고 하네요.. spec이 그렇게 바뀌었다고 하네요.

ㅡㅡ;; 젠장..



메일의 내용 입니다.

=============================================================
Hello

Thank you for reporting this issue.

This bug is being tracked under the following Bug-ID: 4361575
Synopsis: Correct scoping and diagnostics for import declarations

See also Bug-ID: 4491314
Synopsis: Can No Longer Import Classes from Default Package

From the Evaluation of Bug-ID 4361575, we have:

Among other effects of this change, the compiler now rejects
import statements that import a type from the unnamed
namespace. The compiler used to accept such import declarations
before, but they were arguably not allowed by the language
(because the type name appearing in the import clause is not in
scope). Rather than try to rationalize the specification with the
compiler's behavior, the compiler has been brought into line with
the specification, and the specification is being clarified to
outright say that you can't have a simple name in an import
statement, nor can you import from the unnamed namespace. There
were ample warnings in the language specification warning against
importing names from the unnamed namespace into a named
namespace. Those warnings are no longer necessary, as it is
outright illegal.

This is likely to break lots of code, but virtually all of it is
example code rather than production code.

To summarize, the syntax

import SimpleName;

is no longer legal. Nor is the syntax

import ClassInUnnamedNamespace.Nested;

which would import a nested class from the unnamed namespace.

To fix such problems in your code, move all of the classes from
the unnamed namespace into a named namespace.



The Java(SM) Developer Connection(SM) (JDC) is a free
channel that is maintained by staff here at Sun. Access
this web page to join:
http://developer.java.sun.com/servlet/Registration

Feel free to check the status of Java(TM) bugs via the JDC at:
http://developer.java.sun.com/developer/bugParade/index.html


----------------- Original Bug Report-------------------

category : java
release : 1.4.1
subcategory : compiler
type : bug
synopsis : doing in compilation, compiler don't interprete root package description : FULL PRODUCT VERSION : java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01) Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

FULL OPERATING SYSTEM VERSION :
solaris 7

ADDITIONAL OPERATING SYSTEMS :
Ultra sparc II 400M



A DESCRIPTION OF THE PROBLEM :
While using JSP in resin, I discovered jsp that translated
to java file was not compiled.

in compliation, can't import some package....

that some package were all in root directory in package

in JDK 1.3, that was not invoked....

if class is in some package, compilation was successful.







REGRESSION. Last worked in version 1.3.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.make directory temp
and in this directory I made 2 files
A.java and B.java..

class A :

public class A {
private int a = 1;

public int get(){
return a;
}
}

class B :

package pac; // if no package was defined, result was same import A; class B {
int c;
public void kk(){
A acl = new A();
c = acl.get();
}
}

2. in temp directory..
javac A.java
3. in temp dirctory
javac -d . B.java




EXPECTED VERSUS ACTUAL BEHAVIOR :
no message is expected...


ERROR MESSAGES/STACK TRACES THAT OCCUR :
[/temp] javac -d . B.java
B.java:2: '.' expected
import A;
^
1 error

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
class A :

public class A {
private int a = 1;

public int get(){
return a;
}
}

class B :

import A;
class B {
int c;
public void kk(){
A acl = new A();
c = acl.get();
}
}
---------- END SOURCE ----------

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



이제 디폴트 패키지를 사용하면 안 되겠군요..



참고하세요...
반응형

'Know > Java' 카테고리의 다른 글

DataSource를 이용한 ConnectionPool 설정  (0) 2006.05.16
Eclipse에 Tomcat Server플러그인 설치하기  (0) 2006.05.05
AIX Java News and FAQ  (0) 2006.03.16
자바서비스넷 기술자료 링크  (2) 2006.02.07
A Collection of JVM Options  (0) 2006.01.26