Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
8bbc2c00
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8bbc2c00
编写于
8月 18, 2009
作者:
T
tbell
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
02e74527
e1fdaadf
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
428 addition
and
150 deletion
+428
-150
make/build.properties
make/build.properties
+44
-29
make/build.xml
make/build.xml
+115
-107
src/share/bin/launcher.sh-template
src/share/bin/launcher.sh-template
+1
-1
src/share/classes/com/sun/tools/javac/file/CloseableURLClassLoader.java
...ses/com/sun/tools/javac/file/CloseableURLClassLoader.java
+105
-0
src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
...re/classes/com/sun/tools/javac/file/JavacFileManager.java
+38
-2
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
+16
-7
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
...un/tools/javac/processing/JavacProcessingEnvironment.java
+8
-4
test/tools/javac/T6558476.java
test/tools/javac/T6558476.java
+101
-0
未找到文件。
make/build.properties
浏览文件 @
8bbc2c00
...
...
@@ -26,10 +26,10 @@
# This is the JDK used to build and run the bootstrap version of javac.
# The bootstrap javac is used to compile both boostrap versions of the
# other tools, and product versions of all the tools.
# Override this path as needed, either on the command line or in
# Override this path as needed, either on the command line or in
# one of the standard user build.properties files (see build.xml)
# boot.java.home = /opt/jdk/1.6.0
# boot.java.home = /opt/jdk/1.6.0
boot.java
=
${boot.java.home}/bin/java
boot.javac
=
${boot.java.home}/bin/javac
boot.javac.source
=
6
...
...
@@ -37,7 +37,7 @@ boot.javac.target = 6
# This is the JDK used to run the product version of the tools,
# for example, for testing. If you're building a complete JDK, specify that.
# Override this path as needed, either on the command line or in
# Override this path as needed, either on the command line or in
# one of the standard user build.properties files (see build.xml)
# target.java.home = /opt/jdk/1.7.0
...
...
@@ -66,23 +66,23 @@ javac.debug = true
javac.debuglevel
=
source,lines
javac.no.jdk.warnings
=
-XDignore.symbol.file=true
# set the following to -version to verify the versions of javac being used
javac.version.opt
=
javac.version.opt
=
# in time, there should be no exceptions to -Xlint:all
javac.lint.opts
=
-Xlint:all,-deprecation -Werror
# options for the <javadoc> task for javac
javadoc.jls3.url
=
http://java.sun.com/docs/books/jls/
javadoc.jls3.cite
=
<a href="${javadoc.jls3.url}">The Java Language Specification, Third Edition</a>
javadoc.jls3.cite
=
<a href="${javadoc.jls3.url}">The Java Language Specification, Third Edition</a>
javadoc.jls3.option
=
-tag "jls3:a:See <cite>${javadoc.jls3.cite}</cite>:"
# jtreg, used to run the JDK regression tests
# Override this path as needed, either on the command line or in
# Override this path as needed, either on the command line or in
# one of the standard user build.properties files (see build.xml)
# jtreg.home = /opt/jtreg/3.2.2_02
# findbugs
# Override this path as needed, either on the command line or in
# Override this path as needed, either on the command line or in
# one of the standard user build.properties files (see build.xml)
# findbugs.home = /opt/findbugs/1.2.1
...
...
@@ -94,46 +94,61 @@ javadoc.jls3.option=-tag "jls3:a:See <cite>${javadoc.jls3.cite}</cite&g
# parameter of Ant filesets. In particular, note the trailing '/'.
javac.includes
=
\
javax/annotation/processing/
\
javax/lang/model/
\
javax/tools/
\
com/sun/source/ com/sun/tools/javac/
javax/annotation/processing/
\
javax/lang/model/
\
javax/tools/
\
com/sun/source/ com/sun/tools/javac/
javac.tests
=
\
tools/javac
tools/javac
#
javadoc.includes
=
\
com/sun/javadoc/
\
com/sun/tools/javadoc/
com/sun/javadoc/
\
com/sun/tools/javadoc/
javadoc.tests
=
\
tools/javadoc/
tools/javadoc/
#
doclets.includes
=
\
com/sun/tools/doclets/
com/sun/tools/doclets/
doclets.tests
=
\
com/sun/javadoc/
com/sun/javadoc/
#
javah.includes
=
\
com/sun/tools/javah/
com/sun/tools/javah/
javah.tests
=
\
tools/javah/
tools/javah/
#
javap.includes
=
\
com/sun/tools/classfile/
\
com/sun/tools/javap/
\
sun/tools/javap/
com/sun/tools/classfile/
\
com/sun/tools/javap/
\
sun/tools/javap/
javap.tests
=
\
tools/javap/
tools/javap/
#
apt.includes
=
\
com/sun/mirror/
\
com/sun/tools/apt/
com/sun/mirror/
\
com/sun/tools/apt/
apt.tests
=
\
tools/apt/
tools/apt/
#
# The following value is used by the main jtreg target.
# An empty value means all tests
# Override as desired to run a specific set of tests
jtreg.tests
=
make/build.xml
浏览文件 @
8bbc2c00
此差异已折叠。
点击以展开。
src/share/bin/launcher.sh-template
浏览文件 @
8bbc2c00
...
...
@@ -45,7 +45,7 @@ if [ "$LANGTOOLS_USE_BOOTCLASSPATH" != "no" ]; then
fi
# tools currently assumes that assertions are enabled in the launcher
ea
=
-ea
:com.sun.tools
ea
=
-ea
:com.sun.tools
...
# Any parameters starting with -J are passed to the JVM.
# All other parameters become parameters of #PROGRAM#.
...
...
src/share/classes/com/sun/tools/javac/file/CloseableURLClassLoader.java
0 → 100644
浏览文件 @
8bbc2c00
/*
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
com.sun.tools.javac.file
;
import
java.io.Closeable
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.net.URL
;
import
java.net.URLClassLoader
;
import
java.util.ArrayList
;
import
java.util.jar.JarFile
;
/**
* A URLClassLoader that also implements Closeable.
* Reflection is used to access internal data structures in the URLClassLoader,
* since no public API exists for this purpose. Therefore this code is somewhat
* fragile. Caveat emptor.
* @throws Error if the internal data structures are not as expected.
*
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
* you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
class
CloseableURLClassLoader
extends
URLClassLoader
implements
Closeable
{
CloseableURLClassLoader
(
URL
[]
urls
,
ClassLoader
parent
)
throws
Error
{
super
(
urls
,
parent
);
try
{
getLoaders
();
//proactive check that URLClassLoader is as expected
}
catch
(
Throwable
t
)
{
throw
new
Error
(
"cannot create CloseableURLClassLoader"
,
t
);
}
}
/**
* Close any jar files that may have been opened by the class loader.
* Reflection is used to access the jar files in the URLClassLoader's
* internal data structures.
* @throws java.io.IOException if the jar files cannot be found for any
* reson, or if closing the jar file itself causes an IOException.
*/
public
void
close
()
throws
IOException
{
try
{
for
(
Object
l:
getLoaders
())
{
if
(
l
.
getClass
().
getName
().
equals
(
"sun.misc.URLClassPath$JarLoader"
))
{
Field
jarField
=
l
.
getClass
().
getDeclaredField
(
"jar"
);
JarFile
jar
=
(
JarFile
)
getField
(
l
,
jarField
);
//System.err.println("CloseableURLClassLoader: closing " + jar);
jar
.
close
();
}
}
}
catch
(
Throwable
t
)
{
IOException
e
=
new
IOException
(
"cannot close class loader"
);
e
.
initCause
(
t
);
throw
e
;
}
}
private
ArrayList
<?>
getLoaders
()
throws
NoSuchFieldException
,
IllegalArgumentException
,
IllegalAccessException
{
Field
ucpField
=
URLClassLoader
.
class
.
getDeclaredField
(
"ucp"
);
Object
urlClassPath
=
getField
(
this
,
ucpField
);
if
(
urlClassPath
==
null
)
throw
new
AssertionError
(
"urlClassPath not set in URLClassLoader"
);
Field
loadersField
=
urlClassPath
.
getClass
().
getDeclaredField
(
"loaders"
);
return
(
ArrayList
<?>)
getField
(
urlClassPath
,
loadersField
);
}
private
Object
getField
(
Object
o
,
Field
f
)
throws
IllegalArgumentException
,
IllegalAccessException
{
boolean
prev
=
f
.
isAccessible
();
try
{
f
.
setAccessible
(
true
);
return
f
.
get
(
o
);
}
finally
{
f
.
setAccessible
(
prev
);
}
}
}
src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
浏览文件 @
8bbc2c00
...
...
@@ -33,6 +33,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.OutputStreamWriter
;
import
java.lang.ref.SoftReference
;
import
java.lang.reflect.Constructor
;
import
java.net.MalformedURLException
;
import
java.net.URI
;
import
java.net.URL
;
...
...
@@ -76,6 +77,7 @@ import com.sun.tools.javac.util.ListBuffer;
import
com.sun.tools.javac.util.Log
;
import
com.sun.tools.javac.util.Options
;
import
java.io.Closeable
;
import
static
javax
.
tools
.
StandardLocation
.*;
import
static
com
.
sun
.
tools
.
javac
.
main
.
OptionName
.*;
...
...
@@ -131,6 +133,7 @@ public class JavacFileManager implements StandardJavaFileManager {
protected
boolean
mmappedIO
;
protected
boolean
ignoreSymbolFile
;
protected
String
classLoaderClass
;
/**
* User provided charset (through javax.tools).
...
...
@@ -180,6 +183,7 @@ public class JavacFileManager implements StandardJavaFileManager {
mmappedIO
=
options
.
get
(
"mmappedIO"
)
!=
null
;
ignoreSymbolFile
=
options
.
get
(
"ignore.symbol.file"
)
!=
null
;
classLoaderClass
=
options
.
get
(
"procloader"
);
}
public
JavaFileObject
getFileForInput
(
String
name
)
{
...
...
@@ -747,8 +751,40 @@ public class JavacFileManager implements StandardJavaFileManager {
throw
new
AssertionError
(
e
);
}
}
return
new
URLClassLoader
(
lb
.
toArray
(
new
URL
[
lb
.
size
()]),
getClass
().
getClassLoader
());
URL
[]
urls
=
lb
.
toArray
(
new
URL
[
lb
.
size
()]);
ClassLoader
thisClassLoader
=
getClass
().
getClassLoader
();
// Bug: 6558476
// Ideally, ClassLoader should be Closeable, but before JDK7 it is not.
// On older versions, try the following, to get a closeable classloader.
// 1: Allow client to specify the class to use via hidden option
if
(
classLoaderClass
!=
null
)
{
try
{
Class
<?
extends
ClassLoader
>
loader
=
Class
.
forName
(
classLoaderClass
).
asSubclass
(
ClassLoader
.
class
);
Class
<?>[]
constrArgTypes
=
{
URL
[].
class
,
ClassLoader
.
class
};
Constructor
<?
extends
ClassLoader
>
constr
=
loader
.
getConstructor
(
constrArgTypes
);
return
constr
.
newInstance
(
new
Object
[]
{
urls
,
thisClassLoader
});
}
catch
(
Throwable
t
)
{
// ignore errors loading user-provided class loader, fall through
}
}
// 2: If URLClassLoader implements Closeable, use that.
if
(
Closeable
.
class
.
isAssignableFrom
(
URLClassLoader
.
class
))
return
new
URLClassLoader
(
urls
,
thisClassLoader
);
// 3: Try using private reflection-based CloseableURLClassLoader
try
{
return
new
CloseableURLClassLoader
(
urls
,
thisClassLoader
);
}
catch
(
Throwable
t
)
{
// ignore errors loading workaround class loader, fall through
}
// 4: If all else fails, use plain old standard URLClassLoader
return
new
URLClassLoader
(
urls
,
thisClassLoader
);
}
public
Iterable
<
JavaFileObject
>
list
(
Location
location
,
...
...
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
浏览文件 @
8bbc2c00
...
...
@@ -813,6 +813,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
}
catch
(
Abort
ex
)
{
if
(
devVerbose
)
ex
.
printStackTrace
();
}
finally
{
if
(
procEnvImpl
!=
null
)
procEnvImpl
.
close
();
}
}
...
...
@@ -936,7 +939,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
/**
* Object to handle annotation processing.
*/
JavacProcessingEnvironment
procEnvImpl
=
null
;
private
JavacProcessingEnvironment
procEnvImpl
=
null
;
/**
* Check if we should process annotations.
...
...
@@ -947,7 +950,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
* @param processors user provided annotation processors to bypass
* discovery, {@code null} means that no processors were provided
*/
public
void
initProcessAnnotations
(
Iterable
<?
extends
Processor
>
processors
)
{
public
void
initProcessAnnotations
(
Iterable
<?
extends
Processor
>
processors
)
throws
IOException
{
// Process annotations if processing is not disabled and there
// is at least one Processor available.
Options
options
=
Options
.
instance
(
context
);
...
...
@@ -974,7 +978,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
}
// TODO: called by JavacTaskImpl
public
JavaCompiler
processAnnotations
(
List
<
JCCompilationUnit
>
roots
)
throws
IOException
{
public
JavaCompiler
processAnnotations
(
List
<
JCCompilationUnit
>
roots
)
throws
IOException
{
return
processAnnotations
(
roots
,
List
.<
String
>
nil
());
}
...
...
@@ -1061,10 +1066,14 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
return
this
;
}
}
JavaCompiler
c
=
procEnvImpl
.
doProcessing
(
context
,
roots
,
classSymbols
,
pckSymbols
);
if
(
c
!=
this
)
annotationProcessingOccurred
=
c
.
annotationProcessingOccurred
=
true
;
return
c
;
try
{
JavaCompiler
c
=
procEnvImpl
.
doProcessing
(
context
,
roots
,
classSymbols
,
pckSymbols
);
if
(
c
!=
this
)
annotationProcessingOccurred
=
c
.
annotationProcessingOccurred
=
true
;
return
c
;
}
finally
{
procEnvImpl
.
close
();
}
}
catch
(
CompletionFailure
ex
)
{
log
.
error
(
"cant.access"
,
ex
.
sym
,
ex
.
getDetailValue
());
return
this
;
...
...
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
浏览文件 @
8bbc2c00
...
...
@@ -136,6 +136,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
*/
Source
source
;
private
ClassLoader
processorClassLoader
;
/**
* JavacMessages object used for localization
*/
...
...
@@ -203,7 +205,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
JavaFileManager
fileManager
=
context
.
get
(
JavaFileManager
.
class
);
try
{
// If processorpath is not explicitly set, use the classpath.
ClassLoader
processorCL
=
fileManager
.
hasLocation
(
ANNOTATION_PROCESSOR_PATH
)
processorClassLoader
=
fileManager
.
hasLocation
(
ANNOTATION_PROCESSOR_PATH
)
?
fileManager
.
getClassLoader
(
ANNOTATION_PROCESSOR_PATH
)
:
fileManager
.
getClassLoader
(
CLASS_PATH
);
...
...
@@ -213,9 +215,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
* provider mechanism to create the processor iterator.
*/
if
(
processorNames
!=
null
)
{
processorIterator
=
new
NameProcessIterator
(
processorNames
,
processorC
L
,
log
);
processorIterator
=
new
NameProcessIterator
(
processorNames
,
processorC
lassLoader
,
log
);
}
else
{
processorIterator
=
new
ServiceIterator
(
processorC
L
,
log
);
processorIterator
=
new
ServiceIterator
(
processorC
lassLoader
,
log
);
}
}
catch
(
SecurityException
e
)
{
/*
...
...
@@ -1019,9 +1021,11 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
/**
* Free resources related to annotation processing.
*/
public
void
close
()
{
public
void
close
()
throws
IOException
{
filer
.
close
();
discoveredProcs
=
null
;
if
(
processorClassLoader
!=
null
&&
processorClassLoader
instanceof
Closeable
)
((
Closeable
)
processorClassLoader
).
close
();
}
private
List
<
ClassSymbol
>
getTopLevelClasses
(
List
<?
extends
JCCompilationUnit
>
units
)
{
...
...
test/tools/javac/T6558476.java
0 → 100644
浏览文件 @
8bbc2c00
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @run main/othervm -Xmx512m -Xms512m T6558476
*/
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.Random
;
import
com.sun.tools.javac.Main
;
public
class
T6558476
{
private
static
File
copyFileTo
(
File
file
,
File
directory
)
throws
IOException
{
File
newFile
=
new
File
(
directory
,
file
.
getName
());
FileInputStream
fis
=
null
;
FileOutputStream
fos
=
null
;
try
{
fis
=
new
FileInputStream
(
file
);
fos
=
new
FileOutputStream
(
newFile
);
byte
buff
[]
=
new
byte
[
1024
];
int
val
;
while
((
val
=
fis
.
read
(
buff
))
>
0
)
fos
.
write
(
buff
,
0
,
val
);
}
finally
{
if
(
fis
!=
null
)
fis
.
close
();
if
(
fos
!=
null
)
fos
.
close
();
}
return
newFile
;
}
private
static
String
generateJavaClass
(
String
className
)
{
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"import sun.net.spi.nameservice.dns.DNSNameService;\n"
);
sb
.
append
(
"public class "
);
sb
.
append
(
className
);
sb
.
append
(
" {\n"
);
sb
.
append
(
" public void doStuff() {\n"
);
sb
.
append
(
" DNSNameService dns = null;\n"
);
sb
.
append
(
" }\n"
);
sb
.
append
(
"}\n"
);
return
sb
.
toString
();
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
File
javaHomeDir
=
new
File
(
System
.
getProperty
(
"java.home"
));
File
tmpDir
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
));
File
outputDir
=
new
File
(
tmpDir
,
"outputDir"
+
new
Random
().
nextInt
(
65536
));
outputDir
.
mkdir
();
outputDir
.
deleteOnExit
();
File
dnsjarfile
=
new
File
(
javaHomeDir
,
"lib"
+
File
.
separator
+
"ext"
+
File
.
separator
+
"dnsns.jar"
);
File
tmpJar
=
copyFileTo
(
dnsjarfile
,
outputDir
);
String
className
=
"TheJavaFile"
;
File
javaFile
=
new
File
(
outputDir
,
className
+
".java"
);
javaFile
.
deleteOnExit
();
FileOutputStream
fos
=
new
FileOutputStream
(
javaFile
);
fos
.
write
(
generateJavaClass
(
className
).
getBytes
());
fos
.
close
();
int
rc
=
Main
.
compile
(
new
String
[]{
"-d"
,
outputDir
.
getPath
(),
"-classpath"
,
tmpJar
.
getPath
(),
javaFile
.
getAbsolutePath
()});
if
(
rc
!=
0
)
{
throw
new
Error
(
"Couldn't compile the file (exit code="
+
rc
+
")"
);
}
if
(
tmpJar
.
delete
())
{
System
.
out
.
println
(
"jar file successfully deleted"
);
}
else
{
throw
new
Error
(
"Error deleting file \""
+
tmpJar
.
getPath
()
+
"\""
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录