Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
2cc0addc
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看板
提交
2cc0addc
编写于
2月 23, 2010
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
cad3967f
40e309b4
变更
33
隐藏空白更改
内联
并排
Showing
33 changed file
with
513 addition
and
314 deletion
+513
-314
make/Makefile
make/Makefile
+1
-1
src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java
...e/classes/com/sun/mirror/util/SourceOrderDeclScanner.java
+5
-1
src/share/classes/com/sun/tools/apt/comp/Apt.java
src/share/classes/com/sun/tools/apt/comp/Apt.java
+5
-50
src/share/classes/com/sun/tools/apt/main/Main.java
src/share/classes/com/sun/tools/apt/main/Main.java
+2
-55
src/share/classes/com/sun/tools/javac/file/Paths.java
src/share/classes/com/sun/tools/javac/file/Paths.java
+59
-0
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
...un/tools/javac/processing/JavacProcessingEnvironment.java
+74
-113
src/share/classes/com/sun/tools/javadoc/DocletInvoker.java
src/share/classes/com/sun/tools/javadoc/DocletInvoker.java
+1
-55
test/tools/javac/6341866/Anno.java
test/tools/javac/6341866/Anno.java
+5
-1
test/tools/javac/EarlyAssert.java
test/tools/javac/EarlyAssert.java
+2
-0
test/tools/javac/EarlyAssertWrapper.java
test/tools/javac/EarlyAssertWrapper.java
+83
-0
test/tools/javac/T6403466.java
test/tools/javac/T6403466.java
+20
-14
test/tools/javac/T6406771.java
test/tools/javac/T6406771.java
+5
-1
test/tools/javac/T6411379.java
test/tools/javac/T6411379.java
+5
-1
test/tools/javac/T6423583.java
test/tools/javac/T6423583.java
+4
-1
test/tools/javac/T6855236.java
test/tools/javac/T6855236.java
+5
-1
test/tools/javac/api/6421111/T6421111.java
test/tools/javac/api/6421111/T6421111.java
+4
-1
test/tools/javac/api/6468404/T6468404.java
test/tools/javac/api/6468404/T6468404.java
+5
-1
test/tools/javac/api/T6412669.java
test/tools/javac/api/T6412669.java
+5
-1
test/tools/javac/enum/6424358/T6424358.java
test/tools/javac/enum/6424358/T6424358.java
+6
-2
test/tools/javac/processing/6348499/A.java
test/tools/javac/processing/6348499/A.java
+4
-1
test/tools/javac/processing/6414633/A.java
test/tools/javac/processing/6414633/A.java
+5
-1
test/tools/javac/processing/6430209/T6430209.java
test/tools/javac/processing/6430209/T6430209.java
+0
-1
test/tools/javac/processing/6430209/b6341534.java
test/tools/javac/processing/6430209/b6341534.java
+6
-1
test/tools/javac/processing/6634138/Dummy.java
test/tools/javac/processing/6634138/Dummy.java
+27
-0
test/tools/javac/processing/6634138/ExerciseDependency.java
test/tools/javac/processing/6634138/ExerciseDependency.java
+37
-0
test/tools/javac/processing/6634138/T6634138.java
test/tools/javac/processing/6634138/T6634138.java
+93
-0
test/tools/javac/processing/T6439826.java
test/tools/javac/processing/T6439826.java
+5
-1
test/tools/javac/processing/model/element/TypeParamBounds.java
...tools/javac/processing/model/element/TypeParamBounds.java
+5
-1
test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java
...javac/processing/model/type/MirroredTypeEx/OverEager.java
+5
-1
test/tools/javac/processing/model/type/NoTypes.java
test/tools/javac/processing/model/type/NoTypes.java
+5
-2
test/tools/javac/processing/model/util/GetTypeElemBadArg.java
.../tools/javac/processing/model/util/GetTypeElemBadArg.java
+6
-1
test/tools/javac/processing/model/util/OverridesSpecEx.java
test/tools/javac/processing/model/util/OverridesSpecEx.java
+5
-1
test/tools/javac/treepostests/TreePosTest.java
test/tools/javac/treepostests/TreePosTest.java
+14
-4
未找到文件。
make/Makefile
浏览文件 @
2cc0addc
...
...
@@ -70,7 +70,7 @@ ifdef QUIET
endif
ifdef
VERBOSE
ANT_OPTIONS
+=
-verbose
-d
iagnostics
ANT_OPTIONS
+=
-verbose
-d
ebug
endif
ifdef
JDK_VERSION
...
...
src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java
浏览文件 @
2cc0addc
...
...
@@ -101,7 +101,11 @@ class SourceOrderDeclScanner extends DeclarationScanner {
}
@SuppressWarnings
(
"cast"
)
private
int
compareEqualPosition
(
Declaration
d1
,
Declaration
d2
)
{
assert
d1
.
getPosition
()
==
d2
.
getPosition
();
assert
(
d1
.
getPosition
()
==
d2
.
getPosition
())
||
// Handles two null positions.
(
d1
.
getPosition
().
file
().
compareTo
(
d2
.
getPosition
().
file
())
==
0
&&
d1
.
getPosition
().
line
()
==
d2
.
getPosition
().
line
()
&&
d1
.
getPosition
().
column
()
==
d2
.
getPosition
().
column
());
DeclPartialOrder
dpo1
=
new
DeclPartialOrder
();
DeclPartialOrder
dpo2
=
new
DeclPartialOrder
();
...
...
src/share/classes/com/sun/tools/apt/comp/Apt.java
浏览文件 @
2cc0addc
...
...
@@ -496,57 +496,12 @@ public class Apt extends ListBuffer<Env<AttrContext>> {
* won't match anything.
*/
Pattern
importStringToPattern
(
String
s
)
{
if
(
s
.
equals
(
"*"
))
{
return
allMatches
;
if
(
com
.
sun
.
tools
.
javac
.
processing
.
JavacProcessingEnvironment
.
isValidImportString
(
s
))
{
return
com
.
sun
.
tools
.
javac
.
processing
.
JavacProcessingEnvironment
.
validImportStringToPattern
(
s
)
;
}
else
{
String
t
=
s
;
boolean
star
=
false
;
/*
* Validate string from factory is legal. If the string
* has more than one asterisks or the asterisks does not
* appear as the last character (preceded by a period),
* the string is not legal.
*/
boolean
valid
=
true
;
int
index
=
t
.
indexOf
(
'*'
);
if
(
index
!=
-
1
)
{
// '*' must be last character...
if
(
index
==
t
.
length
()
-
1
)
{
// ... and preceeding character must be '.'
if
(
index
-
1
>=
0
)
{
valid
=
t
.
charAt
(
index
-
1
)
==
'.'
;
// Strip off ".*$" for identifier checks
t
=
t
.
substring
(
0
,
t
.
length
()-
2
);
}
}
else
valid
=
false
;
}
// Verify string is off the form (javaId \.)+ or javaId
if
(
valid
)
{
String
[]
javaIds
=
t
.
split
(
"\\."
,
t
.
length
()+
2
);
for
(
String
javaId:
javaIds
)
valid
&=
isJavaIdentifier
(
javaId
);
}
if
(!
valid
)
{
Bark
bark
=
Bark
.
instance
(
context
);
bark
.
aptWarning
(
"MalformedSupportedString"
,
s
);
return
noMatches
;
// won't match any valid identifier
}
String
s_prime
=
s
.
replaceAll
(
"\\."
,
"\\\\."
);
if
(
s_prime
.
endsWith
(
"*"
))
{
s_prime
=
s_prime
.
substring
(
0
,
s_prime
.
length
()
-
1
)
+
".+"
;
}
return
Pattern
.
compile
(
s_prime
);
Bark
bark
=
Bark
.
instance
(
context
);
bark
.
aptWarning
(
"MalformedSupportedString"
,
s
);
return
com
.
sun
.
tools
.
javac
.
processing
.
JavacProcessingEnvironment
.
noMatches
;
}
}
private
static
final
Pattern
allMatches
=
Pattern
.
compile
(
".*"
);
private
static
final
Pattern
noMatches
=
Pattern
.
compile
(
"(\\P{all})+"
);
}
src/share/classes/com/sun/tools/apt/main/Main.java
浏览文件 @
2cc0addc
...
...
@@ -56,6 +56,8 @@ import com.sun.tools.apt.comp.UsageMessageNeededException;
import
com.sun.tools.apt.util.Bark
;
import
com.sun.mirror.apt.AnnotationProcessorFactory
;
import
static
com
.
sun
.
tools
.
javac
.
file
.
Paths
.
pathToURLs
;
/** This class provides a commandline interface to the apt build-time
* tool.
*
...
...
@@ -1276,59 +1278,4 @@ public class Main {
}
}
}
// Borrowed from DocletInvoker
/**
* Utility method for converting a search path string to an array
* of directory and JAR file URLs.
*
* @param path the search path string
* @return the resulting array of directory and JAR file URLs
*/
static
URL
[]
pathToURLs
(
String
path
)
{
StringTokenizer
st
=
new
StringTokenizer
(
path
,
File
.
pathSeparator
);
URL
[]
urls
=
new
URL
[
st
.
countTokens
()];
int
count
=
0
;
while
(
st
.
hasMoreTokens
())
{
URL
url
=
fileToURL
(
new
File
(
st
.
nextToken
()));
if
(
url
!=
null
)
{
urls
[
count
++]
=
url
;
}
}
if
(
urls
.
length
!=
count
)
{
URL
[]
tmp
=
new
URL
[
count
];
System
.
arraycopy
(
urls
,
0
,
tmp
,
0
,
count
);
urls
=
tmp
;
}
return
urls
;
}
/**
* Returns the directory or JAR file URL corresponding to the specified
* local file name.
*
* @param file the File object
* @return the resulting directory or JAR file URL, or null if unknown
*/
static
URL
fileToURL
(
File
file
)
{
String
name
;
try
{
name
=
file
.
getCanonicalPath
();
}
catch
(
IOException
e
)
{
name
=
file
.
getAbsolutePath
();
}
name
=
name
.
replace
(
File
.
separatorChar
,
'/'
);
if
(!
name
.
startsWith
(
"/"
))
{
name
=
"/"
+
name
;
}
// If the file does not exist, then assume that it's a directory
if
(!
file
.
isFile
())
{
name
=
name
+
"/"
;
}
try
{
return
new
URL
(
"file"
,
""
,
name
);
}
catch
(
MalformedURLException
e
)
{
throw
new
IllegalArgumentException
(
"file"
);
}
}
}
src/share/classes/com/sun/tools/javac/file/Paths.java
浏览文件 @
2cc0addc
...
...
@@ -27,6 +27,8 @@ package com.sun.tools.javac.file;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
...
...
@@ -34,6 +36,7 @@ import java.util.Set;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.LinkedHashSet
;
import
java.util.StringTokenizer
;
import
java.util.zip.ZipFile
;
import
javax.tools.JavaFileManager.Location
;
...
...
@@ -449,4 +452,60 @@ public class Paths {
return
fsInfo
.
isFile
(
file
)
&&
(
n
.
endsWith
(
".jar"
)
||
n
.
endsWith
(
".zip"
));
}
/**
* Utility method for converting a search path string to an array
* of directory and JAR file URLs.
*
* Note that this method is called by apt and the DocletInvoker.
*
* @param path the search path string
* @return the resulting array of directory and JAR file URLs
*/
public
static
URL
[]
pathToURLs
(
String
path
)
{
StringTokenizer
st
=
new
StringTokenizer
(
path
,
File
.
pathSeparator
);
URL
[]
urls
=
new
URL
[
st
.
countTokens
()];
int
count
=
0
;
while
(
st
.
hasMoreTokens
())
{
URL
url
=
fileToURL
(
new
File
(
st
.
nextToken
()));
if
(
url
!=
null
)
{
urls
[
count
++]
=
url
;
}
}
if
(
urls
.
length
!=
count
)
{
URL
[]
tmp
=
new
URL
[
count
];
System
.
arraycopy
(
urls
,
0
,
tmp
,
0
,
count
);
urls
=
tmp
;
}
return
urls
;
}
/**
* Returns the directory or JAR file URL corresponding to the specified
* local file name.
*
* @param file the File object
* @return the resulting directory or JAR file URL, or null if unknown
*/
private
static
URL
fileToURL
(
File
file
)
{
String
name
;
try
{
name
=
file
.
getCanonicalPath
();
}
catch
(
IOException
e
)
{
name
=
file
.
getAbsolutePath
();
}
name
=
name
.
replace
(
File
.
separatorChar
,
'/'
);
if
(!
name
.
startsWith
(
"/"
))
{
name
=
"/"
+
name
;
}
// If the file does not exist, then assume that it's a directory
if
(!
file
.
isFile
())
{
name
=
name
+
"/"
;
}
try
{
return
new
URL
(
"file"
,
""
,
name
);
}
catch
(
MalformedURLException
e
)
{
throw
new
IllegalArgumentException
(
file
.
toString
());
}
}
}
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
浏览文件 @
2cc0addc
...
...
@@ -25,7 +25,6 @@
package
com.sun.tools.javac.processing
;
import
java.lang.reflect.*
;
import
java.util.*
;
import
java.util.regex.*
;
...
...
@@ -874,20 +873,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
JavaFileManager
fileManager
=
currentContext
.
get
(
JavaFileManager
.
class
);
List
<
JavaFileObject
>
fileObjects
=
List
.
nil
();
for
(
JavaFileObject
jfo
:
filer
.
getGeneratedSourceFileObjects
()
)
{
fileObjects
=
fileObjects
.
prepend
(
jfo
);
}
compiler
=
JavaCompiler
.
instance
(
currentContext
);
List
<
JCCompilationUnit
>
parsedFiles
=
compiler
.
parseFiles
(
fileObjects
);
roots
=
cleanTrees
(
roots
).
reverse
();
for
(
JCCompilationUnit
unit
:
parsedFiles
)
roots
=
roots
.
prepend
(
unit
);
roots
=
roots
.
reverse
();
List
<
JCCompilationUnit
>
parsedFiles
=
sourcesToParsedFiles
(
compiler
);
roots
=
cleanTrees
(
roots
).
appendList
(
parsedFiles
);
// Check for errors after parsing
if
(
compiler
.
parseErrors
())
{
...
...
@@ -921,11 +909,16 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
break
runAround
;
// No new files
}
}
runLastRound
(
xout
,
roundNumber
,
errorStatus
,
taskListener
);
roots
=
runLastRound
(
xout
,
roundNumber
,
errorStatus
,
compiler
,
roots
,
taskListener
);
// Set error status for any files compiled and generated in
// the last round
if
(
compiler
.
parseErrors
())
errorStatus
=
true
;
compiler
.
close
(
false
);
currentContext
=
contextForNextRound
(
currentContext
,
true
);
compiler
=
JavaCompiler
.
instance
(
currentContext
);
filer
.
newRound
(
currentContext
,
true
);
filer
.
warnIfUnclosedFiles
();
warnIfUnmatchedOptions
();
...
...
@@ -979,10 +972,22 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
return
compiler
;
}
private
List
<
JCCompilationUnit
>
sourcesToParsedFiles
(
JavaCompiler
compiler
)
throws
IOException
{
List
<
JavaFileObject
>
fileObjects
=
List
.
nil
();
for
(
JavaFileObject
jfo
:
filer
.
getGeneratedSourceFileObjects
()
)
{
fileObjects
=
fileObjects
.
prepend
(
jfo
);
}
return
compiler
.
parseFiles
(
fileObjects
);
}
// Call the last round of annotation processing
private
void
runLastRound
(
PrintWriter
xout
,
int
roundNumber
,
boolean
errorStatus
,
private
List
<
JCCompilationUnit
>
runLastRound
(
PrintWriter
xout
,
int
roundNumber
,
boolean
errorStatus
,
JavaCompiler
compiler
,
List
<
JCCompilationUnit
>
roots
,
TaskListener
taskListener
)
throws
IOException
{
roundNumber
++;
List
<
ClassSymbol
>
noTopLevelClasses
=
List
.
nil
();
...
...
@@ -1003,6 +1008,15 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
if
(
taskListener
!=
null
)
taskListener
.
finished
(
new
TaskEvent
(
TaskEvent
.
Kind
.
ANNOTATION_PROCESSING_ROUND
));
}
// Add any sources generated during the last round to the set
// of files to be compiled.
if
(
moreToDo
())
{
List
<
JCCompilationUnit
>
parsedFiles
=
sourcesToParsedFiles
(
compiler
);
roots
=
cleanTrees
(
roots
).
appendList
(
parsedFiles
);
}
return
roots
;
}
private
void
updateProcessingState
(
Context
currentContext
,
boolean
lastRound
)
{
...
...
@@ -1340,115 +1354,62 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
return
specifiedPackages
;
}
// Borrowed from DocletInvoker and apt
// TODO: remove from apt's Main
private
static
final
Pattern
allMatches
=
Pattern
.
compile
(
".*"
);
public
static
final
Pattern
noMatches
=
Pattern
.
compile
(
"(\\P{all})+"
);
/**
* Utility method for converting a search path string to an array
* of directory and JAR file URLs.
*
* @param path the search path string
* @return the resulting array of directory and JAR file URLs
* Convert import-style string for supported annotations into a
* regex matching that string. If the string is a valid
* import-style string, return a regex that won't match anything.
*/
public
static
URL
[]
pathToURLs
(
String
path
)
{
StringTokenizer
st
=
new
StringTokenizer
(
path
,
File
.
pathSeparator
);
URL
[]
urls
=
new
URL
[
st
.
countTokens
()];
int
count
=
0
;
while
(
st
.
hasMoreTokens
())
{
URL
url
=
fileToURL
(
new
File
(
st
.
nextToken
()));
if
(
url
!=
null
)
{
urls
[
count
++]
=
url
;
}
}
if
(
urls
.
length
!=
count
)
{
URL
[]
tmp
=
new
URL
[
count
];
System
.
arraycopy
(
urls
,
0
,
tmp
,
0
,
count
);
urls
=
tmp
;
private
static
Pattern
importStringToPattern
(
String
s
,
Processor
p
,
Log
log
)
{
if
(
isValidImportString
(
s
))
{
return
validImportStringToPattern
(
s
);
}
else
{
log
.
warning
(
"proc.malformed.supported.string"
,
s
,
p
.
getClass
().
getName
());
return
noMatches
;
// won't match any valid identifier
}
return
urls
;
}
/**
* Returns the directory or JAR file URL corresponding to the specified
* local file name.
*
* @param file the File object
* @return the resulting directory or JAR file URL, or null if unknown
* Return true if the argument string is a valid import-style
* string specifying claimed annotations; return false otherwise.
*/
private
static
URL
fileToURL
(
File
file
)
{
String
name
;
try
{
name
=
file
.
getCanonicalPath
();
}
catch
(
IOException
e
)
{
name
=
file
.
getAbsolutePath
();
}
name
=
name
.
replace
(
File
.
separatorChar
,
'/'
);
if
(!
name
.
startsWith
(
"/"
))
{
name
=
"/"
+
name
;
}
// If the file does not exist, then assume that it's a directory
if
(!
file
.
isFile
())
{
name
=
name
+
"/"
;
public
static
boolean
isValidImportString
(
String
s
)
{
if
(
s
.
equals
(
"*"
))
return
true
;
boolean
valid
=
true
;
String
t
=
s
;
int
index
=
t
.
indexOf
(
'*'
);
if
(
index
!=
-
1
)
{
// '*' must be last character...
if
(
index
==
t
.
length
()
-
1
)
{
// ... any and preceding character must be '.'
if
(
index
-
1
>=
0
)
{
valid
=
t
.
charAt
(
index
-
1
)
==
'.'
;
// Strip off ".*$" for identifier checks
t
=
t
.
substring
(
0
,
t
.
length
()-
2
);
}
}
else
return
false
;
}
try
{
return
new
URL
(
"file"
,
""
,
name
);
}
catch
(
MalformedURLException
e
)
{
throw
new
IllegalArgumentException
(
"file"
);
// Verify string is off the form (javaId \.)+ or javaId
if
(
valid
)
{
String
[]
javaIds
=
t
.
split
(
"\\."
,
t
.
length
()+
2
);
for
(
String
javaId:
javaIds
)
valid
&=
SourceVersion
.
isIdentifier
(
javaId
);
}
return
valid
;
}
private
static
final
Pattern
allMatches
=
Pattern
.
compile
(
".*"
);
private
static
final
Pattern
noMatches
=
Pattern
.
compile
(
"(\\P{all})+"
);
/**
* Convert import-style string to regex matching that string. If
* the string is a valid import-style string, return a regex that
* won't match anything.
*/
// TODO: remove version in Apt.java
public
static
Pattern
importStringToPattern
(
String
s
,
Processor
p
,
Log
log
)
{
public
static
Pattern
validImportStringToPattern
(
String
s
)
{
if
(
s
.
equals
(
"*"
))
{
return
allMatches
;
}
else
{
String
t
=
s
;
boolean
star
=
false
;
/*
* Validate string from factory is legal. If the string
* has more than one asterisks or the asterisks does not
* appear as the last character (preceded by a period),
* the string is not legal.
*/
boolean
valid
=
true
;
int
index
=
t
.
indexOf
(
'*'
);
if
(
index
!=
-
1
)
{
// '*' must be last character...
if
(
index
==
t
.
length
()
-
1
)
{
// ... and preceeding character must be '.'
if
(
index
-
1
>=
0
)
{
valid
=
t
.
charAt
(
index
-
1
)
==
'.'
;
// Strip off ".*$" for identifier checks
t
=
t
.
substring
(
0
,
t
.
length
()-
2
);
}
}
else
valid
=
false
;
}
// Verify string is off the form (javaId \.)+ or javaId
if
(
valid
)
{
String
[]
javaIds
=
t
.
split
(
"\\."
,
t
.
length
()+
2
);
for
(
String
javaId:
javaIds
)
valid
&=
SourceVersion
.
isIdentifier
(
javaId
);
}
if
(!
valid
)
{
log
.
warning
(
"proc.malformed.supported.string"
,
s
,
p
.
getClass
().
getName
());
return
noMatches
;
// won't match any valid identifier
}
String
s_prime
=
s
.
replaceAll
(
"\\."
,
"\\\\."
);
String
s_prime
=
s
.
replace
(
"."
,
"\\."
);
if
(
s_prime
.
endsWith
(
"*"
))
{
s_prime
=
s_prime
.
substring
(
0
,
s_prime
.
length
()
-
1
)
+
".+"
;
...
...
src/share/classes/com/sun/tools/javadoc/DocletInvoker.java
浏览文件 @
2cc0addc
...
...
@@ -81,7 +81,7 @@ public class DocletInvoker {
cpString
=
appendPath
(
System
.
getProperty
(
"env.class.path"
),
cpString
);
cpString
=
appendPath
(
System
.
getProperty
(
"java.class.path"
),
cpString
);
cpString
=
appendPath
(
docletPath
,
cpString
);
URL
[]
urls
=
pathToURLs
(
cpString
);
URL
[]
urls
=
com
.
sun
.
tools
.
javac
.
file
.
Paths
.
pathToURLs
(
cpString
);
if
(
docletParentClassLoader
==
null
)
appClassLoader
=
new
URLClassLoader
(
urls
,
getDelegationClassLoader
(
docletClassName
));
else
...
...
@@ -313,58 +313,4 @@ public class DocletInvoker {
Thread
.
currentThread
().
setContextClassLoader
(
savedCCL
);
}
}
/**
* Utility method for converting a search path string to an array
* of directory and JAR file URLs.
*
* @param path the search path string
* @return the resulting array of directory and JAR file URLs
*/
static
URL
[]
pathToURLs
(
String
path
)
{
StringTokenizer
st
=
new
StringTokenizer
(
path
,
File
.
pathSeparator
);
URL
[]
urls
=
new
URL
[
st
.
countTokens
()];
int
count
=
0
;
while
(
st
.
hasMoreTokens
())
{
URL
url
=
fileToURL
(
new
File
(
st
.
nextToken
()));
if
(
url
!=
null
)
{
urls
[
count
++]
=
url
;
}
}
if
(
urls
.
length
!=
count
)
{
URL
[]
tmp
=
new
URL
[
count
];
System
.
arraycopy
(
urls
,
0
,
tmp
,
0
,
count
);
urls
=
tmp
;
}
return
urls
;
}
/**
* Returns the directory or JAR file URL corresponding to the specified
* local file name.
*
* @param file the File object
* @return the resulting directory or JAR file URL, or null if unknown
*/
static
URL
fileToURL
(
File
file
)
{
String
name
;
try
{
name
=
file
.
getCanonicalPath
();
}
catch
(
IOException
e
)
{
name
=
file
.
getAbsolutePath
();
}
name
=
name
.
replace
(
File
.
separatorChar
,
'/'
);
if
(!
name
.
startsWith
(
"/"
))
{
name
=
"/"
+
name
;
}
// If the file does not exist, then assume that it's a directory
if
(!
file
.
isFile
())
{
name
=
name
+
"/"
;
}
try
{
return
new
URL
(
"file"
,
""
,
name
);
}
catch
(
MalformedURLException
e
)
{
throw
new
IllegalArgumentException
(
"file"
);
}
}
}
test/tools/javac/6341866/Anno.java
浏览文件 @
2cc0addc
...
...
@@ -27,7 +27,6 @@ import javax.lang.model.*;
import
javax.lang.model.element.*
;
@SupportedAnnotationTypes
(
"*"
)
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_7
)
public
class
Anno
extends
AbstractProcessor
{
public
boolean
process
(
Set
<?
extends
TypeElement
>
annotations
,
RoundEnvironment
roundEnv
)
{
...
...
@@ -35,4 +34,9 @@ public class Anno extends AbstractProcessor {
// System.err.println("annotation processing");
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
}
test/tools/javac/EarlyAssert.java
浏览文件 @
2cc0addc
...
...
@@ -27,6 +27,8 @@
* @summary Verify that assertions are enabled before the class is initialized
* and not thereafter
* @author gafter
* @build EarlyAssert EarlyAssertWrapper
* @run main EarlyAssertWrapper
*/
/*
...
...
test/tools/javac/EarlyAssertWrapper.java
0 → 100644
浏览文件 @
2cc0addc
/*
* Copyright 2010 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.
*/
import
java.io.*
;
import
java.util.*
;
/*
* Wrapper for the EarlyAssert test to run the test in a JVM without assertions
* enabled.
*/
public
class
EarlyAssertWrapper
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
EarlyAssertWrapper
w
=
new
EarlyAssertWrapper
();
w
.
run
();
}
void
run
()
throws
Exception
{
List
<
String
>
cmd
=
new
ArrayList
<
String
>();
File
java_home
=
new
File
(
System
.
getProperty
(
"java.home"
));
if
(
java_home
.
getName
().
equals
(
"jre"
))
java_home
=
java_home
.
getParentFile
();
cmd
.
add
(
new
File
(
new
File
(
java_home
,
"bin"
),
"java"
).
getPath
());
// ensure we run with the same bootclasspath as this test,
// in case this test is being run with -Xbootclasspath
cmd
.
add
(
"-Xbootclasspath:"
+
System
.
getProperty
(
"sun.boot.class.path"
));
// propogate classpath
cmd
.
add
(
"-classpath"
);
cmd
.
add
(
System
.
getProperty
(
"java.class.path"
));
// ensure all assertions disabled in target VM
cmd
.
add
(
"-da"
);
cmd
.
add
(
"-dsa"
);
cmd
.
add
(
"EarlyAssert"
);
System
.
err
.
println
(
"Running command: "
+
cmd
);
ProcessBuilder
pb
=
new
ProcessBuilder
(
cmd
);
pb
.
redirectErrorStream
(
true
);
Process
p
=
pb
.
start
();
p
.
getOutputStream
().
close
();
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
String
line
;
DataInputStream
in
=
new
DataInputStream
(
p
.
getInputStream
());
try
{
while
((
line
=
in
.
readLine
())
!=
null
)
pw
.
println
(
line
);
}
finally
{
in
.
close
();
}
pw
.
close
();
String
out
=
sw
.
toString
();
int
rc
=
p
.
waitFor
();
if
(
rc
!=
0
||
out
.
length
()
>
0
)
throw
new
Error
(
"failed: rc="
+
rc
+
(
out
.
length
()
>
0
?
": "
+
out
:
""
));
}
}
test/tools/javac/T6403466.java
浏览文件 @
2cc0addc
...
...
@@ -41,7 +41,6 @@ import com.sun.tools.javac.api.JavacTool;
@Wrap
@SupportedAnnotationTypes
(
"Wrap"
)
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
public
class
T6403466
extends
AbstractProcessor
{
static
final
String
testSrcDir
=
System
.
getProperty
(
"test.src"
);
...
...
@@ -73,24 +72,31 @@ public class T6403466 extends AbstractProcessor {
}
public
boolean
process
(
Set
<?
extends
TypeElement
>
annos
,
RoundEnvironment
rEnv
)
{
Filer
filer
=
processingEnv
.
getFiler
();
for
(
TypeElement
anno:
annos
)
{
Set
<?
extends
Element
>
elts
=
rEnv
.
getElementsAnnotatedWith
(
anno
);
System
.
err
.
println
(
"anno: "
+
anno
);
System
.
err
.
println
(
"elts: "
+
elts
);
for
(
TypeElement
te:
ElementFilter
.
typesIn
(
elts
))
{
try
{
Writer
out
=
filer
.
createSourceFile
(
te
.
getSimpleName
()
+
"Wrapper"
).
openWriter
();
out
.
write
(
"class "
+
te
.
getSimpleName
()
+
"Wrapper { }"
);
out
.
close
();
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
if
(!
rEnv
.
processingOver
())
{
Filer
filer
=
processingEnv
.
getFiler
();
for
(
TypeElement
anno:
annos
)
{
Set
<?
extends
Element
>
elts
=
rEnv
.
getElementsAnnotatedWith
(
anno
);
System
.
err
.
println
(
"anno: "
+
anno
);
System
.
err
.
println
(
"elts: "
+
elts
);
for
(
TypeElement
te:
ElementFilter
.
typesIn
(
elts
))
{
try
{
Writer
out
=
filer
.
createSourceFile
(
te
.
getSimpleName
()
+
"Wrapper"
).
openWriter
();
out
.
write
(
"class "
+
te
.
getSimpleName
()
+
"Wrapper { }"
);
out
.
close
();
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
}
}
}
}
}
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
}
@Retention
(
RetentionPolicy
.
SOURCE
)
...
...
test/tools/javac/T6406771.java
浏览文件 @
2cc0addc
...
...
@@ -17,7 +17,7 @@ import com.sun.source.tree.*;
import
com.sun.source.util.*
;
import
com.sun.tools.javac.tree.JCTree
;
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
@SupportedAnnotationTypes
(
"*"
)
public
class
T6406771
extends
AbstractProcessor
{
String
[]
tests
=
{
...
...
@@ -95,4 +95,8 @@ public class T6406771 extends AbstractProcessor {
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
}
test/tools/javac/T6411379.java
浏览文件 @
2cc0addc
...
...
@@ -37,7 +37,6 @@ import com.sun.source.tree.*;
import
com.sun.source.util.*
;
@SupportedAnnotationTypes
(
"*"
)
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
public
class
T6411379
extends
AbstractProcessor
{
public
boolean
process
(
Set
<?
extends
TypeElement
>
annoElems
,
...
...
@@ -58,6 +57,11 @@ public class T6411379 extends AbstractProcessor {
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
public
void
checkNull
(
Object
o
)
{
if
(
o
!=
null
)
throw
new
AssertionError
(
"expected null"
);
...
...
test/tools/javac/T6423583.java
浏览文件 @
2cc0addc
...
...
@@ -37,7 +37,6 @@ import com.sun.source.tree.*;
import
com.sun.source.util.*
;
@SupportedAnnotationTypes
(
"*"
)
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
public
class
T6423583
extends
AbstractProcessor
{
boolean
b1
=
true
;
boolean
b2
=
false
;
...
...
@@ -59,6 +58,10 @@ public class T6423583 extends AbstractProcessor {
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
private
static
class
Test
extends
TreeScanner
<
Void
,
Void
>
{
...
...
test/tools/javac/T6855236.java
浏览文件 @
2cc0addc
...
...
@@ -38,7 +38,6 @@ import javax.lang.model.element.*;
import
com.sun.source.tree.*
;
import
com.sun.source.util.*
;
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
@SupportedAnnotationTypes
(
"*"
)
public
class
T6855236
extends
AbstractProcessor
{
...
...
@@ -63,6 +62,11 @@ public class T6855236 extends AbstractProcessor {
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
class
CodeVisitor
extends
TreePathScanner
<
Object
,
Trees
>
{
@Override
...
...
test/tools/javac/api/6421111/T6421111.java
浏览文件 @
2cc0addc
...
...
@@ -76,7 +76,6 @@ public class T6421111 extends ToolTester {
throw
new
AssertionError
(
"Annotation processor failed"
);
}
@SupportedAnnotationTypes
(
"*"
)
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
static
class
MyProcessor
extends
AbstractProcessor
{
void
test
(
TypeElement
element
,
boolean
fbound
)
{
TypeParameterElement
tpe
=
element
.
getTypeParameters
().
iterator
().
next
();
...
...
@@ -96,6 +95,10 @@ public class T6421111 extends ToolTester {
test
(
processingEnv
.
getElementUtils
().
getTypeElement
(
"Test2"
),
true
);
return
false
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
}
public
static
void
main
(
String
...
args
)
{
new
T6421111
().
test
(
args
);
...
...
test/tools/javac/api/6468404/T6468404.java
浏览文件 @
2cc0addc
...
...
@@ -105,7 +105,6 @@ class DummyFO extends SimpleJavaFileObject {
}
@SupportedAnnotationTypes
(
"*"
)
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
class
P
extends
AbstractProcessor
{
boolean
ran
=
false
;
...
...
@@ -145,4 +144,9 @@ class P extends AbstractProcessor {
}
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
}
test/tools/javac/api/T6412669.java
浏览文件 @
2cc0addc
...
...
@@ -38,7 +38,6 @@ import com.sun.source.util.*;
import
com.sun.tools.javac.api.*
;
@SupportedAnnotationTypes
(
"*"
)
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
public
class
T6412669
extends
AbstractProcessor
{
public
static
void
main
(
String
...
args
)
throws
IOException
{
String
testSrc
=
System
.
getProperty
(
"test.src"
,
"."
);
...
...
@@ -72,4 +71,9 @@ public class T6412669 extends AbstractProcessor {
}
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
}
test/tools/javac/enum/6424358/T6424358.java
浏览文件 @
2cc0addc
...
...
@@ -34,13 +34,12 @@ import java.util.Set;
import
javax.annotation.processing.*
;
import
javax.lang.model.element.*
;
import
javax.lang.model.util.*
;
import
javax.lang.model.SourceVersion
;
import
static
javax
.
tools
.
Diagnostic
.
Kind
.*;
import
static
javax
.
lang
.
model
.
SourceVersion
.
RELEASE_6
;
@interface
TestMe
{}
@SupportedAnnotationTypes
(
"*"
)
@SupportedSourceVersion
(
RELEASE_6
)
public
class
T6424358
extends
AbstractProcessor
{
@TestMe
enum
Test
{
FOO
;
}
...
...
@@ -66,4 +65,9 @@ public class T6424358 extends AbstractProcessor {
scan
.
scan
(
e
);
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
}
test/tools/javac/processing/6348499/A.java
浏览文件 @
2cc0addc
...
...
@@ -28,7 +28,6 @@ import javax.lang.model.*;
import
javax.lang.model.element.*
;
@SupportedAnnotationTypes
(
"*"
)
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_7
)
public
class
A
extends
AbstractProcessor
{
public
boolean
process
(
Set
<?
extends
TypeElement
>
tes
,
RoundEnvironment
renv
)
{
Filer
filer
=
processingEnv
.
getFiler
();
...
...
@@ -40,4 +39,8 @@ public class A extends AbstractProcessor {
}
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
}
test/tools/javac/processing/6414633/A.java
浏览文件 @
2cc0addc
...
...
@@ -30,7 +30,6 @@ import javax.lang.model.element.*;
import
javax.tools.*
;
@SupportedAnnotationTypes
(
"*"
)
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_7
)
public
class
A
extends
AbstractProcessor
{
public
boolean
process
(
Set
<?
extends
TypeElement
>
annotations
,
RoundEnvironment
roundEnv
)
{
...
...
@@ -42,4 +41,9 @@ public class A extends AbstractProcessor {
}
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
}
test/tools/javac/processing/6430209/T6430209.java
浏览文件 @
2cc0addc
...
...
@@ -63,7 +63,6 @@ public class T6430209 {
new
File
(
testSrc
,
"test0.java"
),
new
File
(
testSrc
,
"test1.java"
)));
Iterable
<
String
>
opts
=
Arrays
.
asList
(
"-proc:only"
,
"-processor"
,
"b6341534"
,
"-source"
,
"1.6"
,
"-processorpath"
,
testClasses
);
StringWriter
out
=
new
StringWriter
();
JavacTask
task
=
tool
.
getTask
(
out
,
fm
,
dl
,
opts
,
null
,
files
);
...
...
test/tools/javac/processing/6430209/b6341534.java
浏览文件 @
2cc0addc
...
...
@@ -22,6 +22,7 @@
*/
import
javax.annotation.processing.*
;
import
javax.lang.model.SourceVersion
;
import
javax.lang.model.element.*
;
import
javax.lang.model.util.*
;
import
static
javax
.
lang
.
model
.
util
.
ElementFilter
.*;
...
...
@@ -30,7 +31,6 @@ import java.util.*;
import
java.util.Set
;
@SupportedAnnotationTypes
({
"*"
})
@SupportedSourceVersion
(
javax
.
lang
.
model
.
SourceVersion
.
RELEASE_7
)
public
class
b6341534
extends
AbstractProcessor
{
static
int
r
=
0
;
static
Elements
E
=
null
;
...
...
@@ -62,4 +62,9 @@ public class b6341534 extends AbstractProcessor {
if
(
renv
.
errorRaised
()
)
{
msgr
.
printMessage
(
ERROR
,
"FAILED"
);}
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
}
test/tools/javac/processing/6634138/Dummy.java
0 → 100644
浏览文件 @
2cc0addc
/*
* Copyright 2010 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.
*/
/**
* A dummy class to be compiled.
*/
public
class
Dummy
{}
test/tools/javac/processing/6634138/ExerciseDependency.java
0 → 100644
浏览文件 @
2cc0addc
/*
* Copyright 2010 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.
*/
/**
* Class to exercise dependencies on the two source files generated by
* T6634138.java, foo.WrittenAfterProcessing.java and
* foo.package-info.java.
*/
public
class
ExerciseDependency
{
public
static
void
main
(
String
...
args
)
{
foo
.
WrittenAfterProcessing
wap
=
new
foo
.
WrittenAfterProcessing
();
java
.
lang
.
Package
pkg
=
wap
.
getClass
().
getPackage
();
Deprecated
d
=
pkg
.
getAnnotation
(
Deprecated
.
class
);
if
(
d
==
null
)
throw
new
RuntimeException
();
}
}
test/tools/javac/processing/6634138/T6634138.java
0 → 100644
浏览文件 @
2cc0addc
/*
* Copyright 2010 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
* @bug 6634138
* @author Joseph D. Darcy
* @summary Verify source files output after processing is over are compiled
* @compile T6634138.java
* @compile -processor T6634138 Dummy.java
* @run main ExerciseDependency
*/
import
java.lang.annotation.Annotation
;
import
java.io.*
;
import
java.util.Collections
;
import
java.util.Set
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
javax.annotation.processing.*
;
import
javax.lang.model.SourceVersion
;
import
javax.lang.model.element.*
;
import
javax.lang.model.util.*
;
@SupportedAnnotationTypes
(
"*"
)
public
class
T6634138
extends
AbstractProcessor
{
private
Filer
filer
;
public
boolean
process
(
Set
<?
extends
TypeElement
>
annotations
,
RoundEnvironment
roundEnvironment
)
{
// Write out files *after* processing is over.
if
(
roundEnvironment
.
processingOver
())
{
System
.
out
.
println
(
"Writing out source files."
);
try
{
PrintWriter
pw
=
new
PrintWriter
(
filer
.
createSourceFile
(
"foo.WrittenAfterProcessing"
).
openWriter
());
try
{
pw
.
println
(
"package foo;"
);
pw
.
println
(
"public class WrittenAfterProcessing {"
);
pw
.
println
(
" public WrittenAfterProcessing() {super();}"
);
pw
.
println
(
"}"
);
}
finally
{
pw
.
close
();
}
pw
=
new
PrintWriter
(
filer
.
createSourceFile
(
"foo.package-info"
).
openWriter
());
try
{
pw
.
println
(
"@Deprecated"
);
pw
.
println
(
"package foo;"
);
}
finally
{
pw
.
close
();
}
}
catch
(
IOException
io
)
{
throw
new
RuntimeException
(
io
);
}
}
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
public
void
init
(
ProcessingEnvironment
processingEnv
)
{
super
.
init
(
processingEnv
);
filer
=
processingEnv
.
getFiler
();
}
}
test/tools/javac/processing/T6439826.java
浏览文件 @
2cc0addc
...
...
@@ -39,7 +39,6 @@ import static javax.lang.model.util.ElementFilter.*;
@SupportedAnnotationTypes
(
"*"
)
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_7
)
public
class
T6439826
extends
AbstractProcessor
{
public
static
void
main
(
String
...
args
)
{
String
testSrc
=
System
.
getProperty
(
"test.src"
,
"."
);
...
...
@@ -76,6 +75,11 @@ public class T6439826 extends AbstractProcessor {
return
false
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
private
void
writeBadFile
()
{
Filer
filer
=
processingEnv
.
getFiler
();
Messager
messager
=
processingEnv
.
getMessager
();
...
...
test/tools/javac/processing/model/element/TypeParamBounds.java
浏览文件 @
2cc0addc
...
...
@@ -40,7 +40,6 @@ import javax.lang.model.element.*;
import
javax.lang.model.type.*
;
import
javax.lang.model.util.*
;
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
@SupportedAnnotationTypes
(
"*"
)
public
class
TypeParamBounds
extends
AbstractProcessor
{
...
...
@@ -60,6 +59,11 @@ public class TypeParamBounds extends AbstractProcessor {
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
private
void
doit
(
Set
<?
extends
TypeElement
>
annoTypes
,
RoundEnvironment
round
)
{
TypeElement
gen
=
elements
.
getTypeElement
(
"TypeParamBounds.Gen"
);
...
...
test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java
浏览文件 @
2cc0addc
...
...
@@ -38,7 +38,6 @@ import javax.lang.model.type.*;
import
javax.lang.model.util.*
;
import
static
javax
.
lang
.
model
.
util
.
ElementFilter
.*;
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
@SupportedAnnotationTypes
(
"IAm"
)
@IAm
(
OverEager
.
class
)
public
class
OverEager
extends
AbstractProcessor
{
...
...
@@ -59,6 +58,11 @@ public class OverEager extends AbstractProcessor {
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
private
void
doit
(
Set
<?
extends
TypeElement
>
annoTypes
,
RoundEnvironment
round
)
{
for
(
TypeElement
t
:
typesIn
(
round
.
getRootElements
()))
{
...
...
test/tools/javac/processing/model/type/NoTypes.java
浏览文件 @
2cc0addc
...
...
@@ -39,8 +39,6 @@ import javax.lang.model.util.*;
import
static
javax
.
lang
.
model
.
type
.
TypeKind
.*;
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
@SupportedAnnotationTypes
(
"*"
)
public
class
NoTypes
extends
AbstractProcessor
{
...
...
@@ -60,6 +58,11 @@ public class NoTypes extends AbstractProcessor {
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
private
void
doit
(
Set
<?
extends
TypeElement
>
annoTypes
,
RoundEnvironment
round
)
{
...
...
test/tools/javac/processing/model/util/GetTypeElemBadArg.java
浏览文件 @
2cc0addc
...
...
@@ -37,7 +37,6 @@ import javax.lang.model.element.*;
import
javax.lang.model.type.*
;
import
javax.lang.model.util.*
;
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
@SupportedAnnotationTypes
(
"*"
)
public
class
GetTypeElemBadArg
extends
AbstractProcessor
{
...
...
@@ -64,6 +63,12 @@ public class GetTypeElemBadArg extends AbstractProcessor {
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
private
static
void
tellAbout
(
TypeElement
t
)
{
System
.
out
.
println
(
t
);
System
.
out
.
println
(
t
.
getClass
());
...
...
test/tools/javac/processing/model/util/OverridesSpecEx.java
浏览文件 @
2cc0addc
...
...
@@ -40,7 +40,6 @@ import javax.lang.model.util.*;
import
static
javax
.
lang
.
model
.
util
.
ElementFilter
.*;
@SupportedSourceVersion
(
SourceVersion
.
RELEASE_6
)
@SupportedAnnotationTypes
(
"*"
)
public
class
OverridesSpecEx
extends
AbstractProcessor
{
...
...
@@ -60,6 +59,11 @@ public class OverridesSpecEx extends AbstractProcessor {
return
true
;
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
}
private
void
doit
(
Set
<?
extends
TypeElement
>
annoTypes
,
RoundEnvironment
round
)
{
TypeElement
string
=
elements
.
getTypeElement
(
"java.lang.String"
);
...
...
test/tools/javac/treepostests/TreePosTest.java
浏览文件 @
2cc0addc
...
...
@@ -98,7 +98,7 @@ import static com.sun.tools.javac.util.Position.NOPOS;
* @test
* @bug 6919889
* @summary assorted position errors in compiler syntax trees
* @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations .
* @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations
-et ANNOTATED_TYPE
.
*/
public
class
TreePosTest
{
/**
...
...
@@ -150,6 +150,8 @@ public class TreePosTest {
tags
.
add
(
args
[++
i
]);
else
if
(
arg
.
equals
(
"-ef"
)
&&
i
+
1
<
args
.
length
)
excludeFiles
.
add
(
new
File
(
baseDir
,
args
[++
i
]));
else
if
(
arg
.
equals
(
"-et"
)
&&
i
+
1
<
args
.
length
)
excludeTags
.
add
(
args
[++
i
]);
else
if
(
arg
.
equals
(
"-r"
))
{
if
(
excludeFiles
.
size
()
>
0
)
throw
new
Error
(
"-r must be used before -ef"
);
...
...
@@ -199,6 +201,7 @@ public class TreePosTest {
out
.
println
(
"-t tag Limit checks to tree nodes with this tag"
);
out
.
println
(
" Can be repeated if desired"
);
out
.
println
(
"-ef file Exclude file or directory"
);
out
.
println
(
"-et tag Exclude tree nodes with given tag name"
);
out
.
println
(
""
);
out
.
println
(
"files may be directories or files"
);
out
.
println
(
"directories will be scanned recursively"
);
...
...
@@ -304,6 +307,8 @@ public class TreePosTest {
Set
<
String
>
tags
=
new
HashSet
<
String
>();
/** Set of files and directories to be excluded from analysis. */
Set
<
File
>
excludeFiles
=
new
HashSet
<
File
>();
/** Set of tag names to be excluded from analysis. */
Set
<
String
>
excludeTags
=
new
HashSet
<
String
>();
/** Table of printable names for tree tag values. */
TagNames
tagNames
=
new
TagNames
();
...
...
@@ -324,7 +329,7 @@ public class TreePosTest {
return
;
Info
self
=
new
Info
(
tree
,
endPosTable
);
if
(
check
(
self
))
{
if
(
check
(
encl
,
self
))
{
// Modifiers nodes are present throughout the tree even where
// there is no corresponding source text.
// Redundant semicolons in a class definition can cause empty
...
...
@@ -392,8 +397,13 @@ public class TreePosTest {
super
.
visitVarDef
(
tree
);
}
boolean
check
(
Info
x
)
{
return
tags
.
size
()
==
0
||
tags
.
contains
(
tagNames
.
get
(
x
.
tag
));
boolean
check
(
Info
encl
,
Info
self
)
{
if
(
excludeTags
.
size
()
>
0
)
{
if
(
encl
!=
null
&&
excludeTags
.
contains
(
tagNames
.
get
(
encl
.
tag
))
||
excludeTags
.
contains
(
tagNames
.
get
(
self
.
tag
)))
return
false
;
}
return
tags
.
size
()
==
0
||
tags
.
contains
(
tagNames
.
get
(
self
.
tag
));
}
void
check
(
String
label
,
Info
encl
,
Info
self
,
boolean
ok
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录