From 80cc4706a6f14e802665c2163fced9e738680920 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Wed, 31 Oct 2012 16:20:03 -0700 Subject: [PATCH 01/94] 7194607: VerifyLocalVariableTableOnRetransformTest.sh fails after JSR-292 merge Use verifier_max_size instead of max_size to get code attribute max stack size. Reviewed-by: dcubed, minqi --- hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp index 01beff1b4bb..11281c61946 100644 --- a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp +++ b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp @@ -228,7 +228,7 @@ void JvmtiClassFileReconstituter::write_code_attribute(methodHandle method) { write_attribute_name_index("Code"); write_u4(size); - write_u2(method->max_stack()); + write_u2(method->verifier_max_stack()); write_u2(method->max_locals()); write_u4(code_size); copy_bytecodes(method, (unsigned char*)writeable_address(code_size)); From dd5c8eb66043afa9e6670c89d7617f8ab521fc23 Mon Sep 17 00:00:00 2001 From: Bill Pittore Date: Wed, 7 Nov 2012 17:53:02 -0500 Subject: [PATCH 02/94] 8001185: parsing of sun.boot.library.path in os::dll_build_name somewhat broken Dll_dir can contain multiple paths, need to parse them correctly when loading agents Reviewed-by: dholmes, dlong --- hotspot/src/os/bsd/vm/os_bsd.cpp | 12 +++++++---- hotspot/src/os/linux/vm/os_linux.cpp | 12 +++++++---- hotspot/src/os/solaris/vm/os_solaris.cpp | 12 +++++++---- hotspot/src/os/windows/vm/os_windows.cpp | 13 ++++++++---- .../src/share/vm/classfile/classLoader.cpp | 6 ++++-- hotspot/src/share/vm/prims/jvmtiExport.cpp | 13 +++++++----- hotspot/src/share/vm/runtime/os.cpp | 20 ++++++++++++------- hotspot/src/share/vm/runtime/os.hpp | 3 ++- hotspot/src/share/vm/runtime/thread.cpp | 11 ++++++---- 9 files changed, 67 insertions(+), 35 deletions(-) diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 9a845fc9ec8..83b8b19f93f 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -1198,19 +1198,20 @@ static bool file_exists(const char* filename) { return os::stat(filename, &statbuf) == 0; } -void os::dll_build_name(char* buffer, size_t buflen, +bool os::dll_build_name(char* buffer, size_t buflen, const char* pname, const char* fname) { + bool retval = false; // Copied from libhpi const size_t pnamelen = pname ? strlen(pname) : 0; - // Quietly truncate on buffer overflow. Should be an error. + // Return error on buffer overflow. if (pnamelen + strlen(fname) + strlen(JNI_LIB_PREFIX) + strlen(JNI_LIB_SUFFIX) + 2 > buflen) { - *buffer = '\0'; - return; + return retval; } if (pnamelen == 0) { snprintf(buffer, buflen, JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, fname); + retval = true; } else if (strchr(pname, *os::path_separator()) != NULL) { int n; char** pelements = split_path(pname, &n); @@ -1222,6 +1223,7 @@ void os::dll_build_name(char* buffer, size_t buflen, snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, pelements[i], fname); if (file_exists(buffer)) { + retval = true; break; } } @@ -1236,7 +1238,9 @@ void os::dll_build_name(char* buffer, size_t buflen, } } else { snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, pname, fname); + retval = true; } + return retval; } const char* os::get_current_directory(char *buf, int buflen) { diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index d2f92f8f51b..cbb48d5b17d 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -1650,19 +1650,20 @@ static bool file_exists(const char* filename) { return os::stat(filename, &statbuf) == 0; } -void os::dll_build_name(char* buffer, size_t buflen, +bool os::dll_build_name(char* buffer, size_t buflen, const char* pname, const char* fname) { + bool retval = false; // Copied from libhpi const size_t pnamelen = pname ? strlen(pname) : 0; - // Quietly truncate on buffer overflow. Should be an error. + // Return error on buffer overflow. if (pnamelen + strlen(fname) + 10 > (size_t) buflen) { - *buffer = '\0'; - return; + return retval; } if (pnamelen == 0) { snprintf(buffer, buflen, "lib%s.so", fname); + retval = true; } else if (strchr(pname, *os::path_separator()) != NULL) { int n; char** pelements = split_path(pname, &n); @@ -1673,6 +1674,7 @@ void os::dll_build_name(char* buffer, size_t buflen, } snprintf(buffer, buflen, "%s/lib%s.so", pelements[i], fname); if (file_exists(buffer)) { + retval = true; break; } } @@ -1687,7 +1689,9 @@ void os::dll_build_name(char* buffer, size_t buflen, } } else { snprintf(buffer, buflen, "%s/lib%s.so", pname, fname); + retval = true; } + return retval; } const char* os::get_current_directory(char *buf, int buflen) { diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index e3415b8d802..dfa4ef1bf4d 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -1894,18 +1894,19 @@ static bool file_exists(const char* filename) { return os::stat(filename, &statbuf) == 0; } -void os::dll_build_name(char* buffer, size_t buflen, +bool os::dll_build_name(char* buffer, size_t buflen, const char* pname, const char* fname) { + bool retval = false; const size_t pnamelen = pname ? strlen(pname) : 0; - // Quietly truncate on buffer overflow. Should be an error. + // Return error on buffer overflow. if (pnamelen + strlen(fname) + 10 > (size_t) buflen) { - *buffer = '\0'; - return; + return retval; } if (pnamelen == 0) { snprintf(buffer, buflen, "lib%s.so", fname); + retval = true; } else if (strchr(pname, *os::path_separator()) != NULL) { int n; char** pelements = split_path(pname, &n); @@ -1916,6 +1917,7 @@ void os::dll_build_name(char* buffer, size_t buflen, } snprintf(buffer, buflen, "%s/lib%s.so", pelements[i], fname); if (file_exists(buffer)) { + retval = true; break; } } @@ -1930,7 +1932,9 @@ void os::dll_build_name(char* buffer, size_t buflen, } } else { snprintf(buffer, buflen, "%s/lib%s.so", pname, fname); + retval = true; } + return retval; } const char* os::get_current_directory(char *buf, int buflen) { diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 420368f1010..e2c36ee1252 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -1132,21 +1132,23 @@ static bool file_exists(const char* filename) { return GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES; } -void os::dll_build_name(char *buffer, size_t buflen, +bool os::dll_build_name(char *buffer, size_t buflen, const char* pname, const char* fname) { + bool retval = false; const size_t pnamelen = pname ? strlen(pname) : 0; const char c = (pnamelen > 0) ? pname[pnamelen-1] : 0; - // Quietly truncates on buffer overflow. Should be an error. + // Return error on buffer overflow. if (pnamelen + strlen(fname) + 10 > buflen) { - *buffer = '\0'; - return; + return retval; } if (pnamelen == 0) { jio_snprintf(buffer, buflen, "%s.dll", fname); + retval = true; } else if (c == ':' || c == '\\') { jio_snprintf(buffer, buflen, "%s%s.dll", pname, fname); + retval = true; } else if (strchr(pname, *os::path_separator()) != NULL) { int n; char** pelements = split_path(pname, &n); @@ -1164,6 +1166,7 @@ void os::dll_build_name(char *buffer, size_t buflen, jio_snprintf(buffer, buflen, "%s\\%s.dll", path, fname); } if (file_exists(buffer)) { + retval = true; break; } } @@ -1178,7 +1181,9 @@ void os::dll_build_name(char *buffer, size_t buflen, } } else { jio_snprintf(buffer, buflen, "%s\\%s.dll", pname, fname); + retval = true; } + return retval; } // Needs to be in os specific directory because windows requires another diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 057b177282c..b5e858a3372 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -605,8 +605,10 @@ void ClassLoader::load_zip_library() { // Load zip library char path[JVM_MAXPATHLEN]; char ebuf[1024]; - os::dll_build_name(path, sizeof(path), Arguments::get_dll_dir(), "zip"); - void* handle = os::dll_load(path, ebuf, sizeof ebuf); + void* handle = NULL; + if (os::dll_build_name(path, sizeof(path), Arguments::get_dll_dir(), "zip")) { + handle = os::dll_load(path, ebuf, sizeof ebuf); + } if (handle == NULL) { vm_exit_during_initialization("Unable to load ZIP library", path); } diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp index 40e8e21159f..63cab9c7dde 100644 --- a/hotspot/src/share/vm/prims/jvmtiExport.cpp +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp @@ -2177,7 +2177,7 @@ extern "C" { jint JvmtiExport::load_agent_library(AttachOperation* op, outputStream* st) { char ebuf[1024]; char buffer[JVM_MAXPATHLEN]; - void* library; + void* library = NULL; jint result = JNI_ERR; // get agent name and options @@ -2196,13 +2196,16 @@ jint JvmtiExport::load_agent_library(AttachOperation* op, outputStream* st) { library = os::dll_load(agent, ebuf, sizeof ebuf); } else { // Try to load the agent from the standard dll directory - os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), agent); - library = os::dll_load(buffer, ebuf, sizeof ebuf); + if (os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), + agent)) { + library = os::dll_load(buffer, ebuf, sizeof ebuf); + } if (library == NULL) { // not found - try local path char ns[1] = {0}; - os::dll_build_name(buffer, sizeof(buffer), ns, agent); - library = os::dll_load(buffer, ebuf, sizeof ebuf); + if (os::dll_build_name(buffer, sizeof(buffer), ns, agent)) { + library = os::dll_load(buffer, ebuf, sizeof ebuf); + } } } diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index 56bd8261322..93041c0aa6b 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -397,12 +397,16 @@ void* os::native_java_library() { // Try to load verify dll first. In 1.3 java dll depends on it and is not // always able to find it when the loading executable is outside the JDK. // In order to keep working with 1.2 we ignore any loading errors. - dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify"); - dll_load(buffer, ebuf, sizeof(ebuf)); + if (dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), + "verify")) { + dll_load(buffer, ebuf, sizeof(ebuf)); + } // Load java dll - dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "java"); - _native_java_library = dll_load(buffer, ebuf, sizeof(ebuf)); + if (dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), + "java")) { + _native_java_library = dll_load(buffer, ebuf, sizeof(ebuf)); + } if (_native_java_library == NULL) { vm_exit_during_initialization("Unable to load native library", ebuf); } @@ -410,8 +414,10 @@ void* os::native_java_library() { #if defined(__OpenBSD__) // Work-around OpenBSD's lack of $ORIGIN support by pre-loading libnet.so // ignore errors - dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "net"); - dll_load(buffer, ebuf, sizeof(ebuf)); + if (dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), + "net")) { + dll_load(buffer, ebuf, sizeof(ebuf)); + } #endif } static jboolean onLoaded = JNI_FALSE; @@ -1156,7 +1162,7 @@ char** os::split_path(const char* path, int* n) { if (inpath == NULL) { return NULL; } - strncpy(inpath, path, strlen(path)); + strcpy(inpath, path); int count = 1; char* p = strchr(inpath, psepchar); // Get a count of elements to allocate memory diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index bb5d6ea9e28..ad43ddf83f0 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -479,7 +479,8 @@ class os: AllStatic { static const char* get_current_directory(char *buf, int buflen); // Builds a platform-specific full library path given a ld path and lib name - static void dll_build_name(char* buffer, size_t size, + // Returns true if buffer contains full path to existing file, false otherwise + static bool dll_build_name(char* buffer, size_t size, const char* pathname, const char* fname); // Symbol lookup, find nearest function name; basically it implements diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 615ca40ab6e..01578d69f7e 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -3706,8 +3706,10 @@ static OnLoadEntry_t lookup_on_load(AgentLibrary* agent, const char *on_load_sym } } else { // Try to load the agent from the standard dll directory - os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), name); - library = os::dll_load(buffer, ebuf, sizeof ebuf); + if (os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), + name)) { + library = os::dll_load(buffer, ebuf, sizeof ebuf); + } #ifdef KERNEL // Download instrument dll if (library == NULL && strcmp(name, "instrument") == 0) { @@ -3732,8 +3734,9 @@ static OnLoadEntry_t lookup_on_load(AgentLibrary* agent, const char *on_load_sym #endif // KERNEL if (library == NULL) { // Try the local directory char ns[1] = {0}; - os::dll_build_name(buffer, sizeof(buffer), ns, name); - library = os::dll_load(buffer, ebuf, sizeof ebuf); + if (os::dll_build_name(buffer, sizeof(buffer), ns, name)) { + library = os::dll_load(buffer, ebuf, sizeof ebuf); + } if (library == NULL) { const char *sub_msg = " on the library path, with error: "; size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; From 14d669246197248398a2004c84e75abd2f2ff670 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Fri, 9 Nov 2012 00:38:31 +0100 Subject: [PATCH 03/94] 7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java Reduce the amount of calls to ChunkManager verification code Reviewed-by: jmasa, coleenp --- hotspot/src/share/vm/memory/metaspace.cpp | 65 +++++++++++++++-------- hotspot/src/share/vm/memory/metaspace.hpp | 1 + hotspot/src/share/vm/memory/universe.cpp | 2 + 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp index fc2609f2a99..7245e4f28f4 100644 --- a/hotspot/src/share/vm/memory/metaspace.cpp +++ b/hotspot/src/share/vm/memory/metaspace.cpp @@ -42,6 +42,10 @@ typedef BinaryTreeDictionary BlockTreeDictionary; typedef BinaryTreeDictionary ChunkTreeDictionary; +// Define this macro to enable slow integrity checking of +// the free chunk lists +const bool metaspace_slow_verify = false; + // Parameters for stress mode testing const uint metadata_deallocate_a_lot_block = 10; @@ -161,7 +165,17 @@ class ChunkManager VALUE_OBJ_CLASS_SPEC { size_t sum_free_chunks_count(); void locked_verify_free_chunks_total(); + void slow_locked_verify_free_chunks_total() { + if (metaspace_slow_verify) { + locked_verify_free_chunks_total(); + } + } void locked_verify_free_chunks_count(); + void slow_locked_verify_free_chunks_count() { + if (metaspace_slow_verify) { + locked_verify_free_chunks_count(); + } + } void verify_free_chunks_count(); public: @@ -201,7 +215,17 @@ class ChunkManager VALUE_OBJ_CLASS_SPEC { // Debug support void verify(); + void slow_verify() { + if (metaspace_slow_verify) { + verify(); + } + } void locked_verify(); + void slow_locked_verify() { + if (metaspace_slow_verify) { + locked_verify(); + } + } void verify_free_chunks_total(); void locked_print_free_chunks(outputStream* st); @@ -1507,7 +1531,7 @@ size_t ChunkManager::free_chunks_total() { if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) { MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); - locked_verify_free_chunks_total(); + slow_locked_verify_free_chunks_total(); } #endif return _free_chunks_total; @@ -1524,10 +1548,10 @@ size_t ChunkManager::free_chunks_count() { Mutex::_no_safepoint_check_flag); // This lock is only needed in debug because the verification // of the _free_chunks_totals walks the list of free chunks - locked_verify_free_chunks_count(); + slow_locked_verify_free_chunks_count(); } #endif - return _free_chunks_count; + return _free_chunks_count; } void ChunkManager::locked_verify_free_chunks_total() { @@ -1561,14 +1585,9 @@ void ChunkManager::verify_free_chunks_count() { } void ChunkManager::verify() { -#ifdef ASSERT - if (!UseConcMarkSweepGC) { - MutexLockerEx cl(SpaceManager::expand_lock(), - Mutex::_no_safepoint_check_flag); - locked_verify_free_chunks_total(); - locked_verify_free_chunks_count(); - } -#endif + MutexLockerEx cl(SpaceManager::expand_lock(), + Mutex::_no_safepoint_check_flag); + locked_verify(); } void ChunkManager::locked_verify() { @@ -1642,7 +1661,7 @@ void ChunkManager::free_chunks_put(Metachunk* chunk) { free_list->set_head(chunk); // chunk is being returned to the chunk free list inc_free_chunks_total(chunk->capacity_word_size()); - locked_verify(); + slow_locked_verify(); } void ChunkManager::chunk_freelist_deallocate(Metachunk* chunk) { @@ -1650,8 +1669,8 @@ void ChunkManager::chunk_freelist_deallocate(Metachunk* chunk) { // manangement code for a Metaspace and does not hold the // lock. assert(chunk != NULL, "Deallocating NULL"); - // MutexLockerEx fcl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); - locked_verify(); + assert_lock_strong(SpaceManager::expand_lock()); + slow_locked_verify(); if (TraceMetadataChunkAllocation) { tty->print_cr("ChunkManager::chunk_freelist_deallocate: chunk " PTR_FORMAT " size " SIZE_FORMAT, @@ -1663,7 +1682,7 @@ void ChunkManager::chunk_freelist_deallocate(Metachunk* chunk) { Metachunk* ChunkManager::free_chunks_get(size_t word_size) { assert_lock_strong(SpaceManager::expand_lock()); - locked_verify(); + slow_locked_verify(); Metachunk* chunk = NULL; if (!SpaceManager::is_humongous(word_size)) { @@ -1708,13 +1727,13 @@ Metachunk* ChunkManager::free_chunks_get(size_t word_size) { #endif } } - locked_verify(); + slow_locked_verify(); return chunk; } Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) { assert_lock_strong(SpaceManager::expand_lock()); - locked_verify(); + slow_locked_verify(); // Take from the beginning of the list Metachunk* chunk = free_chunks_get(word_size); @@ -1959,7 +1978,7 @@ SpaceManager::~SpaceManager() { ChunkManager* chunk_manager = vs_list()->chunk_manager(); - chunk_manager->locked_verify(); + chunk_manager->slow_locked_verify(); if (TraceMetadataChunkAllocation && Verbose) { gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this); @@ -2015,7 +2034,7 @@ SpaceManager::~SpaceManager() { humongous_chunks = next_humongous_chunks; } set_chunks_in_use(HumongousIndex, NULL); - chunk_manager->locked_verify(); + chunk_manager->slow_locked_verify(); } void SpaceManager::deallocate(MetaWord* p, size_t word_size) { @@ -2330,8 +2349,7 @@ size_t MetaspaceAux::free_chunks_total(Metaspace::MetadataType mdtype) { ChunkManager* chunk = (mdtype == Metaspace::ClassType) ? Metaspace::class_space_list()->chunk_manager() : Metaspace::space_list()->chunk_manager(); - - chunk->verify_free_chunks_total(); + chunk->slow_verify(); return chunk->free_chunks_total(); } @@ -2435,6 +2453,11 @@ void MetaspaceAux::dump(outputStream* out) { print_waste(out); } +void MetaspaceAux::verify_free_chunks() { + Metaspace::space_list()->chunk_manager()->verify(); + Metaspace::class_space_list()->chunk_manager()->verify(); +} + // Metaspace methods size_t Metaspace::_first_chunk_word_size = 0; diff --git a/hotspot/src/share/vm/memory/metaspace.hpp b/hotspot/src/share/vm/memory/metaspace.hpp index c42a979cb1d..743fed13011 100644 --- a/hotspot/src/share/vm/memory/metaspace.hpp +++ b/hotspot/src/share/vm/memory/metaspace.hpp @@ -189,6 +189,7 @@ class MetaspaceAux : AllStatic { static void print_waste(outputStream* out); static void dump(outputStream* out); + static void verify_free_chunks(); }; // Metaspace are deallocated when their class loader are GC'ed. diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 35cc0db712e..759c005c281 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -1304,6 +1304,8 @@ void Universe::verify(bool silent, VerifyOption option) { if (!silent) gclog_or_tty->print("cldg "); ClassLoaderDataGraph::verify(); #endif + if (!silent) gclog_or_tty->print("metaspace chunks "); + MetaspaceAux::verify_free_chunks(); if (!silent) gclog_or_tty->print("hand "); JNIHandles::verify(); if (!silent) gclog_or_tty->print("C-heap "); From 1abc21c31084499ccd20698618af3f7cfcf4704f Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Fri, 9 Nov 2012 11:04:06 -0500 Subject: [PATCH 04/94] 8002273: NMT to report JNI memory leaks when -Xcheck:jni is on Allows NMT to report that JNI thread failed to detach from JVM before exiting, which leaks the JavaThread object when check:jni option is on. Reviewed-by: acorn, dholmes, coleenp, ctornqvi --- hotspot/src/share/vm/services/memSnapshot.cpp | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/services/memSnapshot.cpp b/hotspot/src/share/vm/services/memSnapshot.cpp index 936df1985ac..02659af20f6 100644 --- a/hotspot/src/share/vm/services/memSnapshot.cpp +++ b/hotspot/src/share/vm/services/memSnapshot.cpp @@ -123,20 +123,31 @@ bool VMMemPointerIterator::insert_record_after(MemPointerRecord* rec) { // in different types. bool VMMemPointerIterator::add_reserved_region(MemPointerRecord* rec) { assert(rec->is_allocation_record(), "Sanity check"); - VMMemRegion* cur = (VMMemRegion*)current(); + VMMemRegion* reserved_region = (VMMemRegion*)current(); // we don't have anything yet - if (cur == NULL) { + if (reserved_region == NULL) { return insert_record(rec); } - assert(cur->is_reserved_region(), "Sanity check"); + assert(reserved_region->is_reserved_region(), "Sanity check"); // duplicated records - if (cur->is_same_region(rec)) { + if (reserved_region->is_same_region(rec)) { return true; } - assert(cur->base() > rec->addr(), "Just check: locate()"); - assert(!cur->overlaps_region(rec), "overlapping reserved regions"); + // Overlapping stack regions indicate that a JNI thread failed to + // detach from the VM before exiting. This leaks the JavaThread object. + if (CheckJNICalls) { + guarantee(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) != mtThreadStack || + !reserved_region->overlaps_region(rec), + "Attached JNI thread exited without being detached"); + } + // otherwise, we should not have overlapping reserved regions + assert(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) == mtThreadStack || + reserved_region->base() > rec->addr(), "Just check: locate()"); + assert(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) == mtThreadStack || + !reserved_region->overlaps_region(rec), "overlapping reserved regions"); + return insert_record(rec); } From 8735609a8c27509eb30db8efea4a5bb6513488ac Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Fri, 9 Nov 2012 08:36:17 -0800 Subject: [PATCH 05/94] 8003231: new hotspot build - hs25-b10 Reviewed-by: jcoomes --- hotspot/make/hotspot_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version index 9ad3194b9eb..8556a1f8b87 100644 --- a/hotspot/make/hotspot_version +++ b/hotspot/make/hotspot_version @@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2012 HS_MAJOR_VER=25 HS_MINOR_VER=0 -HS_BUILD_NUMBER=09 +HS_BUILD_NUMBER=10 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 From f47de1cb41bfa76aabbf527090c4c50989d360e8 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Fri, 9 Nov 2012 19:24:31 -0500 Subject: [PATCH 06/94] 8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180 Fixed NMT that miscounted arena memory when it is used as value or stack object. Reviewed-by: acorn, coleenp --- hotspot/src/share/vm/services/memBaseline.cpp | 32 +++-- hotspot/src/share/vm/services/memPtr.hpp | 10 +- hotspot/src/share/vm/services/memSnapshot.cpp | 117 ++++++++---------- hotspot/src/share/vm/services/memSnapshot.hpp | 83 +++++++++---- hotspot/src/share/vm/services/memTracker.hpp | 6 +- 5 files changed, 135 insertions(+), 113 deletions(-) diff --git a/hotspot/src/share/vm/services/memBaseline.cpp b/hotspot/src/share/vm/services/memBaseline.cpp index 57bdb013874..9127e00f981 100644 --- a/hotspot/src/share/vm/services/memBaseline.cpp +++ b/hotspot/src/share/vm/services/memBaseline.cpp @@ -115,17 +115,25 @@ bool MemBaseline::baseline_malloc_summary(const MemPointerArray* malloc_records) while (malloc_ptr != NULL) { index = flag2index(FLAGS_TO_MEMORY_TYPE(malloc_ptr->flags())); size_t size = malloc_ptr->size(); - _total_malloced += size; - _malloc_data[index].inc(size); - if (MemPointerRecord::is_arena_record(malloc_ptr->flags())) { - // see if arena size record present - MemPointerRecord* next_malloc_ptr = (MemPointerRecordEx*)malloc_itr.peek_next(); - if (MemPointerRecord::is_arena_size_record(next_malloc_ptr->flags())) { - assert(next_malloc_ptr->is_size_record_of_arena(malloc_ptr), "arena records do not match"); - size = next_malloc_ptr->size(); - _arena_data[index].inc(size); - used_arena_size += size; - malloc_itr.next(); + if (malloc_ptr->is_arena_memory_record()) { + // We do have anonymous arenas, they are either used as value objects, + // which are embedded inside other objects, or used as stack objects. + _arena_data[index].inc(size); + used_arena_size += size; + } else { + _total_malloced += size; + _malloc_data[index].inc(size); + if (malloc_ptr->is_arena_record()) { + // see if arena memory record present + MemPointerRecord* next_malloc_ptr = (MemPointerRecordEx*)malloc_itr.peek_next(); + if (next_malloc_ptr->is_arena_memory_record()) { + assert(next_malloc_ptr->is_memory_record_of_arena(malloc_ptr), + "Arena records do not match"); + size = next_malloc_ptr->size(); + _arena_data[index].inc(size); + used_arena_size += size; + malloc_itr.next(); + } } } malloc_ptr = (MemPointerRecordEx*)malloc_itr.next(); @@ -193,7 +201,7 @@ bool MemBaseline::baseline_malloc_details(const MemPointerArray* malloc_records) // baseline memory that is totaled over 1 KB while (malloc_ptr != NULL) { - if (!MemPointerRecord::is_arena_size_record(malloc_ptr->flags())) { + if (!MemPointerRecord::is_arena_memory_record(malloc_ptr->flags())) { // skip thread stacks if (!IS_MEMORY_TYPE(malloc_ptr->flags(), mtThreadStack)) { if (malloc_callsite.addr() != malloc_ptr->pc()) { diff --git a/hotspot/src/share/vm/services/memPtr.hpp b/hotspot/src/share/vm/services/memPtr.hpp index 3f888d968a6..a27c3eb4a10 100644 --- a/hotspot/src/share/vm/services/memPtr.hpp +++ b/hotspot/src/share/vm/services/memPtr.hpp @@ -165,7 +165,7 @@ public: return (flags & (otArena | tag_size)) == otArena; } - inline static bool is_arena_size_record(MEMFLAGS flags) { + inline static bool is_arena_memory_record(MEMFLAGS flags) { return (flags & (otArena | tag_size)) == (otArena | tag_size); } @@ -256,8 +256,8 @@ public: } // if this record records a size information of an arena - inline bool is_arena_size_record() const { - return is_arena_size_record(_flags); + inline bool is_arena_memory_record() const { + return is_arena_memory_record(_flags); } // if this pointer represents an address to an arena object @@ -266,8 +266,8 @@ public: } // if this record represents a size information of specific arena - inline bool is_size_record_of_arena(const MemPointerRecord* arena_rc) { - assert(is_arena_size_record(), "not size record"); + inline bool is_memory_record_of_arena(const MemPointerRecord* arena_rc) { + assert(is_arena_memory_record(), "not size record"); assert(arena_rc->is_arena_record(), "not arena record"); return (arena_rc->addr() + sizeof(void*)) == addr(); } diff --git a/hotspot/src/share/vm/services/memSnapshot.cpp b/hotspot/src/share/vm/services/memSnapshot.cpp index 936df1985ac..cd6870c910f 100644 --- a/hotspot/src/share/vm/services/memSnapshot.cpp +++ b/hotspot/src/share/vm/services/memSnapshot.cpp @@ -50,7 +50,7 @@ void decode_pointer_record(MemPointerRecord* rec) { tty->print_cr(" (tag)"); } } else { - if (rec->is_arena_size_record()) { + if (rec->is_arena_memory_record()) { tty->print_cr(" (arena size)"); } else if (rec->is_allocation_record()) { tty->print_cr(" (malloc)"); @@ -390,21 +390,31 @@ MemSnapshot::~MemSnapshot() { } } -void MemSnapshot::copy_pointer(MemPointerRecord* dest, const MemPointerRecord* src) { + +void MemSnapshot::copy_seq_pointer(MemPointerRecord* dest, const MemPointerRecord* src) { assert(dest != NULL && src != NULL, "Just check"); assert(dest->addr() == src->addr(), "Just check"); + assert(dest->seq() > 0 && src->seq() > 0, "not sequenced"); - MEMFLAGS flags = dest->flags(); + if (MemTracker::track_callsite()) { + *(SeqMemPointerRecordEx*)dest = *(SeqMemPointerRecordEx*)src; + } else { + *(SeqMemPointerRecord*)dest = *(SeqMemPointerRecord*)src; + } +} + +void MemSnapshot::assign_pointer(MemPointerRecord*dest, const MemPointerRecord* src) { + assert(src != NULL && dest != NULL, "Just check"); + assert(dest->seq() == 0 && src->seq() >0, "cast away sequence"); if (MemTracker::track_callsite()) { *(MemPointerRecordEx*)dest = *(MemPointerRecordEx*)src; } else { - *dest = *src; + *(MemPointerRecord*)dest = *(MemPointerRecord*)src; } } - -// merge a per-thread memory recorder to the staging area +// merge a recorder to the staging area bool MemSnapshot::merge(MemRecorder* rec) { assert(rec != NULL && !rec->out_of_memory(), "Just check"); @@ -412,71 +422,45 @@ bool MemSnapshot::merge(MemRecorder* rec) { MutexLockerEx lock(_lock, true); MemPointerIterator malloc_staging_itr(_staging_area.malloc_data()); - MemPointerRecord *p1, *p2; - p1 = (MemPointerRecord*) itr.current(); - while (p1 != NULL) { - if (p1->is_vm_pointer()) { + MemPointerRecord* incoming_rec = (MemPointerRecord*) itr.current(); + MemPointerRecord* matched_rec; + + while (incoming_rec != NULL) { + if (incoming_rec->is_vm_pointer()) { // we don't do anything with virtual memory records during merge - if (!_staging_area.vm_data()->append(p1)) { + if (!_staging_area.vm_data()->append(incoming_rec)) { return false; } } else { // locate matched record and/or also position the iterator to proper // location for this incoming record. - p2 = (MemPointerRecord*)malloc_staging_itr.locate(p1->addr()); - // we have not seen this memory block, so just add to staging area - if (p2 == NULL) { - if (!malloc_staging_itr.insert(p1)) { + matched_rec = (MemPointerRecord*)malloc_staging_itr.locate(incoming_rec->addr()); + // we have not seen this memory block in this generation, + // so just add to staging area + if (matched_rec == NULL) { + if (!malloc_staging_itr.insert(incoming_rec)) { return false; } - } else if (p1->addr() == p2->addr()) { - MemPointerRecord* staging_next = (MemPointerRecord*)malloc_staging_itr.peek_next(); - // a memory block can have many tagging records, find right one to replace or - // right position to insert - while (staging_next != NULL && staging_next->addr() == p1->addr()) { - if ((staging_next->flags() & MemPointerRecord::tag_masks) <= - (p1->flags() & MemPointerRecord::tag_masks)) { - p2 = (MemPointerRecord*)malloc_staging_itr.next(); - staging_next = (MemPointerRecord*)malloc_staging_itr.peek_next(); - } else { - break; - } + } else if (incoming_rec->addr() == matched_rec->addr()) { + // whoever has higher sequence number wins + if (incoming_rec->seq() > matched_rec->seq()) { + copy_seq_pointer(matched_rec, incoming_rec); } - int df = (p1->flags() & MemPointerRecord::tag_masks) - - (p2->flags() & MemPointerRecord::tag_masks); - if (df == 0) { - assert(p1->seq() > 0, "not sequenced"); - assert(p2->seq() > 0, "not sequenced"); - if (p1->seq() > p2->seq()) { - copy_pointer(p2, p1); - } - } else if (df < 0) { - if (!malloc_staging_itr.insert(p1)) { - return false; - } - } else { - if (!malloc_staging_itr.insert_after(p1)) { - return false; - } - } - } else if (p1->addr() < p2->addr()) { - if (!malloc_staging_itr.insert(p1)) { + } else if (incoming_rec->addr() < matched_rec->addr()) { + if (!malloc_staging_itr.insert(incoming_rec)) { return false; } } else { - if (!malloc_staging_itr.insert_after(p1)) { - return false; - } + ShouldNotReachHere(); } } - p1 = (MemPointerRecord*)itr.next(); + incoming_rec = (MemPointerRecord*)itr.next(); } NOT_PRODUCT(void check_staging_data();) return true; } - // promote data to next generation bool MemSnapshot::promote() { assert(_alloc_ptrs != NULL && _vm_ptrs != NULL, "Just check"); @@ -507,20 +491,25 @@ bool MemSnapshot::promote_malloc_records(MemPointerArrayIterator* itr) { // found matched memory block if (matched_rec != NULL && new_rec->addr() == matched_rec->addr()) { // snapshot already contains 'live' records - assert(matched_rec->is_allocation_record() || matched_rec->is_arena_size_record(), + assert(matched_rec->is_allocation_record() || matched_rec->is_arena_memory_record(), "Sanity check"); // update block states - if (new_rec->is_allocation_record() || new_rec->is_arena_size_record()) { - copy_pointer(matched_rec, new_rec); + if (new_rec->is_allocation_record()) { + assign_pointer(matched_rec, new_rec); + } else if (new_rec->is_arena_memory_record()) { + if (new_rec->size() == 0) { + // remove size record once size drops to 0 + malloc_snapshot_itr.remove(); + } else { + assign_pointer(matched_rec, new_rec); + } } else { // a deallocation record assert(new_rec->is_deallocation_record(), "Sanity check"); // an arena record can be followed by a size record, we need to remove both if (matched_rec->is_arena_record()) { MemPointerRecord* next = (MemPointerRecord*)malloc_snapshot_itr.peek_next(); - if (next->is_arena_size_record()) { - // it has to match the arena record - assert(next->is_size_record_of_arena(matched_rec), "Sanity check"); + if (next->is_arena_memory_record() && next->is_memory_record_of_arena(matched_rec)) { malloc_snapshot_itr.remove(); } } @@ -528,17 +517,13 @@ bool MemSnapshot::promote_malloc_records(MemPointerArrayIterator* itr) { malloc_snapshot_itr.remove(); } } else { - // it is a new record, insert into snapshot - if (new_rec->is_arena_size_record()) { - MemPointerRecord* prev = (MemPointerRecord*)malloc_snapshot_itr.peek_prev(); - if (prev == NULL || !prev->is_arena_record() || !new_rec->is_size_record_of_arena(prev)) { - // no matched arena record, ignore the size record - new_rec = NULL; - } + // don't insert size 0 record + if (new_rec->is_arena_memory_record() && new_rec->size() == 0) { + new_rec = NULL; } - // only 'live' record can go into snapshot + if (new_rec != NULL) { - if (new_rec->is_allocation_record() || new_rec->is_arena_size_record()) { + if (new_rec->is_allocation_record() || new_rec->is_arena_memory_record()) { if (matched_rec != NULL && new_rec->addr() > matched_rec->addr()) { if (!malloc_snapshot_itr.insert_after(new_rec)) { return false; diff --git a/hotspot/src/share/vm/services/memSnapshot.hpp b/hotspot/src/share/vm/services/memSnapshot.hpp index dd52f4cd7f7..1620c545471 100644 --- a/hotspot/src/share/vm/services/memSnapshot.hpp +++ b/hotspot/src/share/vm/services/memSnapshot.hpp @@ -31,7 +31,6 @@ #include "services/memBaseline.hpp" #include "services/memPtrArray.hpp" - // Snapshot pointer array iterator // The pointer array contains malloc-ed pointers @@ -165,39 +164,58 @@ class VMMemPointerIterator : public MemPointerIterator { }; class MallocRecordIterator : public MemPointerArrayIterator { - protected: + private: MemPointerArrayIteratorImpl _itr; + + public: MallocRecordIterator(MemPointerArray* arr) : _itr(arr) { } virtual MemPointer* current() const { - MemPointerRecord* cur = (MemPointerRecord*)_itr.current(); - assert(cur == NULL || !cur->is_vm_pointer(), "seek error"); - MemPointerRecord* next = (MemPointerRecord*)_itr.peek_next(); - if (next == NULL || next->addr() != cur->addr()) { - return cur; - } else { - assert(!cur->is_vm_pointer(), "Sanity check"); - assert(cur->is_allocation_record() && next->is_deallocation_record(), - "sorting order"); - assert(cur->seq() != next->seq(), "Sanity check"); - return cur->seq() > next->seq() ? cur : next; +#ifdef ASSERT + MemPointer* cur_rec = _itr.current(); + if (cur_rec != NULL) { + MemPointer* prev_rec = _itr.peek_prev(); + MemPointer* next_rec = _itr.peek_next(); + assert(prev_rec == NULL || prev_rec->addr() < cur_rec->addr(), "Sorting order"); + assert(next_rec == NULL || next_rec->addr() > cur_rec->addr(), "Sorting order"); } +#endif + return _itr.current(); } - virtual MemPointer* next() { - MemPointerRecord* cur = (MemPointerRecord*)_itr.current(); - assert(cur == NULL || !cur->is_vm_pointer(), "Sanity check"); - MemPointerRecord* next = (MemPointerRecord*)_itr.next(); - if (next == NULL) { - return NULL; + MemPointerRecord* next_rec = (MemPointerRecord*)_itr.next(); + // arena memory record is a special case, which we have to compare + // sequence number against its associated arena record. + if (next_rec != NULL && next_rec->is_arena_memory_record()) { + MemPointerRecord* prev_rec = (MemPointerRecord*)_itr.peek_prev(); + // if there is an associated arena record, it has to be previous + // record because of sorting order (by address) - NMT generates a pseudo address + // for arena's size record by offsetting arena's address, that guarantees + // the order of arena record and it's size record. + if (prev_rec != NULL && prev_rec->is_arena_record() && + next_rec->is_memory_record_of_arena(prev_rec)) { + if (prev_rec->seq() > next_rec->seq()) { + // Skip this arena memory record + // Two scenarios: + // - if the arena record is an allocation record, this early + // size record must be leftover by previous arena, + // and the last size record should have size = 0. + // - if the arena record is a deallocation record, this + // size record should be its cleanup record, which should + // also have size = 0. In other world, arena alway reset + // its size before gone (see Arena's destructor) + assert(next_rec->size() == 0, "size not reset"); + return _itr.next(); + } else { + assert(prev_rec->is_allocation_record(), + "Arena size record ahead of allocation record"); + } + } } - if (cur->addr() == next->addr()) { - next = (MemPointerRecord*)_itr.next(); - } - return current(); + return next_rec; } MemPointer* peek_next() const { ShouldNotReachHere(); return NULL; } @@ -213,9 +231,12 @@ class MallocRecordIterator : public MemPointerArrayIterator { // still chances seeing duplicated records during promotion. // We want to use the record with higher sequence number, because it has // more accurate callsite pc. -class VMRecordIterator : public MallocRecordIterator { +class VMRecordIterator : public MemPointerArrayIterator { + private: + MemPointerArrayIteratorImpl _itr; + public: - VMRecordIterator(MemPointerArray* arr) : MallocRecordIterator(arr) { + VMRecordIterator(MemPointerArray* arr) : _itr(arr) { MemPointerRecord* cur = (MemPointerRecord*)_itr.current(); MemPointerRecord* next = (MemPointerRecord*)_itr.peek_next(); while (next != NULL) { @@ -256,6 +277,12 @@ class VMRecordIterator : public MallocRecordIterator { return cur; } + MemPointer* peek_next() const { ShouldNotReachHere(); return NULL; } + MemPointer* peek_prev() const { ShouldNotReachHere(); return NULL; } + void remove() { ShouldNotReachHere(); } + bool insert(MemPointer* ptr) { ShouldNotReachHere(); return false; } + bool insert_after(MemPointer* ptr) { ShouldNotReachHere(); return false; } + private: bool is_duplicated_record(MemPointerRecord* p1, MemPointerRecord* p2) const { bool ret = (p1->addr() == p2->addr() && p1->size() == p2->size() && p1->flags() == p2->flags()); @@ -348,8 +375,10 @@ class MemSnapshot : public CHeapObj { DEBUG_ONLY( void dump_all_vm_pointers();) private: - // copy pointer data from src to dest - void copy_pointer(MemPointerRecord* dest, const MemPointerRecord* src); + // copy sequenced pointer from src to dest + void copy_seq_pointer(MemPointerRecord* dest, const MemPointerRecord* src); + // assign a sequenced pointer to non-sequenced pointer + void assign_pointer(MemPointerRecord*dest, const MemPointerRecord* src); bool promote_malloc_records(MemPointerArrayIterator* itr); bool promote_virtual_memory_records(MemPointerArrayIterator* itr); diff --git a/hotspot/src/share/vm/services/memTracker.hpp b/hotspot/src/share/vm/services/memTracker.hpp index c42f01bf668..13eb4caf8ee 100644 --- a/hotspot/src/share/vm/services/memTracker.hpp +++ b/hotspot/src/share/vm/services/memTracker.hpp @@ -284,14 +284,14 @@ class MemTracker : AllStatic { } } - // record arena size + // record arena memory size static inline void record_arena_size(address addr, size_t size) { - // we add a positive offset to arena address, so we can have arena size record + // we add a positive offset to arena address, so we can have arena memory record // sorted after arena record if (is_on() && !UseMallocOnly) { assert(addr != NULL, "Sanity check"); create_memory_record((addr + sizeof(void*)), MemPointerRecord::arena_size_tag(), size, - 0, NULL); + DEBUG_CALLER_PC, NULL); } } From a28380d97e87f7a21bf16f8aff519e0d0447dca2 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Mon, 12 Nov 2012 15:58:11 -0500 Subject: [PATCH 07/94] 7122219: Passed StringTableSize value not verified Check that the values specified for -XX:StringTableSize are within a certain range. Reviewed-by: dholmes, coleenp --- hotspot/src/share/vm/classfile/symbolTable.hpp | 11 +++-------- hotspot/src/share/vm/runtime/arguments.cpp | 6 ++++++ hotspot/src/share/vm/runtime/globals.hpp | 2 +- hotspot/src/share/vm/runtime/os.cpp | 4 +++- hotspot/src/share/vm/utilities/globalDefinitions.hpp | 6 ++++++ 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/hotspot/src/share/vm/classfile/symbolTable.hpp b/hotspot/src/share/vm/classfile/symbolTable.hpp index 98ebcced201..3eee99ddbc2 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.hpp +++ b/hotspot/src/share/vm/classfile/symbolTable.hpp @@ -262,19 +262,14 @@ public: // The string table static StringTable* the_table() { return _the_table; } + // Size of one bucket in the string table. Used when checking for rollover. + static uint bucket_size() { return sizeof(HashtableBucket); } + static void create_table() { assert(_the_table == NULL, "One string table allowed."); _the_table = new StringTable(); } - static void create_table(HashtableBucket* t, int length, - int number_of_entries) { - assert(_the_table == NULL, "One string table allowed."); - assert((size_t)length == StringTableSize * sizeof(HashtableBucket), - "bad shared string size."); - _the_table = new StringTable(t, number_of_entries); - } - // GC support // Delete pointers to otherwise-unreachable objects. static void unlink(BoolObjectClosure* cl); diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 5d0fe7adae2..24a98be331f 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/javaAssertions.hpp" +#include "classfile/symbolTable.hpp" #include "compiler/compilerOracle.hpp" #include "memory/allocation.inline.hpp" #include "memory/cardTableRS.hpp" @@ -1844,6 +1845,11 @@ bool Arguments::check_vm_args_consistency() { status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio"); status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio"); + // Divide by bucket size to prevent a large size from causing rollover when + // calculating amount of memory needed to be allocated for the String table. + status = status && verify_interval(StringTableSize, defaultStringTableSize, + (max_uintx / StringTable::bucket_size()), "StringTable size"); + if (MinHeapFreeRatio > MaxHeapFreeRatio) { jio_fprintf(defaultStream::error_stream(), "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or " diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 62ad97f8958..e0e048a2e74 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -3593,7 +3593,7 @@ class CommandLineFlags { diagnostic(bool, PrintDTraceDOF, false, \ "Print the DTrace DOF passed to the system for JSDT probes") \ \ - product(uintx, StringTableSize, 1009, \ + product(uintx, StringTableSize, defaultStringTableSize, \ "Number of buckets in the interned String table") \ \ develop(bool, TraceDefaultMethods, false, \ diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index 56bd8261322..34184d92838 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -576,7 +576,9 @@ void* os::malloc(size_t size, MEMFLAGS memflags, address caller) { // if NULL is returned the calling functions assume out of memory. size = 1; } - + if (size > size + space_before + space_after) { // Check for rollover. + return NULL; + } NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap()); u_char* ptr = (u_char*)::malloc(size + space_before + space_after); diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp index 0c8ad4af862..9c51c1d5874 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp @@ -327,6 +327,12 @@ typedef jlong s8; const int max_method_code_size = 64*K - 1; // JVM spec, 2nd ed. section 4.8.1 (p.134) +//---------------------------------------------------------------------------------------------------- +// Minimum StringTableSize value + +const int defaultStringTableSize=1009; + + //---------------------------------------------------------------------------------------------------- // HotSwap - for JVMTI aka Class File Replacement and PopFrame // From 4aad9b74e748c76ef6605690d67985b83fdb0171 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Mon, 12 Nov 2012 16:15:05 -0500 Subject: [PATCH 08/94] 8001471: Klass::cast() does nothing Remove function Klass::cast() and calls to it. Reviewed-by: dholmes, coleenp --- hotspot/src/share/vm/c1/c1_Runtime1.cpp | 8 +- hotspot/src/share/vm/ci/ciEnv.cpp | 2 +- hotspot/src/share/vm/ci/ciType.cpp | 2 +- .../share/vm/classfile/classFileParser.cpp | 10 +- hotspot/src/share/vm/classfile/dictionary.cpp | 6 +- .../src/share/vm/classfile/javaClasses.cpp | 16 +-- .../src/share/vm/classfile/javaClasses.hpp | 10 +- .../share/vm/classfile/loaderConstraints.cpp | 2 +- .../src/share/vm/classfile/placeholders.cpp | 14 +-- .../src/share/vm/classfile/placeholders.hpp | 4 +- .../share/vm/classfile/systemDictionary.cpp | 20 ++-- hotspot/src/share/vm/code/dependencies.cpp | 16 +-- hotspot/src/share/vm/code/nmethod.cpp | 5 +- .../src/share/vm/compiler/disassembler.cpp | 2 +- .../vm/interpreter/bytecodeInterpreter.cpp | 4 +- .../vm/interpreter/interpreterRuntime.cpp | 4 +- .../src/share/vm/interpreter/linkResolver.cpp | 44 ++++----- .../src/share/vm/memory/metaspaceShared.cpp | 2 +- hotspot/src/share/vm/memory/universe.cpp | 2 +- hotspot/src/share/vm/oops/arrayKlass.cpp | 2 +- hotspot/src/share/vm/oops/cpCache.cpp | 2 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 32 +++--- hotspot/src/share/vm/oops/klass.cpp | 14 +-- hotspot/src/share/vm/oops/klass.hpp | 6 -- hotspot/src/share/vm/oops/klassVtable.cpp | 4 +- hotspot/src/share/vm/oops/method.cpp | 14 +-- hotspot/src/share/vm/oops/objArrayKlass.cpp | 16 +-- hotspot/src/share/vm/oops/objArrayKlass.hpp | 2 +- hotspot/src/share/vm/opto/runtime.cpp | 6 +- hotspot/src/share/vm/prims/jni.cpp | 62 ++++++------ hotspot/src/share/vm/prims/jniCheck.cpp | 2 +- hotspot/src/share/vm/prims/jvm.cpp | 98 +++++++++---------- hotspot/src/share/vm/prims/jvmtiEnv.cpp | 36 +++---- hotspot/src/share/vm/prims/jvmtiEnvBase.cpp | 4 +- hotspot/src/share/vm/prims/jvmtiExport.cpp | 12 +-- .../share/vm/prims/jvmtiGetLoadedClasses.cpp | 20 ++-- hotspot/src/share/vm/prims/jvmtiImpl.cpp | 6 +- .../share/vm/prims/jvmtiRedefineClasses.cpp | 14 +-- hotspot/src/share/vm/prims/jvmtiTagMap.cpp | 10 +- hotspot/src/share/vm/prims/jvmtiTrace.cpp | 2 +- hotspot/src/share/vm/prims/methodHandles.cpp | 40 ++++---- hotspot/src/share/vm/prims/nativeLookup.cpp | 2 +- hotspot/src/share/vm/prims/unsafe.cpp | 4 +- .../src/share/vm/runtime/biasedLocking.cpp | 14 +-- hotspot/src/share/vm/runtime/reflection.cpp | 42 ++++---- .../src/share/vm/runtime/sharedRuntime.cpp | 6 +- hotspot/src/share/vm/runtime/signature.cpp | 2 +- hotspot/src/share/vm/runtime/synchronizer.cpp | 6 +- hotspot/src/share/vm/runtime/thread.cpp | 2 +- hotspot/src/share/vm/runtime/vframe.cpp | 6 +- .../share/vm/services/classLoadingService.hpp | 2 +- hotspot/src/share/vm/services/heapDumper.cpp | 22 ++--- hotspot/src/share/vm/services/management.cpp | 2 +- hotspot/src/share/vm/services/serviceUtil.hpp | 7 +- 54 files changed, 343 insertions(+), 351 deletions(-) diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp index 8936114585a..3002c1304a1 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp @@ -374,7 +374,7 @@ JRT_END JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* thread, oopDesc* obj)) ResourceMark rm(thread); - const char* klass_name = Klass::cast(obj->klass())->external_name(); + const char* klass_name = obj->klass()->external_name(); SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayStoreException(), klass_name); JRT_END @@ -631,7 +631,7 @@ JRT_ENTRY(void, Runtime1::throw_class_cast_exception(JavaThread* thread, oopDesc NOT_PRODUCT(_throw_class_cast_exception_count++;) ResourceMark rm(thread); char* message = SharedRuntime::generate_class_cast_message( - thread, Klass::cast(object->klass())->external_name()); + thread, object->klass()->external_name()); SharedRuntime::throw_and_post_jvmti_exception( thread, vmSymbols::java_lang_ClassCastException(), message); JRT_END @@ -876,7 +876,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i case Bytecodes::_anewarray: { Bytecode_anewarray anew(caller_method(), caller_method->bcp_from(bci)); Klass* ek = caller_method->constants()->klass_at(anew.index(), CHECK); - k = Klass::cast(ek)->array_klass(CHECK); + k = ek->array_klass(CHECK); } break; case Bytecodes::_ldc: @@ -1236,7 +1236,7 @@ template int obj_arraycopy_work(oopDesc* src, T* src_addr, } else { Klass* bound = ObjArrayKlass::cast(dst->klass())->element_klass(); Klass* stype = ObjArrayKlass::cast(src->klass())->element_klass(); - if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) { + if (stype == bound || stype->is_subtype_of(bound)) { // Elements are guaranteed to be subtypes, so no check necessary bs->write_ref_array_pre(dst_addr, length); Copy::conjoint_oops_atomic(src_addr, dst_addr, length); diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp index 0465b9cf9c1..83dcf8d19d2 100644 --- a/hotspot/src/share/vm/ci/ciEnv.cpp +++ b/hotspot/src/share/vm/ci/ciEnv.cpp @@ -426,7 +426,7 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass, for (int i = cpool->length() - 1; i >= 1; i--) { if (cpool->tag_at(i).is_klass()) { Klass* kls = cpool->resolved_klass_at(i); - if (Klass::cast(kls)->name() == sym) { + if (kls->name() == sym) { found_klass = KlassHandle(THREAD, kls); break; } diff --git a/hotspot/src/share/vm/ci/ciType.cpp b/hotspot/src/share/vm/ci/ciType.cpp index c1c448f59c5..47412130f04 100644 --- a/hotspot/src/share/vm/ci/ciType.cpp +++ b/hotspot/src/share/vm/ci/ciType.cpp @@ -45,7 +45,7 @@ ciType::ciType(BasicType basic_type) : ciMetadata() { } ciType::ciType(KlassHandle k) : ciMetadata(k()) { - _basic_type = Klass::cast(k())->oop_is_array() ? T_ARRAY : T_OBJECT; + _basic_type = k()->oop_is_array() ? T_ARRAY : T_OBJECT; } diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 8ada34ab568..f53fff63dab 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -824,7 +824,7 @@ Array* ClassFileParser::parse_interfaces(constantPoolHandle cp, interf = KlassHandle(THREAD, k); } - if (!Klass::cast(interf())->is_interface()) { + if (!interf()->is_interface()) { THROW_MSG_(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class", NULL); } if (InstanceKlass::cast(interf())->has_default_methods()) { @@ -3831,7 +3831,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name, if (TraceClassResolution) { ResourceMark rm; // print out the superclass. - const char * from = Klass::cast(this_klass())->external_name(); + const char * from = this_klass()->external_name(); if (this_klass->java_super() != NULL) { tty->print("RESOLVE %s %s (super)\n", from, InstanceKlass::cast(this_klass->java_super())->external_name()); } @@ -3982,13 +3982,13 @@ void ClassFileParser::set_precomputed_flags(instanceKlassHandle k) { // java.lang.Object has empty default constructor k->set_has_vanilla_constructor(); } else { - if (Klass::cast(super)->has_vanilla_constructor() && + if (super->has_vanilla_constructor() && _has_vanilla_constructor) { k->set_has_vanilla_constructor(); } #ifdef ASSERT bool v = false; - if (Klass::cast(super)->has_vanilla_constructor()) { + if (super->has_vanilla_constructor()) { Method* constructor = k->find_method(vmSymbols::object_initializer_name( ), vmSymbols::void_method_signature()); if (constructor != NULL && constructor->is_vanilla_constructor()) { @@ -4130,7 +4130,7 @@ void ClassFileParser::check_super_interface_access(instanceKlassHandle this_klas int lng = local_interfaces->length(); for (int i = lng - 1; i >= 0; i--) { Klass* k = local_interfaces->at(i); - assert (k != NULL && Klass::cast(k)->is_interface(), "invalid interface"); + assert (k != NULL && k->is_interface(), "invalid interface"); if (!Reflection::verify_class_access(this_klass(), k, false)) { ResourceMark rm(THREAD); Exceptions::fthrow( diff --git a/hotspot/src/share/vm/classfile/dictionary.cpp b/hotspot/src/share/vm/classfile/dictionary.cpp index b5918049c79..33470303f20 100644 --- a/hotspot/src/share/vm/classfile/dictionary.cpp +++ b/hotspot/src/share/vm/classfile/dictionary.cpp @@ -346,7 +346,7 @@ void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data, KlassHandle obj) { assert_locked_or_safepoint(SystemDictionary_lock); assert(obj() != NULL, "adding NULL obj"); - assert(Klass::cast(obj())->name() == class_name, "sanity check on name"); + assert(obj()->name() == class_name, "sanity check on name"); unsigned int hash = compute_hash(class_name, loader_data); int index = hash_to_index(hash); @@ -553,7 +553,7 @@ void Dictionary::print() { bool is_defining_class = (loader_data == InstanceKlass::cast(e)->class_loader_data()); tty->print("%s%s", is_defining_class ? " " : "^", - Klass::cast(e)->external_name()); + e->external_name()); tty->print(", loader "); loader_data->print_value(); @@ -575,7 +575,7 @@ void Dictionary::verify() { probe = probe->next()) { Klass* e = probe->klass(); ClassLoaderData* loader_data = probe->loader_data(); - guarantee(Klass::cast(e)->oop_is_instance(), + guarantee(e->oop_is_instance(), "Verify of system dictionary failed"); // class loader must be present; a null class loader is the // boostrap loader diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index c414079e9ed..701e0802d8f 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -545,7 +545,7 @@ oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) { assert(k->oop_is_objArray(), "Must be"); Klass* element_klass = ObjArrayKlass::cast(k())->element_klass(); assert(element_klass != NULL, "Must have an element klass"); - comp_mirror = Klass::cast(element_klass)->java_mirror(); + comp_mirror = element_klass->java_mirror(); } assert(comp_mirror.not_null(), "must have a mirror"); @@ -628,8 +628,8 @@ void java_lang_Class::print_signature(oop java_class, outputStream* st) { name = vmSymbols::type_signature(primitive_type(java_class)); } else { Klass* k = as_Klass(java_class); - is_instance = Klass::cast(k)->oop_is_instance(); - name = Klass::cast(k)->name(); + is_instance = k->oop_is_instance(); + name = k->name(); } if (name == NULL) { st->print(""); @@ -651,12 +651,12 @@ Symbol* java_lang_Class::as_signature(oop java_class, bool intern_if_not_found, name->increment_refcount(); } else { Klass* k = as_Klass(java_class); - if (!Klass::cast(k)->oop_is_instance()) { - name = Klass::cast(k)->name(); + if (!k->oop_is_instance()) { + name = k->name(); name->increment_refcount(); } else { ResourceMark rm; - const char* sigstr = Klass::cast(k)->signature_name(); + const char* sigstr = k->signature_name(); int siglen = (int) strlen(sigstr); if (!intern_if_not_found) { name = SymbolTable::probe(sigstr, siglen); @@ -671,13 +671,13 @@ Symbol* java_lang_Class::as_signature(oop java_class, bool intern_if_not_found, Klass* java_lang_Class::array_klass(oop java_class) { Klass* k = ((Klass*)java_class->metadata_field(_array_klass_offset)); - assert(k == NULL || k->is_klass() && Klass::cast(k)->oop_is_array(), "should be array klass"); + assert(k == NULL || k->is_klass() && k->oop_is_array(), "should be array klass"); return k; } void java_lang_Class::set_array_klass(oop java_class, Klass* klass) { - assert(klass->is_klass() && Klass::cast(klass)->oop_is_array(), "should be array klass"); + assert(klass->is_klass() && klass->oop_is_array(), "should be array klass"); java_class->metadata_field_put(_array_klass_offset, klass); } diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 902099f1953..81b67a2827e 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -912,7 +912,7 @@ class java_lang_invoke_MethodHandle: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass()); + return klass->is_subclass_of(SystemDictionary::MethodHandle_klass()); } static bool is_instance(oop obj) { return obj != NULL && is_subclass(obj->klass()); @@ -942,7 +942,7 @@ class java_lang_invoke_LambdaForm: AllStatic { // Testers static bool is_subclass(Klass* klass) { return SystemDictionary::LambdaForm_klass() != NULL && - Klass::cast(klass)->is_subclass_of(SystemDictionary::LambdaForm_klass()); + klass->is_subclass_of(SystemDictionary::LambdaForm_klass()); } static bool is_instance(oop obj) { return obj != NULL && is_subclass(obj->klass()); @@ -1004,7 +1004,7 @@ class java_lang_invoke_MemberName: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass()); + return klass->is_subclass_of(SystemDictionary::MemberName_klass()); } static bool is_instance(oop obj) { return obj != NULL && is_subclass(obj->klass()); @@ -1090,7 +1090,7 @@ public: // Testers static bool is_subclass(Klass* klass) { - return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass()); + return klass->is_subclass_of(SystemDictionary::CallSite_klass()); } static bool is_instance(oop obj) { return obj != NULL && is_subclass(obj->klass()); @@ -1160,7 +1160,7 @@ class java_lang_ClassLoader : AllStatic { // Testers static bool is_subclass(Klass* klass) { - return Klass::cast(klass)->is_subclass_of(SystemDictionary::ClassLoader_klass()); + return klass->is_subclass_of(SystemDictionary::ClassLoader_klass()); } static bool is_instance(oop obj) { return obj != NULL && is_subclass(obj->klass()); diff --git a/hotspot/src/share/vm/classfile/loaderConstraints.cpp b/hotspot/src/share/vm/classfile/loaderConstraints.cpp index 6bd4bfc09e6..135eb59e81a 100644 --- a/hotspot/src/share/vm/classfile/loaderConstraints.cpp +++ b/hotspot/src/share/vm/classfile/loaderConstraints.cpp @@ -320,7 +320,7 @@ Klass* LoaderConstraintTable::find_constrained_klass(Symbol* name, Handle loader) { LoaderConstraintEntry *p = *(find_loader_constraint(name, loader)); if (p != NULL && p->klass() != NULL) { - if (Klass::cast(p->klass())->oop_is_instance() && !InstanceKlass::cast(p->klass())->is_loaded()) { + if (p->klass()->oop_is_instance() && !InstanceKlass::cast(p->klass())->is_loaded()) { // Only return fully loaded classes. Classes found through the // constraints might still be in the process of loading. return NULL; diff --git a/hotspot/src/share/vm/classfile/placeholders.cpp b/hotspot/src/share/vm/classfile/placeholders.cpp index ba957ba4bd1..1babaaf978c 100644 --- a/hotspot/src/share/vm/classfile/placeholders.cpp +++ b/hotspot/src/share/vm/classfile/placeholders.cpp @@ -45,7 +45,7 @@ PlaceholderEntry* PlaceholderTable::new_entry(int hash, Symbol* name, entry->set_loadInstanceThreadQ(NULL); entry->set_defineThreadQ(NULL); entry->set_definer(NULL); - entry->set_instanceKlass(NULL); + entry->set_instance_klass(NULL); return entry; } @@ -188,7 +188,7 @@ void PlaceholderTable::classes_do(KlassClosure* f) { void PlaceholderEntry::classes_do(KlassClosure* closure) { assert(klassname() != NULL, "should have a non-null klass"); if (_instanceKlass != NULL) { - closure->do_klass(InstanceKlass()); + closure->do_klass(instance_klass()); } } @@ -220,9 +220,9 @@ void PlaceholderEntry::print() const { tty->print(", definer "); definer()->print_value(); } - if (InstanceKlass() != NULL) { + if (instance_klass() != NULL) { tty->print(", InstanceKlass "); - InstanceKlass()->print_value(); + instance_klass()->print_value(); } tty->print("\n"); tty->print("loadInstanceThreadQ threads:"); @@ -241,9 +241,9 @@ void PlaceholderEntry::verify() const { guarantee(loader_data() != NULL, "Must have been setup."); guarantee(loader_data()->class_loader() == NULL || loader_data()->class_loader()->is_instance(), "checking type of _loader"); - guarantee(InstanceKlass() == NULL - || Klass::cast(InstanceKlass())->oop_is_instance(), - "checking type of InstanceKlass result"); + guarantee(instance_klass() == NULL + || instance_klass()->oop_is_instance(), + "checking type of instance_klass result"); } void PlaceholderTable::verify() { diff --git a/hotspot/src/share/vm/classfile/placeholders.hpp b/hotspot/src/share/vm/classfile/placeholders.hpp index 54ff7bb182b..af4518a462f 100644 --- a/hotspot/src/share/vm/classfile/placeholders.hpp +++ b/hotspot/src/share/vm/classfile/placeholders.hpp @@ -191,8 +191,8 @@ class PlaceholderEntry : public HashtableEntry { Thread* definer() const {return _definer; } void set_definer(Thread* definer) { _definer = definer; } - Klass* InstanceKlass() const {return _instanceKlass; } - void set_instanceKlass(Klass* InstanceKlass) { _instanceKlass = InstanceKlass; } + Klass* instance_klass() const {return _instanceKlass; } + void set_instance_klass(Klass* ik) { _instanceKlass = ik; } SeenThread* superThreadQ() const { return _superThreadQ; } void set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; } diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index f0e61daf2ac..7a997ebb413 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -240,7 +240,7 @@ Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name, protection_domain, CHECK_NULL); if (k != NULL) { - k = Klass::cast(k)->array_klass(fd.dimension(), CHECK_NULL); + k = k->array_klass(fd.dimension(), CHECK_NULL); } } else { k = Universe::typeArrayKlassObj(t); @@ -328,8 +328,8 @@ Klass* SystemDictionary::resolve_super_or_fail(Symbol* child_name, if ((childk != NULL ) && (is_superclass) && ((quicksuperk = InstanceKlass::cast(childk)->super()) != NULL) && - ((Klass::cast(quicksuperk)->name() == class_name) && - (Klass::cast(quicksuperk)->class_loader() == class_loader()))) { + ((quicksuperk->name() == class_name) && + (quicksuperk->class_loader() == class_loader()))) { return quicksuperk; } else { PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, child_name, loader_data); @@ -928,7 +928,7 @@ Klass* SystemDictionary::find_instance_or_array_klass(Symbol* class_name, k = SystemDictionary::find(fd.object_key(), class_loader, protection_domain, THREAD); } if (k != NULL) { - k = Klass::cast(k)->array_klass_or_null(fd.dimension()); + k = k->array_klass_or_null(fd.dimension()); } } else { k = find(class_name, class_loader, protection_domain, THREAD); @@ -1537,7 +1537,7 @@ instanceKlassHandle SystemDictionary::find_or_define_instance_class(Symbol* clas // Only special cases allow parallel defines and can use other thread's results // Other cases fall through, and may run into duplicate defines // caught by finding an entry in the SystemDictionary - if ((UnsyncloadClass || is_parallelDefine(class_loader)) && (probe->InstanceKlass() != NULL)) { + if ((UnsyncloadClass || is_parallelDefine(class_loader)) && (probe->instance_klass() != NULL)) { probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS); placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, THREAD); SystemDictionary_lock->notify_all(); @@ -1545,7 +1545,7 @@ instanceKlassHandle SystemDictionary::find_or_define_instance_class(Symbol* clas Klass* check = find_class(d_index, d_hash, name_h, loader_data); assert(check != NULL, "definer missed recording success"); #endif - return(instanceKlassHandle(THREAD, probe->InstanceKlass())); + return(instanceKlassHandle(THREAD, probe->instance_klass())); } else { // This thread will define the class (even if earlier thread tried and had an error) probe->set_definer(THREAD); @@ -1566,7 +1566,7 @@ instanceKlassHandle SystemDictionary::find_or_define_instance_class(Symbol* clas linkage_exception = Handle(THREAD,PENDING_EXCEPTION); CLEAR_PENDING_EXCEPTION; } else { - probe->set_instanceKlass(k()); + probe->set_instance_klass(k()); } probe->set_definer(NULL); probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS); @@ -2149,7 +2149,7 @@ Klass* SystemDictionary::find_constrained_instance_or_array_klass( } // If element class already loaded, allocate array klass if (klass != NULL) { - klass = Klass::cast(klass)->array_klass_or_null(fd.dimension()); + klass = klass->array_klass_or_null(fd.dimension()); } } else { MutexLocker mu(SystemDictionary_lock, THREAD); @@ -2466,9 +2466,9 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature, Klass* sel_klass = java_lang_Class::as_Klass(mirror); mirror = NULL; // safety // Emulate ConstantPool::verify_constant_pool_resolve. - if (Klass::cast(sel_klass)->oop_is_objArray()) + if (sel_klass->oop_is_objArray()) sel_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass(); - if (Klass::cast(sel_klass)->oop_is_instance()) { + if (sel_klass->oop_is_instance()) { KlassHandle sel_kh(THREAD, sel_klass); LinkResolver::check_klass_accessability(accessing_klass, sel_kh, CHECK_(empty)); } diff --git a/hotspot/src/share/vm/code/dependencies.cpp b/hotspot/src/share/vm/code/dependencies.cpp index 93db50afe07..e34ee205134 100644 --- a/hotspot/src/share/vm/code/dependencies.cpp +++ b/hotspot/src/share/vm/code/dependencies.cpp @@ -552,7 +552,7 @@ void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], } tty->print(" %s = %s", what, (put_star? "*": "")); if (arg.is_klass()) - tty->print("%s", Klass::cast((Klass*)arg.metadata_value())->external_name()); + tty->print("%s", ((Klass*)arg.metadata_value())->external_name()); else if (arg.is_method()) ((Method*)arg.metadata_value())->print_value(); else @@ -563,7 +563,7 @@ void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], bool put_star = !Dependencies::is_concrete_klass(witness); tty->print_cr(" witness = %s%s", (put_star? "*": ""), - Klass::cast(witness)->external_name()); + witness->external_name()); } } @@ -808,7 +808,7 @@ class ClassHierarchyWalker { if (!(m->is_public() || m->is_protected())) // The override story is complex when packages get involved. return true; // Must punt the assertion to true. - Klass* k = Klass::cast(ctxk); + Klass* k = ctxk; Method* lm = k->lookup_method(m->name(), m->signature()); if (lm == NULL && k->oop_is_instance()) { // It might be an abstract interface method, devoid of mirandas. @@ -835,7 +835,7 @@ class ClassHierarchyWalker { } ResourceMark rm; tty->print_cr("Dependency method not found in the associated context:"); - tty->print_cr(" context = %s", Klass::cast(ctxk)->external_name()); + tty->print_cr(" context = %s", ctxk->external_name()); tty->print( " method = "); m->print_short_name(tty); tty->cr(); if (lm != NULL) { tty->print( " found = "); lm->print_short_name(tty); tty->cr(); @@ -1010,7 +1010,7 @@ Klass* ClassHierarchyWalker::find_witness_in(KlassDepChange& changes, for (int i = 0; i < num_participants(); i++) { Klass* part = participant(i); if (part == NULL) continue; - assert(changes.involves_context(part) == Klass::cast(new_type)->is_subtype_of(part), + assert(changes.involves_context(part) == new_type->is_subtype_of(part), "correct marking of participants, b/c new_type is unique"); if (changes.involves_context(part)) { // new guy is protected from this check by previous participant @@ -1146,7 +1146,7 @@ Klass* ClassHierarchyWalker::find_witness_anywhere(Klass* context_type, bool Dependencies::is_concrete_klass(Klass* k) { - if (Klass::cast(k)->is_abstract()) return false; + if (k->is_abstract()) return false; // %%% We could treat classes which are concrete but // have not yet been instantiated as virtually abstract. // This would require a deoptimization barrier on first instantiation. @@ -1705,12 +1705,12 @@ KlassDepChange::~KlassDepChange() { } bool KlassDepChange::involves_context(Klass* k) { - if (k == NULL || !Klass::cast(k)->oop_is_instance()) { + if (k == NULL || !k->oop_is_instance()) { return false; } InstanceKlass* ik = InstanceKlass::cast(k); bool is_contained = ik->is_marked_dependent(); - assert(is_contained == Klass::cast(new_type())->is_subtype_of(k), + assert(is_contained == new_type()->is_subtype_of(k), "correct marking of potential context types"); return is_contained; } diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index e7726908816..157136edc0d 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -2568,9 +2568,8 @@ void nmethod::print_dependencies() { deps.print_dependency(); Klass* ctxk = deps.context_type(); if (ctxk != NULL) { - Klass* k = Klass::cast(ctxk); - if (k->oop_is_instance() && ((InstanceKlass*)k)->is_dependent_nmethod(this)) { - tty->print_cr(" [nmethod<=klass]%s", k->external_name()); + if (ctxk->oop_is_instance() && ((InstanceKlass*)ctxk)->is_dependent_nmethod(this)) { + tty->print_cr(" [nmethod<=klass]%s", ctxk->external_name()); } } deps.log_dependency(); // put it into the xml log also diff --git a/hotspot/src/share/vm/compiler/disassembler.cpp b/hotspot/src/share/vm/compiler/disassembler.cpp index 676440c14cc..3efe079142f 100644 --- a/hotspot/src/share/vm/compiler/disassembler.cpp +++ b/hotspot/src/share/vm/compiler/disassembler.cpp @@ -353,7 +353,7 @@ void decode_env::print_address(address adr) { obj->print_value_on(st); if (st->count() == c) { // No output. (Can happen in product builds.) - st->print("(a %s)", Klass::cast(obj->klass())->external_name()); + st->print("(a %s)", obj->klass()->external_name()); } return; } diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp index a9d6cc9a981..0d139fdf71c 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp @@ -2043,8 +2043,8 @@ run: if (objKlassOop != klassOf && !objKlassOop->is_subtype_of(klassOf)) { ResourceMark rm(THREAD); - const char* objName = Klass::cast(objKlassOop)->external_name(); - const char* klassName = Klass::cast(klassOf)->external_name(); + const char* objName = objKlassOop->external_name(); + const char* klassName = klassOf->external_name(); char* message = SharedRuntime::generate_class_cast_message( objName, klassName); VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message); diff --git a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp index 6aa8ea116b9..81ddbf01dfd 100644 --- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp +++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp @@ -312,7 +312,7 @@ IRT_END IRT_ENTRY(void, InterpreterRuntime::create_klass_exception(JavaThread* thread, char* name, oopDesc* obj)) ResourceMark rm(thread); - const char* klass_name = Klass::cast(obj->klass())->external_name(); + const char* klass_name = obj->klass()->external_name(); // lookup exception klass TempNewSymbol s = SymbolTable::new_symbol(name, CHECK); if (ProfileTraps) { @@ -341,7 +341,7 @@ IRT_ENTRY(void, InterpreterRuntime::throw_ClassCastException( ResourceMark rm(thread); char* message = SharedRuntime::generate_class_cast_message( - thread, Klass::cast(obj->klass())->external_name()); + thread, obj->klass()->external_name()); if (ProfileTraps) { note_trap(thread, Deoptimization::Reason_class_check, CHECK); diff --git a/hotspot/src/share/vm/interpreter/linkResolver.cpp b/hotspot/src/share/vm/interpreter/linkResolver.cpp index 4a32b794110..81607cc2523 100644 --- a/hotspot/src/share/vm/interpreter/linkResolver.cpp +++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp @@ -203,7 +203,7 @@ void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, Klass Method* result_oop = klass->uncached_lookup_method(name, signature); result = methodHandle(THREAD, result_oop); while (!result.is_null() && result->is_static()) { - klass = KlassHandle(THREAD, Klass::cast(result->method_holder())->super()); + klass = KlassHandle(THREAD, result->method_holder()->super()); result = methodHandle(THREAD, klass->uncached_lookup_method(name, signature)); } } @@ -428,7 +428,7 @@ void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle res // 3. method lookup failed ResourceMark rm(THREAD); THROW_MSG_CAUSE(vmSymbols::java_lang_NoSuchMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + Method::name_and_sig_as_C_string(resolved_klass(), method_name, method_signature), nested_exception); @@ -448,7 +448,7 @@ void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle res if (resolved_method->is_abstract() && !resolved_klass->is_abstract()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + Method::name_and_sig_as_C_string(resolved_klass(), method_name, method_signature)); } @@ -477,7 +477,7 @@ void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle res " \"%s\" the class loader (instance of %s) of the current class, %s," " and the class loader (instance of %s) for resolved class, %s, have" " different Class objects for the type %s used in the signature"; - char* sig = Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name,method_signature); + char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature); const char* loader1 = SystemDictionary::loader_name(loader()); char* current = InstanceKlass::cast(current_klass())->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(class_loader()); @@ -505,7 +505,7 @@ void LinkResolver::resolve_interface_method(methodHandle& resolved_method, if (!resolved_klass->is_interface()) { ResourceMark rm(THREAD); char buf[200]; - jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", Klass::cast(resolved_klass())->external_name()); + jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass()->external_name()); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } @@ -519,7 +519,7 @@ void LinkResolver::resolve_interface_method(methodHandle& resolved_method, // no method found ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + Method::name_and_sig_as_C_string(resolved_klass(), method_name, method_signature)); } @@ -540,7 +540,7 @@ void LinkResolver::resolve_interface_method(methodHandle& resolved_method, "current class, %s, and the class loader (instance of %s) for " "resolved class, %s, have different Class objects for the type %s " "used in the signature"; - char* sig = Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name,method_signature); + char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature); const char* loader1 = SystemDictionary::loader_name(loader()); char* current = InstanceKlass::cast(current_klass())->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(class_loader()); @@ -627,7 +627,7 @@ void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle poo if (is_static != fd.is_static()) { ResourceMark rm(THREAD); char msg[200]; - jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", Klass::cast(resolved_klass())->external_name(), fd.name()->as_C_string()); + jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string()); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg); } @@ -701,7 +701,7 @@ void LinkResolver::resolve_static_call(CallInfo& result, KlassHandle& resolved_k bool check_access, bool initialize_class, TRAPS) { methodHandle resolved_method; linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); - resolved_klass = KlassHandle(THREAD, Klass::cast(resolved_method->method_holder())); + resolved_klass = KlassHandle(THREAD, resolved_method->method_holder()); // Initialize klass (this should only happen if everything is ok) if (initialize_class && resolved_klass->should_be_initialized()) { @@ -725,7 +725,7 @@ void LinkResolver::linktime_resolve_static_method(methodHandle& resolved_method, if (!resolved_method->is_static()) { ResourceMark rm(THREAD); char buf[200]; - jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass(), resolved_method->name(), resolved_method->signature())); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); @@ -789,7 +789,7 @@ void LinkResolver::linktime_resolve_special_method(methodHandle& resolved_method char buf[200]; jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", - Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + Method::name_and_sig_as_C_string(resolved_klass(), resolved_method->name(), resolved_method->signature())); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); @@ -829,7 +829,7 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result, methodHandle if (sel_method.is_null()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + Method::name_and_sig_as_C_string(resolved_klass(), resolved_method->name(), resolved_method->signature())); } @@ -840,7 +840,7 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result, methodHandle if (sel_method->is_static()) { ResourceMark rm(THREAD); char buf[200]; - jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), resolved_method->name(), resolved_method->signature())); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); @@ -850,7 +850,7 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result, methodHandle if (sel_method->is_abstract()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + Method::name_and_sig_as_C_string(resolved_klass(), sel_method->name(), sel_method->signature())); } @@ -881,7 +881,7 @@ void LinkResolver::linktime_resolve_virtual_method(methodHandle &resolved_method if (resolved_method->is_static()) { ResourceMark rm(THREAD); char buf[200]; - jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), resolved_method->name(), resolved_method->signature())); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); @@ -950,7 +950,7 @@ void LinkResolver::runtime_resolve_virtual_method(CallInfo& result, if (selected_method.is_null()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + Method::name_and_sig_as_C_string(resolved_klass(), resolved_method->name(), resolved_method->signature())); } @@ -959,7 +959,7 @@ void LinkResolver::runtime_resolve_virtual_method(CallInfo& result, if (check_null_and_abstract && selected_method->is_abstract()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + Method::name_and_sig_as_C_string(resolved_klass(), selected_method->name(), selected_method->signature())); } @@ -999,8 +999,8 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result, methodHand ResourceMark rm(THREAD); char buf[200]; jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s", - (Klass::cast(recv_klass()))->external_name(), - (Klass::cast(resolved_klass()))->external_name()); + recv_klass()->external_name(), + resolved_klass()->external_name()); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } // do lookup based on receiver klass @@ -1012,7 +1012,7 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result, methodHand if (sel_method.is_null()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(recv_klass()), + Method::name_and_sig_as_C_string(recv_klass(), resolved_method->name(), resolved_method->signature())); } @@ -1020,7 +1020,7 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result, methodHand if (!sel_method->is_public()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), - Method::name_and_sig_as_C_string(Klass::cast(recv_klass()), + Method::name_and_sig_as_C_string(recv_klass(), sel_method->name(), sel_method->signature())); } @@ -1028,7 +1028,7 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result, methodHand if (check_null_and_abstract && sel_method->is_abstract()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(recv_klass()), + Method::name_and_sig_as_C_string(recv_klass(), sel_method->name(), sel_method->signature())); } diff --git a/hotspot/src/share/vm/memory/metaspaceShared.cpp b/hotspot/src/share/vm/memory/metaspaceShared.cpp index dde26b5f8c5..519a766a251 100644 --- a/hotspot/src/share/vm/memory/metaspaceShared.cpp +++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp @@ -431,7 +431,7 @@ void VM_PopulateDumpSharedSpace::doit() { } static void link_shared_classes(Klass* obj, TRAPS) { - Klass* k = Klass::cast(obj); + Klass* k = obj; if (k->oop_is_instance()) { InstanceKlass* ik = (InstanceKlass*) k; // Link the class to cause the bytecodes to be rewritten and the diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 35cc0db712e..3b23f9e901c 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -346,7 +346,7 @@ void Universe::genesis(TRAPS) { // --- // New // Have already been initialized. - Klass::cast(_objectArrayKlassObj)->append_to_sibling_list(); + _objectArrayKlassObj->append_to_sibling_list(); // Compute is_jdk version flags. // Only 1.3 or later has the java.lang.Shutdown class. diff --git a/hotspot/src/share/vm/oops/arrayKlass.cpp b/hotspot/src/share/vm/oops/arrayKlass.cpp index 781c8945377..9b5ec951bbb 100644 --- a/hotspot/src/share/vm/oops/arrayKlass.cpp +++ b/hotspot/src/share/vm/oops/arrayKlass.cpp @@ -67,7 +67,7 @@ oop ArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) { Method* ArrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const { // There are no methods in an array klass but the super class (Object) has some assert(super(), "super klass must be present"); - return Klass::cast(super())->uncached_lookup_method(name, signature); + return super()->uncached_lookup_method(name, signature); } ArrayKlass::ArrayKlass(Symbol* name) { diff --git a/hotspot/src/share/vm/oops/cpCache.cpp b/hotspot/src/share/vm/oops/cpCache.cpp index 3aded474350..d625db57b5e 100644 --- a/hotspot/src/share/vm/oops/cpCache.cpp +++ b/hotspot/src/share/vm/oops/cpCache.cpp @@ -375,7 +375,7 @@ Method* ConstantPoolCacheEntry::method_if_resolved(constantPoolHandle cpool) { int holder_index = cpool->uncached_klass_ref_index_at(constant_pool_index()); if (cpool->tag_at(holder_index).is_klass()) { Klass* klass = cpool->resolved_klass_at(holder_index); - if (!Klass::cast(klass)->oop_is_instance()) + if (!klass->oop_is_instance()) klass = SystemDictionary::Object_klass(); return InstanceKlass::cast(klass)->method_at_vtable(f2_as_index()); } diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index c5b20d8ffd0..72cb8a3924a 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -727,8 +727,8 @@ void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { // Step 7 Klass* super_klass = this_oop->super(); - if (super_klass != NULL && !this_oop->is_interface() && Klass::cast(super_klass)->should_be_initialized()) { - Klass::cast(super_klass)->initialize(THREAD); + if (super_klass != NULL && !this_oop->is_interface() && super_klass->should_be_initialized()) { + super_klass->initialize(THREAD); if (HAS_PENDING_EXCEPTION) { Handle e(THREAD, PENDING_EXCEPTION); @@ -924,7 +924,7 @@ GrowableArray* InstanceKlass::compute_secondary_supers(int num_extra_slo } bool InstanceKlass::compute_is_subtype_of(Klass* k) { - if (Klass::cast(k)->is_interface()) { + if (k->is_interface()) { return implements_interface(k); } else { return Klass::compute_is_subtype_of(k); @@ -933,7 +933,7 @@ bool InstanceKlass::compute_is_subtype_of(Klass* k) { bool InstanceKlass::implements_interface(Klass* k) const { if (this == k) return true; - assert(Klass::cast(k)->is_interface(), "should be an interface class"); + assert(k->is_interface(), "should be an interface class"); for (int i = 0; i < transitive_interfaces()->length(); i++) { if (transitive_interfaces()->at(i) == k) { return true; @@ -1100,7 +1100,7 @@ Klass* InstanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescr const int n = local_interfaces()->length(); for (int i = 0; i < n; i++) { Klass* intf1 = local_interfaces()->at(i); - assert(Klass::cast(intf1)->is_interface(), "just checking type"); + assert(intf1->is_interface(), "just checking type"); // search for field in current interface if (InstanceKlass::cast(intf1)->find_local_field(name, sig, fd)) { assert(fd->is_static(), "interface field must be static"); @@ -1171,7 +1171,7 @@ bool InstanceKlass::find_field_from_offset(int offset, bool is_static, fieldDesc if (InstanceKlass::cast(klass)->find_local_field_from_offset(offset, is_static, fd)) { return true; } - klass = Klass::cast(klass)->super(); + klass = klass->super(); } return false; } @@ -2359,19 +2359,19 @@ const char* InstanceKlass::signature_name() const { bool InstanceKlass::is_same_class_package(Klass* class2) { Klass* class1 = this; oop classloader1 = InstanceKlass::cast(class1)->class_loader(); - Symbol* classname1 = Klass::cast(class1)->name(); + Symbol* classname1 = class1->name(); - if (Klass::cast(class2)->oop_is_objArray()) { + if (class2->oop_is_objArray()) { class2 = ObjArrayKlass::cast(class2)->bottom_klass(); } oop classloader2; - if (Klass::cast(class2)->oop_is_instance()) { + if (class2->oop_is_instance()) { classloader2 = InstanceKlass::cast(class2)->class_loader(); } else { - assert(Klass::cast(class2)->oop_is_typeArray(), "should be type array"); + assert(class2->oop_is_typeArray(), "should be type array"); classloader2 = NULL; } - Symbol* classname2 = Klass::cast(class2)->name(); + Symbol* classname2 = class2->name(); return InstanceKlass::is_same_class_package(classloader1, classname1, classloader2, classname2); @@ -2380,7 +2380,7 @@ bool InstanceKlass::is_same_class_package(Klass* class2) { bool InstanceKlass::is_same_class_package(oop classloader2, Symbol* classname2) { Klass* class1 = this; oop classloader1 = InstanceKlass::cast(class1)->class_loader(); - Symbol* classname1 = Klass::cast(class1)->name(); + Symbol* classname1 = class1->name(); return InstanceKlass::is_same_class_package(classloader1, classname1, classloader2, classname2); @@ -2471,7 +2471,7 @@ Klass* InstanceKlass::compute_enclosing_class_impl(instanceKlassHandle self, bool InstanceKlass::is_same_package_member_impl(instanceKlassHandle class1, Klass* class2_oop, TRAPS) { if (class2_oop == class1()) return true; - if (!Klass::cast(class2_oop)->oop_is_instance()) return false; + if (!class2_oop->oop_is_instance()) return false; instanceKlassHandle class2(THREAD, class2_oop); // must be in same package before we try anything else @@ -3004,7 +3004,7 @@ void InstanceKlass::verify_on(outputStream* st) { if (im != NULL) { guarantee(is_interface(), "only interfaces should have implementor set"); guarantee(im->is_klass(), "should be klass"); - guarantee(!Klass::cast(im)->is_interface() || im == this, + guarantee(!im->is_interface() || im == this, "implementors cannot be interfaces"); } @@ -3013,7 +3013,7 @@ void InstanceKlass::verify_on(outputStream* st) { Array* local_interfaces = this->local_interfaces(); for (int j = 0; j < local_interfaces->length(); j++) { Klass* e = local_interfaces->at(j); - guarantee(e->is_klass() && Klass::cast(e)->is_interface(), "invalid local interface"); + guarantee(e->is_klass() && e->is_interface(), "invalid local interface"); } } @@ -3022,7 +3022,7 @@ void InstanceKlass::verify_on(outputStream* st) { Array* transitive_interfaces = this->transitive_interfaces(); for (int j = 0; j < transitive_interfaces->length(); j++) { Klass* e = transitive_interfaces->at(j); - guarantee(e->is_klass() && Klass::cast(e)->is_interface(), "invalid transitive interface"); + guarantee(e->is_klass() && e->is_interface(), "invalid transitive interface"); } } diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 06a99aff6b0..6980e0e51ae 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -56,7 +56,7 @@ bool Klass::is_subclass_of(Klass* k) const { while (t != NULL) { if (t == k) return true; - t = Klass::cast(t)->super(); + t = t->super(); } return false; } @@ -243,16 +243,16 @@ void Klass::initialize_supers(Klass* k, TRAPS) { juint j = super_depth(); assert(j == my_depth, "computed accessor gets right answer"); Klass* t = this; - while (!Klass::cast(t)->can_be_primary_super()) { - t = Klass::cast(t)->super(); - j = Klass::cast(t)->super_depth(); + while (!t->can_be_primary_super()) { + t = t->super(); + j = t->super_depth(); } for (juint j1 = j+1; j1 < primary_super_limit(); j1++) { assert(primary_super_of_depth(j1) == NULL, "super list padding"); } while (t != NULL) { assert(primary_super_of_depth(j) == t, "super list initialization"); - t = Klass::cast(t)->super(); + t = t->super(); --j; } assert(j == (juint)-1, "correct depth count"); @@ -333,7 +333,7 @@ GrowableArray* Klass::compute_secondary_supers(int num_extra_slots) { Klass* Klass::subklass() const { - return _subklass == NULL ? NULL : Klass::cast(_subklass); + return _subklass == NULL ? NULL : _subklass; } InstanceKlass* Klass::superklass() const { @@ -342,7 +342,7 @@ InstanceKlass* Klass::superklass() const { } Klass* Klass::next_sibling() const { - return _next_sibling == NULL ? NULL : Klass::cast(_next_sibling); + return _next_sibling == NULL ? NULL : _next_sibling; } void Klass::set_subklass(Klass* s) { diff --git a/hotspot/src/share/vm/oops/klass.hpp b/hotspot/src/share/vm/oops/klass.hpp index 129b7252224..58c94b20b59 100644 --- a/hotspot/src/share/vm/oops/klass.hpp +++ b/hotspot/src/share/vm/oops/klass.hpp @@ -422,12 +422,6 @@ class Klass : public Metadata { // if not, throw either an Error or an Exception. virtual void check_valid_for_instantiation(bool throwError, TRAPS); - // Casting - static Klass* cast(Klass* k) { - assert(k->is_klass(), "cast to Klass"); - return k; - } - // array copying virtual void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); diff --git a/hotspot/src/share/vm/oops/klassVtable.cpp b/hotspot/src/share/vm/oops/klassVtable.cpp index 83e002cb341..f8e4d02236f 100644 --- a/hotspot/src/share/vm/oops/klassVtable.cpp +++ b/hotspot/src/share/vm/oops/klassVtable.cpp @@ -746,7 +746,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass while (target != NULL && target->is_static()) { // continue with recursive lookup through the superclass Klass* super = target->method_holder()->super(); - target = (super == NULL) ? (Method*)NULL : Klass::cast(super)->uncached_lookup_method(method_name, method_signature); + target = (super == NULL) ? (Method*)NULL : super->uncached_lookup_method(method_name, method_signature); } if (target == NULL || !target->is_public() || target->is_abstract()) { // Entry do not resolve. Leave it empty @@ -852,7 +852,7 @@ void visit_all_interfaces(Array* transitive_intf, InterfaceVisiterClosur // Handle array argument for(int i = 0; i < transitive_intf->length(); i++) { Klass* intf = transitive_intf->at(i); - assert(Klass::cast(intf)->is_interface(), "sanity check"); + assert(intf->is_interface(), "sanity check"); // Find no. of methods excluding a int method_count = InstanceKlass::cast(intf)->methods()->length(); diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index f64a7b27ea3..93e4532b07b 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -152,11 +152,11 @@ address Method::get_c2i_unverified_entry() { } char* Method::name_and_sig_as_C_string() const { - return name_and_sig_as_C_string(Klass::cast(constants()->pool_holder()), name(), signature()); + return name_and_sig_as_C_string(constants()->pool_holder(), name(), signature()); } char* Method::name_and_sig_as_C_string(char* buf, int size) const { - return name_and_sig_as_C_string(Klass::cast(constants()->pool_holder()), name(), signature(), buf, size); + return name_and_sig_as_C_string(constants()->pool_holder(), name(), signature(), buf, size); } char* Method::name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature) { @@ -578,8 +578,8 @@ objArrayHandle Method::resolved_checked_exceptions_impl(Method* this_oop, TRAPS) for (int i = 0; i < length; i++) { CheckedExceptionElement* table = h_this->checked_exceptions_start(); // recompute on each iteration, not gc safe Klass* k = h_this->constants()->klass_at(table[i].class_cp_index, CHECK_(objArrayHandle())); - assert(Klass::cast(k)->is_subclass_of(SystemDictionary::Throwable_klass()), "invalid exception class"); - mirrors->obj_at_put(i, Klass::cast(k)->java_mirror()); + assert(k->is_subclass_of(SystemDictionary::Throwable_klass()), "invalid exception class"); + mirrors->obj_at_put(i, k->java_mirror()); } return mirrors; } @@ -618,7 +618,7 @@ bool Method::is_klass_loaded_by_klass_index(int klass_index) const { Thread *thread = Thread::current(); Symbol* klass_name = constants()->klass_name_at(klass_index); Handle loader(thread, method_holder()->class_loader()); - Handle prot (thread, Klass::cast(method_holder())->protection_domain()); + Handle prot (thread, method_holder()->protection_domain()); return SystemDictionary::find(klass_name, loader, prot, thread) != NULL; } else { return true; @@ -1067,8 +1067,8 @@ methodHandle Method::make_method_handle_intrinsic(vmIntrinsics::ID iid, } Klass* Method::check_non_bcp_klass(Klass* klass) { - if (klass != NULL && Klass::cast(klass)->class_loader() != NULL) { - if (Klass::cast(klass)->oop_is_objArray()) + if (klass != NULL && klass->class_loader() != NULL) { + if (klass->oop_is_objArray()) klass = ObjArrayKlass::cast(klass)->bottom_klass(); return klass; } diff --git a/hotspot/src/share/vm/oops/objArrayKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlass.cpp index 925e04c688c..6260c05fcfb 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp @@ -81,7 +81,7 @@ Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data, Array* element_supers = element_klass->secondary_supers(); for( int i = element_supers->length()-1; i >= 0; i-- ) { Klass* elem_super = element_supers->at(i); - if (Klass::cast(elem_super)->array_klass_or_null() == NULL) { + if (elem_super->array_klass_or_null() == NULL) { supers_exist = false; break; } @@ -172,7 +172,7 @@ ObjArrayKlass::ObjArrayKlass(int n, KlassHandle element_klass, Symbol* name) : A } else { bk = element_klass(); } - assert(bk != NULL && (Klass::cast(bk)->oop_is_instance() || Klass::cast(bk)->oop_is_typeArray()), "invalid bottom klass"); + assert(bk != NULL && (bk->oop_is_instance() || bk->oop_is_typeArray()), "invalid bottom klass"); this->set_bottom_klass(bk); this->set_class_loader_data(bk->class_loader_data()); @@ -254,7 +254,7 @@ template void ObjArrayKlass::do_copy(arrayOop s, T* src, // We have to make sure all elements conform to the destination array Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass(); Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass(); - if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) { + if (stype == bound || stype->is_subtype_of(bound)) { // elements are guaranteed to be subtypes, so no check necessary bs->write_ref_array_pre(dst, length); Copy::conjoint_oops_atomic(src, dst, length); @@ -271,7 +271,7 @@ template void ObjArrayKlass::do_copy(arrayOop s, T* src, oop new_val = element_is_null ? oop(NULL) : oopDesc::decode_heap_oop_not_null(element); if (element_is_null || - Klass::cast((new_val->klass()))->is_subtype_of(bound)) { + (new_val->klass())->is_subtype_of(bound)) { bs->write_ref_field_pre(p, new_val); *p = *from; } else { @@ -381,7 +381,7 @@ bool ObjArrayKlass::can_be_primary_super_slow() const { GrowableArray* ObjArrayKlass::compute_secondary_supers(int num_extra_slots) { // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... }; - Array* elem_supers = Klass::cast(element_klass())->secondary_supers(); + Array* elem_supers = element_klass()->secondary_supers(); int num_elem_supers = elem_supers == NULL ? 0 : elem_supers->length(); int num_secondaries = num_extra_slots + 2 + num_elem_supers; if (num_secondaries == 2) { @@ -411,7 +411,7 @@ bool ObjArrayKlass::compute_is_subtype_of(Klass* k) { } void ObjArrayKlass::initialize(TRAPS) { - Klass::cast(bottom_klass())->initialize(THREAD); // dispatches to either InstanceKlass or TypeArrayKlass + bottom_klass()->initialize(THREAD); // dispatches to either InstanceKlass or TypeArrayKlass } #define ObjArrayKlass_SPECIALIZED_OOP_ITERATE(T, a, p, do_oop) \ @@ -607,7 +607,7 @@ jint ObjArrayKlass::compute_modifier_flags(TRAPS) const { return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; } // Return the flags of the bottom element type. - jint element_flags = Klass::cast(bottom_klass())->compute_modifier_flags(CHECK_0); + jint element_flags = bottom_klass()->compute_modifier_flags(CHECK_0); return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED)) | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL); @@ -686,7 +686,7 @@ void ObjArrayKlass::verify_on(outputStream* st) { guarantee(element_klass()->is_klass(), "should be klass"); guarantee(bottom_klass()->is_metadata(), "should be in metaspace"); guarantee(bottom_klass()->is_klass(), "should be klass"); - Klass* bk = Klass::cast(bottom_klass()); + Klass* bk = bottom_klass(); guarantee(bk->oop_is_instance() || bk->oop_is_typeArray(), "invalid bottom klass"); } diff --git a/hotspot/src/share/vm/oops/objArrayKlass.hpp b/hotspot/src/share/vm/oops/objArrayKlass.hpp index 7cb778e77f0..2234aa8314d 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.hpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp @@ -74,7 +74,7 @@ class ObjArrayKlass : public ArrayKlass { void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); // Compute protection domain - oop protection_domain() { return Klass::cast(bottom_klass())->protection_domain(); } + oop protection_domain() { return bottom_klass()->protection_domain(); } private: // Either oop or narrowOop depending on UseCompressedOops. diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp index 51987e25e32..fb90705726e 100644 --- a/hotspot/src/share/vm/opto/runtime.cpp +++ b/hotspot/src/share/vm/opto/runtime.cpp @@ -236,7 +236,7 @@ JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, JavaThread* thre assert(check_compiled_frame(thread), "incorrect caller"); // These checks are cheap to make and support reflective allocation. - int lh = Klass::cast(klass)->layout_helper(); + int lh = klass->layout_helper(); if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) { KlassHandle kh(THREAD, klass); @@ -283,7 +283,7 @@ JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, JavaT // Scavenge and allocate an instance. oop result; - if (Klass::cast(array_type)->oop_is_typeArray()) { + if (array_type->oop_is_typeArray()) { // The oopFactory likes to work with the element type. // (We could bypass the oopFactory, since it doesn't add much value.) BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type(); @@ -321,7 +321,7 @@ JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len // Scavenge and allocate an instance. oop result; - assert(Klass::cast(array_type)->oop_is_typeArray(), "should be called only for type array"); + assert(array_type->oop_is_typeArray(), "should be called only for type array"); // The oopFactory likes to work with the element type. BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type(); result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD); diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index aeb62798ba1..ab8b3baeaaf 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -233,13 +233,13 @@ bool jfieldIDWorkaround::is_valid_jfieldID(Klass* k, jfieldID id) { intptr_t jfieldIDWorkaround::encode_klass_hash(Klass* k, intptr_t offset) { if (offset <= small_offset_mask) { Klass* field_klass = k; - Klass* super_klass = Klass::cast(field_klass)->super(); + Klass* super_klass = field_klass->super(); // With compressed oops the most super class with nonstatic fields would // be the owner of fields embedded in the header. while (InstanceKlass::cast(super_klass)->has_nonstatic_fields() && InstanceKlass::cast(super_klass)->contains_field_offset(offset)) { field_klass = super_klass; // super contains the field also - super_klass = Klass::cast(field_klass)->super(); + super_klass = field_klass->super(); } debug_only(No_Safepoint_Verifier nosafepoint;) uintptr_t klass_hash = field_klass->identity_hash(); @@ -249,7 +249,7 @@ intptr_t jfieldIDWorkaround::encode_klass_hash(Klass* k, intptr_t offset) { #ifndef PRODUCT { ResourceMark rm; - warning("VerifyJNIFields: long offset %d in %s", offset, Klass::cast(k)->external_name()); + warning("VerifyJNIFields: long offset %d in %s", offset, k->external_name()); } #endif #endif @@ -265,7 +265,7 @@ bool jfieldIDWorkaround::klass_hash_ok(Klass* k, jfieldID id) { // Could use a non-blocking query for identity_hash here... if ((k->identity_hash() & klass_mask) == klass_hash) return true; - k = Klass::cast(k)->super(); + k = k->super(); } while (k != NULL); return false; } @@ -283,7 +283,7 @@ void jfieldIDWorkaround::verify_instance_jfieldID(Klass* k, jfieldID id) { #ifndef PRODUCT if (Verbose) { ResourceMark rm; - warning("VerifyJNIFields: unverified offset %d for %s", offset, Klass::cast(k)->external_name()); + warning("VerifyJNIFields: unverified offset %d for %s", offset, k->external_name()); } #endif #endif @@ -415,7 +415,7 @@ JNI_ENTRY(jclass, jni_DefineClass(JNIEnv *env, const char *name, jobject loaderR } cls = (jclass)JNIHandles::make_local( - env, Klass::cast(k)->java_mirror()); + env, k->java_mirror()); return cls; JNI_END @@ -536,7 +536,7 @@ JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method)) KlassHandle k1(THREAD, k); // Make sure class is initialized before handing id's out to methods - Klass::cast(k1())->initialize(CHECK_NULL); + k1()->initialize(CHECK_NULL); Method* m = InstanceKlass::cast(k1())->method_with_idnum(slot); ret = m==NULL? NULL : m->jmethod_id(); // return NULL if reflected method deleted return ret; @@ -569,7 +569,7 @@ JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field)) KlassHandle k1(THREAD, k); // Make sure class is initialized before handing id's out to fields - Klass::cast(k1())->initialize(CHECK_NULL); + k1()->initialize(CHECK_NULL); // First check if this is a static field if (modifiers & JVM_ACC_STATIC) { @@ -648,17 +648,17 @@ JNI_ENTRY(jclass, jni_GetSuperclass(JNIEnv *env, jclass sub)) // interfaces return NULL // proper classes return Klass::super() Klass* k = java_lang_Class::as_Klass(mirror); - if (Klass::cast(k)->is_interface()) return NULL; + if (k->is_interface()) return NULL; // return mirror for superclass - Klass* super = Klass::cast(k)->java_super(); + Klass* super = k->java_super(); // super2 is the value computed by the compiler's getSuperClass intrinsic: - debug_only(Klass* super2 = ( Klass::cast(k)->oop_is_array() + debug_only(Klass* super2 = ( k->oop_is_array() ? SystemDictionary::Object_klass() - : Klass::cast(k)->super() ) ); + : k->super() ) ); assert(super == super2, "java_super computation depends on interface, array, other super"); - obj = (super == NULL) ? NULL : (jclass) JNIHandles::make_local(Klass::cast(super)->java_mirror()); + obj = (super == NULL) ? NULL : (jclass) JNIHandles::make_local(super->java_mirror()); return obj; JNI_END @@ -686,7 +686,7 @@ JNI_QUICK_ENTRY(jboolean, jni_IsAssignableFrom(JNIEnv *env, jclass sub, jclass s Klass* sub_klass = java_lang_Class::as_Klass(sub_mirror); Klass* super_klass = java_lang_Class::as_Klass(super_mirror); assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom"); - jboolean ret = Klass::cast(sub_klass)->is_subtype_of(super_klass) ? + jboolean ret = sub_klass->is_subtype_of(super_klass) ? JNI_TRUE : JNI_FALSE; #ifndef USDT2 DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); @@ -820,7 +820,7 @@ JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env)) ResourceMark rm(THREAD); jio_fprintf(defaultStream::error_stream(), ". Uncaught exception of type %s.", - Klass::cast(ex->klass())->external_name()); + ex->klass()->external_name()); } } } @@ -1358,7 +1358,7 @@ static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receive Method* m = Method::resolve_jmethod_id(method_id); number_of_parameters = m->size_of_parameters(); Klass* holder = m->method_holder(); - if (!(Klass::cast(holder))->is_interface()) { + if (!(holder)->is_interface()) { // non-interface call -- for that little speed boost, don't handlize debug_only(No_Safepoint_Verifier nosafepoint;) if (call_type == JNI_VIRTUAL) { @@ -1423,7 +1423,7 @@ static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receive static instanceOop alloc_object(jclass clazz, TRAPS) { KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); - Klass::cast(k())->check_valid_for_instantiation(false, CHECK_NULL); + k()->check_valid_for_instantiation(false, CHECK_NULL); InstanceKlass::cast(k())->initialize(CHECK_NULL); instanceOop ih = InstanceKlass::cast(k())->allocate_instance(THREAD); return ih; @@ -1545,7 +1545,7 @@ JNI_ENTRY(jclass, jni_GetObjectClass(JNIEnv *env, jobject obj)) #endif /* USDT2 */ Klass* k = JNIHandles::resolve_non_null(obj)->klass(); jclass ret = - (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); + (jclass) JNIHandles::make_local(env, k->java_mirror()); #ifndef USDT2 DTRACE_PROBE1(hotspot_jni, GetObjectClass__return, ret); #else /* USDT2 */ @@ -1610,7 +1610,7 @@ static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str, // Make sure class is linked and initialized before handing id's out to // Method*s. - Klass::cast(klass())->initialize(CHECK_NULL); + klass()->initialize(CHECK_NULL); Method* m; if (name == vmSymbols::object_initializer_name() || @@ -2426,7 +2426,7 @@ JNI_ENTRY(ResultType, \ JNI_ArgumentPusherVaArg ap(methodID, args); \ /* Make sure class is initialized before trying to invoke its method */ \ KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); \ - Klass::cast(k())->initialize(CHECK_0); \ + k()->initialize(CHECK_0); \ jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ va_end(args); \ ret = jvalue.get_##ResultType(); \ @@ -2611,10 +2611,10 @@ JNI_ENTRY(jfieldID, jni_GetFieldID(JNIEnv *env, jclass clazz, KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); // Make sure class is initialized before handing id's out to fields - Klass::cast(k())->initialize(CHECK_NULL); + k()->initialize(CHECK_NULL); fieldDescriptor fd; - if (!Klass::cast(k())->oop_is_instance() || + if (!k()->oop_is_instance() || !InstanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) { THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); } @@ -2976,10 +2976,10 @@ JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz, KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); // Make sure class is initialized before handing id's out to static fields - Klass::cast(k())->initialize(CHECK_NULL); + k()->initialize(CHECK_NULL); fieldDescriptor fd; - if (!Klass::cast(k())->oop_is_instance() || + if (!k()->oop_is_instance() || !InstanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) { THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); } @@ -3439,7 +3439,7 @@ JNI_ENTRY(jobjectArray, jni_NewObjectArray(JNIEnv *env, jsize length, jclass ele jobjectArray ret = NULL; DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret); KlassHandle ek(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass))); - Klass* ako = Klass::cast(ek())->array_klass(CHECK_NULL); + Klass* ako = ek()->array_klass(CHECK_NULL); KlassHandle ak = KlassHandle(THREAD, ako); ObjArrayKlass::cast(ak())->initialize(CHECK_NULL); objArrayOop result = ObjArrayKlass::cast(ak())->allocate(length, CHECK_NULL); @@ -3970,7 +3970,7 @@ static Method* find_prefixed_native(KlassHandle k, if (trial_name == NULL) { continue; // no such symbol, so this prefix wasn't used, try the next prefix } - method = Klass::cast(k())->lookup_method(trial_name, signature); + method = k()->lookup_method(trial_name, signature); if (method == NULL) { continue; // signature doesn't match, try the next prefix } @@ -3987,12 +3987,12 @@ static Method* find_prefixed_native(KlassHandle k, } static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, address entry, TRAPS) { - Method* method = Klass::cast(k())->lookup_method(name, signature); + Method* method = k()->lookup_method(name, signature); if (method == NULL) { ResourceMark rm; stringStream st; st.print("Method %s name or signature does not match", - Method::name_and_sig_as_C_string(Klass::cast(k()), name, signature)); + Method::name_and_sig_as_C_string(k(), name, signature)); THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); } if (!method->is_native()) { @@ -4002,7 +4002,7 @@ static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, addr ResourceMark rm; stringStream st; st.print("Method %s is not declared as native", - Method::name_and_sig_as_C_string(Klass::cast(k()), name, signature)); + Method::name_and_sig_as_C_string(k(), name, signature)); THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); } } @@ -4058,7 +4058,7 @@ JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz, if (name == NULL || signature == NULL) { ResourceMark rm; stringStream st; - st.print("Method %s.%s%s not found", Klass::cast(h_k())->external_name(), meth_name, meth_sig); + st.print("Method %s.%s%s not found", h_k()->external_name(), meth_name, meth_sig); // Must return negative value on failure THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), -1); } @@ -4084,7 +4084,7 @@ JNI_ENTRY(jint, jni_UnregisterNatives(JNIEnv *env, jclass clazz)) #endif /* USDT2 */ Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); //%note jni_2 - if (Klass::cast(k)->oop_is_instance()) { + if (k->oop_is_instance()) { for (int index = 0; index < InstanceKlass::cast(k)->methods()->length(); index++) { Method* m = InstanceKlass::cast(k)->methods()->at(index); if (m->is_native()) { diff --git a/hotspot/src/share/vm/prims/jniCheck.cpp b/hotspot/src/share/vm/prims/jniCheck.cpp index aa8475f065f..ad738b85ef9 100644 --- a/hotspot/src/share/vm/prims/jniCheck.cpp +++ b/hotspot/src/share/vm/prims/jniCheck.cpp @@ -383,7 +383,7 @@ void jniCheck::validate_throwable_klass(JavaThread* thr, Klass* klass) { ASSERT_OOPS_ALLOWED; assert(klass != NULL, "klass argument must have a value"); - if (!Klass::cast(klass)->oop_is_instance() || + if (!klass->oop_is_instance() || !InstanceKlass::cast(klass)->is_subclass_of(SystemDictionary::Throwable_klass())) { ReportJNIFatalError(thr, fatal_class_not_a_throwable_class); } diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index 9b6f05f35d5..c381674ffb5 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -305,7 +305,7 @@ JVM_ENTRY(void, JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src assert(s->is_oop(), "JVM_ArrayCopy: src not an oop"); assert(d->is_oop(), "JVM_ArrayCopy: dst not an oop"); // Do copy - Klass::cast(s->klass())->copy_array(s, src_pos, d, dst_pos, length, thread); + s->klass()->copy_array(s, src_pos, d, dst_pos, length, thread); JVM_END @@ -675,7 +675,7 @@ JVM_END JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth)) JVMWrapper("JVM_GetCallerClass"); Klass* k = thread->security_get_caller_class(depth); - return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); + return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror()); JVM_END @@ -739,7 +739,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env, if (TraceClassResolution) { trace_class_resolution(k); } - return (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); + return (jclass) JNIHandles::make_local(env, k->java_mirror()); JVM_END JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, @@ -785,8 +785,8 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, oop class_loader = NULL; oop protection_domain = NULL; if (from_class != NULL) { - class_loader = Klass::cast(from_class)->class_loader(); - protection_domain = Klass::cast(from_class)->protection_domain(); + class_loader = from_class->class_loader(); + protection_domain = from_class->protection_domain(); } Handle h_loader(THREAD, class_loader); Handle h_prot (THREAD, protection_domain); @@ -798,11 +798,11 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, ResourceMark rm; oop from_mirror = JNIHandles::resolve_non_null(from); Klass* from_class = java_lang_Class::as_Klass(from_mirror); - const char * from_name = Klass::cast(from_class)->external_name(); + const char * from_name = from_class->external_name(); oop mirror = JNIHandles::resolve_non_null(result); Klass* to_class = java_lang_Class::as_Klass(mirror); - const char * to = Klass::cast(to_class)->external_name(); + const char * to = to_class->external_name(); tty->print("RESOLVE %s %s (verification)\n", from_name, to); } @@ -875,7 +875,7 @@ static jclass jvm_define_class_common(JNIEnv *env, const char *name, trace_class_resolution(k); } - return (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); + return (jclass) JNIHandles::make_local(env, k->java_mirror()); } @@ -936,7 +936,7 @@ JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name) CHECK_NULL); return (k == NULL) ? NULL : - (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); + (jclass) JNIHandles::make_local(env, k->java_mirror()); JVM_END @@ -954,7 +954,7 @@ JVM_ENTRY(jstring, JVM_GetClassName(JNIEnv *env, jclass cls)) // Consider caching interned string in Klass Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); assert(k->is_klass(), "just checking"); - name = Klass::cast(k)->external_name(); + name = k->external_name(); } oop result = StringTable::intern((char*) name, CHECK_NULL); return (jstring) JNIHandles::make_local(env, result); @@ -991,12 +991,12 @@ JVM_ENTRY(jobjectArray, JVM_GetClassInterfaces(JNIEnv *env, jclass cls)) // Regular instance klass, fill in all local interfaces for (int index = 0; index < size; index++) { Klass* k = InstanceKlass::cast(klass())->local_interfaces()->at(index); - result->obj_at_put(index, Klass::cast(k)->java_mirror()); + result->obj_at_put(index, k->java_mirror()); } } else { // All arrays implement java.lang.Cloneable and java.io.Serializable - result->obj_at_put(0, Klass::cast(SystemDictionary::Cloneable_klass())->java_mirror()); - result->obj_at_put(1, Klass::cast(SystemDictionary::Serializable_klass())->java_mirror()); + result->obj_at_put(0, SystemDictionary::Cloneable_klass()->java_mirror()); + result->obj_at_put(1, SystemDictionary::Serializable_klass()->java_mirror()); } return (jobjectArray) JNIHandles::make_local(env, result()); JVM_END @@ -1008,7 +1008,7 @@ JVM_ENTRY(jobject, JVM_GetClassLoader(JNIEnv *env, jclass cls)) return NULL; } Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); - oop loader = Klass::cast(k)->class_loader(); + oop loader = k->class_loader(); return JNIHandles::make_local(env, loader); JVM_END @@ -1020,8 +1020,8 @@ JVM_QUICK_ENTRY(jboolean, JVM_IsInterface(JNIEnv *env, jclass cls)) return JNI_FALSE; } Klass* k = java_lang_Class::as_Klass(mirror); - jboolean result = Klass::cast(k)->is_interface(); - assert(!result || Klass::cast(k)->oop_is_instance(), + jboolean result = k->is_interface(); + assert(!result || k->oop_is_instance(), "all interfaces are instance types"); // The compiler intrinsic for isInterface tests the // Klass::_access_flags bits in the same way. @@ -1039,7 +1039,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassSigners(JNIEnv *env, jclass cls)) Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); objArrayOop signers = NULL; - if (Klass::cast(k)->oop_is_instance()) { + if (k->oop_is_instance()) { signers = InstanceKlass::cast(k)->signers(); } @@ -1066,7 +1066,7 @@ JVM_ENTRY(void, JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signer // Signers are only set once, ClassLoader.java, and thus shouldn't // be called with an array. Only the bootstrap loader creates arrays. Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); - if (Klass::cast(k)->oop_is_instance()) { + if (k->oop_is_instance()) { InstanceKlass::cast(k)->set_signers(objArrayOop(JNIHandles::resolve(signers))); } } @@ -1085,7 +1085,7 @@ JVM_ENTRY(jobject, JVM_GetProtectionDomain(JNIEnv *env, jclass cls)) } Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); - return (jobject) JNIHandles::make_local(env, Klass::cast(k)->protection_domain()); + return (jobject) JNIHandles::make_local(env, k->protection_domain()); JVM_END @@ -1101,7 +1101,7 @@ JVM_ENTRY(void, JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protect Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); // cls won't be an array, as this called only from ClassLoader.defineClass - if (Klass::cast(k)->oop_is_instance()) { + if (k->oop_is_instance()) { oop pd = JNIHandles::resolve(protection_domain); assert(pd == NULL || pd->is_oop(), "just checking"); InstanceKlass::cast(k)->set_protection_domain(pd); @@ -1124,7 +1124,7 @@ JVM_ENTRY(jobject, JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, job Handle object (THREAD, JNIHandles::resolve(action)); // get run() method - Method* m_oop = Klass::cast(object->klass())->uncached_lookup_method( + Method* m_oop = object->klass()->uncached_lookup_method( vmSymbols::run_method_name(), vmSymbols::void_object_signature()); methodHandle m (THREAD, m_oop); @@ -1267,7 +1267,7 @@ JVM_END JVM_QUICK_ENTRY(jboolean, JVM_IsArrayClass(JNIEnv *env, jclass cls)) JVMWrapper("JVM_IsArrayClass"); Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); - return (k != NULL) && Klass::cast(k)->oop_is_array() ? true : false; + return (k != NULL) && k->oop_is_array() ? true : false; JVM_END @@ -1293,7 +1293,7 @@ JVM_ENTRY(jint, JVM_GetClassModifiers(JNIEnv *env, jclass cls)) return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; } - Klass* k = Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); + Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); debug_only(int computed_modifiers = k->compute_modifier_flags(CHECK_0)); assert(k->modifier_flags() == computed_modifiers, "modifiers cache is OK"); return k->modifier_flags(); @@ -1308,7 +1308,7 @@ JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)) // of an InstanceKlass if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || - ! Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_instance()) { + ! java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_instance()) { oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); return (jobjectArray)JNIHandles::make_local(env, result); } @@ -1372,7 +1372,7 @@ JVM_ENTRY(jclass, JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)) { // ofClass is a reference to a java_lang_Class object. if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || - ! Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_instance()) { + ! java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_instance()) { return NULL; } @@ -1382,7 +1382,7 @@ JVM_ENTRY(jclass, JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)) )->compute_enclosing_class(&inner_is_member, CHECK_NULL); if (outer_klass == NULL) return NULL; // already a top-level class if (!inner_is_member) return NULL; // an anonymous class (inside a method) - return (jclass) JNIHandles::make_local(env, Klass::cast(outer_klass)->java_mirror()); + return (jclass) JNIHandles::make_local(env, outer_klass->java_mirror()); } JVM_END @@ -1452,7 +1452,7 @@ JVM_ENTRY(jstring, JVM_GetClassSignature(JNIEnv *env, jclass cls)) // Return null for arrays and primatives if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); - if (Klass::cast(k)->oop_is_instance()) { + if (k->oop_is_instance()) { Symbol* sym = InstanceKlass::cast(k)->generic_signature(); if (sym == NULL) return NULL; Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); @@ -1470,7 +1470,7 @@ JVM_ENTRY(jbyteArray, JVM_GetClassAnnotations(JNIEnv *env, jclass cls)) // Return null for arrays and primitives if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); - if (Klass::cast(k)->oop_is_instance()) { + if (k->oop_is_instance()) { typeArrayOop a = Annotations::make_java_array(InstanceKlass::cast(k)->class_annotations(), CHECK_NULL); return (jbyteArray) JNIHandles::make_local(env, a); } @@ -1583,7 +1583,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, // Exclude primitive types and array types if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || - Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_array()) { + java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) { // Return empty array oop res = oopFactory::new_objArray(SystemDictionary::reflect_Field_klass(), 0, CHECK_NULL); return (jobjectArray) JNIHandles::make_local(env, res); @@ -1646,7 +1646,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, // Exclude primitive types and array types if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) - || Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_array()) { + || java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) { // Return empty array oop res = oopFactory::new_objArray(SystemDictionary::reflect_Method_klass(), 0, CHECK_NULL); return (jobjectArray) JNIHandles::make_local(env, res); @@ -1698,7 +1698,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofC // Exclude primitive types and array types if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) - || Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_array()) { + || java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) { // Return empty array oop res = oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), 0 , CHECK_NULL); return (jobjectArray) JNIHandles::make_local(env, res); @@ -1751,7 +1751,7 @@ JVM_ENTRY(jint, JVM_GetClassAccessFlags(JNIEnv *env, jclass cls)) return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; } - Klass* k = Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); + Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); return k->access_flags().as_int() & JVM_ACC_WRITTEN_FLAGS; } JVM_END @@ -1767,7 +1767,7 @@ JVM_ENTRY(jobject, JVM_GetClassConstantPool(JNIEnv *env, jclass cls)) // Return null for primitives and arrays if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); - if (Klass::cast(k)->oop_is_instance()) { + if (k->oop_is_instance()) { instanceKlassHandle k_h(THREAD, k); Handle jcp = sun_reflect_ConstantPool::create(CHECK_NULL); sun_reflect_ConstantPool::set_cp(jcp(), k_h->constants()); @@ -2043,12 +2043,12 @@ JVM_ENTRY(jboolean, JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclas if (java_lang_Class::is_primitive(r)) return false; Klass* k = java_lang_Class::as_Klass(r); - assert(Klass::cast(k)->oop_is_instance(), "must be an instance klass"); - if (! Klass::cast(k)->oop_is_instance()) return false; + assert(k->oop_is_instance(), "must be an instance klass"); + if (! k->oop_is_instance()) return false; ResourceMark rm(THREAD); - const char* name = Klass::cast(k)->name()->as_C_string(); - bool system_class = Klass::cast(k)->class_loader() == NULL; + const char* name = k->name()->as_C_string(); + bool system_class = k->class_loader() == NULL; return JavaAssertions::enabled(name, system_class); JVM_END @@ -2079,7 +2079,7 @@ JVM_ENTRY(const char*, JVM_GetClassNameUTF(JNIEnv *env, jclass cls)) JVMWrapper("JVM_GetClassNameUTF"); Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); - return Klass::cast(k)->name()->as_utf8(); + return k->name()->as_utf8(); JVM_END @@ -2089,7 +2089,7 @@ JVM_QUICK_ENTRY(void, JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); // types will have length zero if this is not an InstanceKlass // (length is determined by call to JVM_GetClassCPEntriesCount) - if (Klass::cast(k)->oop_is_instance()) { + if (k->oop_is_instance()) { ConstantPool* cp = InstanceKlass::cast(k)->constants(); for (int index = cp->length() - 1; index >= 0; index--) { constantTag tag = cp->tag_at(index); @@ -2103,7 +2103,7 @@ JVM_QUICK_ENTRY(jint, JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)) JVMWrapper("JVM_GetClassCPEntriesCount"); Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); - if (!Klass::cast(k)->oop_is_instance()) + if (!k->oop_is_instance()) return 0; return InstanceKlass::cast(k)->constants()->length(); JVM_END @@ -2113,7 +2113,7 @@ JVM_QUICK_ENTRY(jint, JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)) JVMWrapper("JVM_GetClassFieldsCount"); Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); - if (!Klass::cast(k)->oop_is_instance()) + if (!k->oop_is_instance()) return 0; return InstanceKlass::cast(k)->java_fields_count(); JVM_END @@ -2123,7 +2123,7 @@ JVM_QUICK_ENTRY(jint, JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)) JVMWrapper("JVM_GetClassMethodsCount"); Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); - if (!Klass::cast(k)->oop_is_instance()) + if (!k->oop_is_instance()) return 0; return InstanceKlass::cast(k)->methods()->length(); JVM_END @@ -3123,7 +3123,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env)) // Fill in mirrors corresponding to method holders int index = 0; while (first != NULL) { - result->obj_at_put(index++, Klass::cast(first->klass())->java_mirror()); + result->obj_at_put(index++, first->klass()->java_mirror()); first = first->next; } assert(index == depth, "just checking"); @@ -3217,7 +3217,7 @@ bool force_verify_field_access(Klass* current_class, Klass* field_class, AccessF if (access.is_protected()) { // See if current_class is a subclass of field_class - if (Klass::cast(current_class)->is_subclass_of(field_class)) { + if (current_class->is_subclass_of(field_class)) { return true; } } @@ -3241,8 +3241,8 @@ JVM_ENTRY(jobject, JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass c } // Arrays not allowed here, must use JVM_AllocateNewArray - if (Klass::cast(java_lang_Class::as_Klass(curr_mirror))->oop_is_array() || - Klass::cast(java_lang_Class::as_Klass(init_mirror))->oop_is_array()) { + if (java_lang_Class::as_Klass(curr_mirror)->oop_is_array() || + java_lang_Class::as_Klass(init_mirror)->oop_is_array()) { ResourceMark rm(THREAD); THROW_0(vmSymbols::java_lang_InvalidClassException()); } @@ -3264,7 +3264,7 @@ JVM_ENTRY(jobject, JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass c if (m.is_null()) { ResourceMark rm(THREAD); THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(init_klass()), + Method::name_and_sig_as_C_string(init_klass(), vmSymbols::object_initializer_name(), vmSymbols::void_method_signature())); } @@ -4245,7 +4245,7 @@ JVM_ENTRY(jobjectArray, JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)) return NULL; } Klass* k = java_lang_Class::as_Klass(mirror()); - if (!Klass::cast(k)->oop_is_instance()) { + if (!k->oop_is_instance()) { return NULL; } instanceKlassHandle ik_h(THREAD, k); @@ -4256,7 +4256,7 @@ JVM_ENTRY(jobjectArray, JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)) objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL); objArrayHandle dest(THREAD, dest_o); Klass* enc_k = ik_h->constants()->klass_at(encl_method_class_idx, CHECK_NULL); - dest->obj_at_put(0, Klass::cast(enc_k)->java_mirror()); + dest->obj_at_put(0, enc_k->java_mirror()); int encl_method_method_idx = ik_h->enclosing_method_method_index(); if (encl_method_method_idx != 0) { Symbol* sym = ik_h->constants()->symbol_at( diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp index 5cdac08eb81..a456cacc6c1 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp @@ -2116,7 +2116,7 @@ JvmtiEnv::GetClassSignature(oop k_mirror, char** signature_ptr, char** generic_p result[0] = tchar; result[1] = '\0'; } else { - const char* class_sig = Klass::cast(k)->signature_name(); + const char* class_sig = k->signature_name(); result = (char *) jvmtiMalloc(strlen(class_sig)+1); strcpy(result, class_sig); } @@ -2124,7 +2124,7 @@ JvmtiEnv::GetClassSignature(oop k_mirror, char** signature_ptr, char** generic_p } if (generic_ptr != NULL) { *generic_ptr = NULL; - if (!isPrimitive && Klass::cast(k)->oop_is_instance()) { + if (!isPrimitive && k->oop_is_instance()) { Symbol* soo = InstanceKlass::cast(k)->generic_signature(); if (soo != NULL) { const char *gen_sig = soo->as_C_string(); @@ -2155,7 +2155,7 @@ JvmtiEnv::GetClassStatus(oop k_mirror, jint* status_ptr) { } else { Klass* k = java_lang_Class::as_Klass(k_mirror); NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); - result = Klass::cast(k)->jvmti_class_status(); + result = k->jvmti_class_status(); } *status_ptr = result; @@ -2173,7 +2173,7 @@ JvmtiEnv::GetSourceFileName(oop k_mirror, char** source_name_ptr) { Klass* k_klass = java_lang_Class::as_Klass(k_mirror); NULL_CHECK(k_klass, JVMTI_ERROR_INVALID_CLASS); - if (!Klass::cast(k_klass)->oop_is_instance()) { + if (!k_klass->oop_is_instance()) { return JVMTI_ERROR_ABSENT_INFORMATION; } @@ -2200,7 +2200,7 @@ JvmtiEnv::GetClassModifiers(oop k_mirror, jint* modifiers_ptr) { if (!java_lang_Class::is_primitive(k_mirror)) { Klass* k = java_lang_Class::as_Klass(k_mirror); NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); - result = Klass::cast(k)->compute_modifier_flags(current_thread); + result = k->compute_modifier_flags(current_thread); JavaThread* THREAD = current_thread; // pass to macros if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; @@ -2208,7 +2208,7 @@ JvmtiEnv::GetClassModifiers(oop k_mirror, jint* modifiers_ptr) { }; // Reset the deleted ACC_SUPER bit ( deleted in compute_modifier_flags()). - if(Klass::cast(k)->is_super()) { + if(k->is_super()) { result |= JVM_ACC_SUPER; } } else { @@ -2237,11 +2237,11 @@ JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** meth NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); // Return CLASS_NOT_PREPARED error as per JVMTI spec. - if (!(Klass::cast(k)->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) { + if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) { return JVMTI_ERROR_CLASS_NOT_PREPARED; } - if (!Klass::cast(k)->oop_is_instance()) { + if (!k->oop_is_instance()) { *method_count_ptr = 0; *methods_ptr = (jmethodID*) jvmtiMalloc(0 * sizeof(jmethodID)); return JVMTI_ERROR_NONE; @@ -2293,11 +2293,11 @@ JvmtiEnv::GetClassFields(oop k_mirror, jint* field_count_ptr, jfieldID** fields_ NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); // Return CLASS_NOT_PREPARED error as per JVMTI spec. - if (!(Klass::cast(k)->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) { + if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) { return JVMTI_ERROR_CLASS_NOT_PREPARED; } - if (!Klass::cast(k)->oop_is_instance()) { + if (!k->oop_is_instance()) { *field_count_ptr = 0; *fields_ptr = (jfieldID*) jvmtiMalloc(0 * sizeof(jfieldID)); return JVMTI_ERROR_NONE; @@ -2348,10 +2348,10 @@ JvmtiEnv::GetImplementedInterfaces(oop k_mirror, jint* interface_count_ptr, jcla NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); // Return CLASS_NOT_PREPARED error as per JVMTI spec. - if (!(Klass::cast(k)->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) + if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) return JVMTI_ERROR_CLASS_NOT_PREPARED; - if (!Klass::cast(k)->oop_is_instance()) { + if (!k->oop_is_instance()) { *interface_count_ptr = 0; *interfaces_ptr = (jclass*) jvmtiMalloc(0 * sizeof(jclass)); return JVMTI_ERROR_NONE; @@ -2363,8 +2363,8 @@ JvmtiEnv::GetImplementedInterfaces(oop k_mirror, jint* interface_count_ptr, jcla for (int i_index = 0; i_index < result_length; i_index += 1) { Klass* klass_at = interface_list->at(i_index); assert(klass_at->is_klass(), "interfaces must be Klass*s"); - assert(Klass::cast(klass_at)->is_interface(), "interfaces must be interfaces"); - oop mirror_at = Klass::cast(klass_at)->java_mirror(); + assert(klass_at->is_interface(), "interfaces must be interfaces"); + oop mirror_at = klass_at->java_mirror(); Handle handle_at = Handle(current_thread, mirror_at); result_list[i_index] = (jclass) jni_reference(handle_at); } @@ -2468,7 +2468,7 @@ JvmtiEnv::IsInterface(oop k_mirror, jboolean* is_interface_ptr) { bool result = false; if (!java_lang_Class::is_primitive(k_mirror)) { Klass* k = java_lang_Class::as_Klass(k_mirror); - if (k != NULL && Klass::cast(k)->is_interface()) { + if (k != NULL && k->is_interface()) { result = true; } } @@ -2487,7 +2487,7 @@ JvmtiEnv::IsArrayClass(oop k_mirror, jboolean* is_array_class_ptr) { bool result = false; if (!java_lang_Class::is_primitive(k_mirror)) { Klass* k = java_lang_Class::as_Klass(k_mirror); - if (k != NULL && Klass::cast(k)->oop_is_array()) { + if (k != NULL && k->oop_is_array()) { result = true; } } @@ -2512,7 +2512,7 @@ JvmtiEnv::GetClassLoader(oop k_mirror, jobject* classloader_ptr) { Klass* k = java_lang_Class::as_Klass(k_mirror); NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); - oop result_oop = Klass::cast(k)->class_loader(); + oop result_oop = k->class_loader(); if (result_oop == NULL) { *classloader_ptr = (jclass) jni_reference(Handle()); return JVMTI_ERROR_NONE; @@ -2535,7 +2535,7 @@ JvmtiEnv::GetSourceDebugExtension(oop k_mirror, char** source_debug_extension_pt } Klass* k = java_lang_Class::as_Klass(k_mirror); NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); - if (!Klass::cast(k)->oop_is_instance()) { + if (!k->oop_is_instance()) { return JVMTI_ERROR_ABSENT_INFORMATION; } char* sde = InstanceKlass::cast(k)->source_debug_extension(); diff --git a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp index d6924fc426f..eed31268141 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp @@ -590,7 +590,7 @@ JvmtiEnvBase::vframeFor(JavaThread* java_thread, jint depth) { jclass JvmtiEnvBase::get_jni_class_non_null(Klass* k) { assert(k != NULL, "k != NULL"); - return (jclass)jni_reference(Klass::cast(k)->java_mirror()); + return (jclass)jni_reference(k->java_mirror()); } #ifndef JVMTI_KERNEL @@ -1365,7 +1365,7 @@ JvmtiEnvBase::check_top_frame(JavaThread* current_thread, JavaThread* java_threa // Method return type signature. char* ty_sign = 1 + strchr(signature->as_C_string(), ')'); - if (!VM_GetOrSetLocal::is_assignable(ty_sign, Klass::cast(ob_kh()), current_thread)) { + if (!VM_GetOrSetLocal::is_assignable(ty_sign, ob_kh(), current_thread)) { return JVMTI_ERROR_TYPE_MISMATCH; } *ret_ob_h = ob_h; diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp index 40e8e21159f..4e37135f389 100644 --- a/hotspot/src/share/vm/prims/jvmtiExport.cpp +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp @@ -196,7 +196,7 @@ public: jobject to_jobject(oop obj) { return JNIHandles::make_local(_thread,obj); } #endif - jclass to_jclass(Klass* klass) { return (klass == NULL ? NULL : (jclass)to_jobject(Klass::cast(klass)->java_mirror())); } + jclass to_jclass(Klass* klass) { return (klass == NULL ? NULL : (jclass)to_jobject(klass->java_mirror())); } jmethodID to_jmethodID(methodHandle method) { return method->jmethod_id(); } @@ -920,7 +920,7 @@ void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) { if (ets->is_enabled(JVMTI_EVENT_CLASS_LOAD)) { EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("JVMTI [%s] Evt Class Load sent %s", JvmtiTrace::safe_get_thread_name(thread), - kh()==NULL? "NULL" : Klass::cast(kh())->external_name() )); + kh()==NULL? "NULL" : kh()->external_name() )); JvmtiEnv *env = ets->get_env(); JvmtiClassEventMark jem(thread, kh()); @@ -949,7 +949,7 @@ void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) { if (ets->is_enabled(JVMTI_EVENT_CLASS_PREPARE)) { EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("JVMTI [%s] Evt Class Prepare sent %s", JvmtiTrace::safe_get_thread_name(thread), - kh()==NULL? "NULL" : Klass::cast(kh())->external_name() )); + kh()==NULL? "NULL" : kh()->external_name() )); JvmtiEnv *env = ets->get_env(); JvmtiClassEventMark jem(thread, kh()); @@ -979,12 +979,12 @@ void JvmtiExport::post_class_unload(Klass* klass) { for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled((jvmtiEvent)EXT_EVENT_CLASS_UNLOAD)) { EVT_TRACE(EXT_EVENT_CLASS_UNLOAD, ("JVMTI [?] Evt Class Unload sent %s", - kh()==NULL? "NULL" : Klass::cast(kh())->external_name() )); + kh()==NULL? "NULL" : kh()->external_name() )); // do everything manually, since this is a proxy - needs special care JNIEnv* jni_env = real_thread->jni_environment(); jthread jt = (jthread)JNIHandles::make_local(real_thread, real_thread->threadObj()); - jclass jk = (jclass)JNIHandles::make_local(real_thread, Klass::cast(kh())->java_mirror()); + jclass jk = (jclass)JNIHandles::make_local(real_thread, kh()->java_mirror()); // Before we call the JVMTI agent, we have to set the state in the // thread for which we are proxying. @@ -2121,7 +2121,7 @@ void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) { if (env->is_enabled(JVMTI_EVENT_VM_OBJECT_ALLOC)) { EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("JVMTI [%s] Evt vmobject alloc sent %s", JvmtiTrace::safe_get_thread_name(thread), - object==NULL? "NULL" : Klass::cast(java_lang_Class::as_Klass(object))->external_name())); + object==NULL? "NULL" : java_lang_Class::as_Klass(object)->external_name())); JvmtiVMObjectAllocEventMark jem(thread, h()); JvmtiJavaThreadEventTransition jet(thread); diff --git a/hotspot/src/share/vm/prims/jvmtiGetLoadedClasses.cpp b/hotspot/src/share/vm/prims/jvmtiGetLoadedClasses.cpp index 8473dd50bf2..51cfb384ac9 100644 --- a/hotspot/src/share/vm/prims/jvmtiGetLoadedClasses.cpp +++ b/hotspot/src/share/vm/prims/jvmtiGetLoadedClasses.cpp @@ -169,7 +169,7 @@ class JvmtiGetLoadedClassesClosure : public StackObj { static void increment(Klass* k) { JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); if (that->get_initiatingLoader() == NULL) { - for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) { + for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) { that->set_count(that->get_count() + 1); } } else if (k != NULL) { @@ -182,7 +182,7 @@ class JvmtiGetLoadedClassesClosure : public StackObj { JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); oop class_loader = loader_data->class_loader(); if (class_loader == JNIHandles::resolve(that->get_initiatingLoader())) { - for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) { + for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) { that->set_count(that->get_count() + 1); } } @@ -200,14 +200,14 @@ class JvmtiGetLoadedClassesClosure : public StackObj { JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); if (that->available()) { if (that->get_initiatingLoader() == NULL) { - for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) { - oop mirror = Klass::cast(l)->java_mirror(); + for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) { + oop mirror = l->java_mirror(); that->set_element(that->get_index(), mirror); that->set_index(that->get_index() + 1); } } else if (k != NULL) { // if initiating loader not null, just include the instance with 1 dimension - oop mirror = Klass::cast(k)->java_mirror(); + oop mirror = k->java_mirror(); that->set_element(that->get_index(), mirror); that->set_index(that->get_index() + 1); } @@ -219,8 +219,8 @@ class JvmtiGetLoadedClassesClosure : public StackObj { if (that->available()) { oop class_loader = loader_data->class_loader(); if (class_loader == JNIHandles::resolve(that->get_initiatingLoader())) { - for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) { - oop mirror = Klass::cast(l)->java_mirror(); + for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) { + oop mirror = l->java_mirror(); that->set_element(that->get_index(), mirror); that->set_index(that->get_index() + 1); } @@ -234,7 +234,7 @@ class JvmtiGetLoadedClassesClosure : public StackObj { static void increment_for_basic_type_arrays(Klass* k) { JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); assert(that != NULL, "no JvmtiGetLoadedClassesClosure"); - for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) { + for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) { that->set_count(that->get_count() + 1); } } @@ -244,8 +244,8 @@ class JvmtiGetLoadedClassesClosure : public StackObj { JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); assert(that != NULL, "no JvmtiGetLoadedClassesClosure"); assert(that->available(), "no list"); - for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) { - oop mirror = Klass::cast(l)->java_mirror(); + for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) { + oop mirror = l->java_mirror(); that->set_element(that->get_index(), mirror); that->set_index(that->get_index() + 1); } diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.cpp b/hotspot/src/share/vm/prims/jvmtiImpl.cpp index df5b145b9e0..4ff9bf3c5b4 100644 --- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp +++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp @@ -641,14 +641,14 @@ bool VM_GetOrSetLocal::is_assignable(const char* ty_sign, Klass* klass, Thread* int super_depth = klass->super_depth(); int idx; for (idx = 0; idx < super_depth; idx++) { - if (Klass::cast(klass->primary_super_of_depth(idx))->name() == ty_sym) { + if (klass->primary_super_of_depth(idx)->name() == ty_sym) { return true; } } // Compare secondary supers Array* sec_supers = klass->secondary_supers(); for (idx = 0; idx < sec_supers->length(); idx++) { - if (Klass::cast((Klass*) sec_supers->at(idx))->name() == ty_sym) { + if (((Klass*) sec_supers->at(idx))->name() == ty_sym) { return true; } } @@ -726,7 +726,7 @@ bool VM_GetOrSetLocal::check_slot_type(javaVFrame* jvf) { KlassHandle ob_kh = KlassHandle(cur_thread, obj->klass()); NULL_CHECK(ob_kh, (_result = JVMTI_ERROR_INVALID_OBJECT, false)); - if (!is_assignable(signature, Klass::cast(ob_kh()), cur_thread)) { + if (!is_assignable(signature, ob_kh(), cur_thread)) { _result = JVMTI_ERROR_TYPE_MISMATCH; return false; } diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp index 44be3d5f27b..e3653000fea 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -222,7 +222,7 @@ bool VM_RedefineClasses::is_modifiable_class(oop klass_mirror) { } Klass* the_class_oop = java_lang_Class::as_Klass(klass_mirror); // classes for arrays cannot be redefined - if (the_class_oop == NULL || !Klass::cast(the_class_oop)->oop_is_instance()) { + if (the_class_oop == NULL || !the_class_oop->oop_is_instance()) { return false; } return true; @@ -573,8 +573,8 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( // Check for NULL superclass first since this might be java.lang.Object if (the_class->super() != scratch_class->super() && (the_class->super() == NULL || scratch_class->super() == NULL || - Klass::cast(the_class->super())->name() != - Klass::cast(scratch_class->super())->name())) { + the_class->super()->name() != + scratch_class->super()->name())) { return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED; } @@ -592,8 +592,8 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED; } for (i = 0; i < n_intfs; i++) { - if (Klass::cast(k_interfaces->at(i))->name() != - Klass::cast(k_new_interfaces->at(i))->name()) { + if (k_interfaces->at(i)->name() != + k_new_interfaces->at(i)->name()) { return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED; } } @@ -2684,7 +2684,7 @@ void VM_RedefineClasses::adjust_cpool_cache_and_vtable(Klass* k_oop, // interface, then we have to call adjust_method_entries() for // every InstanceKlass that has an itable since there isn't a // subclass relationship between an interface and an InstanceKlass. - if (ik->itable_length() > 0 && (Klass::cast(_the_class_oop)->is_interface() + if (ik->itable_length() > 0 && (_the_class_oop->is_interface() || ik->is_subclass_of(_the_class_oop))) { // ik->itable() creates a wrapper object; rm cleans it up ResourceMark rm(THREAD); @@ -2929,7 +2929,7 @@ class TransferNativeFunctionRegistration { Symbol* signature) { TempNewSymbol name_symbol = SymbolTable::probe(name_str, (int)name_len); if (name_symbol != NULL) { - Method* method = Klass::cast(the_class())->lookup_method(name_symbol, signature); + Method* method = the_class()->lookup_method(name_symbol, signature); if (method != NULL) { // Even if prefixed, intermediate methods must exist. if (method->is_native()) { diff --git a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp index c3e744bd32e..3dbc70adf62 100644 --- a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp +++ b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp @@ -2774,7 +2774,7 @@ inline bool VM_HeapWalkOperation::iterate_over_array(oop o) { // a type array references its class inline bool VM_HeapWalkOperation::iterate_over_type_array(oop o) { Klass* k = o->klass(); - oop mirror = Klass::cast(k)->java_mirror(); + oop mirror = k->java_mirror(); if (!CallbackInvoker::report_class_reference(o, mirror)) { return false; } @@ -2823,7 +2823,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { // super (only if something more interesting than java.lang.Object) Klass* java_super = ik->java_super(); if (java_super != NULL && java_super != SystemDictionary::Object_klass()) { - oop super = Klass::cast(java_super)->java_mirror(); + oop super = java_super->java_mirror(); if (!CallbackInvoker::report_superclass_reference(mirror, super)) { return false; } @@ -2865,7 +2865,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { // If the entry is non-null it is resolved. if (entry == NULL) continue; } else { - entry = Klass::cast(pool->resolved_klass_at(i))->java_mirror(); + entry = pool->resolved_klass_at(i)->java_mirror(); } if (!CallbackInvoker::report_constant_pool_reference(mirror, entry, (jint)i)) { return false; @@ -2879,7 +2879,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { // but are specified by IterateOverReachableObjects and must be reported). Array* interfaces = ik->local_interfaces(); for (i = 0; i < interfaces->length(); i++) { - oop interf = Klass::cast((Klass*)interfaces->at(i))->java_mirror(); + oop interf = ((Klass*)interfaces->at(i))->java_mirror(); if (interf == NULL) { continue; } @@ -2928,7 +2928,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { // references from the class). inline bool VM_HeapWalkOperation::iterate_over_object(oop o) { // reference to the class - if (!CallbackInvoker::report_class_reference(o, Klass::cast(o->klass())->java_mirror())) { + if (!CallbackInvoker::report_class_reference(o, o->klass()->java_mirror())) { return false; } diff --git a/hotspot/src/share/vm/prims/jvmtiTrace.cpp b/hotspot/src/share/vm/prims/jvmtiTrace.cpp index 9a85e7f0be4..279e23ab3c6 100644 --- a/hotspot/src/share/vm/prims/jvmtiTrace.cpp +++ b/hotspot/src/share/vm/prims/jvmtiTrace.cpp @@ -292,7 +292,7 @@ const char * JvmtiTrace::get_class_name(oop k_mirror) { if (k_oop == NULL) { return "INVALID"; } - return Klass::cast(k_oop)->external_name(); + return k_oop->external_name(); } #endif /*JVMTI_TRACE */ diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp index 69139aeae3c..67e6f954c80 100644 --- a/hotspot/src/share/vm/prims/methodHandles.cpp +++ b/hotspot/src/share/vm/prims/methodHandles.cpp @@ -138,7 +138,7 @@ oop MethodHandles::init_MemberName(oop mname_oop, oop target_oop) { oop clazz = java_lang_reflect_Method::clazz(target_oop); int slot = java_lang_reflect_Method::slot(target_oop); Klass* k = java_lang_Class::as_Klass(clazz); - if (k != NULL && Klass::cast(k)->oop_is_instance()) { + if (k != NULL && k->oop_is_instance()) { Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); return init_method_MemberName(mname_oop, m, true, k); } @@ -146,7 +146,7 @@ oop MethodHandles::init_MemberName(oop mname_oop, oop target_oop) { oop clazz = java_lang_reflect_Constructor::clazz(target_oop); int slot = java_lang_reflect_Constructor::slot(target_oop); Klass* k = java_lang_Class::as_Klass(clazz); - if (k != NULL && Klass::cast(k)->oop_is_instance()) { + if (k != NULL && k->oop_is_instance()) { Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); return init_method_MemberName(mname_oop, m, false, k); } @@ -187,14 +187,14 @@ oop MethodHandles::init_method_MemberName(oop mname_oop, Method* m, bool do_disp } else if (mods.is_static()) { flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT); } else if (receiver_limit != mklass && - !Klass::cast(receiver_limit)->is_subtype_of(mklass)) { + !receiver_limit->is_subtype_of(mklass)) { return NULL; // bad receiver limit - } else if (Klass::cast(receiver_limit)->is_interface() && - Klass::cast(mklass)->is_interface()) { + } else if (receiver_limit->is_interface() && + mklass->is_interface()) { flags |= IS_METHOD | (JVM_REF_invokeInterface << REFERENCE_KIND_SHIFT); receiver_limit = mklass; // ignore passed-in limit; interfaces are interconvertible vmindex = klassItable::compute_itable_index(m); - } else if (mklass != receiver_limit && Klass::cast(mklass)->is_interface()) { + } else if (mklass != receiver_limit && mklass->is_interface()) { flags |= IS_METHOD | (JVM_REF_invokeVirtual << REFERENCE_KIND_SHIFT); // it is a miranda method, so m->vtable_index is not what we want ResourceMark rm; @@ -210,7 +210,7 @@ oop MethodHandles::init_method_MemberName(oop mname_oop, Method* m, bool do_disp java_lang_invoke_MemberName::set_flags(mname_oop, flags); java_lang_invoke_MemberName::set_vmtarget(mname_oop, m); java_lang_invoke_MemberName::set_vmindex(mname_oop, vmindex); // vtable/itable index - java_lang_invoke_MemberName::set_clazz(mname_oop, Klass::cast(receiver_limit)->java_mirror()); + java_lang_invoke_MemberName::set_clazz(mname_oop, receiver_limit->java_mirror()); // Note: name and type can be lazily computed by resolve_MemberName, // if Java code needs them as resolved String and MethodType objects. // The clazz must be eagerly stored, because it provides a GC @@ -258,7 +258,7 @@ oop MethodHandles::init_field_MemberName(oop mname_oop, Klass* field_holder, java_lang_invoke_MemberName::set_flags(mname_oop, flags); java_lang_invoke_MemberName::set_vmtarget(mname_oop, vmtarget); java_lang_invoke_MemberName::set_vmindex(mname_oop, vmindex); - java_lang_invoke_MemberName::set_clazz(mname_oop, Klass::cast(field_holder)->java_mirror()); + java_lang_invoke_MemberName::set_clazz(mname_oop, field_holder->java_mirror()); if (name != NULL) java_lang_invoke_MemberName::set_name(mname_oop, name); if (type != NULL) @@ -299,7 +299,7 @@ bool MethodHandles::is_method_handle_invoke_name(Klass* klass, Symbol* name) { // The following test will fail spuriously during bootstrap of MethodHandle itself: // if (klass != SystemDictionary::MethodHandle_klass()) // Test the name instead: - if (Klass::cast(klass)->name() != vmSymbols::java_lang_invoke_MethodHandle()) + if (klass->name() != vmSymbols::java_lang_invoke_MethodHandle()) return false; Symbol* poly_sig = vmSymbols::object_array_object_signature(); Method* m = InstanceKlass::cast(klass)->find_method(name, poly_sig); @@ -363,7 +363,7 @@ vmIntrinsics::ID MethodHandles::signature_polymorphic_name_id(Symbol* name) { vmIntrinsics::ID MethodHandles::signature_polymorphic_name_id(Klass* klass, Symbol* name) { if (klass != NULL && - Klass::cast(klass)->name() == vmSymbols::java_lang_invoke_MethodHandle()) { + klass->name() == vmSymbols::java_lang_invoke_MethodHandle()) { vmIntrinsics::ID iid = signature_polymorphic_name_id(name); if (iid != vmIntrinsics::_none) return iid; @@ -539,7 +539,7 @@ void MethodHandles::print_as_basic_type_signature_on(outputStream* st, static oop object_java_mirror() { - return Klass::cast(SystemDictionary::Object_klass())->java_mirror(); + return SystemDictionary::Object_klass()->java_mirror(); } static oop field_name_or_null(Symbol* s) { @@ -560,9 +560,9 @@ static oop field_signature_type_or_null(Symbol* s) { if (s == vmSymbols::object_signature()) { return object_java_mirror(); } else if (s == vmSymbols::class_signature()) { - return Klass::cast(SystemDictionary::Class_klass())->java_mirror(); + return SystemDictionary::Class_klass()->java_mirror(); } else if (s == vmSymbols::string_signature()) { - return Klass::cast(SystemDictionary::String_klass())->java_mirror(); + return SystemDictionary::String_klass()->java_mirror(); } } return NULL; @@ -603,8 +603,8 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) { { Klass* defc_klass = java_lang_Class::as_Klass(defc_oop()); if (defc_klass == NULL) return empty; // a primitive; no resolution possible - if (!Klass::cast(defc_klass)->oop_is_instance()) { - if (!Klass::cast(defc_klass)->oop_is_array()) return empty; + if (!defc_klass->oop_is_instance()) { + if (!defc_klass->oop_is_array()) return empty; defc_klass = SystemDictionary::Object_klass(); } defc = instanceKlassHandle(THREAD, defc_klass); @@ -767,7 +767,7 @@ void MethodHandles::expand_MemberName(Handle mname, int suppress, TRAPS) { { // This is taken from LinkResolver::resolve_field, sans access checks. assert(vmtarget->is_klass(), "field vmtarget is Klass*"); - if (!Klass::cast((Klass*) vmtarget)->oop_is_instance()) break; + if (!((Klass*) vmtarget)->oop_is_instance()) break; instanceKlassHandle defc(THREAD, (Klass*) vmtarget); DEBUG_ONLY(vmtarget = NULL); // safety bool is_static = ((flags & JVM_ACC_STATIC) != 0); @@ -805,7 +805,7 @@ int MethodHandles::find_MemberNames(Klass* k, // %%% take caller into account! - if (k == NULL || !Klass::cast(k)->oop_is_instance()) return -1; + if (k == NULL || !k->oop_is_instance()) return -1; int rfill = 0, rlimit = results->length(), rskip = skip; // overflow measurement: @@ -1032,7 +1032,7 @@ JVM_ENTRY(jobject, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, if (!Reflection::verify_class_access(caller, reference_klass, true)) { - THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), Klass::cast(reference_klass)->external_name()); + THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), reference_klass->external_name()); } } } @@ -1108,7 +1108,7 @@ JVM_ENTRY(jobject, MHN_getMemberVMInfo(JNIEnv *env, jobject igcls, jobject mname if (vmtarget == NULL) { x = NULL; } else if (vmtarget->is_klass()) { - x = Klass::cast((Klass*) vmtarget)->java_mirror(); + x = ((Klass*) vmtarget)->java_mirror(); } else if (vmtarget->is_method()) { Handle mname2 = MethodHandles::new_MemberName(CHECK_NULL); x = MethodHandles::init_method_MemberName(mname2(), (Method*)vmtarget, false, NULL); @@ -1237,7 +1237,7 @@ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) if (SystemDictionary::MethodHandle_klass() == NULL) { enable_MH = false; } else { - oop mirror = Klass::cast(SystemDictionary::MethodHandle_klass())->java_mirror(); + oop mirror = SystemDictionary::MethodHandle_klass()->java_mirror(); MH_class = (jclass) JNIHandles::make_local(env, mirror); } diff --git a/hotspot/src/share/vm/prims/nativeLookup.cpp b/hotspot/src/share/vm/prims/nativeLookup.cpp index 690a1d24e0d..5fdd070aaa4 100644 --- a/hotspot/src/share/vm/prims/nativeLookup.cpp +++ b/hotspot/src/share/vm/prims/nativeLookup.cpp @@ -349,7 +349,7 @@ address NativeLookup::lookup_entry_prefixed(methodHandle method, bool& in_base_l TempNewSymbol wrapper_symbol = SymbolTable::probe(wrapper_name, wrapper_name_len); if (wrapper_symbol != NULL) { KlassHandle kh(method->method_holder()); - Method* wrapper_method = Klass::cast(kh())->lookup_method(wrapper_symbol, + Method* wrapper_method = kh()->lookup_method(wrapper_symbol, method->signature()); if (wrapper_method != NULL && !wrapper_method->is_native()) { // we found a wrapper method, use its native entry diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index e3750e66f1c..8d8b30df0d5 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -771,7 +771,7 @@ UNSAFE_ENTRY(void, Unsafe_EnsureClassInitialized(JNIEnv *env, jobject unsafe, jo oop mirror = JNIHandles::resolve_non_null(clazz); Klass* klass = java_lang_Class::as_Klass(mirror); - if (klass != NULL && Klass::cast(klass)->should_be_initialized()) { + if (klass != NULL && klass->should_be_initialized()) { InstanceKlass* k = InstanceKlass::cast(klass); k->initialize(CHECK); } @@ -785,7 +785,7 @@ UNSAFE_ENTRY(jboolean, Unsafe_ShouldBeInitialized(JNIEnv *env, jobject unsafe, j } oop mirror = JNIHandles::resolve_non_null(clazz); Klass* klass = java_lang_Class::as_Klass(mirror); - if (klass != NULL && Klass::cast(klass)->should_be_initialized()) { + if (klass != NULL && klass->should_be_initialized()) { return true; } return false; diff --git a/hotspot/src/share/vm/runtime/biasedLocking.cpp b/hotspot/src/share/vm/runtime/biasedLocking.cpp index 3d9c279a2ae..f526fbcbc7f 100644 --- a/hotspot/src/share/vm/runtime/biasedLocking.cpp +++ b/hotspot/src/share/vm/runtime/biasedLocking.cpp @@ -39,7 +39,7 @@ static GrowableArray* _preserved_oop_stack = NULL; static GrowableArray* _preserved_mark_stack = NULL; static void enable_biased_locking(Klass* k) { - Klass::cast(k)->set_prototype_header(markOopDesc::biased_locking_prototype()); + k->set_prototype_header(markOopDesc::biased_locking_prototype()); } class VM_EnableBiasedLocking: public VM_Operation { @@ -149,7 +149,7 @@ static BiasedLocking::Condition revoke_bias(oop obj, bool allow_rebias, bool is_ if (TraceBiasedLocking) { ResourceMark rm; tty->print_cr(" (Skipping revocation of object of type %s because it's no longer biased)", - Klass::cast(obj->klass())->external_name()); + obj->klass()->external_name()); } return BiasedLocking::NOT_BIASED; } @@ -161,7 +161,7 @@ static BiasedLocking::Condition revoke_bias(oop obj, bool allow_rebias, bool is_ if (TraceBiasedLocking && (Verbose || !is_bulk)) { ResourceMark rm; tty->print_cr("Revoking bias of object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s , prototype header " INTPTR_FORMAT " , allow rebias %d , requesting thread " INTPTR_FORMAT, - (intptr_t) obj, (intptr_t) mark, Klass::cast(obj->klass())->external_name(), (intptr_t) Klass::cast(obj->klass())->prototype_header(), (allow_rebias ? 1 : 0), (intptr_t) requesting_thread); + (intptr_t) obj, (intptr_t) mark, obj->klass()->external_name(), (intptr_t) obj->klass()->prototype_header(), (allow_rebias ? 1 : 0), (intptr_t) requesting_thread); } JavaThread* biased_thread = mark->biased_locker(); @@ -326,7 +326,7 @@ static BiasedLocking::Condition bulk_revoke_or_rebias_at_safepoint(oop o, tty->print_cr("* Beginning bulk revocation (kind == %s) because of object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s", (bulk_rebias ? "rebias" : "revoke"), - (intptr_t) o, (intptr_t) o->mark(), Klass::cast(o->klass())->external_name()); + (intptr_t) o, (intptr_t) o->mark(), o->klass()->external_name()); } jlong cur_time = os::javaTimeMillis(); @@ -334,7 +334,7 @@ static BiasedLocking::Condition bulk_revoke_or_rebias_at_safepoint(oop o, Klass* k_o = o->klass(); - Klass* klass = Klass::cast(k_o); + Klass* klass = k_o; if (bulk_rebias) { // Use the epoch in the klass of the object to implicitly revoke @@ -546,7 +546,7 @@ BiasedLocking::Condition BiasedLocking::revoke_and_rebias(Handle obj, bool attem return BIAS_REVOKED; } } else if (mark->has_bias_pattern()) { - Klass* k = Klass::cast(obj->klass()); + Klass* k = obj->klass(); markOop prototype_header = k->prototype_header(); if (!prototype_header->has_bias_pattern()) { // This object has a stale bias from before the bulk revocation @@ -590,7 +590,7 @@ BiasedLocking::Condition BiasedLocking::revoke_and_rebias(Handle obj, bool attem if (heuristics == HR_NOT_BIASED) { return NOT_BIASED; } else if (heuristics == HR_SINGLE_REVOKE) { - Klass *k = Klass::cast(obj->klass()); + Klass *k = obj->klass(); markOop prototype_header = k->prototype_header(); if (mark->biased_locker() == THREAD && prototype_header->bias_epoch() == mark->bias_epoch()) { diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp index d4756bcf924..448266cde41 100644 --- a/hotspot/src/share/vm/runtime/reflection.cpp +++ b/hotspot/src/share/vm/runtime/reflection.cpp @@ -70,8 +70,8 @@ static void trace_class_resolution(Klass* to_class) { } } if (caller != NULL) { - const char * from = Klass::cast(caller)->external_name(); - const char * to = Klass::cast(to_class)->external_name(); + const char * from = caller->external_name(); + const char * to = to_class->external_name(); // print in a single call to reduce interleaving between threads if (source_file != NULL) { tty->print("RESOLVE %s %s %s:%d (reflection)\n", from, to, source_file, line_number); @@ -330,7 +330,7 @@ arrayOop Reflection::reflect_new_array(oop element_mirror, jint length, TRAPS) { return TypeArrayKlass::cast(tak)->allocate(length, THREAD); } else { Klass* k = java_lang_Class::as_Klass(element_mirror); - if (Klass::cast(k)->oop_is_array() && ArrayKlass::cast(k)->dimension() >= MAX_DIM) { + if (k->oop_is_array() && ArrayKlass::cast(k)->dimension() >= MAX_DIM) { THROW_0(vmSymbols::java_lang_IllegalArgumentException()); } return oopFactory::new_objArray(k, length, THREAD); @@ -366,7 +366,7 @@ arrayOop Reflection::reflect_new_multi_array(oop element_mirror, typeArrayOop di klass = basic_type_mirror_to_arrayklass(element_mirror, CHECK_NULL); } else { klass = java_lang_Class::as_Klass(element_mirror); - if (Klass::cast(klass)->oop_is_array()) { + if (klass->oop_is_array()) { int k_dim = ArrayKlass::cast(klass)->dimension(); if (k_dim + len > MAX_DIM) { THROW_0(vmSymbols::java_lang_IllegalArgumentException()); @@ -374,7 +374,7 @@ arrayOop Reflection::reflect_new_multi_array(oop element_mirror, typeArrayOop di dim += k_dim; } } - klass = Klass::cast(klass)->array_klass(dim, CHECK_NULL); + klass = klass->array_klass(dim, CHECK_NULL); oop obj = ArrayKlass::cast(klass)->multi_allocate(len, dimensions, THREAD); assert(obj->is_array(), "just checking"); return arrayOop(obj); @@ -387,7 +387,7 @@ oop Reflection::array_component_type(oop mirror, TRAPS) { } Klass* klass = java_lang_Class::as_Klass(mirror); - if (!Klass::cast(klass)->oop_is_array()) { + if (!klass->oop_is_array()) { return NULL; } @@ -395,15 +395,15 @@ oop Reflection::array_component_type(oop mirror, TRAPS) { #ifdef ASSERT oop result2 = NULL; if (ArrayKlass::cast(klass)->dimension() == 1) { - if (Klass::cast(klass)->oop_is_typeArray()) { + if (klass->oop_is_typeArray()) { result2 = basic_type_arrayklass_to_mirror(klass, CHECK_NULL); } else { - result2 = Klass::cast(ObjArrayKlass::cast(klass)->element_klass())->java_mirror(); + result2 = ObjArrayKlass::cast(klass)->element_klass()->java_mirror(); } } else { Klass* lower_dim = ArrayKlass::cast(klass)->lower_dimension(); - assert(Klass::cast(lower_dim)->oop_is_array(), "just checking"); - result2 = Klass::cast(lower_dim)->java_mirror(); + assert(lower_dim->oop_is_array(), "just checking"); + result2 = lower_dim->java_mirror(); } assert(result == result2, "results must be consistent"); #endif //ASSERT @@ -442,7 +442,7 @@ bool Reflection::reflect_check_access(Klass* field_class, AccessFlags acc, Klass if (acc.is_protected()) { if (target_class != client_class) { if (!is_same_class_package(client_class, field_class)) { - if (!Klass::cast(target_class)->is_subclass_of(client_class)) { + if (!target_class->is_subclass_of(client_class)) { THROW_(vmSymbols::java_lang_IllegalAccessException(), false); } } @@ -468,7 +468,7 @@ bool Reflection::verify_class_access(Klass* current_class, Klass* new_class, boo // sun/reflect/MagicAccessorImpl subclasses to succeed trivially. if ( JDK_Version::is_gte_jdk14x_version() && UseNewReflection - && Klass::cast(current_class)->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { + && current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { return true; } @@ -546,12 +546,12 @@ bool Reflection::verify_field_access(Klass* current_class, if (access.is_protected()) { if (!protected_restriction) { // See if current_class is a subclass of field_class - if (Klass::cast(current_class)->is_subclass_of(field_class)) { + if (current_class->is_subclass_of(field_class)) { if (access.is_static() || // static fields are ok, see 6622385 current_class == resolved_class || field_class == resolved_class || - Klass::cast(current_class)->is_subclass_of(resolved_class) || - Klass::cast(resolved_class)->is_subclass_of(current_class)) { + current_class->is_subclass_of(resolved_class) || + resolved_class->is_subclass_of(current_class)) { return true; } } @@ -566,7 +566,7 @@ bool Reflection::verify_field_access(Klass* current_class, // sun/reflect/MagicAccessorImpl subclasses to succeed trivially. if ( JDK_Version::is_gte_jdk14x_version() && UseNewReflection - && Klass::cast(current_class)->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { + && current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { return true; } @@ -693,7 +693,7 @@ Handle Reflection::new_type(Symbol* signature, KlassHandle k, TRAPS) { } oop loader = InstanceKlass::cast(k())->class_loader(); - oop protection_domain = Klass::cast(k())->protection_domain(); + oop protection_domain = k()->protection_domain(); Klass* result = SystemDictionary::resolve_or_fail(signature, Handle(THREAD, loader), Handle(THREAD, protection_domain), @@ -703,7 +703,7 @@ Handle Reflection::new_type(Symbol* signature, KlassHandle k, TRAPS) { trace_class_resolution(result); } - oop nt = Klass::cast(result)->java_mirror(); + oop nt = result->java_mirror(); return Handle(THREAD, nt); } @@ -937,7 +937,7 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method, ResourceMark rm(THREAD); Handle h_origexception = Exceptions::new_exception(THREAD, vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(target_klass()), + Method::name_and_sig_as_C_string(target_klass(), method->name(), method->signature())); JavaCallArguments args(h_origexception); @@ -947,7 +947,7 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method, } else { ResourceMark rm(THREAD); THROW_MSG_0(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(target_klass()), + Method::name_and_sig_as_C_string(target_klass(), method->name(), method->signature())); } @@ -962,7 +962,7 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method, if (method.is_null()) { ResourceMark rm(THREAD); THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), - Method::name_and_sig_as_C_string(Klass::cast(klass()), + Method::name_and_sig_as_C_string(klass(), reflected_method->name(), reflected_method->signature())); } diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index 7a7c97e13fc..363f065bcd8 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -1775,7 +1775,7 @@ JRT_ENTRY(void, SharedRuntime::slow_arraycopy_C(oopDesc* src, jint src_pos, // The copy_array mechanism is awkward and could be removed, but // the compilers don't call this function except as a last resort, // so it probably doesn't matter. - Klass::cast(src->klass())->copy_array((arrayOopDesc*)src, src_pos, + src->klass()->copy_array((arrayOopDesc*)src, src_pos, (arrayOopDesc*)dest, dest_pos, length, thread); } @@ -1788,8 +1788,8 @@ char* SharedRuntime::generate_class_cast_message( vframeStream vfst(thread, true); assert(!vfst.at_end(), "Java frame must exist"); Bytecode_checkcast cc(vfst.method(), vfst.method()->bcp_from(vfst.bci())); - Klass* targetKlass = Klass::cast(vfst.method()->constants()->klass_at( - cc.index(), thread)); + Klass* targetKlass = vfst.method()->constants()->klass_at( + cc.index(), thread); return generate_class_cast_message(objName, targetKlass->external_name()); } diff --git a/hotspot/src/share/vm/runtime/signature.cpp b/hotspot/src/share/vm/runtime/signature.cpp index 4599928b800..ce1b069ee6b 100644 --- a/hotspot/src/share/vm/runtime/signature.cpp +++ b/hotspot/src/share/vm/runtime/signature.cpp @@ -354,7 +354,7 @@ oop SignatureStream::as_java_mirror(Handle class_loader, Handle protection_domai return Universe::java_mirror(type()); Klass* klass = as_klass(class_loader, protection_domain, failure_mode, CHECK_NULL); if (klass == NULL) return NULL; - return Klass::cast(klass)->java_mirror(); + return klass->java_mirror(); } Symbol* SignatureStream::as_symbol_or_null() { diff --git a/hotspot/src/share/vm/runtime/synchronizer.cpp b/hotspot/src/share/vm/runtime/synchronizer.cpp index 021998d02db..1ffc285b2c2 100644 --- a/hotspot/src/share/vm/runtime/synchronizer.cpp +++ b/hotspot/src/share/vm/runtime/synchronizer.cpp @@ -1323,7 +1323,7 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { ResourceMark rm; tty->print_cr("Inflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s", (intptr_t) object, (intptr_t) object->mark(), - Klass::cast(object->klass())->external_name()); + object->klass()->external_name()); } } return m ; @@ -1373,7 +1373,7 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { ResourceMark rm; tty->print_cr("Inflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s", (intptr_t) object, (intptr_t) object->mark(), - Klass::cast(object->klass())->external_name()); + object->klass()->external_name()); } } return m ; @@ -1440,7 +1440,7 @@ bool ObjectSynchronizer::deflate_monitor(ObjectMonitor* mid, oop obj, if (obj->is_instance()) { ResourceMark rm; tty->print_cr("Deflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s", - (intptr_t) obj, (intptr_t) obj->mark(), Klass::cast(obj->klass())->external_name()); + (intptr_t) obj, (intptr_t) obj->mark(), obj->klass()->external_name()); } } diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index a3656dcda4f..4e379777d8d 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -1785,7 +1785,7 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) { jio_fprintf(defaultStream::error_stream(), "\nException: %s thrown from the UncaughtExceptionHandler" " in thread \"%s\"\n", - Klass::cast(pending_exception()->klass())->external_name(), + pending_exception()->klass()->external_name(), get_thread_name()); CLEAR_PENDING_EXCEPTION; } diff --git a/hotspot/src/share/vm/runtime/vframe.cpp b/hotspot/src/share/vm/runtime/vframe.cpp index 382ac4b0961..bc9ca0a419d 100644 --- a/hotspot/src/share/vm/runtime/vframe.cpp +++ b/hotspot/src/share/vm/runtime/vframe.cpp @@ -149,7 +149,7 @@ static void print_locked_object_class_name(outputStream* st, Handle obj, const c Klass* target_klass = java_lang_Class::as_Klass(obj()); st->print_cr("(a java.lang.Class for %s)", InstanceKlass::cast(target_klass)->external_name()); } else { - Klass* k = Klass::cast(obj->klass()); + Klass* k = obj->klass(); st->print_cr("(a %s)", k->external_name()); } } @@ -172,7 +172,7 @@ void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) { } } else if (thread()->current_park_blocker() != NULL) { oop obj = thread()->current_park_blocker(); - Klass* k = Klass::cast(obj->klass()); + Klass* k = obj->klass(); st->print_cr("\t- %s <" INTPTR_FORMAT "> (a %s)", "parking to wait for ", (address)obj, k->external_name()); } } @@ -550,7 +550,7 @@ void javaVFrame::print_value() const { InstanceKlass* k = m->method_holder(); tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")", _fr.sp(), _fr.unextended_sp(), _fr.fp(), _fr.pc()); - tty->print("%s.%s", Klass::cast(k)->internal_name(), m->name()->as_C_string()); + tty->print("%s.%s", k->internal_name(), m->name()->as_C_string()); if (!m->is_native()) { Symbol* source_name = k->source_file_name(); diff --git a/hotspot/src/share/vm/services/classLoadingService.hpp b/hotspot/src/share/vm/services/classLoadingService.hpp index a18534d4759..1ea177f8352 100644 --- a/hotspot/src/share/vm/services/classLoadingService.hpp +++ b/hotspot/src/share/vm/services/classLoadingService.hpp @@ -135,7 +135,7 @@ public: // The spec is unclear at this point to count array klasses or not // and also indirect creation of array of super class and secondaries // - // for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) { + // for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) { // KlassHandle h(_current_thread, l); // _loaded_classes->append(h); // } diff --git a/hotspot/src/share/vm/services/heapDumper.cpp b/hotspot/src/share/vm/services/heapDumper.cpp index 46d1fad6d7c..0dbe2e86589 100644 --- a/hotspot/src/share/vm/services/heapDumper.cpp +++ b/hotspot/src/share/vm/services/heapDumper.cpp @@ -879,7 +879,7 @@ void DumperSupport::dump_instance(DumpWriter* writer, oop o) { writer->write_u4(STACK_TRACE_ID); // class ID - writer->write_classID(Klass::cast(k)); + writer->write_classID(k); // number of bytes that follow writer->write_u4(instance_size(k) ); @@ -891,7 +891,7 @@ void DumperSupport::dump_instance(DumpWriter* writer, oop o) { // creates HPROF_GC_CLASS_DUMP record for the given class and each of // its array classes void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) { - Klass* klass = Klass::cast(k); + Klass* klass = k; assert(klass->oop_is_instance(), "not an InstanceKlass"); InstanceKlass* ik = (InstanceKlass*)klass; @@ -906,7 +906,7 @@ void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) { if (java_super == NULL) { writer->write_objectID(oop(NULL)); } else { - writer->write_classID(Klass::cast(java_super)); + writer->write_classID(java_super); } writer->write_objectID(ik->class_loader()); @@ -932,7 +932,7 @@ void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) { // array classes k = klass->array_klass_or_null(); while (k != NULL) { - Klass* klass = Klass::cast(k); + Klass* klass = k; assert(klass->oop_is_objArray(), "not an ObjArrayKlass"); writer->write_u1(HPROF_GC_CLASS_DUMP); @@ -942,7 +942,7 @@ void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) { // super class of array classes is java.lang.Object java_super = klass->java_super(); assert(java_super != NULL, "checking"); - writer->write_classID(Klass::cast(java_super)); + writer->write_classID(java_super); writer->write_objectID(ik->class_loader()); writer->write_objectID(ik->signers()); @@ -965,7 +965,7 @@ void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) { void DumperSupport::dump_basic_type_array_class(DumpWriter* writer, Klass* k) { // array classes while (k != NULL) { - Klass* klass = Klass::cast(k); + Klass* klass = k; writer->write_u1(HPROF_GC_CLASS_DUMP); writer->write_classID(klass); @@ -974,7 +974,7 @@ void DumperSupport::dump_basic_type_array_class(DumpWriter* writer, Klass* k) { // super class of array classes is java.lang.Object Klass* java_super = klass->java_super(); assert(java_super != NULL, "checking"); - writer->write_classID(Klass::cast(java_super)); + writer->write_classID(java_super); writer->write_objectID(oop(NULL)); // loader writer->write_objectID(oop(NULL)); // signers @@ -1001,7 +1001,7 @@ void DumperSupport::dump_object_array(DumpWriter* writer, objArrayOop array) { writer->write_u4((u4)array->length()); // array class ID - writer->write_classID(Klass::cast(array->klass())); + writer->write_classID(array->klass()); // [id]* elements for (int index=0; indexlength(); index++) { @@ -1525,7 +1525,7 @@ void VM_HeapDumper::do_load_class(Klass* k) { writer()->write_u4(++class_serial_num); // class ID - Klass* klass = Klass::cast(k); + Klass* klass = k; writer()->write_classID(klass); // add the Klass* and class serial number pair @@ -1796,7 +1796,7 @@ void VM_HeapDumper::dump_stack_traces() { // write fake frame that makes it look like the thread, which caused OOME, // is in the OutOfMemoryError zero-parameter constructor if (thread == _oome_thread && _oome_constructor != NULL) { - int oome_serial_num = _klass_map->find(Klass::cast(_oome_constructor->method_holder())); + int oome_serial_num = _klass_map->find(_oome_constructor->method_holder()); // the class serial number starts from 1 assert(oome_serial_num > 0, "OutOfMemoryError class not found"); DumperSupport::dump_stack_frame(writer(), ++frame_serial_num, oome_serial_num, @@ -1806,7 +1806,7 @@ void VM_HeapDumper::dump_stack_traces() { for (int j=0; j < depth; j++) { StackFrameInfo* frame = stack_trace->stack_frame_at(j); Method* m = frame->method(); - int class_serial_num = _klass_map->find(Klass::cast(m->method_holder())); + int class_serial_num = _klass_map->find(m->method_holder()); // the class serial number starts from 1 assert(class_serial_num > 0, "class not found"); DumperSupport::dump_stack_frame(writer(), ++frame_serial_num, class_serial_num, m, frame->bci()); diff --git a/hotspot/src/share/vm/services/management.cpp b/hotspot/src/share/vm/services/management.cpp index 2a95468e70f..a5b68d9b655 100644 --- a/hotspot/src/share/vm/services/management.cpp +++ b/hotspot/src/share/vm/services/management.cpp @@ -1417,7 +1417,7 @@ JVM_ENTRY(jobjectArray, jmm_GetLoadedClasses(JNIEnv *env)) for (int i = 0; i < num_classes; i++) { KlassHandle kh = lce.get_klass(i); - oop mirror = Klass::cast(kh())->java_mirror(); + oop mirror = kh()->java_mirror(); classes_ah->obj_at_put(i, mirror); } diff --git a/hotspot/src/share/vm/services/serviceUtil.hpp b/hotspot/src/share/vm/services/serviceUtil.hpp index 9aa43e5bfff..42e03d9df53 100644 --- a/hotspot/src/share/vm/services/serviceUtil.hpp +++ b/hotspot/src/share/vm/services/serviceUtil.hpp @@ -57,14 +57,13 @@ class ServiceUtil : public AllStatic { if (k->is_klass()) { // if it's a class for an object, an object array, or // primitive (type) array then it's visible. - Klass* klass = k; - if (Klass::cast(klass)->oop_is_instance()) { + if (k->oop_is_instance()) { return true; } - if (Klass::cast(klass)->oop_is_objArray()) { + if (k->oop_is_objArray()) { return true; } - if (Klass::cast(klass)->oop_is_typeArray()) { + if (k->oop_is_typeArray()) { return true; } } From f712e12f985e96c490ec023f919248f2e300d9cc Mon Sep 17 00:00:00 2001 From: Yumin Qi Date: Mon, 12 Nov 2012 14:03:53 -0800 Subject: [PATCH 09/94] 6830717: replay of compilations would help with debugging When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method. Reviewed-by: kvn, twisti, sspitsyn --- hotspot/agent/doc/c2replay.html | 41 + hotspot/agent/doc/clhsdb.html | 19 + hotspot/agent/doc/index.html | 6 + hotspot/agent/make/Makefile | 16 +- .../sun/jvm/hotspot/CommandProcessor.java | 107 ++ .../sun/jvm/hotspot/ci/ciBaseObject.java | 10 +- .../sun/jvm/hotspot/ci/ciConstant.java | 12 +- .../classes/sun/jvm/hotspot/ci/ciEnv.java | 33 +- .../sun/jvm/hotspot/ci/ciInstanceKlass.java | 86 +- .../classes/sun/jvm/hotspot/ci/ciMethod.java | 21 +- .../sun/jvm/hotspot/ci/ciMethodData.java | 54 +- .../classes/sun/jvm/hotspot/code/NMethod.java | 36 + .../sun/jvm/hotspot/compiler/CompileTask.java | 2 +- .../jvm/hotspot/oops/ConstantPoolCache.java | 2 +- .../classes/sun/jvm/hotspot/oops/Field.java | 2 + .../sun/jvm/hotspot/oops/InstanceKlass.java | 97 +- .../sun/jvm/hotspot/oops/Metadata.java | 3 + .../classes/sun/jvm/hotspot/oops/Method.java | 19 + .../sun/jvm/hotspot/oops/MethodData.java | 55 + hotspot/src/share/vm/ci/ciClassList.hpp | 1 + hotspot/src/share/vm/ci/ciEnv.cpp | 46 + hotspot/src/share/vm/ci/ciEnv.hpp | 9 + hotspot/src/share/vm/ci/ciInstanceKlass.cpp | 111 +++ hotspot/src/share/vm/ci/ciInstanceKlass.hpp | 3 + hotspot/src/share/vm/ci/ciMetadata.hpp | 1 + hotspot/src/share/vm/ci/ciMethod.cpp | 47 +- hotspot/src/share/vm/ci/ciMethod.hpp | 5 +- hotspot/src/share/vm/ci/ciMethodData.cpp | 79 ++ hotspot/src/share/vm/ci/ciMethodData.hpp | 2 + hotspot/src/share/vm/ci/ciObject.hpp | 1 + hotspot/src/share/vm/ci/ciObjectFactory.hpp | 1 + hotspot/src/share/vm/ci/ciReplay.cpp | 942 ++++++++++++++++++ hotspot/src/share/vm/ci/ciReplay.hpp | 55 + hotspot/src/share/vm/ci/ciSymbol.cpp | 5 + hotspot/src/share/vm/ci/ciSymbol.hpp | 3 + hotspot/src/share/vm/ci/ciUtilities.hpp | 5 +- .../src/share/vm/classfile/javaClasses.cpp | 16 + .../src/share/vm/classfile/javaClasses.hpp | 2 + hotspot/src/share/vm/code/dependencies.cpp | 1 + .../vm/interpreter/invocationCounter.hpp | 5 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 7 + hotspot/src/share/vm/oops/instanceKlass.hpp | 1 + hotspot/src/share/vm/oops/symbol.cpp | 20 +- hotspot/src/share/vm/oops/symbol.hpp | 2 + hotspot/src/share/vm/opto/bytecodeInfo.cpp | 13 +- hotspot/src/share/vm/prims/jni.cpp | 2 + hotspot/src/share/vm/prims/jvmtiExport.hpp | 2 + .../share/vm/runtime/compilationPolicy.cpp | 13 + hotspot/src/share/vm/runtime/globals.hpp | 20 + hotspot/src/share/vm/runtime/vmStructs.cpp | 1 + hotspot/src/share/vm/utilities/array.hpp | 6 +- hotspot/src/share/vm/utilities/utf8.cpp | 149 ++- hotspot/src/share/vm/utilities/utf8.hpp | 32 +- hotspot/src/share/vm/utilities/vmError.cpp | 9 + 54 files changed, 2160 insertions(+), 78 deletions(-) create mode 100644 hotspot/agent/doc/c2replay.html create mode 100644 hotspot/src/share/vm/ci/ciReplay.cpp create mode 100644 hotspot/src/share/vm/ci/ciReplay.hpp diff --git a/hotspot/agent/doc/c2replay.html b/hotspot/agent/doc/c2replay.html new file mode 100644 index 00000000000..cf90e0e8f62 --- /dev/null +++ b/hotspot/agent/doc/c2replay.html @@ -0,0 +1,41 @@ + + + +C2 Replay + + + + +

C2 compiler replay

+

+The C2 compiler replay is a function to repeat the compiling process from a crashed java process in compiled method
+This function only exists in debug version of VM +

+

Usage

+
 
+First, use SA to attach to the core file, if suceeded, do
+       clhsdb>dumpreplaydata 
| -a | [> replay.txt] + create file replay.txt, address is address of Method, or nmethod(CodeBlob) + clhsdb>buildreplayjars [all | boot | app] + create files: + all: + app.jar, boot.jar + boot: + boot.jar + app: + app.jar + exit SA now. +Second, use the obtained replay text file, replay.txt and jar files, app.jar and boot.jar, using debug version of java + java -Xbootclasspath/p:boot.jar -cp app.jar -XX:ReplayDataFile= -XX:+ReplayCompiles .... + This will replay the compiling process. + + With ReplayCompiles, the replay will recompile all the methods in app.jar, and in boot.jar to emulate the process in java app. + +notes: + 1) Most time, we don't need the boot.jar which is the classes loaded from JDK. It will be only modified when an agent(JVMDI) is running and modifies the classes. + 2) If encounter error as "" not found, that means the SA is using a VMStructs which is different from the one with corefile. In this case, SA has a utility tool vmstructsdump which is located at agent/src/os//proc/ + + Use this tool to dump VM type library: + vmstructsdump libjvm.so > .db + + set env SA_TYPEDB=.db (refer different shell for set envs) diff --git a/hotspot/agent/doc/clhsdb.html b/hotspot/agent/doc/clhsdb.html index 838ad556c9c..f1c43fd1e5f 100644 --- a/hotspot/agent/doc/clhsdb.html +++ b/hotspot/agent/doc/clhsdb.html @@ -37,12 +37,19 @@ Each CLHSDB command can have zero or more arguments and optionally end with outp Available commands: assert true | false turn on/off asserts in SA code attach pid | exec core attach SA to a process or core + buildreplayjars [all | boot | app] build jars for replay, boot.jar for bootclasses, app.jar for application classes class name find a Java class from debuggee and print oop classes print all loaded Java classes with Klass* detach detach SA from current target dis address [ length ] disassemble (sparc/x86) specified number of instructions from given address + dissemble address disassemble nmethod + dumpcfg -a | id Dump the PhaseCFG for every compiler thread that has one live dumpclass { address | name } [ directory ] dump .class file for given Klass* or class name + dumpcodecache dump codecache contents dumpheap [ file ] dump heap in hprof binary format + dumpideal -a | id dump ideal graph like debug flag -XX:+PrintIdeal + dumpilt -a | id dump inline tree for C2 compilation + dumpreplaydata
| -a | [>replay.txt] dump replay data into a file echo [ true | false ] turn on/off command echo mode examine [ address/count ] | [ address,address] show contents of memory from given address field [ type [ name fieldtype isStatic offset address ] ] print info about a field of HotSpot type @@ -51,29 +58,35 @@ Available commands: help [ command ] print help message for all commands or just given command history show command history. usual !command-number syntax works. inspect expression inspect a given oop + intConstant [ name [ value ] ] print out hotspot integer constant(s) jdis address show bytecode disassembly of a given Method* jhisto show Java heap histogram jseval script evaluate a given string as JavaScript code jsload file load and evaluate a JavaScript file jstack [-v] show Java stack trace of all Java threads. -v is verbose mode livenmethods show all live nmethods + longConstant [ name [ value ] ] print out hotspot long constant(s)s mem address [ length ] show contents of memory -- also shows closest ELF/COFF symbol if found pmap show Solaris pmap-like output print expression print given Klass*, Method* or arbitrary address printas type expression print given address as given HotSpot type. eg. print JavaThread <address> + printmdo -a | expression print method data oop printstatics [ type ] print static fields of given HotSpot type (or all types if none specified) pstack [-v] show mixed mode stack trace for all Java, non-Java threads. -v is verbose mode quit quit CLHSDB tool reattach detach and re-attach SA to current target + revptrs find liveness of oops scanoops start end [ type ] scan a Oop from given start to end address search [ heap | codecache | threads ] value search a value in heap or codecache or threads source filename load and execute CLHSDB commands from given file symbol name show address of a given ELF/COFF symbol sysprops show all Java System properties + thread id show thread of id threads show all Java threads tokenize ... type [ type [ name super isOop isInteger isUnsigned size ] ] show info. on HotSpot type universe print gc universe + vmstructsdump dump hotspot type library in text verbose true | false turn on/off verbose mode versioncheck [ true | false ] turn on/off debuggee VM version check whatis address print info about any arbitrary address @@ -114,5 +127,11 @@ hsdb> jsload test.js
+

C2 Compilation Replay

+

+When a java process crashes in compiled method, usually a core file is saved. +The C2 replay function can reproduce the compiling process in the core. +c2replay.html + diff --git a/hotspot/agent/doc/index.html b/hotspot/agent/doc/index.html index 987e5f9c659..395f10ef6c8 100644 --- a/hotspot/agent/doc/index.html +++ b/hotspot/agent/doc/index.html @@ -220,6 +220,12 @@ These scripts are used to run SA remotely. +

C2 Compilation Replay

+

+When a java process crashes in compiled method, usually a core file is saved. +The C2 replay function can reproduce the compiling process in the core. +c2replay.html +

Debugging transported core dumps

When a core dump is moved from the machine where it was produced to a diff --git a/hotspot/agent/make/Makefile b/hotspot/agent/make/Makefile index c0183f17bc7..a30a9998286 100644 --- a/hotspot/agent/make/Makefile +++ b/hotspot/agent/make/Makefile @@ -58,10 +58,8 @@ sun.jvm.hotspot.debugger.cdbg.basic \ sun.jvm.hotspot.debugger.cdbg.basic.amd64 \ sun.jvm.hotspot.debugger.cdbg.basic.x86 \ sun.jvm.hotspot.debugger.dummy \ -sun.jvm.hotspot.debugger.ia64 \ sun.jvm.hotspot.debugger.linux \ sun.jvm.hotspot.debugger.linux.amd64 \ -sun.jvm.hotspot.debugger.linux.ia64 \ sun.jvm.hotspot.debugger.linux.x86 \ sun.jvm.hotspot.debugger.posix \ sun.jvm.hotspot.debugger.posix.elf \ @@ -77,7 +75,6 @@ sun.jvm.hotspot.debugger.sparc \ sun.jvm.hotspot.debugger.win32.coff \ sun.jvm.hotspot.debugger.windbg \ sun.jvm.hotspot.debugger.windbg.amd64 \ -sun.jvm.hotspot.debugger.windbg.ia64 \ sun.jvm.hotspot.debugger.windbg.x86 \ sun.jvm.hotspot.debugger.x86 \ sun.jvm.hotspot.gc_implementation \ @@ -97,10 +94,8 @@ sun.jvm.hotspot.runtime.amd64 \ sun.jvm.hotspot.runtime.bsd \ sun.jvm.hotspot.runtime.bsd_amd64 \ sun.jvm.hotspot.runtime.bsd_x86 \ -sun.jvm.hotspot.runtime.ia64 \ sun.jvm.hotspot.runtime.linux \ sun.jvm.hotspot.runtime.linux_amd64 \ -sun.jvm.hotspot.runtime.linux_ia64 \ sun.jvm.hotspot.runtime.linux_sparc \ sun.jvm.hotspot.runtime.linux_x86 \ sun.jvm.hotspot.runtime.posix \ @@ -109,7 +104,6 @@ sun.jvm.hotspot.runtime.solaris_sparc \ sun.jvm.hotspot.runtime.solaris_x86 \ sun.jvm.hotspot.runtime.sparc \ sun.jvm.hotspot.runtime.win32_amd64 \ -sun.jvm.hotspot.runtime.win32_ia64 \ sun.jvm.hotspot.runtime.win32_x86 \ sun.jvm.hotspot.runtime.x86 \ sun.jvm.hotspot.tools \ @@ -152,7 +146,6 @@ sun/jvm/hotspot/debugger/cdbg/basic/*.java \ sun/jvm/hotspot/debugger/cdbg/basic/amd64/*.java \ sun/jvm/hotspot/debugger/cdbg/basic/x86/*.java \ sun/jvm/hotspot/debugger/dummy/*.java \ -sun/jvm/hotspot/debugger/ia64/*.java \ sun/jvm/hotspot/debugger/linux/*.java \ sun/jvm/hotspot/debugger/linux/x86/*.java \ sun/jvm/hotspot/debugger/posix/*.java \ @@ -168,7 +161,6 @@ sun/jvm/hotspot/debugger/remote/x86/*.java \ sun/jvm/hotspot/debugger/sparc/*.java \ sun/jvm/hotspot/debugger/win32/coff/*.java \ sun/jvm/hotspot/debugger/windbg/*.java \ -sun/jvm/hotspot/debugger/windbg/ia64/*.java \ sun/jvm/hotspot/debugger/windbg/x86/*.java \ sun/jvm/hotspot/debugger/x86/*.java \ sun/jvm/hotspot/gc_implementation/g1/*.java \ @@ -186,10 +178,8 @@ sun/jvm/hotspot/runtime/amd64/*.java \ sun/jvm/hotspot/runtime/bsd/*.java \ sun/jvm/hotspot/runtime/bsd_amd64/*.java \ sun/jvm/hotspot/runtime/bsd_x86/*.java \ -sun/jvm/hotspot/runtime/ia64/*.java \ sun/jvm/hotspot/runtime/linux/*.java \ sun/jvm/hotspot/runtime/linux_amd64/*.java \ -sun/jvm/hotspot/runtime/linux_ia64/*.java \ sun/jvm/hotspot/runtime/linux_sparc/*.java \ sun/jvm/hotspot/runtime/linux_x86/*.java \ sun/jvm/hotspot/runtime/posix/*.java \ @@ -198,7 +188,6 @@ sun/jvm/hotspot/runtime/solaris_sparc/*.java \ sun/jvm/hotspot/runtime/solaris_x86/*.java \ sun/jvm/hotspot/runtime/sparc/*.java \ sun/jvm/hotspot/runtime/win32_amd64/*.java \ -sun/jvm/hotspot/runtime/win32_ia64/*.java \ sun/jvm/hotspot/runtime/win32_x86/*.java \ sun/jvm/hotspot/runtime/x86/*.java \ sun/jvm/hotspot/tools/*.java \ @@ -258,6 +247,7 @@ SA_BUILD_VERSION_PROP = "sun.jvm.hotspot.runtime.VM.saBuildVersion=$(SA_BUILD_VE SA_PROPERTIES = $(OUTPUT_DIR)/sa.properties JAVAC = $(JDK_HOME)/bin/javac +JAVA = $(JDK_HOME)/bin/java JAVADOC = $(JDK_HOME)/bin/javadoc RMIC = $(JDK_HOME)/bin/rmic @@ -298,7 +288,7 @@ filelist: $(ALLFILES) .PHONY: natives natives: - cd ../src/os/`java -classpath $(OUTPUT_DIR) sun.jvm.hotspot.utilities.PlatformInfo`; $(MAKE) all + cd ../src/os/`$(JAVA) -classpath $(OUTPUT_DIR) sun.jvm.hotspot.utilities.PlatformInfo`; $(MAKE) all .PHONY: sa-jdi.jar sa-jdi.jar: @@ -323,5 +313,5 @@ sa.jar: clean:: rm -rf filelist - cd ../src/os/`java -classpath $(OUTPUT_DIR) sun.jvm.hotspot.utilities.PlatformInfo`; $(MAKE) clean + cd ../src/os/`$(JAVA) -classpath $(OUTPUT_DIR) sun.jvm.hotspot.utilities.PlatformInfo`; $(MAKE) clean rm -rf $(BUILD_DIR)/* diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java index c640e4ecc72..23058f42858 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java @@ -33,6 +33,7 @@ import sun.jvm.hotspot.types.Type; import sun.jvm.hotspot.types.Field; import sun.jvm.hotspot.HotSpotTypeDataBase; import sun.jvm.hotspot.types.basic.BasicType; +import sun.jvm.hotspot.types.basic.BasicTypeDataBase; import sun.jvm.hotspot.types.CIntegerType; import sun.jvm.hotspot.code.*; import sun.jvm.hotspot.compiler.*; @@ -448,6 +449,112 @@ public class CommandProcessor { } } }, + new Command("dumpreplaydata", "dumpreplaydata {

| -a | }", false) { + // This is used to dump replay data from ciInstanceKlass, ciMethodData etc + // default file name is replay.txt, also if java crashes in compiler + // thread, this file will be dumped in error processing. + public void doit(Tokens t) { + if (t.countTokens() != 1) { + usage(); + return; + } + String name = t.nextToken(); + Address a = null; + try { + a = VM.getVM().getDebugger().parseAddress(name); + } catch (NumberFormatException e) { } + if (a != null) { + // only nmethod, Method, MethodData and InstanceKlass needed to + // dump replay data + + CodeBlob cb = VM.getVM().getCodeCache().findBlob(a); + if (cb != null && (cb instanceof NMethod)) { + ((NMethod)cb).dumpReplayData(out); + return; + } + // assume it is Metadata + Metadata meta = Metadata.instantiateWrapperFor(a); + if (meta != null) { + meta.dumpReplayData(out); + } else { + usage(); + return; + } + } + // Not an address + boolean all = name.equals("-a"); + Threads threads = VM.getVM().getThreads(); + for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + thread.printThreadIDOn(new PrintStream(bos)); + if (all || bos.toString().equals(name)) { + if (thread instanceof CompilerThread) { + CompilerThread ct = (CompilerThread)thread; + ciEnv env = ct.env(); + if (env != null) { + env.dumpReplayData(out); + } + } + } + } + } + }, + new Command("buildreplayjars", "buildreplayjars [ all | app | boot ] | [ prefix ]", false) { + // This is used to dump jar files of all the classes + // loaded in the core. Everything on the bootclasspath + // will go in boot.jar and everything else will go in + // app.jar. Then the classes can be loaded by the replay + // jvm using -Xbootclasspath/p:boot.jar -cp app.jar. boot.jar usually + // not needed, unless changed by jvmti. + public void doit(Tokens t) { + int tcount = t.countTokens(); + if (tcount > 2) { + usage(); + return; + } + try { + String prefix = ""; + String option = "all"; // default + switch(tcount) { + case 0: + break; + case 1: + option = t.nextToken(); + if (!option.equalsIgnoreCase("all") && !option.equalsIgnoreCase("app") && + !option.equalsIgnoreCase("root")) { + prefix = option; + option = "all"; + } + break; + case 2: + option = t.nextToken(); + prefix = t.nextToken(); + break; + default: + usage(); + return; + } + if (!option.equalsIgnoreCase("all") && !option.equalsIgnoreCase("app") && + !option.equalsIgnoreCase("boot")) { + usage(); + return; + } + ClassDump cd = new ClassDump(); + if (option.equalsIgnoreCase("all") || option.equalsIgnoreCase("boot")) { + cd.setClassFilter(new BootFilter()); + cd.setJarOutput(prefix + "boot.jar"); + cd.run(); + } + if (option.equalsIgnoreCase("all") || option.equalsIgnoreCase("app")) { + cd.setClassFilter(new NonBootFilter()); + cd.setJarOutput(prefix + "app.jar"); + cd.run(); + } + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + }, new Command("findpc", "findpc address", false) { public void doit(Tokens t) { if (t.countTokens() != 1) { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciBaseObject.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciBaseObject.java index fc8826e8d23..e69be922fe0 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciBaseObject.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciBaseObject.java @@ -16,9 +16,9 @@ * 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. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -50,4 +50,8 @@ public class ciBaseObject extends VMObject { public ciBaseObject(Address addr) { super(addr); } + + public void dumpReplayData(PrintStream out) { + out.println("# Unknown ci type " + getAddress().getAddressAt(0)); + } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciConstant.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciConstant.java index ab69f43984d..0b75eac3e29 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciConstant.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciConstant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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 @@ -16,9 +16,9 @@ * 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. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -60,4 +60,8 @@ public class ciConstant extends VMObject { public ciConstant(Address addr) { super(addr); } + + public void dumpReplayData(PrintStream out) { + // Nothing to be done + } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java index eb48eedb330..871ee414a44 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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 @@ -16,9 +16,9 @@ * 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. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -74,4 +74,29 @@ public class ciEnv extends VMObject { public CompileTask task() { return new CompileTask(taskField.getValue(this.getAddress())); } + + public void dumpReplayData(PrintStream out) { + out.println("JvmtiExport can_access_local_variables " + + (JvmtiExport.canAccessLocalVariables() ? '1' : '0')); + out.println("JvmtiExport can_hotswap_or_post_breakpoint " + + (JvmtiExport.canHotswapOrPostBreakpoint() ? '1' : '0')); + out.println("JvmtiExport can_post_on_exceptions " + + (JvmtiExport.canPostOnExceptions() ? '1' : '0')); + + GrowableArray objects = factory().objects(); + out.println("# " + objects.length() + " ciObject found"); + for (int i = 0; i < objects.length(); i++) { + ciMetadata o = objects.at(i); + out.println("# ciMetadata" + i + " @ " + o); + o.dumpReplayData(out); + } + CompileTask task = task(); + Method method = task.method(); + int entryBci = task.osrBci(); + Klass holder = method.getMethodHolder(); + out.println("compile " + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + entryBci); + } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java index 4798977ab1a..0d0a0f63740 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java @@ -16,9 +16,9 @@ * 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. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -80,4 +80,84 @@ public class ciInstanceKlass extends ciKlass { public boolean isInitialized() { return initState() == CLASS_STATE_FULLY_INITIALIZED; } + + public void dumpReplayData(PrintStream out) { + InstanceKlass ik = (InstanceKlass)getMetadata(); + ConstantPool cp = ik.getConstants(); + + // Try to record related loaded classes + Klass sub = ik.getSubklassKlass(); + while (sub != null) { + if (sub instanceof InstanceKlass) { + out.println("instanceKlass " + sub.getName().asString()); + } + sub = sub.getNextSiblingKlass(); + } + + final int length = (int) cp.getLength(); + out.print("ciInstanceKlass " + name() + " " + (isLinked() ? 1 : 0) + " " + (isInitialized() ? 1 : 0) + " " + length); + for (int index = 1; index < length; index++) { + out.print(" " + cp.getTags().at(index)); + } + out.println(); + if (isInitialized()) { + Field[] staticFields = ik.getStaticFields(); + for (int i = 0; i < staticFields.length; i++) { + Field f = staticFields[i]; + Oop mirror = ik.getJavaMirror(); + if (f.isFinal() && !f.hasInitialValue()) { + out.print("staticfield " + name() + " " + + OopUtilities.escapeString(f.getID().getName()) + " " + + f.getFieldType().getSignature().asString() + " "); + if (f instanceof ByteField) { + ByteField bf = (ByteField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof BooleanField) { + BooleanField bf = (BooleanField)f; + out.println(bf.getValue(mirror) ? 1 : 0); + } else if (f instanceof ShortField) { + ShortField bf = (ShortField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof CharField) { + CharField bf = (CharField)f; + out.println(bf.getValue(mirror) & 0xffff); + } else if (f instanceof IntField) { + IntField bf = (IntField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof LongField) { + LongField bf = (LongField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof FloatField) { + FloatField bf = (FloatField)f; + out.println(Float.floatToRawIntBits(bf.getValue(mirror))); + } else if (f instanceof DoubleField) { + DoubleField bf = (DoubleField)f; + out.println(Double.doubleToRawLongBits(bf.getValue(mirror))); + } else if (f instanceof OopField) { + OopField bf = (OopField)f; + Oop value = bf.getValue(mirror); + if (value == null) { + out.println("null"); + } else if (value.isInstance()) { + Instance inst = (Instance)value; + if (inst.isA(SystemDictionary.getStringKlass())) { + out.println("\"" + OopUtilities.stringOopToEscapedString(inst) + "\""); + } else { + out.println(inst.getKlass().getName().asString()); + } + } else if (value.isObjArray()) { + ObjArray oa = (ObjArray)value; + Klass ek = (ObjArrayKlass)oa.getKlass(); + out.println(oa.getLength() + " " + ek.getName().asString()); + } else if (value.isTypeArray()) { + TypeArray ta = (TypeArray)value; + out.println(ta.getLength()); + } else { + out.println(value); + } + } + } + } + } + } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java index 45d43cd0d16..3468b0d6514 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java @@ -16,9 +16,9 @@ * 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. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -88,4 +88,19 @@ public class ciMethod extends ciMetadata { st.printf(" %s::%s", method.getMethodHolder().getName().asString().replace('/', '.'), method.getName().asString()); } + + public void dumpReplayData(PrintStream out) { + Method method = (Method)getMetadata(); + NMethod nm = method.getNativeMethod(); + Klass holder = method.getMethodHolder(); + out.println("ciMethod " + + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + method.getInvocationCounter() + " " + + method.getBackedgeCounter() + " " + + interpreterInvocationCount() + " " + + interpreterThrowoutCount() + " " + + instructionsSize()); + } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java index 0399e275151..117a9488cf7 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java @@ -16,9 +16,9 @@ * 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. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -174,4 +174,52 @@ public class ciMethodData extends ciMetadata { } } + public void dumpReplayData(PrintStream out) { + MethodData mdo = (MethodData)getMetadata(); + Method method = mdo.getMethod(); + Klass holder = method.getMethodHolder(); + out.print("ciMethodData " + + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + state() + " " + currentMileage()); + byte[] orig = orig(); + out.print(" orig " + orig.length); + for (int i = 0; i < orig.length; i++) { + out.print(" " + (orig[i] & 0xff)); + } + + long[] data = data(); + out.print(" data " + data.length); + for (int i = 0; i < data.length; i++) { + out.print(" 0x" + Long.toHexString(data[i])); + } + int count = 0; + for (int round = 0; round < 2; round++) { + if (round == 1) out.print(" oops " + count); + ProfileData pdata = firstData(); + for ( ; isValid(pdata); pdata = nextData(pdata)) { + if (pdata instanceof ciReceiverTypeData) { + ciReceiverTypeData vdata = (ciReceiverTypeData)pdata; + for (int i = 0; i < vdata.rowLimit(); i++) { + ciKlass k = vdata.receiverAt(i); + if (k != null) { + if (round == 0) count++; + else out.print(" " + ((vdata.dp() + vdata.cellOffset(vdata.receiverCellIndex(i))) / MethodData.cellSize) + " " + k.name()); + } + } + } else if (pdata instanceof ciVirtualCallData) { + ciVirtualCallData vdata = (ciVirtualCallData)pdata; + for (int i = 0; i < vdata.rowLimit(); i++) { + ciKlass k = vdata.receiverAt(i); + if (k != null) { + if (round == 0) count++; + else out.print(" " + ((vdata.dp() + vdata.cellOffset(vdata.receiverCellIndex(i))) / MethodData.cellSize + " " + k.name())); + } + } + } + } + } + out.println(); + } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java index 839ad00aafb..b0b370cef3c 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java @@ -498,6 +498,42 @@ public class NMethod extends CodeBlob { method.getSignature().asString(); } + public void dumpReplayData(PrintStream out) { + HashMap h = new HashMap(); + for (int i = 1; i < getMetadataLength(); i++) { + Metadata meta = Metadata.instantiateWrapperFor(getMetadataAt(i)); + System.err.println(meta); + if (h.get(meta) != null) continue; + h.put(meta, meta); + if (meta instanceof InstanceKlass) { + ((InstanceKlass)meta).dumpReplayData(out); + } else if (meta instanceof Method) { + ((Method)meta).dumpReplayData(out); + MethodData mdo = ((Method)meta).getMethodData(); + if (mdo != null) { + mdo.dumpReplayData(out); + } + } + } + Method method = getMethod(); + if (h.get(method) == null) { + method.dumpReplayData(out); + MethodData mdo = method.getMethodData(); + if (mdo != null) { + mdo.dumpReplayData(out); + } + } + if (h.get(method.getMethodHolder()) == null) { + ((InstanceKlass)method.getMethodHolder()).dumpReplayData(out); + } + Klass holder = method.getMethodHolder(); + out.println("compile " + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + getEntryBCI()); + + } + //-------------------------------------------------------------------------------- // Internals only below this point // diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java index deca63123df..45ef0a2d27a 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java @@ -56,7 +56,7 @@ public class CompileTask extends VMObject { } public Method method() { - Address oh = methodField.getValue(getAddress()).getAddressAt(0); + Address oh = methodField.getValue(getAddress()); return (Method)Metadata.instantiateWrapperFor(oh); } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java index 7b7d0c3ad1d..b238cd30992 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java @@ -86,7 +86,7 @@ public class ConstantPoolCache extends Metadata { public void printValueOn(PrintStream tty) { - tty.print("ConstantPoolCache for " + getConstants().getPoolHolder().getName().asString()); + tty.print("ConstantPoolCache for " + getConstants().getPoolHolder().getName().asString() + " address = " + getAddress() + " offset = " + baseOffset); } public int getLength() { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java index 665315361c8..621c8cf4b9a 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java @@ -110,6 +110,8 @@ public class Field { public Symbol getSignature() { return signature; } public Symbol getGenericSignature() { return genericSignature; } + public boolean hasInitialValue() { return holder.getFieldInitialValueIndex(fieldIndex) != 0; } + // // Following acccessors are for named, non-VM fields only // diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java index a2c7afb6027..ba07fa34800 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @@ -278,7 +278,7 @@ public class InstanceKlass extends Klass { } public short getFieldGenericSignatureIndex(int index) { - int len = getFields().length(); + // int len = getFields().length(); int allFieldsCount = getAllFieldsCount(); int generic_signature_slot = allFieldsCount * FIELD_SLOTS; for (int i = 0; i < allFieldsCount; i++) { @@ -325,7 +325,7 @@ public class InstanceKlass extends Klass { public KlassArray getTransitiveInterfaces() { return new KlassArray(transitiveInterfaces.getValue(getAddress())); } public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } public int getAllFieldsCount() { - int len = getFields().length(); + int len = getFields().length(); int allFieldsCount = 0; for (; allFieldsCount*FIELD_SLOTS < len; allFieldsCount++) { short flags = getFieldAccessFlags(allFieldsCount); @@ -581,6 +581,19 @@ public class InstanceKlass extends Klass { } } + public Field[] getStaticFields() { + U2Array fields = getFields(); + int length = getJavaFieldsCount(); + ArrayList result = new ArrayList(); + for (int index = 0; index < length; index++) { + Field f = newField(index); + if (f.isStatic()) { + result.add(f); + } + } + return (Field[])result.toArray(new Field[result.size()]); + } + public void iterateNonStaticFields(OopVisitor visitor, Oop obj) { if (getSuper() != null) { ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj); @@ -979,4 +992,84 @@ public class InstanceKlass extends Klass { } return -1; } + + public void dumpReplayData(PrintStream out) { + ConstantPool cp = getConstants(); + + // Try to record related loaded classes + Klass sub = getSubklassKlass(); + while (sub != null) { + if (sub instanceof InstanceKlass) { + out.println("instanceKlass " + sub.getName().asString()); + } + sub = sub.getNextSiblingKlass(); + } + + final int length = (int) cp.getLength(); + out.print("ciInstanceKlass " + getName().asString() + " " + (isLinked() ? 1 : 0) + " " + (isInitialized() ? 1 : 0) + " " + length); + for (int index = 1; index < length; index++) { + out.print(" " + cp.getTags().at(index)); + } + out.println(); + if (isInitialized()) { + Field[] staticFields = getStaticFields(); + for (int i = 0; i < staticFields.length; i++) { + Field f = staticFields[i]; + Oop mirror = getJavaMirror(); + if (f.isFinal() && !f.hasInitialValue()) { + out.print("staticfield " + getName().asString() + " " + + OopUtilities.escapeString(f.getID().getName()) + " " + + f.getFieldType().getSignature().asString() + " "); + if (f instanceof ByteField) { + ByteField bf = (ByteField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof BooleanField) { + BooleanField bf = (BooleanField)f; + out.println(bf.getValue(mirror) ? 1 : 0); + } else if (f instanceof ShortField) { + ShortField bf = (ShortField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof CharField) { + CharField bf = (CharField)f; + out.println(bf.getValue(mirror) & 0xffff); + } else if (f instanceof IntField) { + IntField bf = (IntField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof LongField) { + LongField bf = (LongField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof FloatField) { + FloatField bf = (FloatField)f; + out.println(Float.floatToRawIntBits(bf.getValue(mirror))); + } else if (f instanceof DoubleField) { + DoubleField bf = (DoubleField)f; + out.println(Double.doubleToRawLongBits(bf.getValue(mirror))); + } else if (f instanceof OopField) { + OopField bf = (OopField)f; + + Oop value = bf.getValue(mirror); + if (value == null) { + out.println("null"); + } else if (value.isInstance()) { + Instance inst = (Instance)value; + if (inst.isA(SystemDictionary.getStringKlass())) { + out.println("\"" + OopUtilities.stringOopToEscapedString(inst) + "\""); + } else { + out.println(inst.getKlass().getName().asString()); + } + } else if (value.isObjArray()) { + ObjArray oa = (ObjArray)value; + Klass ek = (ObjArrayKlass)oa.getKlass(); + out.println(oa.getLength() + " " + ek.getName().asString()); + } else if (value.isTypeArray()) { + TypeArray ta = (TypeArray)value; + out.println(ta.getLength()); + } else { + out.println(value); + } + } + } + } + } + } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Metadata.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Metadata.java index 35ce375b52e..4fc2ed8c6a8 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Metadata.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Metadata.java @@ -79,4 +79,7 @@ abstract public class Metadata extends VMObject { } abstract public void printValueOn(PrintStream tty); + public void dumpReplayData(PrintStream out) { + out.println("# Unknown Metadata"); + } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java index 449c0695bd1..2fd57fd9728 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java @@ -358,6 +358,25 @@ public class Method extends Metadata { buf.append(")"); return buf.toString().replace('/', '.'); } + + public void dumpReplayData(PrintStream out) { + NMethod nm = getNativeMethod(); + int code_size = 0; + if (nm != null) { + code_size = (int)nm.codeEnd().minus(nm.getVerifiedEntryPoint()); + } + Klass holder = getMethodHolder(); + out.println("ciMethod " + + holder.getName().asString() + " " + + OopUtilities.escapeString(getName().asString()) + " " + + getSignature().asString() + " " + + getInvocationCounter() + " " + + getBackedgeCounter() + " " + + interpreterInvocationCount() + " " + + interpreterThrowoutCount() + " " + + code_size); + } + public int interpreterThrowoutCount() { return (int) interpreterThrowoutCountField.getValue(this); } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java index e6d233f1471..40ede727708 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java @@ -332,4 +332,59 @@ public class MethodData extends Metadata { public int currentMileage() { return 20000; } + + public void dumpReplayData(PrintStream out) { + Method method = getMethod(); + Klass holder = method.getMethodHolder(); + out.print("ciMethodData " + + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + "2" + " " + + currentMileage()); + byte[] orig = orig(); + out.print(" orig " + orig.length); + for (int i = 0; i < orig.length; i++) { + out.print(" " + (orig[i] & 0xff)); + } + + long[] data = data(); + out.print(" data " + data.length); + for (int i = 0; i < data.length; i++) { + out.print(" 0x" + Long.toHexString(data[i])); + } + int count = 0; + for (int round = 0; round < 2; round++) { + if (round == 1) out.print(" oops " + count); + ProfileData pdata = firstData(); + for ( ; isValid(pdata); pdata = nextData(pdata)) { + if (pdata instanceof ReceiverTypeData) { + ReceiverTypeData vdata = (ReceiverTypeData)pdata; + for (int i = 0; i < vdata.rowLimit(); i++) { + Klass k = vdata.receiver(i); + if (k != null) { + if (round == 0) count++; + else out.print(" " + + (dpToDi(vdata.dp() + + vdata.cellOffset(vdata.receiverCellIndex(i))) / cellSize) + " " + + k.getName().asString()); + } + } + } else if (pdata instanceof VirtualCallData) { + VirtualCallData vdata = (VirtualCallData)pdata; + for (int i = 0; i < vdata.rowLimit(); i++) { + Klass k = vdata.receiver(i); + if (k != null) { + if (round == 0) count++; + else out.print(" " + + (dpToDi(vdata.dp() + + vdata.cellOffset(vdata.receiverCellIndex(i))) / cellSize) + " " + + k.getName().asString()); + } + } + } + } + } + out.println(); + } } diff --git a/hotspot/src/share/vm/ci/ciClassList.hpp b/hotspot/src/share/vm/ci/ciClassList.hpp index 7272ea87586..71e5dd18c7f 100644 --- a/hotspot/src/share/vm/ci/ciClassList.hpp +++ b/hotspot/src/share/vm/ci/ciClassList.hpp @@ -106,6 +106,7 @@ friend class ciSymbol; \ friend class ciArray; \ friend class ciObjArray; \ friend class ciMetadata; \ +friend class ciReplay; \ friend class ciTypeArray; \ friend class ciType; \ friend class ciReturnAddress; \ diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp index 0465b9cf9c1..878313d1110 100644 --- a/hotspot/src/share/vm/ci/ciEnv.cpp +++ b/hotspot/src/share/vm/ci/ciEnv.cpp @@ -30,6 +30,7 @@ #include "ci/ciInstanceKlass.hpp" #include "ci/ciMethod.hpp" #include "ci/ciNullObject.hpp" +#include "ci/ciReplay.hpp" #include "ci/ciUtilities.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" @@ -772,6 +773,11 @@ ciMethod* ciEnv::get_method_by_index_impl(constantPoolHandle cpool, : !m->method_holder()->is_loaded())) { m = NULL; } +#ifdef ASSERT + if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) { + m = NULL; + } +#endif if (m != NULL) { // We found the method. return get_method(m); @@ -1144,3 +1150,43 @@ void ciEnv::record_out_of_memory_failure() { // If memory is low, we stop compiling methods. record_method_not_compilable("out of memory"); } + +fileStream* ciEnv::_replay_data_stream = NULL; + +void ciEnv::dump_replay_data() { + VM_ENTRY_MARK; + MutexLocker ml(Compile_lock); + if (_replay_data_stream == NULL) { + _replay_data_stream = new (ResourceObj::C_HEAP, mtCompiler) fileStream(ReplayDataFile); + if (_replay_data_stream == NULL) { + fatal(err_msg("Can't open %s for replay data", ReplayDataFile)); + } + } + dump_replay_data(_replay_data_stream); +} + + +void ciEnv::dump_replay_data(outputStream* out) { + ASSERT_IN_VM; + +#if INCLUDE_JVMTI + out->print_cr("JvmtiExport can_access_local_variables %d", _jvmti_can_access_local_variables); + out->print_cr("JvmtiExport can_hotswap_or_post_breakpoint %d", _jvmti_can_hotswap_or_post_breakpoint); + out->print_cr("JvmtiExport can_post_on_exceptions %d", _jvmti_can_post_on_exceptions); +#endif // INCLUDE_JVMTI + + GrowableArray* objects = _factory->get_ci_metadata(); + out->print_cr("# %d ciObject found", objects->length()); + for (int i = 0; i < objects->length(); i++) { + objects->at(i)->dump_replay_data(out); + } + Method* method = task()->method(); + int entry_bci = task()->osr_bci(); + // Klass holder = method->method_holder(); + out->print_cr("compile %s %s %s %d", + method->klass_name()->as_quoted_ascii(), + method->name()->as_quoted_ascii(), + method->signature()->as_quoted_ascii(), + entry_bci); + out->flush(); +} diff --git a/hotspot/src/share/vm/ci/ciEnv.hpp b/hotspot/src/share/vm/ci/ciEnv.hpp index f252dc7c0f4..042bc32fa00 100644 --- a/hotspot/src/share/vm/ci/ciEnv.hpp +++ b/hotspot/src/share/vm/ci/ciEnv.hpp @@ -46,6 +46,8 @@ class ciEnv : StackObj { friend class CompileBroker; friend class Dependencies; // for get_object, during logging + static fileStream* _replay_data_stream; + private: Arena* _arena; // Alias for _ciEnv_arena except in init_shared_objects() Arena _ciEnv_arena; @@ -448,6 +450,13 @@ public: // RedefineClasses support void metadata_do(void f(Metadata*)) { _factory->metadata_do(f); } + + // Dump the compilation replay data for this ciEnv to + // ReplayDataFile, creating the file if needed. + void dump_replay_data(); + + // Dump the compilation replay data for the ciEnv to the stream. + void dump_replay_data(outputStream* out); }; #endif // SHARE_VM_CI_CIENV_HPP diff --git a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp index 7a3eb328f57..de5e973bfbf 100644 --- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp +++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp @@ -561,3 +561,114 @@ ciInstanceKlass* ciInstanceKlass::implementor() { } return impl; } + +// Utility class for printing of the contents of the static fields for +// use by compilation replay. It only prints out the information that +// could be consumed by the compiler, so for primitive types it prints +// out the actual value. For Strings it's the actual string value. +// For array types it it's first level array size since that's the +// only value which statically unchangeable. For all other reference +// types it simply prints out the dynamic type. + +class StaticFinalFieldPrinter : public FieldClosure { + outputStream* _out; + const char* _holder; + public: + StaticFinalFieldPrinter(outputStream* out, const char* holder) : + _out(out), + _holder(holder) { + } + void do_field(fieldDescriptor* fd) { + if (fd->is_final() && !fd->has_initial_value()) { + oop mirror = fd->field_holder()->java_mirror(); + _out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii()); + switch (fd->field_type()) { + case T_BYTE: _out->print_cr("%d", mirror->byte_field(fd->offset())); break; + case T_BOOLEAN: _out->print_cr("%d", mirror->bool_field(fd->offset())); break; + case T_SHORT: _out->print_cr("%d", mirror->short_field(fd->offset())); break; + case T_CHAR: _out->print_cr("%d", mirror->char_field(fd->offset())); break; + case T_INT: _out->print_cr("%d", mirror->int_field(fd->offset())); break; + case T_LONG: _out->print_cr(INT64_FORMAT, mirror->long_field(fd->offset())); break; + case T_FLOAT: { + float f = mirror->float_field(fd->offset()); + _out->print_cr("%d", *(int*)&f); + break; + } + case T_DOUBLE: { + double d = mirror->double_field(fd->offset()); + _out->print_cr(INT64_FORMAT, *(jlong*)&d); + break; + } + case T_ARRAY: { + oop value = mirror->obj_field_acquire(fd->offset()); + if (value == NULL) { + _out->print_cr("null"); + } else { + typeArrayOop ta = (typeArrayOop)value; + _out->print("%d", ta->length()); + if (value->is_objArray()) { + objArrayOop oa = (objArrayOop)value; + const char* klass_name = value->klass()->name()->as_quoted_ascii(); + _out->print(" %s", klass_name); + } + _out->cr(); + } + break; + } + case T_OBJECT: { + oop value = mirror->obj_field_acquire(fd->offset()); + if (value == NULL) { + _out->print_cr("null"); + } else if (value->is_instance()) { + if (value->is_a(SystemDictionary::String_klass())) { + _out->print("\""); + _out->print_raw(java_lang_String::as_quoted_ascii(value)); + _out->print_cr("\""); + } else { + const char* klass_name = value->klass()->name()->as_quoted_ascii(); + _out->print_cr(klass_name); + } + } else { + ShouldNotReachHere(); + } + break; + } + default: + ShouldNotReachHere(); + } + } + } +}; + + +void ciInstanceKlass::dump_replay_data(outputStream* out) { + ASSERT_IN_VM; + InstanceKlass* ik = get_instanceKlass(); + ConstantPool* cp = ik->constants(); + + // Try to record related loaded classes + Klass* sub = ik->subklass(); + while (sub != NULL) { + if (sub->oop_is_instance()) { + out->print_cr("instanceKlass %s", sub->name()->as_quoted_ascii()); + } + sub = sub->next_sibling(); + } + + // Dump out the state of the constant pool tags. During replay the + // tags will be validated for things which shouldn't change and + // classes will be resolved if the tags indicate that they were + // resolved at compile time. + out->print("ciInstanceKlass %s %d %d %d", ik->name()->as_quoted_ascii(), + is_linked(), is_initialized(), cp->length()); + for (int index = 1; index < cp->length(); index++) { + out->print(" %d", cp->tags()->at(index)); + } + out->cr(); + if (is_initialized()) { + // Dump out the static final fields in case the compilation relies + // on their value for correct replay. + StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii()); + ik->do_local_static_fields(&sffp); + } +} diff --git a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp index 205ee493d55..f7aeba2df3b 100644 --- a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp +++ b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp @@ -230,6 +230,9 @@ public: // What kind of ciObject is this? bool is_instance_klass() const { return true; } bool is_java_klass() const { return true; } + + // Dump the current state of this klass for compilation replay. + virtual void dump_replay_data(outputStream* out); }; #endif // SHARE_VM_CI_CIINSTANCEKLASS_HPP diff --git a/hotspot/src/share/vm/ci/ciMetadata.hpp b/hotspot/src/share/vm/ci/ciMetadata.hpp index cbd0bc0287e..e0baea9666d 100644 --- a/hotspot/src/share/vm/ci/ciMetadata.hpp +++ b/hotspot/src/share/vm/ci/ciMetadata.hpp @@ -61,6 +61,7 @@ class ciMetadata: public ciBaseObject { virtual bool is_array_klass() const { return false; } virtual bool is_obj_array_klass() const { return false; } virtual bool is_type_array_klass() const { return false; } + virtual void dump_replay_data(outputStream* st) { /* do nothing */ } ciMethod* as_method() { assert(is_method(), "bad cast"); diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp index 7071f54d0af..951183d60bd 100644 --- a/hotspot/src/share/vm/ci/ciMethod.cpp +++ b/hotspot/src/share/vm/ci/ciMethod.cpp @@ -31,6 +31,7 @@ #include "ci/ciMethodData.hpp" #include "ci/ciStreams.hpp" #include "ci/ciSymbol.hpp" +#include "ci/ciReplay.hpp" #include "ci/ciUtilities.hpp" #include "classfile/systemDictionary.hpp" #include "compiler/abstractCompiler.hpp" @@ -139,6 +140,12 @@ ciMethod::ciMethod(methodHandle h_m) : ciMetadata(h_m()) { } if (_interpreter_invocation_count == 0) _interpreter_invocation_count = 1; + _instructions_size = -1; +#ifdef ASSERT + if (ReplayCompiles) { + ciReplay::initialize(this); + } +#endif } @@ -161,7 +168,8 @@ ciMethod::ciMethod(ciInstanceKlass* holder, #if defined(COMPILER2) || defined(SHARK) , _flow( NULL), - _bcea( NULL) + _bcea( NULL), + _instructions_size(-1) #endif // COMPILER2 || SHARK { // Usually holder and accessor are the same type but in some cases @@ -1000,8 +1008,7 @@ bool ciMethod::can_be_osr_compiled(int entry_bci) { // ------------------------------------------------------------------ // ciMethod::has_compiled_code bool ciMethod::has_compiled_code() { - VM_ENTRY_MARK; - return get_Method()->code() != NULL; + return instructions_size() > 0; } int ciMethod::comp_level() { @@ -1039,14 +1046,18 @@ int ciMethod::code_size_for_inlining() { // junk like exception handler, stubs, and constant table, which are // not highly relevant to an inlined method. So we use the more // specific accessor nmethod::insts_size. -int ciMethod::instructions_size(int comp_level) { - GUARDED_VM_ENTRY( - nmethod* code = get_Method()->code(); - if (code != NULL && (comp_level == CompLevel_any || comp_level == code->comp_level())) { - return code->insts_end() - code->verified_entry_point(); - } - return 0; - ) +int ciMethod::instructions_size() { + if (_instructions_size == -1) { + GUARDED_VM_ENTRY( + nmethod* code = get_Method()->code(); + if (code != NULL && (code->comp_level() == CompLevel_full_optimization)) { + _instructions_size = code->insts_end() - code->verified_entry_point(); + } else { + _instructions_size = 0; + } + ); + } + return _instructions_size; } // ------------------------------------------------------------------ @@ -1166,6 +1177,20 @@ ciMethodBlocks *ciMethod::get_method_blocks() { #undef FETCH_FLAG_FROM_VM +void ciMethod::dump_replay_data(outputStream* st) { + ASSERT_IN_VM; + Method* method = get_Method(); + Klass* holder = method->method_holder(); + st->print_cr("ciMethod %s %s %s %d %d %d %d %d", + holder->name()->as_quoted_ascii(), + method->name()->as_quoted_ascii(), + method->signature()->as_quoted_ascii(), + method->invocation_counter()->raw_counter(), + method->backedge_counter()->raw_counter(), + interpreter_invocation_count(), + interpreter_throwout_count(), + _instructions_size); +} // ------------------------------------------------------------------ // ciMethod::print_codes diff --git a/hotspot/src/share/vm/ci/ciMethod.hpp b/hotspot/src/share/vm/ci/ciMethod.hpp index 15f65213374..ecbaacc45d3 100644 --- a/hotspot/src/share/vm/ci/ciMethod.hpp +++ b/hotspot/src/share/vm/ci/ciMethod.hpp @@ -51,6 +51,7 @@ class ciMethod : public ciMetadata { friend class ciExceptionHandlerStream; friend class ciBytecodeStream; friend class ciMethodHandle; + friend class ciReplay; private: // General method information. @@ -69,6 +70,7 @@ class ciMethod : public ciMetadata { int _handler_count; int _interpreter_invocation_count; int _interpreter_throwout_count; + int _instructions_size; bool _uses_monitors; bool _balanced_monitors; @@ -252,7 +254,6 @@ class ciMethod : public ciMetadata { bool can_be_osr_compiled(int entry_bci); void set_not_compilable(); bool has_compiled_code(); - int instructions_size(int comp_level = CompLevel_any); void log_nmethod_identity(xmlStream* log); bool is_not_reached(int bci); bool was_executed_more_than(int times); @@ -260,6 +261,7 @@ class ciMethod : public ciMetadata { bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const; bool check_call(int refinfo_index, bool is_static) const; bool ensure_method_data(); // make sure it exists in the VM also + int instructions_size(); int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC // JSR 292 support @@ -291,6 +293,7 @@ class ciMethod : public ciMetadata { bool is_accessor () const; bool is_initializer () const; bool can_be_statically_bound() const { return _can_be_statically_bound; } + void dump_replay_data(outputStream* st); // Print the bytecodes of this method. void print_codes_on(outputStream* st); diff --git a/hotspot/src/share/vm/ci/ciMethodData.cpp b/hotspot/src/share/vm/ci/ciMethodData.cpp index aef1c03c7bc..ee5490be877 100644 --- a/hotspot/src/share/vm/ci/ciMethodData.cpp +++ b/hotspot/src/share/vm/ci/ciMethodData.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "ci/ciMetadata.hpp" #include "ci/ciMethodData.hpp" +#include "ci/ciReplay.hpp" #include "ci/ciUtilities.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" @@ -115,6 +116,11 @@ void ciMethodData::load_data() { _arg_local = mdo->arg_local(); _arg_stack = mdo->arg_stack(); _arg_returned = mdo->arg_returned(); +#ifndef PRODUCT + if (ReplayCompiles) { + ciReplay::initialize(this); + } +#endif } void ciReceiverTypeData::translate_receiver_data_from(ProfileData* data) { @@ -366,6 +372,79 @@ void ciMethodData::print_impl(outputStream* st) { ciMetadata::print_impl(st); } +void ciMethodData::dump_replay_data(outputStream* out) { + ASSERT_IN_VM; + MethodData* mdo = get_MethodData(); + Method* method = mdo->method(); + Klass* holder = method->method_holder(); + out->print("ciMethodData %s %s %s %d %d", + holder->name()->as_quoted_ascii(), + method->name()->as_quoted_ascii(), + method->signature()->as_quoted_ascii(), + _state, + current_mileage()); + + // dump the contents of the MDO header as raw data + unsigned char* orig = (unsigned char*)&_orig; + int length = sizeof(_orig); + out->print(" orig %d", length); + for (int i = 0; i < length; i++) { + out->print(" %d", orig[i]); + } + + // dump the MDO data as raw data + int elements = data_size() / sizeof(intptr_t); + out->print(" data %d", elements); + for (int i = 0; i < elements; i++) { + // We could use INTPTR_FORMAT here but that's a zero justified + // which makes comparing it with the SA version of this output + // harder. +#ifdef _LP64 + out->print(" 0x%" FORMAT64_MODIFIER "x", data()[i]); +#else + out->print(" 0x%x", data()[i]); +#endif + } + + // The MDO contained oop references as ciObjects, so scan for those + // and emit pairs of offset and klass name so that they can be + // reconstructed at runtime. The first round counts the number of + // oop references and the second actually emits them. + int count = 0; + for (int round = 0; round < 2; round++) { + if (round == 1) out->print(" oops %d", count); + ProfileData* pdata = first_data(); + for ( ; is_valid(pdata); pdata = next_data(pdata)) { + if (pdata->is_ReceiverTypeData()) { + ciReceiverTypeData* vdata = (ciReceiverTypeData*)pdata; + for (uint i = 0; i < vdata->row_limit(); i++) { + ciKlass* k = vdata->receiver(i); + if (k != NULL) { + if (round == 0) { + count++; + } else { + out->print(" %d %s", dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t), k->name()->as_quoted_ascii()); + } + } + } + } else if (pdata->is_VirtualCallData()) { + ciVirtualCallData* vdata = (ciVirtualCallData*)pdata; + for (uint i = 0; i < vdata->row_limit(); i++) { + ciKlass* k = vdata->receiver(i); + if (k != NULL) { + if (round == 0) { + count++; + } else { + out->print(" %d %s", dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t), k->name()->as_quoted_ascii()); + } + } + } + } + } + } + out->cr(); +} + #ifndef PRODUCT void ciMethodData::print() { print_data_on(tty); diff --git a/hotspot/src/share/vm/ci/ciMethodData.hpp b/hotspot/src/share/vm/ci/ciMethodData.hpp index bca5d1cd1e1..ea650cbd721 100644 --- a/hotspot/src/share/vm/ci/ciMethodData.hpp +++ b/hotspot/src/share/vm/ci/ciMethodData.hpp @@ -144,6 +144,7 @@ public: class ciMethodData : public ciMetadata { CI_PACKAGE_ACCESS + friend class ciReplay; private: // Size in bytes @@ -320,6 +321,7 @@ public: void print(); void print_data_on(outputStream* st); #endif + void dump_replay_data(outputStream* out); }; #endif // SHARE_VM_CI_CIMETHODDATA_HPP diff --git a/hotspot/src/share/vm/ci/ciObject.hpp b/hotspot/src/share/vm/ci/ciObject.hpp index 6246e173e9c..c33b79ed5ed 100644 --- a/hotspot/src/share/vm/ci/ciObject.hpp +++ b/hotspot/src/share/vm/ci/ciObject.hpp @@ -131,6 +131,7 @@ public: // Is this a type or value which has no associated class? // It is true of primitive types and null objects. virtual bool is_classless() const { return false; } + virtual void dump_replay_data(outputStream* st) { /* do nothing */ } // Note: some ciObjects refer to oops which have yet to be created. // We refer to these as "unloaded". Specifically, there are diff --git a/hotspot/src/share/vm/ci/ciObjectFactory.hpp b/hotspot/src/share/vm/ci/ciObjectFactory.hpp index 10870b90471..29de514b2ea 100644 --- a/hotspot/src/share/vm/ci/ciObjectFactory.hpp +++ b/hotspot/src/share/vm/ci/ciObjectFactory.hpp @@ -137,6 +137,7 @@ public: ciReturnAddress* get_return_address(int bci); + GrowableArray* get_ci_metadata() const { return _ci_metadata; } // RedefineClasses support void metadata_do(void f(Metadata*)); diff --git a/hotspot/src/share/vm/ci/ciReplay.cpp b/hotspot/src/share/vm/ci/ciReplay.cpp new file mode 100644 index 00000000000..726d84b1b5d --- /dev/null +++ b/hotspot/src/share/vm/ci/ciReplay.cpp @@ -0,0 +1,942 @@ +/* Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "ci/ciMethodData.hpp" +#include "ci/ciReplay.hpp" +#include "ci/ciUtilities.hpp" +#include "compiler/compileBroker.hpp" +#include "memory/allocation.inline.hpp" +#include "memory/oopFactory.hpp" +#include "memory/resourceArea.hpp" +#include "utilities/copy.hpp" + +#ifdef ASSERT + +// ciReplay + +typedef struct _ciMethodDataRecord { + const char* klass; + const char* method; + const char* signature; + int state; + int current_mileage; + intptr_t* data; + int data_length; + char* orig_data; + int orig_data_length; + int oops_length; + jobject* oops_handles; + int* oops_offsets; +} ciMethodDataRecord; + +typedef struct _ciMethodRecord { + const char* klass; + const char* method; + const char* signature; + int instructions_size; + int interpreter_invocation_count; + int interpreter_throwout_count; + int invocation_counter; + int backedge_counter; +} ciMethodRecord; + +class CompileReplay; +static CompileReplay* replay_state; + +class CompileReplay : public StackObj { + private: + FILE* stream; + Thread* thread; + Handle protection_domain; + Handle loader; + + GrowableArray ci_method_records; + GrowableArray ci_method_data_records; + + const char* _error_message; + + char* bufptr; + char* buffer; + int buffer_length; + int buffer_end; + int line_no; + + public: + CompileReplay(const char* filename, TRAPS) { + thread = THREAD; + loader = Handle(thread, SystemDictionary::java_system_loader()); + stream = fopen(filename, "rt"); + if (stream == NULL) { + fprintf(stderr, "Can't open replay file %s\n", filename); + } + buffer_length = 32; + buffer = NEW_RESOURCE_ARRAY(char, buffer_length); + _error_message = NULL; + + test(); + } + + ~CompileReplay() { + if (stream != NULL) fclose(stream); + } + + void test() { + strcpy(buffer, "1 2 foo 4 bar 0x9 \"this is it\""); + bufptr = buffer; + assert(parse_int("test") == 1, "what"); + assert(parse_int("test") == 2, "what"); + assert(strcmp(parse_string(), "foo") == 0, "what"); + assert(parse_int("test") == 4, "what"); + assert(strcmp(parse_string(), "bar") == 0, "what"); + assert(parse_intptr_t("test") == 9, "what"); + assert(strcmp(parse_quoted_string(), "this is it") == 0, "what"); + } + + bool had_error() { + return _error_message != NULL || thread->has_pending_exception(); + } + + bool can_replay() { + return !(stream == NULL || had_error()); + } + + void report_error(const char* msg) { + _error_message = msg; + // Restore the buffer contents for error reporting + for (int i = 0; i < buffer_end; i++) { + if (buffer[i] == '\0') buffer[i] = ' '; + } + } + + int parse_int(const char* label) { + if (had_error()) { + return 0; + } + + int v = 0; + int read; + if (sscanf(bufptr, "%i%n", &v, &read) != 1) { + report_error(label); + } else { + bufptr += read; + } + return v; + } + + intptr_t parse_intptr_t(const char* label) { + if (had_error()) { + return 0; + } + + intptr_t v = 0; + int read; + if (sscanf(bufptr, INTPTR_FORMAT "%n", &v, &read) != 1) { + report_error(label); + } else { + bufptr += read; + } + return v; + } + + void skip_ws() { + // Skip any leading whitespace + while (*bufptr == ' ' || *bufptr == '\t') { + bufptr++; + } + } + + + char* scan_and_terminate(char delim) { + char* str = bufptr; + while (*bufptr != delim && *bufptr != '\0') { + bufptr++; + } + if (*bufptr != '\0') { + *bufptr++ = '\0'; + } + if (bufptr == str) { + // nothing here + return NULL; + } + return str; + } + + char* parse_string() { + if (had_error()) return NULL; + + skip_ws(); + return scan_and_terminate(' '); + } + + char* parse_quoted_string() { + if (had_error()) return NULL; + + skip_ws(); + + if (*bufptr == '"') { + bufptr++; + return scan_and_terminate('"'); + } else { + return scan_and_terminate(' '); + } + } + + const char* parse_escaped_string() { + char* result = parse_quoted_string(); + if (result != NULL) { + unescape_string(result); + } + return result; + } + + // Look for the tag 'tag' followed by an + bool parse_tag_and_count(const char* tag, int& length) { + const char* t = parse_string(); + if (t == NULL) { + return false; + } + + if (strcmp(tag, t) != 0) { + report_error(tag); + return false; + } + length = parse_int("parse_tag_and_count"); + return !had_error(); + } + + // Parse a sequence of raw data encoded as bytes and return the + // resulting data. + char* parse_data(const char* tag, int& length) { + if (!parse_tag_and_count(tag, length)) { + return NULL; + } + + char * result = NEW_RESOURCE_ARRAY(char, length); + for (int i = 0; i < length; i++) { + int val = parse_int("data"); + result[i] = val; + } + return result; + } + + // Parse a standard chunk of data emitted as: + // 'tag' # # ... + // Where each # is an intptr_t item + intptr_t* parse_intptr_data(const char* tag, int& length) { + if (!parse_tag_and_count(tag, length)) { + return NULL; + } + + intptr_t* result = NEW_RESOURCE_ARRAY(intptr_t, length); + for (int i = 0; i < length; i++) { + skip_ws(); + intptr_t val = parse_intptr_t("data"); + result[i] = val; + } + return result; + } + + // Parse a possibly quoted version of a symbol into a symbolOop + Symbol* parse_symbol(TRAPS) { + const char* str = parse_escaped_string(); + if (str != NULL) { + Symbol* sym = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL); + return sym; + } + return NULL; + } + + // Parse a valid klass name and look it up + Klass* parse_klass(TRAPS) { + const char* str = parse_escaped_string(); + Symbol* klass_name = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL); + if (klass_name != NULL) { + Klass* k = SystemDictionary::resolve_or_fail(klass_name, loader, protection_domain, true, THREAD); + if (HAS_PENDING_EXCEPTION) { + oop throwable = PENDING_EXCEPTION; + java_lang_Throwable::print(throwable, tty); + tty->cr(); + report_error(str); + return NULL; + } + return k; + } + return NULL; + } + + // Lookup a klass + Klass* resolve_klass(const char* klass, TRAPS) { + Symbol* klass_name = SymbolTable::lookup(klass, (int)strlen(klass), CHECK_NULL); + return SystemDictionary::resolve_or_fail(klass_name, loader, protection_domain, true, CHECK_NULL); + } + + // Parse the standard tuple of + Method* parse_method(TRAPS) { + InstanceKlass* k = (InstanceKlass*)parse_klass(CHECK_NULL); + Symbol* method_name = parse_symbol(CHECK_NULL); + Symbol* method_signature = parse_symbol(CHECK_NULL); + Method* m = k->find_method(method_name, method_signature); + if (m == NULL) { + report_error("can't find method"); + } + return m; + } + + // Process each line of the replay file executing each command until + // the file ends. + void process(TRAPS) { + line_no = 1; + int pos = 0; + int c = getc(stream); + while(c != EOF) { + if (pos + 1 >= buffer_length) { + int newl = buffer_length * 2; + char* newb = NEW_RESOURCE_ARRAY(char, newl); + memcpy(newb, buffer, pos); + buffer = newb; + buffer_length = newl; + } + if (c == '\n') { + // null terminate it, reset the pointer and process the line + buffer[pos] = '\0'; + buffer_end = pos++; + bufptr = buffer; + process_command(CHECK); + if (had_error()) { + tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message); + tty->print_cr("%s", buffer); + assert(false, "error"); + return; + } + pos = 0; + buffer_end = 0; + line_no++; + } else if (c == '\r') { + // skip LF + } else { + buffer[pos++] = c; + } + c = getc(stream); + } + } + + void process_command(TRAPS) { + char* cmd = parse_string(); + if (cmd == NULL) { + return; + } + if (strcmp("#", cmd) == 0) { + // ignore + } else if (strcmp("compile", cmd) == 0) { + process_compile(CHECK); + } else if (strcmp("ciMethod", cmd) == 0) { + process_ciMethod(CHECK); + } else if (strcmp("ciMethodData", cmd) == 0) { + process_ciMethodData(CHECK); + } else if (strcmp("staticfield", cmd) == 0) { + process_staticfield(CHECK); + } else if (strcmp("ciInstanceKlass", cmd) == 0) { + process_ciInstanceKlass(CHECK); + } else if (strcmp("instanceKlass", cmd) == 0) { + process_instanceKlass(CHECK); +#if INCLUDE_JVMTI + } else if (strcmp("JvmtiExport", cmd) == 0) { + process_JvmtiExport(CHECK); +#endif // INCLUDE_JVMTI + } else { + report_error("unknown command"); + } + } + + // compile + void process_compile(TRAPS) { + // methodHandle method; + Method* method = parse_method(CHECK); + int entry_bci = parse_int("entry_bci"); + Klass* k = method->method_holder(); + ((InstanceKlass*)k)->initialize(THREAD); + if (HAS_PENDING_EXCEPTION) { + oop throwable = PENDING_EXCEPTION; + java_lang_Throwable::print(throwable, tty); + tty->cr(); + if (ReplayIgnoreInitErrors) { + CLEAR_PENDING_EXCEPTION; + ((InstanceKlass*)k)->set_init_state(InstanceKlass::fully_initialized); + } else { + return; + } + } + // Make sure the existence of a prior compile doesn't stop this one + nmethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, CompLevel_full_optimization, true) : method->code(); + if (nm != NULL) { + nm->make_not_entrant(); + } + replay_state = this; + CompileBroker::compile_method(method, entry_bci, CompLevel_full_optimization, + methodHandle(), 0, "replay", THREAD); + replay_state = NULL; + reset(); + } + + // ciMethod + // + // + void process_ciMethod(TRAPS) { + Method* method = parse_method(CHECK); + ciMethodRecord* rec = new_ciMethod(method); + rec->invocation_counter = parse_int("invocation_counter"); + rec->backedge_counter = parse_int("backedge_counter"); + rec->interpreter_invocation_count = parse_int("interpreter_invocation_count"); + rec->interpreter_throwout_count = parse_int("interpreter_throwout_count"); + rec->instructions_size = parse_int("instructions_size"); + } + + // ciMethodData orig # # ... data # # ... oops + void process_ciMethodData(TRAPS) { + Method* method = parse_method(CHECK); + /* jsut copied from Method, to build interpret data*/ + if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) { + return; + } + // methodOopDesc::build_interpreter_method_data(method, CHECK); + { + // Grab a lock here to prevent multiple + // MethodData*s from being created. + MutexLocker ml(MethodData_lock, THREAD); + if (method->method_data() == NULL) { + ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); + MethodData* method_data = MethodData::allocate(loader_data, method, CHECK); + method->set_method_data(method_data); + } + } + + // collect and record all the needed information for later + ciMethodDataRecord* rec = new_ciMethodData(method); + rec->state = parse_int("state"); + rec->current_mileage = parse_int("current_mileage"); + + rec->orig_data = parse_data("orig", rec->orig_data_length); + if (rec->orig_data == NULL) { + return; + } + rec->data = parse_intptr_data("data", rec->data_length); + if (rec->data == NULL) { + return; + } + if (!parse_tag_and_count("oops", rec->oops_length)) { + return; + } + rec->oops_handles = NEW_RESOURCE_ARRAY(jobject, rec->oops_length); + rec->oops_offsets = NEW_RESOURCE_ARRAY(int, rec->oops_length); + for (int i = 0; i < rec->oops_length; i++) { + int offset = parse_int("offset"); + if (had_error()) { + return; + } + Klass* k = parse_klass(CHECK); + rec->oops_offsets[i] = offset; + rec->oops_handles[i] = (jobject)(new KlassHandle(THREAD, k)); + } + } + + // instanceKlass + // + // Loads and initializes the klass 'name'. This can be used to + // create particular class loading environments + void process_instanceKlass(TRAPS) { + // just load the referenced class + Klass* k = parse_klass(CHECK); + } + + // ciInstanceKlass tag # # # ... + // + // Load the klass 'name' and link or initialize it. Verify that the + // constant pool is the same length as 'length' and make sure the + // constant pool tags are in the same state. + void process_ciInstanceKlass(TRAPS) { + InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK); + int is_linked = parse_int("is_linked"); + int is_initialized = parse_int("is_initialized"); + int length = parse_int("length"); + if (is_initialized) { + k->initialize(THREAD); + if (HAS_PENDING_EXCEPTION) { + oop throwable = PENDING_EXCEPTION; + java_lang_Throwable::print(throwable, tty); + tty->cr(); + if (ReplayIgnoreInitErrors) { + CLEAR_PENDING_EXCEPTION; + k->set_init_state(InstanceKlass::fully_initialized); + } else { + return; + } + } + } else if (is_linked) { + k->link_class(CHECK); + } + ConstantPool* cp = k->constants(); + if (length != cp->length()) { + report_error("constant pool length mismatch: wrong class files?"); + return; + } + + int parsed_two_word = 0; + for (int i = 1; i < length; i++) { + int tag = parse_int("tag"); + if (had_error()) { + return; + } + switch (cp->tag_at(i).value()) { + case JVM_CONSTANT_UnresolvedClass: { + if (tag == JVM_CONSTANT_Class) { + tty->print_cr("Resolving klass %s at %d", cp->unresolved_klass_at(i)->as_utf8(), i); + Klass* k = cp->klass_at(i, CHECK); + } + break; + } + case JVM_CONSTANT_Long: + case JVM_CONSTANT_Double: + parsed_two_word = i + 1; + + case JVM_CONSTANT_ClassIndex: + case JVM_CONSTANT_StringIndex: + case JVM_CONSTANT_String: + case JVM_CONSTANT_UnresolvedClassInError: + case JVM_CONSTANT_Fieldref: + case JVM_CONSTANT_Methodref: + case JVM_CONSTANT_InterfaceMethodref: + case JVM_CONSTANT_NameAndType: + case JVM_CONSTANT_Utf8: + case JVM_CONSTANT_Integer: + case JVM_CONSTANT_Float: + if (tag != cp->tag_at(i).value()) { + report_error("tag mismatch: wrong class files?"); + return; + } + break; + + case JVM_CONSTANT_Class: + if (tag == JVM_CONSTANT_Class) { + } else if (tag == JVM_CONSTANT_UnresolvedClass) { + tty->print_cr("Warning: entry was unresolved in the replay data"); + } else { + report_error("Unexpected tag"); + return; + } + break; + + case 0: + if (parsed_two_word == i) continue; + + default: + ShouldNotReachHere(); + break; + } + + } + } + + // Initialize a class and fill in the value for a static field. + // This is useful when the compile was dependent on the value of + // static fields but it's impossible to properly rerun the static + // initiailizer. + void process_staticfield(TRAPS) { + InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK); + + if (ReplaySuppressInitializers == 0 || + ReplaySuppressInitializers == 2 && k->class_loader() == NULL) { + return; + } + + assert(k->is_initialized(), "must be"); + + const char* field_name = parse_escaped_string();; + const char* field_signature = parse_string(); + fieldDescriptor fd; + Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK); + Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK); + if (!k->find_local_field(name, sig, &fd) || + !fd.is_static() || + fd.has_initial_value()) { + report_error(field_name); + return; + } + + oop java_mirror = k->java_mirror(); + if (field_signature[0] == '[') { + int length = parse_int("array length"); + oop value = NULL; + + if (field_signature[1] == '[') { + // multi dimensional array + ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK); + int rank = 0; + while (field_signature[rank] == '[') { + rank++; + } + int* dims = NEW_RESOURCE_ARRAY(int, rank); + dims[0] = length; + for (int i = 1; i < rank; i++) { + dims[i] = 1; // These aren't relevant to the compiler + } + value = kelem->multi_allocate(rank, dims, CHECK); + } else { + if (strcmp(field_signature, "[B") == 0) { + value = oopFactory::new_byteArray(length, CHECK); + } else if (strcmp(field_signature, "[Z") == 0) { + value = oopFactory::new_boolArray(length, CHECK); + } else if (strcmp(field_signature, "[C") == 0) { + value = oopFactory::new_charArray(length, CHECK); + } else if (strcmp(field_signature, "[S") == 0) { + value = oopFactory::new_shortArray(length, CHECK); + } else if (strcmp(field_signature, "[F") == 0) { + value = oopFactory::new_singleArray(length, CHECK); + } else if (strcmp(field_signature, "[D") == 0) { + value = oopFactory::new_doubleArray(length, CHECK); + } else if (strcmp(field_signature, "[I") == 0) { + value = oopFactory::new_intArray(length, CHECK); + } else if (strcmp(field_signature, "[J") == 0) { + value = oopFactory::new_longArray(length, CHECK); + } else if (field_signature[0] == '[' && field_signature[1] == 'L') { + KlassHandle kelem = resolve_klass(field_signature + 1, CHECK); + value = oopFactory::new_objArray(kelem(), length, CHECK); + } else { + report_error("unhandled array staticfield"); + } + } + java_mirror->obj_field_put(fd.offset(), value); + } else { + const char* string_value = parse_escaped_string(); + if (strcmp(field_signature, "I") == 0) { + int value = atoi(string_value); + java_mirror->int_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "B") == 0) { + int value = atoi(string_value); + java_mirror->byte_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "C") == 0) { + int value = atoi(string_value); + java_mirror->char_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "S") == 0) { + int value = atoi(string_value); + java_mirror->short_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "Z") == 0) { + int value = atol(string_value); + java_mirror->bool_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "J") == 0) { + jlong value; + if (sscanf(string_value, INT64_FORMAT, &value) != 1) { + fprintf(stderr, "Error parsing long: %s\n", string_value); + return; + } + java_mirror->long_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "F") == 0) { + float value = atof(string_value); + java_mirror->float_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "D") == 0) { + double value = atof(string_value); + java_mirror->double_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) { + Handle value = java_lang_String::create_from_str(string_value, CHECK); + java_mirror->obj_field_put(fd.offset(), value()); + } else if (field_signature[0] == 'L') { + Symbol* klass_name = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK); + KlassHandle kelem = resolve_klass(field_signature, CHECK); + oop value = ((InstanceKlass*)kelem())->allocate_instance(CHECK); + java_mirror->obj_field_put(fd.offset(), value); + } else { + report_error("unhandled staticfield"); + } + } + } + +#if INCLUDE_JVMTI + void process_JvmtiExport(TRAPS) { + const char* field = parse_string(); + bool value = parse_int("JvmtiExport flag") != 0; + if (strcmp(field, "can_access_local_variables") == 0) { + JvmtiExport::set_can_access_local_variables(value); + } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) { + JvmtiExport::set_can_hotswap_or_post_breakpoint(value); + } else if (strcmp(field, "can_post_on_exceptions") == 0) { + JvmtiExport::set_can_post_on_exceptions(value); + } else { + report_error("Unrecognized JvmtiExport directive"); + } + } +#endif // INCLUDE_JVMTI + + // Create and initialize a record for a ciMethod + ciMethodRecord* new_ciMethod(Method* method) { + ciMethodRecord* rec = NEW_RESOURCE_OBJ(ciMethodRecord); + rec->klass = method->method_holder()->name()->as_utf8(); + rec->method = method->name()->as_utf8(); + rec->signature = method->signature()->as_utf8(); + ci_method_records.append(rec); + return rec; + } + + // Lookup data for a ciMethod + ciMethodRecord* find_ciMethodRecord(Method* method) { + const char* klass_name = method->method_holder()->name()->as_utf8(); + const char* method_name = method->name()->as_utf8(); + const char* signature = method->signature()->as_utf8(); + for (int i = 0; i < ci_method_records.length(); i++) { + ciMethodRecord* rec = ci_method_records.at(i); + if (strcmp(rec->klass, klass_name) == 0 && + strcmp(rec->method, method_name) == 0 && + strcmp(rec->signature, signature) == 0) { + return rec; + } + } + return NULL; + } + + // Create and initialize a record for a ciMethodData + ciMethodDataRecord* new_ciMethodData(Method* method) { + ciMethodDataRecord* rec = NEW_RESOURCE_OBJ(ciMethodDataRecord); + rec->klass = method->method_holder()->name()->as_utf8(); + rec->method = method->name()->as_utf8(); + rec->signature = method->signature()->as_utf8(); + ci_method_data_records.append(rec); + return rec; + } + + // Lookup data for a ciMethodData + ciMethodDataRecord* find_ciMethodDataRecord(Method* method) { + const char* klass_name = method->method_holder()->name()->as_utf8(); + const char* method_name = method->name()->as_utf8(); + const char* signature = method->signature()->as_utf8(); + for (int i = 0; i < ci_method_data_records.length(); i++) { + ciMethodDataRecord* rec = ci_method_data_records.at(i); + if (strcmp(rec->klass, klass_name) == 0 && + strcmp(rec->method, method_name) == 0 && + strcmp(rec->signature, signature) == 0) { + return rec; + } + } + return NULL; + } + + const char* error_message() { + return _error_message; + } + + void reset() { + _error_message = NULL; + ci_method_records.clear(); + ci_method_data_records.clear(); + } + + // Take an ascii string contain \u#### escapes and convert it to utf8 + // in place. + static void unescape_string(char* value) { + char* from = value; + char* to = value; + while (*from != '\0') { + if (*from != '\\') { + *from++ = *to++; + } else { + switch (from[1]) { + case 'u': { + from += 2; + jchar value=0; + for (int i=0; i<4; i++) { + char c = *from++; + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + value = (value << 4) + c - '0'; + break; + case 'a': case 'b': case 'c': + case 'd': case 'e': case 'f': + value = (value << 4) + 10 + c - 'a'; + break; + case 'A': case 'B': case 'C': + case 'D': case 'E': case 'F': + value = (value << 4) + 10 + c - 'A'; + break; + default: + ShouldNotReachHere(); + } + } + UNICODE::convert_to_utf8(&value, 1, to); + to++; + break; + } + case 't': *to++ = '\t'; from += 2; break; + case 'n': *to++ = '\n'; from += 2; break; + case 'r': *to++ = '\r'; from += 2; break; + case 'f': *to++ = '\f'; from += 2; break; + default: + ShouldNotReachHere(); + } + } + } + *from = *to; + } +}; + +void ciReplay::replay(TRAPS) { + int exit_code = replay_impl(THREAD); + + Threads::destroy_vm(); + + vm_exit(exit_code); +} + +int ciReplay::replay_impl(TRAPS) { + HandleMark hm; + ResourceMark rm; + // Make sure we don't run with background compilation + BackgroundCompilation = false; + + if (ReplaySuppressInitializers > 2) { + // ReplaySuppressInitializers > 2 means that we want to allow + // normal VM bootstrap but once we get into the replay itself + // don't allow any intializers to be run. + ReplaySuppressInitializers = 1; + } + + // Load and parse the replay data + CompileReplay rp(ReplayDataFile, THREAD); + int exit_code = 0; + if (rp.can_replay()) { + rp.process(THREAD); + } else { + exit_code = 1; + return exit_code; + } + + if (HAS_PENDING_EXCEPTION) { + oop throwable = PENDING_EXCEPTION; + CLEAR_PENDING_EXCEPTION; + java_lang_Throwable::print(throwable, tty); + tty->cr(); + java_lang_Throwable::print_stack_trace(throwable, tty); + tty->cr(); + exit_code = 2; + } + + if (rp.had_error()) { + tty->print_cr("Failed on %s", rp.error_message()); + exit_code = 1; + } + return exit_code; +} + + +void ciReplay::initialize(ciMethodData* m) { + if (replay_state == NULL) { + return; + } + + ASSERT_IN_VM; + ResourceMark rm; + + Method* method = m->get_MethodData()->method(); + ciMethodDataRecord* rec = replay_state->find_ciMethodDataRecord(method); + if (rec == NULL) { + // This indicates some mismatch with the original environment and + // the replay environment though it's not always enough to + // interfere with reproducing a bug + tty->print_cr("Warning: requesting ciMethodData record for method with no data: "); + method->print_name(tty); + tty->cr(); + } else { + m->_state = rec->state; + m->_current_mileage = rec->current_mileage; + if (rec->data_length != 0) { + assert(m->_data_size == rec->data_length * (int)sizeof(rec->data[0]), "must agree"); + + // Write the correct ciObjects back into the profile data + ciEnv* env = ciEnv::current(); + for (int i = 0; i < rec->oops_length; i++) { + KlassHandle *h = (KlassHandle *)rec->oops_handles[i]; + *(ciMetadata**)(rec->data + rec->oops_offsets[i]) = + env->get_metadata((*h)()); + } + // Copy the updated profile data into place as intptr_ts +#ifdef _LP64 + Copy::conjoint_jlongs_atomic((jlong *)rec->data, (jlong *)m->_data, rec->data_length); +#else + Copy::conjoint_jints_atomic((jint *)rec->data, (jint *)m->_data, rec->data_length); +#endif + } + + // copy in the original header + Copy::conjoint_jbytes(rec->orig_data, (char*)&m->_orig, rec->orig_data_length); + } +} + + +bool ciReplay::should_not_inline(ciMethod* method) { + if (replay_state == NULL) { + return false; + } + + VM_ENTRY_MARK; + // ciMethod without a record shouldn't be inlined. + return replay_state->find_ciMethodRecord(method->get_Method()) == NULL; +} + + +void ciReplay::initialize(ciMethod* m) { + if (replay_state == NULL) { + return; + } + + ASSERT_IN_VM; + ResourceMark rm; + + Method* method = m->get_Method(); + ciMethodRecord* rec = replay_state->find_ciMethodRecord(method); + if (rec == NULL) { + // This indicates some mismatch with the original environment and + // the replay environment though it's not always enough to + // interfere with reproducing a bug + tty->print_cr("Warning: requesting ciMethod record for method with no data: "); + method->print_name(tty); + tty->cr(); + } else { + // m->_instructions_size = rec->instructions_size; + m->_instructions_size = -1; + m->_interpreter_invocation_count = rec->interpreter_invocation_count; + m->_interpreter_throwout_count = rec->interpreter_throwout_count; + method->invocation_counter()->_counter = rec->invocation_counter; + method->backedge_counter()->_counter = rec->backedge_counter; + } +} + +bool ciReplay::is_loaded(Method* method) { + if (replay_state == NULL) { + return true; + } + + ASSERT_IN_VM; + ResourceMark rm; + + ciMethodRecord* rec = replay_state->find_ciMethodRecord(method); + return rec != NULL; +} +#endif diff --git a/hotspot/src/share/vm/ci/ciReplay.hpp b/hotspot/src/share/vm/ci/ciReplay.hpp new file mode 100644 index 00000000000..5966d3ece76 --- /dev/null +++ b/hotspot/src/share/vm/ci/ciReplay.hpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_CI_CIREPLAY_HPP +#define SHARE_VM_CI_CIREPLAY_HPP + +#include "ci/ciMethod.hpp" + +// ciReplay + +class ciReplay { + CI_PACKAGE_ACCESS + +#ifdef ASSERT + private: + static int replay_impl(TRAPS); + + public: + static void replay(TRAPS); + + // These are used by the CI to fill in the cached data from the + // replay file when replaying compiles. + static void initialize(ciMethodData* method); + static void initialize(ciMethod* method); + + static bool is_loaded(Method* method); + static bool is_loaded(Klass* klass); + + static bool should_not_inline(ciMethod* method); + +#endif +}; + +#endif // SHARE_VM_CI_CIREPLAY_HPP diff --git a/hotspot/src/share/vm/ci/ciSymbol.cpp b/hotspot/src/share/vm/ci/ciSymbol.cpp index 26b3e4d565d..1a89adf5dd3 100644 --- a/hotspot/src/share/vm/ci/ciSymbol.cpp +++ b/hotspot/src/share/vm/ci/ciSymbol.cpp @@ -63,6 +63,11 @@ const char* ciSymbol::as_utf8() { return s->as_utf8(); } +// The text of the symbol as a null-terminated C string. +const char* ciSymbol::as_quoted_ascii() { + GUARDED_VM_QUICK_ENTRY(return get_symbol()->as_quoted_ascii();) +} + // ------------------------------------------------------------------ // ciSymbol::base const jbyte* ciSymbol::base() { diff --git a/hotspot/src/share/vm/ci/ciSymbol.hpp b/hotspot/src/share/vm/ci/ciSymbol.hpp index 642be46252b..d54b54009be 100644 --- a/hotspot/src/share/vm/ci/ciSymbol.hpp +++ b/hotspot/src/share/vm/ci/ciSymbol.hpp @@ -73,6 +73,9 @@ public: const char* as_utf8(); int utf8_length(); + // The text of the symbol as ascii with all non-printable characters quoted as \u#### + const char* as_quoted_ascii(); + // Return the i-th utf8 byte, where i < utf8_length int byte_at(int i); diff --git a/hotspot/src/share/vm/ci/ciUtilities.hpp b/hotspot/src/share/vm/ci/ciUtilities.hpp index 9788f77a734..1a075bf6e98 100644 --- a/hotspot/src/share/vm/ci/ciUtilities.hpp +++ b/hotspot/src/share/vm/ci/ciUtilities.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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 @@ -80,6 +80,9 @@ #define GUARDED_VM_ENTRY(action) \ {if (IS_IN_VM) { action } else { VM_ENTRY_MARK; { action }}} +#define GUARDED_VM_QUICK_ENTRY(action) \ + {if (IS_IN_VM) { action } else { VM_QUICK_ENTRY_MARK; { action }}} + // Redefine this later. #define KILL_COMPILE_ON_FATAL_(result) \ THREAD); \ diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index c414079e9ed..5662fabad27 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -348,6 +348,22 @@ unsigned int java_lang_String::to_hash(oop java_string) { return java_lang_String::to_hash(value->char_at_addr(offset), length); } +char* java_lang_String::as_quoted_ascii(oop java_string) { + typeArrayOop value = java_lang_String::value(java_string); + int offset = java_lang_String::offset(java_string); + int length = java_lang_String::length(java_string); + + jchar* base = (length == 0) ? NULL : value->char_at_addr(offset); + if (base == NULL) return NULL; + + int result_length = UNICODE::quoted_ascii_length(base, length) + 1; + char* result = NEW_RESOURCE_ARRAY(char, result_length); + UNICODE::as_quoted_ascii(base, length, result, result_length); + assert(result_length >= length + 1, "must not be shorter"); + assert(result_length == (int)strlen(result) + 1, "must match"); + return result; +} + unsigned int java_lang_String::hash_string(oop java_string) { int length = java_lang_String::length(java_string); // Zero length string doesn't hash necessarily hash to zero. diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 902099f1953..04e0214d204 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -154,6 +154,8 @@ class java_lang_String : AllStatic { static char* as_utf8_string(oop java_string, int start, int len); static char* as_platform_dependent_str(Handle java_string, TRAPS); static jchar* as_unicode_string(oop java_string, int& length); + // produce an ascii string with all other values quoted using \u#### + static char* as_quoted_ascii(oop java_string); // Compute the hash value for a java.lang.String object which would // contain the characters passed in. diff --git a/hotspot/src/share/vm/code/dependencies.cpp b/hotspot/src/share/vm/code/dependencies.cpp index 93db50afe07..d81fb3f3fb3 100644 --- a/hotspot/src/share/vm/code/dependencies.cpp +++ b/hotspot/src/share/vm/code/dependencies.cpp @@ -569,6 +569,7 @@ void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], void Dependencies::DepStream::log_dependency(Klass* witness) { if (_deps == NULL && xtty == NULL) return; // fast cutout for runtime + ResourceMark rm; int nargs = argument_count(); DepArgument args[max_arg_count]; for (int j = 0; j < nargs; j++) { diff --git a/hotspot/src/share/vm/interpreter/invocationCounter.hpp b/hotspot/src/share/vm/interpreter/invocationCounter.hpp index 38725907ead..db896d8ade6 100644 --- a/hotspot/src/share/vm/interpreter/invocationCounter.hpp +++ b/hotspot/src/share/vm/interpreter/invocationCounter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 @@ -40,6 +40,7 @@ class InvocationCounter VALUE_OBJ_CLASS_SPEC { friend class VMStructs; + friend class ciReplay; private: // bit no: |31 3| 2 | 1 0 | unsigned int _counter; // format: [count|carry|state] @@ -85,6 +86,8 @@ class InvocationCounter VALUE_OBJ_CLASS_SPEC { void set_carry(); // set the sticky carry bit void set_carry_flag() { _counter |= carry_mask; } + int raw_counter() { return _counter; } + // Accessors State state() const { return (State)(_counter & state_mask); } bool carry() const { return (_counter & carry_mask) != 0; } diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index c5b20d8ffd0..2f1ef700624 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -1052,6 +1052,13 @@ Method* InstanceKlass::class_initializer() { } void InstanceKlass::call_class_initializer_impl(instanceKlassHandle this_oop, TRAPS) { + if (ReplayCompiles && + (ReplaySuppressInitializers == 1 || + ReplaySuppressInitializers >= 2 && this_oop->class_loader() != NULL)) { + // Hide the existence of the initializer for the purpose of replaying the compile + return; + } + methodHandle h_method(THREAD, this_oop->class_initializer()); assert(!this_oop->is_initialized(), "we cannot initialize twice"); if (TraceClassInitialization) { diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index f427f338c02..ad59ab0632f 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -133,6 +133,7 @@ class OopMapBlock VALUE_OBJ_CLASS_SPEC { class InstanceKlass: public Klass { friend class VMStructs; friend class ClassFileParser; + friend class CompileReplay; protected: // Constructor diff --git a/hotspot/src/share/vm/oops/symbol.cpp b/hotspot/src/share/vm/oops/symbol.cpp index 6a8191cbe4f..f2253dbcce0 100644 --- a/hotspot/src/share/vm/oops/symbol.cpp +++ b/hotspot/src/share/vm/oops/symbol.cpp @@ -153,17 +153,15 @@ char* Symbol::as_C_string_flexible_buffer(Thread* t, void Symbol::print_symbol_on(outputStream* st) const { st = st ? st : tty; - int length = UTF8::unicode_length((const char*)bytes(), utf8_length()); - const char *ptr = (const char *)bytes(); - jchar value; - for (int index = 0; index < length; index++) { - ptr = UTF8::next(ptr, &value); - if (value >= 32 && value < 127 || value == '\'' || value == '\\') { - st->put(value); - } else { - st->print("\\u%04x", value); - } - } + st->print("%s", as_quoted_ascii()); +} + +char* Symbol::as_quoted_ascii() const { + const char *ptr = (const char *)&_body[0]; + int quoted_length = UTF8::quoted_ascii_length(ptr, utf8_length()); + char* result = NEW_RESOURCE_ARRAY(char, quoted_length + 1); + UTF8::as_quoted_ascii(ptr, result, quoted_length + 1); + return result; } jchar* Symbol::as_unicode(int& length) const { diff --git a/hotspot/src/share/vm/oops/symbol.hpp b/hotspot/src/share/vm/oops/symbol.hpp index 90ec5c17600..55867d2b007 100644 --- a/hotspot/src/share/vm/oops/symbol.hpp +++ b/hotspot/src/share/vm/oops/symbol.hpp @@ -189,6 +189,8 @@ class Symbol : public MetaspaceObj { // Use buf if needed buffer length is <= size. char* as_C_string_flexible_buffer(Thread* t, char* buf, int size) const; + // Returns an escaped form of a Java string. + char* as_quoted_ascii() const; // Returns a null terminated utf8 string in a resource array char* as_utf8() const { return as_C_string(); } diff --git a/hotspot/src/share/vm/opto/bytecodeInfo.cpp b/hotspot/src/share/vm/opto/bytecodeInfo.cpp index 1c08a6ebf3b..80117960dc5 100644 --- a/hotspot/src/share/vm/opto/bytecodeInfo.cpp +++ b/hotspot/src/share/vm/opto/bytecodeInfo.cpp @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "ci/ciReplay.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compileBroker.hpp" @@ -150,7 +151,7 @@ const char* InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_ } else { // Not hot. Check for medium-sized pre-existing nmethod at cold sites. if (callee_method->has_compiled_code() && - callee_method->instructions_size(CompLevel_full_optimization) > inline_small_code_size) + callee_method->instructions_size() > inline_small_code_size) return "already compiled into a medium method"; } if (size > max_inline_size) { @@ -192,7 +193,7 @@ const char* InlineTree::should_not_inline(ciMethod *callee_method, ciMethod* cal } if (callee_method->has_compiled_code() && - callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode) { + callee_method->instructions_size() > InlineSmallCode) { wci_result->set_profit(wci_result->profit() * 0.1); // %%% adjust wci_result->size()? } @@ -216,7 +217,7 @@ const char* InlineTree::should_not_inline(ciMethod *callee_method, ciMethod* cal // Now perform checks which are heuristic if (callee_method->has_compiled_code() && - callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode) { + callee_method->instructions_size() > InlineSmallCode) { return "already compiled into a big method"; } @@ -235,6 +236,12 @@ const char* InlineTree::should_not_inline(ciMethod *callee_method, ciMethod* cal return "disallowed by CompilerOracle"; } +#ifndef PRODUCT + if (ciReplay::should_not_inline(callee_method)) { + return "disallowed by ciReplay"; + } +#endif + if (UseStringCache) { // Do not inline StringCache::profile() method used only at the beginning. if (callee_method->name() == ciSymbol::profile_name() && diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index aeb62798ba1..1678053c656 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -24,6 +24,7 @@ */ #include "precompiled.hpp" +#include "ci/ciReplay.hpp" #include "classfile/altHashing.hpp" #include "classfile/classLoader.hpp" #include "classfile/javaClasses.hpp" @@ -5151,6 +5152,7 @@ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, v // Check if we should compile all classes on bootclasspath NOT_PRODUCT(if (CompileTheWorld) ClassLoader::compile_the_world();) + NOT_PRODUCT(if (ReplayCompiles) ciReplay::replay(thread);) // Since this is not a JVM_ENTRY we have to set the thread state manually before leaving. ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); } else { diff --git a/hotspot/src/share/vm/prims/jvmtiExport.hpp b/hotspot/src/share/vm/prims/jvmtiExport.hpp index 7dcab683149..1100d526995 100644 --- a/hotspot/src/share/vm/prims/jvmtiExport.hpp +++ b/hotspot/src/share/vm/prims/jvmtiExport.hpp @@ -64,6 +64,8 @@ class AttachOperation; // class JvmtiExport : public AllStatic { friend class VMStructs; + friend class CompileReplay; + private: #if INCLUDE_JVMTI diff --git a/hotspot/src/share/vm/runtime/compilationPolicy.cpp b/hotspot/src/share/vm/runtime/compilationPolicy.cpp index 73b8f8393f7..713163a1001 100644 --- a/hotspot/src/share/vm/runtime/compilationPolicy.cpp +++ b/hotspot/src/share/vm/runtime/compilationPolicy.cpp @@ -97,6 +97,9 @@ void CompilationPolicy::completed_vm_startup() { // This is intended to force compiles for methods (usually for // debugging) that would otherwise be interpreted for some reason. bool CompilationPolicy::must_be_compiled(methodHandle m, int comp_level) { + // Don't allow Xcomp to cause compiles in replay mode + if (ReplayCompiles) return false; + if (m->has_compiled_code()) return false; // already compiled if (!can_be_compiled(m, comp_level)) return false; @@ -322,6 +325,16 @@ nmethod* NonTieredCompPolicy::event(methodHandle method, methodHandle inlinee, i return NULL; } } + if (CompileTheWorld || ReplayCompiles) { + // Don't trigger other compiles in testing mode + if (bci == InvocationEntryBci) { + reset_counter_for_invocation_event(method); + } else { + reset_counter_for_back_branch_event(method); + } + return NULL; + } + if (bci == InvocationEntryBci) { // when code cache is full, compilation gets switched off, UseCompiler // is set to false diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 62ad97f8958..785965ca3f5 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -3189,6 +3189,26 @@ class CommandLineFlags { product(ccstrlist, CompileCommand, "", \ "Prepend to .hotspot_compiler; e.g. log,java/lang/String.") \ \ + develop(bool, ReplayCompiles, false, \ + "Enable replay of compilations from ReplayDataFile") \ + \ + develop(ccstr, ReplayDataFile, "replay.txt", \ + "file containing compilation replay information") \ + \ + develop(intx, ReplaySuppressInitializers, 2, \ + "Controls handling of class initialization during replay" \ + "0 - don't do anything special" \ + "1 - treat all class initializers as empty" \ + "2 - treat class initializers for application classes as empty" \ + "3 - allow all class initializers to run during bootstrap but" \ + " pretend they are empty after starting replay") \ + \ + develop(bool, ReplayIgnoreInitErrors, false, \ + "Ignore exceptions thrown during initialization for replay") \ + \ + develop(bool, DumpReplayDataOnError, true, \ + "record replay data for crashing compiler threads") \ + \ product(bool, CICompilerCountPerCPU, false, \ "1 compiler thread for log(N CPUs)") \ \ diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index eb6d3cd78a8..484566125bf 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -993,6 +993,7 @@ typedef BinaryTreeDictionary MetablockTreeDictionary; \ nonstatic_field(ciMethod, _interpreter_invocation_count, int) \ nonstatic_field(ciMethod, _interpreter_throwout_count, int) \ + nonstatic_field(ciMethod, _instructions_size, int) \ \ nonstatic_field(ciMethodData, _data_size, int) \ nonstatic_field(ciMethodData, _state, u_char) \ diff --git a/hotspot/src/share/vm/utilities/array.hpp b/hotspot/src/share/vm/utilities/array.hpp index 9690529c5d2..5578ed9b61f 100644 --- a/hotspot/src/share/vm/utilities/array.hpp +++ b/hotspot/src/share/vm/utilities/array.hpp @@ -353,9 +353,9 @@ protected: // sort the array. bool contains(const T& x) const { return index_of(x) >= 0; } - T at(int i) const { return _data[i]; } - void at_put(const int i, const T& x) { _data[i] = x; } - T* adr_at(const int i) { return &_data[i]; } + T at(int i) const { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); return _data[i]; } + void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); _data[i] = x; } + T* adr_at(const int i) { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); return &_data[i]; } int find(const T& x) { return index_of(x); } T at_acquire(const int which) { return OrderAccess::load_acquire(adr_at(which)); } diff --git a/hotspot/src/share/vm/utilities/utf8.cpp b/hotspot/src/share/vm/utilities/utf8.cpp index be7d1881546..da470b18cc0 100644 --- a/hotspot/src/share/vm/utilities/utf8.cpp +++ b/hotspot/src/share/vm/utilities/utf8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 @@ -147,7 +147,7 @@ static u_char* utf8_write(u_char* base, jchar ch) { void UTF8::convert_to_unicode(const char* utf8_str, jchar* unicode_str, int unicode_length) { unsigned char ch; - const char *ptr = (const char *)utf8_str; + const char *ptr = utf8_str; int index = 0; /* ASCII case loop optimization */ @@ -162,6 +162,119 @@ void UTF8::convert_to_unicode(const char* utf8_str, jchar* unicode_str, int unic } } +// returns the quoted ascii length of a 0-terminated utf8 string +int UTF8::quoted_ascii_length(const char* utf8_str, int utf8_length) { + const char *ptr = utf8_str; + const char* end = ptr + utf8_length; + int result = 0; + while (ptr < end) { + jchar c; + ptr = UTF8::next(ptr, &c); + if (c >= 32 && c < 127) { + result++; + } else { + result += 6; + } + } + return result; +} + +// converts a utf8 string to quoted ascii +void UTF8::as_quoted_ascii(const char* utf8_str, char* buf, int buflen) { + const char *ptr = utf8_str; + char* p = buf; + char* end = buf + buflen; + while (*ptr != '\0') { + jchar c; + ptr = UTF8::next(ptr, &c); + if (c >= 32 && c < 127) { + if (p + 1 >= end) break; // string is truncated + *p++ = (char)c; + } else { + if (p + 6 >= end) break; // string is truncated + sprintf(p, "\\u%04x", c); + p += 6; + } + } + *p = '\0'; +} + + +const char* UTF8::from_quoted_ascii(const char* quoted_ascii_str) { + const char *ptr = quoted_ascii_str; + char* result = NULL; + while (*ptr != '\0') { + char c = *ptr; + if (c < 32 || c >= 127) break; + } + if (*ptr == '\0') { + // nothing to do so return original string + return quoted_ascii_str; + } + // everything up to this point was ok. + int length = ptr - quoted_ascii_str; + char* buffer = NULL; + for (int round = 0; round < 2; round++) { + while (*ptr != '\0') { + if (*ptr != '\\') { + if (buffer != NULL) { + buffer[length] = *ptr; + } + length++; + } else { + switch (ptr[1]) { + case 'u': { + ptr += 2; + jchar value=0; + for (int i=0; i<4; i++) { + char c = *ptr++; + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + value = (value << 4) + c - '0'; + break; + case 'a': case 'b': case 'c': + case 'd': case 'e': case 'f': + value = (value << 4) + 10 + c - 'a'; + break; + case 'A': case 'B': case 'C': + case 'D': case 'E': case 'F': + value = (value << 4) + 10 + c - 'A'; + break; + default: + ShouldNotReachHere(); + } + } + if (buffer == NULL) { + char utf8_buffer[4]; + char* next = (char*)utf8_write((u_char*)utf8_buffer, value); + length += next - utf8_buffer; + } else { + char* next = (char*)utf8_write((u_char*)&buffer[length], value); + length += next - &buffer[length]; + } + break; + } + case 't': if (buffer != NULL) buffer[length] = '\t'; ptr += 2; length++; break; + case 'n': if (buffer != NULL) buffer[length] = '\n'; ptr += 2; length++; break; + case 'r': if (buffer != NULL) buffer[length] = '\r'; ptr += 2; length++; break; + case 'f': if (buffer != NULL) buffer[length] = '\f'; ptr += 2; length++; break; + default: + ShouldNotReachHere(); + } + } + } + if (round == 0) { + buffer = NEW_RESOURCE_ARRAY(char, length + 1); + ptr = quoted_ascii_str; + } else { + buffer[length] = '\0'; + } + } + return buffer; +} + + // Returns NULL if 'c' it not found. This only works as long // as 'c' is an ASCII character const jbyte* UTF8::strrchr(const jbyte* base, int length, jbyte c) { @@ -242,3 +355,35 @@ void UNICODE::convert_to_utf8(const jchar* base, int length, char* utf8_buffer) } *utf8_buffer = '\0'; } + +// returns the quoted ascii length of a unicode string +int UNICODE::quoted_ascii_length(jchar* base, int length) { + int result = 0; + for (int i = 0; i < length; i++) { + jchar c = base[i]; + if (c >= 32 && c < 127) { + result++; + } else { + result += 6; + } + } + return result; +} + +// converts a utf8 string to quoted ascii +void UNICODE::as_quoted_ascii(const jchar* base, int length, char* buf, int buflen) { + char* p = buf; + char* end = buf + buflen; + for (int index = 0; index < length; index++) { + jchar c = base[index]; + if (c >= 32 && c < 127) { + if (p + 1 >= end) break; // string is truncated + *p++ = (char)c; + } else { + if (p + 6 >= end) break; // string is truncated + sprintf(p, "\\u%04x", c); + p += 6; + } + } + *p = '\0'; +} diff --git a/hotspot/src/share/vm/utilities/utf8.hpp b/hotspot/src/share/vm/utilities/utf8.hpp index c56d550ec9d..69710fccec4 100644 --- a/hotspot/src/share/vm/utilities/utf8.hpp +++ b/hotspot/src/share/vm/utilities/utf8.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 @@ -32,22 +32,32 @@ class UTF8 : AllStatic { public: - // returns the unicode length of a 0-terminated uft8 string - static int unicode_length(const char* uft8_str); + // returns the unicode length of a 0-terminated utf8 string + static int unicode_length(const char* utf8_str); - // returns the unicode length of a non-0-terminated uft8 string - static int unicode_length(const char* uft8_str, int len); + // returns the unicode length of a non-0-terminated utf8 string + static int unicode_length(const char* utf8_str, int len); - // converts a uft8 string to a unicode string + // converts a utf8 string to a unicode string static void convert_to_unicode(const char* utf8_str, jchar* unicode_buffer, int unicode_length); + // returns the quoted ascii length of a utf8 string + static int quoted_ascii_length(const char* utf8_str, int utf8_length); + + // converts a utf8 string to quoted ascii + static void as_quoted_ascii(const char* utf8_str, char* buf, int buflen); + + // converts a quoted ascii string to utf8 string. returns the original + // string unchanged if nothing needs to be done. + static const char* from_quoted_ascii(const char* quoted_ascii_string); + // decodes the current utf8 character, stores the result in value, - // and returns the end of the current uft8 chararacter. + // and returns the end of the current utf8 chararacter. static char* next(const char* str, jchar* value); // decodes the current utf8 character, gets the supplementary character instead of // the surrogate pair when seeing a supplementary character in string, - // stores the result in value, and returns the end of the current uft8 chararacter. + // stores the result in value, and returns the end of the current utf8 chararacter. static char* next_character(const char* str, jint* value); // Utility methods @@ -79,6 +89,12 @@ class UNICODE : AllStatic { // in resource area unless a buffer is provided. static char* as_utf8(jchar* base, int length); static char* as_utf8(jchar* base, int length, char* buf, int buflen); + + // returns the quoted ascii length of a unicode string + static int quoted_ascii_length(jchar* base, int length); + + // converts a utf8 string to quoted ascii + static void as_quoted_ascii(const jchar* base, int length, char* buf, int buflen); }; #endif // SHARE_VM_UTILITIES_UTF8_HPP diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp index 175fe382fd7..ddb6e1cf882 100644 --- a/hotspot/src/share/vm/utilities/vmError.cpp +++ b/hotspot/src/share/vm/utilities/vmError.cpp @@ -1009,6 +1009,15 @@ void VMError::report_and_die() { OnError = NULL; } + static bool skip_replay = false; + if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) { + skip_replay = true; + ciEnv* env = ciEnv::current(); + if (env != NULL) { + env->dump_replay_data(); + } + } + static bool skip_bug_url = !should_report_bug(first_error->_id); if (!skip_bug_url) { skip_bug_url = true; From be815ba8faad34cc562f1e64af78d16e10df4320 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Tue, 13 Nov 2012 08:06:00 -0800 Subject: [PATCH 10/94] 8003306: Compiler crash: calculation of inner class access modifier Fix binary sense lost in transition to hasTag Reviewed-by: mcimadamore --- .../sun/tools/javac/comp/LambdaToMethod.java | 4 +- .../tools/javac/lambda/InnerConstructor.java | 48 +++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/InnerConstructor.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index faf421af560..a4cf5cea3ff 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -1120,10 +1120,10 @@ public class LambdaToMethod extends TreeTranslator { if (context != null && tree.encl == null && tree.def == null - && tree.type.getEnclosingType().hasTag(NONE)) { + && !tree.type.getEnclosingType().hasTag(NONE)) { Type encl = tree.type.getEnclosingType(); Type current = context.owner.enclClass().type; - while (current.hasTag(NONE)) { + while (!current.hasTag(NONE)) { if (current.tsym.isSubClass(encl.tsym, types)) { return true; } diff --git a/langtools/test/tools/javac/lambda/InnerConstructor.java b/langtools/test/tools/javac/lambda/InnerConstructor.java new file mode 100644 index 00000000000..6a5bf98498e --- /dev/null +++ b/langtools/test/tools/javac/lambda/InnerConstructor.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Regression test JDK-8003306 inner class constructor in lambda + * @author Robert Field + * @compile -XDallowLambda InnerConstructor.java + */ + +class InnerConstructor { + + public void testLambdaWithInnerConstructor() { + System.out.printf("%s should be %s\n", seq1().m().toString(), "Cbl:nada"); + } + + Ib1 seq1() { + return () -> new Cbl(); + } + + class Cbl { + Cbl() { } + } + + interface Ib1 { + Object m(); + } +} From 4b3c0978fb05a3d36c8c0fc2cf6086c934bf1f70 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 13 Nov 2012 15:09:15 -0800 Subject: [PATCH 11/94] 8003299: Cleanup javac Log support for deferred diagnostics Reviewed-by: mcimadamore, jfranck --- .../com/sun/tools/javac/comp/Attr.java | 8 +- .../sun/tools/javac/comp/DeferredAttr.java | 19 +- .../com/sun/tools/javac/comp/Flow.java | 9 +- .../sun/tools/javac/main/JavaCompiler.java | 33 +-- .../JavacProcessingEnvironment.java | 30 ++- .../classes/com/sun/tools/javac/util/Log.java | 201 ++++++++++++------ 6 files changed, 195 insertions(+), 105 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 6e0027b5a64..c2695df6bdd 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1360,11 +1360,8 @@ public class Attr extends JCTree.Visitor { types.asSuper(resource, syms.autoCloseableType.tsym) != null && !types.isSameType(resource, syms.autoCloseableType)) { // Don't emit warning for AutoCloseable itself Symbol close = syms.noSymbol; - Filter prevDeferDiagsFilter = log.deferredDiagFilter; - Queue prevDeferredDiags = log.deferredDiagnostics; + Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log); try { - log.deferAll(); - log.deferredDiagnostics = ListBuffer.lb(); close = rs.resolveQualifiedMethod(pos, env, resource, @@ -1373,8 +1370,7 @@ public class Attr extends JCTree.Visitor { List.nil()); } finally { - log.deferredDiagFilter = prevDeferDiagsFilter; - log.deferredDiagnostics = prevDeferredDiags; + log.popDiagnosticHandler(discardHandler); } if (close.kind == MTH && close.overrides(syms.autoCloseableClose, resource.tsym, types, true) && diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index d9ef24ffedc..772afbe86ea 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -249,28 +249,25 @@ public class DeferredAttr extends JCTree.Visitor { JCTree newTree = new TreeCopier(make).copy(tree); Env speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared())); speculativeEnv.info.scope.owner = env.info.scope.owner; - Filter prevDeferDiagsFilter = log.deferredDiagFilter; - Queue prevDeferredDiags = log.deferredDiagnostics; final JavaFileObject currentSource = log.currentSourceFile(); + Log.DeferredDiagnosticHandler deferredDiagnosticHandler = + new Log.DeferredDiagnosticHandler(log, new Filter() { + public boolean accepts(JCDiagnostic t) { + return t.getDiagnosticSource().getFile().equals(currentSource); + } + }); try { - log.deferredDiagnostics = new ListBuffer(); - log.deferredDiagFilter = new Filter() { - public boolean accepts(JCDiagnostic t) { - return t.getDiagnosticSource().getFile().equals(currentSource); - } - }; attr.attribTree(newTree, speculativeEnv, resultInfo); unenterScanner.scan(newTree); return newTree; } catch (Abort ex) { //if some very bad condition occurred during deferred attribution //we should dump all errors before killing javac - log.reportDeferredDiagnostics(); + deferredDiagnosticHandler.reportDeferredDiagnostics(); throw ex; } finally { unenterScanner.scan(newTree); - log.deferredDiagFilter = prevDeferDiagsFilter; - log.deferredDiagnostics = prevDeferredDiags; + log.popDiagnosticHandler(deferredDiagnosticHandler); } } //where diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index 3ea31c9b9e8..f5cdb99b06b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -213,24 +213,21 @@ public class Flow { } public void analyzeLambda(Env env, JCLambda that, TreeMaker make, boolean speculative) { - java.util.Queue prevDeferredDiagnostics = log.deferredDiagnostics; - Filter prevDeferDiagsFilter = log.deferredDiagFilter; + Log.DiagnosticHandler diagHandler = null; //we need to disable diagnostics temporarily; the problem is that if //a lambda expression contains e.g. an unreachable statement, an error //message will be reported and will cause compilation to skip the flow analyis //step - if we suppress diagnostics, we won't stop at Attr for flow-analysis //related errors, which will allow for more errors to be detected if (!speculative) { - log.deferAll(); - log.deferredDiagnostics = ListBuffer.lb(); + diagHandler = new Log.DiscardDiagnosticHandler(log); } try { new AliveAnalyzer().analyzeTree(env, that, make); new FlowAnalyzer().analyzeTree(env, that, make); } finally { if (!speculative) { - log.deferredDiagFilter = prevDeferDiagsFilter; - log.deferredDiagnostics = prevDeferredDiagnostics; + log.popDiagnosticHandler(diagHandler); } } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java index b62da0f4b46..1003436fa65 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -1018,6 +1018,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter { */ boolean processAnnotations = false; + Log.DeferredDiagnosticHandler deferredDiagnosticHandler; + /** * Object to handle annotation processing. */ @@ -1048,7 +1050,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { genEndPos = true; if (!taskListener.isEmpty()) taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING)); - log.deferAll(); + deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log); } else { // free resources procEnvImpl.close(); } @@ -1079,7 +1081,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter { // or other errors during enter which cannot be fixed by running // any annotation processors. if (unrecoverableError()) { - log.reportDeferredDiagnostics(); + deferredDiagnosticHandler.reportDeferredDiagnostics(); + log.popDiagnosticHandler(deferredDiagnosticHandler); return this; } } @@ -1102,10 +1105,12 @@ public class JavaCompiler implements ClassReader.SourceCompleter { log.error("proc.no.explicit.annotation.processing.requested", classnames); } - log.reportDeferredDiagnostics(); + Assert.checkNull(deferredDiagnosticHandler); return this; // continue regular compilation } + Assert.checkNonNull(deferredDiagnosticHandler); + try { List classSymbols = List.nil(); List pckSymbols = List.nil(); @@ -1115,7 +1120,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter { if (!explicitAnnotationProcessingRequested()) { log.error("proc.no.explicit.annotation.processing.requested", classnames); - log.reportDeferredDiagnostics(); + deferredDiagnosticHandler.reportDeferredDiagnostics(); + log.popDiagnosticHandler(deferredDiagnosticHandler); return this; // TODO: Will this halt compilation? } else { boolean errors = false; @@ -1148,33 +1154,36 @@ public class JavaCompiler implements ClassReader.SourceCompleter { } } if (errors) { - log.reportDeferredDiagnostics(); + deferredDiagnosticHandler.reportDeferredDiagnostics(); + log.popDiagnosticHandler(deferredDiagnosticHandler); return this; } } } try { - JavaCompiler c = procEnvImpl.doProcessing(context, roots, classSymbols, pckSymbols); + JavaCompiler c = procEnvImpl.doProcessing(context, roots, classSymbols, pckSymbols, + deferredDiagnosticHandler); if (c != this) annotationProcessingOccurred = c.annotationProcessingOccurred = true; // doProcessing will have handled deferred diagnostics - Assert.check(c.log.deferredDiagFilter == null - && c.log.deferredDiagnostics.size() == 0); return c; } finally { procEnvImpl.close(); } } catch (CompletionFailure ex) { log.error("cant.access", ex.sym, ex.getDetailValue()); - log.reportDeferredDiagnostics(); + deferredDiagnosticHandler.reportDeferredDiagnostics(); + log.popDiagnosticHandler(deferredDiagnosticHandler); return this; } } private boolean unrecoverableError() { - for (JCDiagnostic d: log.deferredDiagnostics) { - if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RECOVERABLE)) - return true; + if (deferredDiagnosticHandler != null) { + for (JCDiagnostic d: deferredDiagnosticHandler.getDiagnostics()) { + if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RECOVERABLE)) + return true; + } } return false; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index 4a31cfea401..a3e0e26272f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -781,6 +781,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea final JavaCompiler compiler; /** The log for the round. */ final Log log; + /** The diagnostic handler for the round. */ + final Log.DeferredDiagnosticHandler deferredDiagnosticHandler; /** The ASTs to be compiled. */ List roots; @@ -798,7 +800,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea int nMessagerErrors; /** Create a round (common code). */ - private Round(Context context, int number, int priorErrors, int priorWarnings) { + private Round(Context context, int number, int priorErrors, int priorWarnings, + Log.DeferredDiagnosticHandler deferredDiagnosticHandler) { this.context = context; this.number = number; @@ -806,7 +809,12 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea log = Log.instance(context); log.nerrors = priorErrors; log.nwarnings += priorWarnings; - log.deferAll(); + if (number == 1) { + Assert.checkNonNull(deferredDiagnosticHandler); + this.deferredDiagnosticHandler = deferredDiagnosticHandler; + } else { + this.deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log); + } // the following is for the benefit of JavacProcessingEnvironment.getContext() JavacProcessingEnvironment.this.context = context; @@ -817,8 +825,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea } /** Create the first round. */ - Round(Context context, List roots, List classSymbols) { - this(context, 1, 0, 0); + Round(Context context, List roots, List classSymbols, + Log.DeferredDiagnosticHandler deferredDiagnosticHandler) { + this(context, 1, 0, 0, deferredDiagnosticHandler); this.roots = roots; genClassFiles = new HashMap(); @@ -841,7 +850,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea this(prev.nextContext(), prev.number+1, prev.nMessagerErrors, - prev.compiler.log.nwarnings); + prev.compiler.log.nwarnings, + null); this.genClassFiles = prev.genClassFiles; List parsedFiles = compiler.parseFiles(newSourceFiles); @@ -912,7 +922,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea if (messager.errorRaised()) return true; - for (JCDiagnostic d: log.deferredDiagnostics) { + for (JCDiagnostic d: deferredDiagnosticHandler.getDiagnostics()) { switch (d.getKind()) { case WARNING: if (werror) @@ -1006,7 +1016,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea // suppress errors, which are all presumed to be transient resolve errors kinds.remove(JCDiagnostic.Kind.ERROR); } - log.reportDeferredDiagnostics(kinds); + deferredDiagnosticHandler.reportDeferredDiagnostics(kinds); + log.popDiagnosticHandler(deferredDiagnosticHandler); } /** Print info about this round. */ @@ -1112,7 +1123,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea public JavaCompiler doProcessing(Context context, List roots, List classSymbols, - Iterable pckSymbols) { + Iterable pckSymbols, + Log.DeferredDiagnosticHandler deferredDiagnosticHandler) { log = Log.instance(context); Set specifiedPackages = new LinkedHashSet(); @@ -1120,7 +1132,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea specifiedPackages.add(psym); this.specifiedPackages = Collections.unmodifiableSet(specifiedPackages); - Round round = new Round(context, roots, classSymbols); + Round round = new Round(context, roots, classSymbols, deferredDiagnosticHandler); boolean errorStatus; boolean moreToDo; diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java index 1591ff73e5c..70267f7097c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java @@ -73,6 +73,95 @@ public class Log extends AbstractLog { final String value; } + /** + * DiagnosticHandler's provide the initial handling for diagnostics. + * When a diagnostic handler is created and has been initialized, it + * should install itself as the current diagnostic handler. When a + * client has finished using a handler, the client should call + * {@code log.removeDiagnosticHandler();} + * + * Note that javax.tools.DiagnosticListener (if set) is called later in the + * diagnostic pipeline. + */ + public static abstract class DiagnosticHandler { + /** + * The previously installed diagnostic handler. + */ + protected DiagnosticHandler prev; + + /** + * Install this diagnostic handler as the current one, + * recording the previous one. + */ + protected void install(Log log) { + prev = log.diagnosticHandler; + log.diagnosticHandler = this; + } + + /** + * Handle a diagnostic. + */ + public abstract void report(JCDiagnostic diag); + } + + /** + * A DiagnosticHandler that discards all diagnostics. + */ + public static class DiscardDiagnosticHandler extends DiagnosticHandler { + public DiscardDiagnosticHandler(Log log) { + install(log); + } + + public void report(JCDiagnostic diag) { } + } + + /** + * A DiagnosticHandler that can defer some or all diagnostics, + * by buffering them for later examination and/or reporting. + * If a diagnostic is not deferred, or is subsequently reported + * with reportAllDiagnostics(), it will be reported to the previously + * active diagnostic handler. + */ + public static class DeferredDiagnosticHandler extends DiagnosticHandler { + private Queue deferred = ListBuffer.lb(); + private final Filter filter; + + public DeferredDiagnosticHandler(Log log) { + this(log, null); + } + + public DeferredDiagnosticHandler(Log log, Filter filter) { + this.filter = filter; + install(log); + } + + public void report(JCDiagnostic diag) { + if (filter == null || filter.accepts(diag)) + deferred.add(diag); + else + prev.report(diag); + } + + public Queue getDiagnostics() { + return deferred; + } + + /** Report all deferred diagnostics. */ + public void reportDeferredDiagnostics() { + reportDeferredDiagnostics(EnumSet.allOf(JCDiagnostic.Kind.class)); + } + + /** Report selected deferred diagnostics. */ + public void reportDeferredDiagnostics(Set kinds) { + JCDiagnostic d; + while ((d = deferred.poll()) != null) { + if (kinds.contains(d.getKind())) + prev.report(d); + } + deferred = null; // prevent accidental ongoing use + } + } + public enum WriterKind { NOTICE, WARNING, ERROR }; protected PrintWriter errWriter; @@ -128,10 +217,9 @@ public class Log extends AbstractLog { private JavacMessages messages; /** - * Deferred diagnostics ++ * Handler for initial dispatch of diagnostics. */ - public Filter deferredDiagFilter; - public Queue deferredDiagnostics = new ListBuffer(); + private DiagnosticHandler diagnosticHandler; /** Construct a log with given I/O redirections. */ @@ -147,6 +235,8 @@ public class Log extends AbstractLog { context.get(DiagnosticListener.class); this.diagListener = dl; + diagnosticHandler = new DefaultDiagnosticHandler(); + messages = JavacMessages.instance(context); messages.add(Main.javacBundleName); @@ -305,6 +395,17 @@ public class Log extends AbstractLog { this.sourceMap = other.sourceMap; } + /** + * Replace the specified diagnostic handler with the + * handler that was current at the time this handler was created. + * The given handler must be the currently installed handler; + * it must be specified explicitly for clarity and consistency checking. + */ + public void popDiagnosticHandler(DiagnosticHandler h) { + Assert.check(diagnosticHandler == h); + diagnosticHandler = h.prev; + } + /** Flush the logs */ public void flush() { @@ -443,64 +544,54 @@ public class Log extends AbstractLog { nwarnings++; } - /** Report all deferred diagnostics, and clear the deferDiagnostics flag. */ - public void reportDeferredDiagnostics() { - reportDeferredDiagnostics(EnumSet.allOf(JCDiagnostic.Kind.class)); - } - - /** Report selected deferred diagnostics, and clear the deferDiagnostics flag. */ - public void reportDeferredDiagnostics(Set kinds) { - deferredDiagFilter = null; - JCDiagnostic d; - while ((d = deferredDiagnostics.poll()) != null) { - if (kinds.contains(d.getKind())) - report(d); - } - } + /** + * Primary method to report a diagnostic. + * @param diagnostic + */ + public void report(JCDiagnostic diagnostic) { + diagnosticHandler.report(diagnostic); + } /** * Common diagnostic handling. * The diagnostic is counted, and depending on the options and how many diagnostics have been * reported so far, the diagnostic may be handed off to writeDiagnostic. */ - public void report(JCDiagnostic diagnostic) { - if (deferredDiagFilter != null && deferredDiagFilter.accepts(diagnostic)) { - deferredDiagnostics.add(diagnostic); - return; - } + private class DefaultDiagnosticHandler extends DiagnosticHandler { + public void report(JCDiagnostic diagnostic) { + if (expectDiagKeys != null) + expectDiagKeys.remove(diagnostic.getCode()); - if (expectDiagKeys != null) - expectDiagKeys.remove(diagnostic.getCode()); + switch (diagnostic.getType()) { + case FRAGMENT: + throw new IllegalArgumentException(); - switch (diagnostic.getType()) { - case FRAGMENT: - throw new IllegalArgumentException(); - - case NOTE: - // Print out notes only when we are permitted to report warnings - // Notes are only generated at the end of a compilation, so should be small - // in number. - if ((emitWarnings || diagnostic.isMandatory()) && !suppressNotes) { - writeDiagnostic(diagnostic); - } - break; - - case WARNING: - if (emitWarnings || diagnostic.isMandatory()) { - if (nwarnings < MaxWarnings) { + case NOTE: + // Print out notes only when we are permitted to report warnings + // Notes are only generated at the end of a compilation, so should be small + // in number. + if ((emitWarnings || diagnostic.isMandatory()) && !suppressNotes) { writeDiagnostic(diagnostic); - nwarnings++; } - } - break; + break; - case ERROR: - if (nerrors < MaxErrors - && shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) { - writeDiagnostic(diagnostic); - nerrors++; + case WARNING: + if (emitWarnings || diagnostic.isMandatory()) { + if (nwarnings < MaxWarnings) { + writeDiagnostic(diagnostic); + nwarnings++; + } + } + break; + + case ERROR: + if (nerrors < MaxErrors + && shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) { + writeDiagnostic(diagnostic); + nerrors++; + } + break; } - break; } } @@ -551,18 +642,6 @@ public class Log extends AbstractLog { } } - public void deferAll() { - deferredDiagFilter = new Filter() { - public boolean accepts(JCDiagnostic t) { - return true; - } - }; - } - - public void deferNone() { - deferredDiagFilter = null; - } - /** Find a localized string in the resource bundle. * Because this method is static, it ignores the locale. * Use localize(key, args) when possible. From b873533e9879fd948a51ac64717ead5fbaf16a4d Mon Sep 17 00:00:00 2001 From: Clemens Eisserer Date: Tue, 13 Nov 2012 16:12:10 -0800 Subject: [PATCH 12/94] 7105461: Large JTables are not rendered correctly with Xrender pipeline Reviewed-by: flar, prr --- .../classes/sun/java2d/xr/XRRenderer.java | 55 +++++++++++++------ .../classes/sun/java2d/xr/XRUtils.java | 4 +- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java b/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java index f2fd155ca87..933f5452378 100644 --- a/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java +++ b/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java @@ -27,7 +27,6 @@ package sun.java2d.xr; import java.awt.*; import java.awt.geom.*; - import sun.awt.SunToolkit; import sun.java2d.SunGraphics2D; import sun.java2d.loops.*; @@ -39,6 +38,9 @@ import sun.java2d.pipe.SpanIterator; import sun.java2d.pipe.ShapeSpanIterator; import sun.java2d.pipe.LoopPipe; +import static sun.java2d.xr.XRUtils.clampToShort; +import static sun.java2d.xr.XRUtils.clampToUShort; + /** * XRender provides only accalerated rectangles. To emulate higher "order" * geometry we have to pass everything else to DoPath/FillSpans. @@ -70,17 +72,16 @@ public class XRRenderer implements PixelDrawPipe, PixelFillPipe, ShapeDrawPipe { public void drawLine(SunGraphics2D sg2d, int x1, int y1, int x2, int y2) { Region compClip = sg2d.getCompClip(); - int transX1 = x1 + sg2d.transX; - int transY1 = y1 + sg2d.transY; - int transX2 = x2 + sg2d.transX; - int transY2 = y2 + sg2d.transY; + int transX1 = Region.clipAdd(x1, sg2d.transX); + int transY1 = Region.clipAdd(y1, sg2d.transY); + int transX2 = Region.clipAdd(x2, sg2d.transX); + int transY2 = Region.clipAdd(y2, sg2d.transY); // Non clipped fast path if (compClip.contains(transX1, transY1) && compClip.contains(transX2, transY2)) { + SunToolkit.awtLock(); try { - SunToolkit.awtLock(); - validateSurface(sg2d); tileManager.addLine(transX1, transY1, transX2, transY2); tileManager.fillMask((XRSurfaceData) sg2d.surfaceData); @@ -115,20 +116,40 @@ public class XRRenderer implements PixelDrawPipe, PixelFillPipe, ShapeDrawPipe { draw(sg2d, new Polygon(xpoints, ypoints, npoints)); } - public synchronized void fillRect(SunGraphics2D sg2d, - int x, int y, int width, int height) { + public void fillRect(SunGraphics2D sg2d, int x, int y, int width, int height) { + x = Region.clipAdd(x, sg2d.transX); + y = Region.clipAdd(y, sg2d.transY); + + /* + * Limit x/y to signed short, width/height to unsigned short, + * to match the X11 coordinate limits for rectangles. + * Correct width/height in case x/y have been modified by clipping. + */ + if (x > Short.MAX_VALUE || y > Short.MAX_VALUE) { + return; + } + + int x2 = Region.dimAdd(x, width); + int y2 = Region.dimAdd(y, height); + + if (x2 < Short.MIN_VALUE || y2 < Short.MIN_VALUE) { + return; + } + + x = clampToShort(x); + y = clampToShort(y); + width = clampToUShort(x2 - x); + height = clampToUShort(y2 - y); + + if (width == 0 || height == 0) { + return; + } + SunToolkit.awtLock(); try { validateSurface(sg2d); - - XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData; - - x += sg2d.transform.getTranslateX(); - y += sg2d.transform.getTranslateY(); - tileManager.addRect(x, y, width, height); - tileManager.fillMask(xrsd); - + tileManager.fillMask((XRSurfaceData) sg2d.surfaceData); } finally { SunToolkit.awtUnlock(); } diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java b/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java index e7e05e4f2cc..7a47999ffa2 100644 --- a/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java +++ b/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java @@ -255,7 +255,7 @@ public class XRUtils { : (x < Short.MIN_VALUE ? Short.MIN_VALUE : x)); } - public static short clampToUShort(int x) { - return (short) (x > 65535 ? 65535 : (x < 0) ? 0 : x); + public static int clampToUShort(int x) { + return (x > 65535 ? 65535 : (x < 0) ? 0 : x); } } From f7ee6989a00c39ccc16fb2381a50904a8b6a2c72 Mon Sep 17 00:00:00 2001 From: Konstantin Shefov Date: Wed, 14 Nov 2012 11:37:09 +0000 Subject: [PATCH 13/94] 7147408: [macosx] Add autodelay to fix a regression test Reviewed-by: serb, alexsch --- .../StyledEditorKit/4506788/bug4506788.html | 28 ++++ .../StyledEditorKit/4506788/bug4506788.java | 131 ++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 jdk/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.html create mode 100644 jdk/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.java diff --git a/jdk/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.html b/jdk/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.html new file mode 100644 index 00000000000..690beeeb7fe --- /dev/null +++ b/jdk/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.html @@ -0,0 +1,28 @@ + + + + + + + diff --git a/jdk/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.java b/jdk/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.java new file mode 100644 index 00000000000..b5e0f9eb973 --- /dev/null +++ b/jdk/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 4506788 7147408 + @summary Tests if cursor gets stuck after insertion a character + @author Denis Sharypov + @run applet bug4506788.html + */ +import java.awt.*; +import java.awt.event.*; +import java.lang.reflect.InvocationTargetException; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.text.*; +import sun.awt.SunToolkit; + +public class bug4506788 extends JApplet { + + private volatile boolean passed = false; + private JEditorPane jep; + private SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + @Override + public void init() { + try { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + createAndShowGUI(); + } + }); + } catch (InterruptedException | InvocationTargetException ex) { + ex.printStackTrace(); + throw new RuntimeException("FAILED: SwingUtilities.invokeAndWait method failed then creating and showing GUI"); + } + } + + @Override + public void start() { + Robot robot; + try { + robot = new Robot(); + } catch (AWTException e) { + throw new RuntimeException("Robot could not be created"); + } + + toolkit.realSync(); + + Point p; + try { + p = getJEPLocOnScreen(); + } catch (Exception e) { + throw new RuntimeException("Could not get JEditorPane location on screen"); + } + + robot.setAutoDelay(50); + robot.mouseMove(p.x, p.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.keyPress(KeyEvent.VK_RIGHT); + robot.keyRelease(KeyEvent.VK_RIGHT); + robot.keyPress(KeyEvent.VK_X); + robot.keyRelease(KeyEvent.VK_X); + robot.keyPress(KeyEvent.VK_RIGHT); + robot.keyRelease(KeyEvent.VK_RIGHT); + + toolkit.realSync(); + + if (!passed) { + throw new RuntimeException("Test failed."); + } + } + + private Point getJEPLocOnScreen() throws Exception { + + final Point[] result = new Point[1]; + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + result[0] = jep.getLocationOnScreen(); + } + }); + + return result[0]; + } + + private void createAndShowGUI() { + jep = new JEditorPane(); + String text = "abc"; + JFrame f = new JFrame(); + jep.setEditorKit(new StyledEditorKit()); + jep.setText(text); + jep.addCaretListener(new CaretListener() { + @Override + public void caretUpdate(CaretEvent e) { + passed = (e.getDot() == 3); + } + }); + + DefaultStyledDocument doc = (DefaultStyledDocument) jep.getDocument(); + MutableAttributeSet atr = new SimpleAttributeSet(); + StyleConstants.setBold(atr, true); + doc.setCharacterAttributes(1, 1, atr, false); + + f.getContentPane().add(jep); + f.setSize(100, 100); + f.setVisible(true); + } +} From b05c04c8c063fc6a9b58d7f18f6ef86c0d4dbe9a Mon Sep 17 00:00:00 2001 From: Anton Litvinov Date: Wed, 14 Nov 2012 18:40:05 +0400 Subject: [PATCH 14/94] 6789984: JPasswordField can not receive keyboard input Reviewed-by: naoto, anthony --- jdk/src/share/classes/sun/awt/im/InputContext.java | 4 ++-- jdk/src/share/classes/sun/awt/im/InputMethodAdapter.java | 3 +-- jdk/src/solaris/classes/sun/awt/X11InputMethod.java | 6 +++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/jdk/src/share/classes/sun/awt/im/InputContext.java b/jdk/src/share/classes/sun/awt/im/InputContext.java index 27f05465d95..1eccb6aa792 100644 --- a/jdk/src/share/classes/sun/awt/im/InputContext.java +++ b/jdk/src/share/classes/sun/awt/im/InputContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 @@ -786,7 +786,7 @@ public class InputContext extends java.awt.im.InputContext public void disableNativeIM() { InputMethod inputMethod = getInputMethod(); if (inputMethod != null && inputMethod instanceof InputMethodAdapter) { - ((InputMethodAdapter)inputMethod).disableInputMethod(); + ((InputMethodAdapter)inputMethod).stopListening(); } } diff --git a/jdk/src/share/classes/sun/awt/im/InputMethodAdapter.java b/jdk/src/share/classes/sun/awt/im/InputMethodAdapter.java index 0b5b02837d2..dfc31799bfb 100644 --- a/jdk/src/share/classes/sun/awt/im/InputMethodAdapter.java +++ b/jdk/src/share/classes/sun/awt/im/InputMethodAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 @@ -79,7 +79,6 @@ public abstract class InputMethodAdapter implements InputMethod { /** * Informs the input method adapter not to listen to the native events. - * This method is called when a Java input method is active. */ protected void stopListening() { // ignore - adapters can override if needed diff --git a/jdk/src/solaris/classes/sun/awt/X11InputMethod.java b/jdk/src/solaris/classes/sun/awt/X11InputMethod.java index ccfa5104809..b2a62c60ce8 100644 --- a/jdk/src/solaris/classes/sun/awt/X11InputMethod.java +++ b/jdk/src/solaris/classes/sun/awt/X11InputMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 @@ -415,6 +415,10 @@ public abstract class X11InputMethod extends InputMethodAdapter { setXICFocus(getPeer(lastXICFocussedComponent), false, isLastXICActive); lastXICFocussedComponent = null; isLastXICActive = false; + + resetXIC(); + needResetXICClient = null; + needResetXIC = false; } } From 13e6e19e2c6c4070b26e3ecf532a670ba7abcca4 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 14 Nov 2012 10:05:49 -0800 Subject: [PATCH 15/94] 8002026: build-infra: deploy repository building Change the compare script to handle deploy build artifacts. Reviewed-by: ohair, tbell --- common/bin/compare.sh | 22 ++++++++++++++++++---- common/bin/compare_exceptions.sh.incl | 9 +++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/common/bin/compare.sh b/common/bin/compare.sh index 5816f838900..015f9e2de26 100644 --- a/common/bin/compare.sh +++ b/common/bin/compare.sh @@ -283,7 +283,7 @@ compare_general_files() { ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \ ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \ ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \ - ! -name "*.lib" ! -name "*.war" \ + ! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" \ | $GREP -v "./bin/" | $SORT | $FILTER) echo General files... @@ -611,10 +611,19 @@ compare_bin_file() { DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE) DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE) SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM) - if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] && [ "$DIFF_SIZE_REL" -lt 102 ]; then + if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] \ + && [ "$DIFF_SIZE_REL" -lt 102 ]; then SIZE_MSG="($SIZE_MSG)" DIFF_SIZE= - elif [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_NUM" = 512 ]; then + elif [ "$OPENJDK_TARGET_OS" = "windows" ] \ + && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \ + && [ "$DIFF_SIZE_NUM" = 512 ]; then + # On windows, size of binaries increase in 512 increments. + SIZE_MSG="($SIZE_MSG)" + DIFF_SIZE= + elif [ "$OPENJDK_TARGET_OS" = "windows" ] \ + && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \ + && [ "$DIFF_SIZE_NUM" = -512 ]; then # On windows, size of binaries increase in 512 increments. SIZE_MSG="($SIZE_MSG)" DIFF_SIZE= @@ -840,7 +849,7 @@ compare_all_libs() { OTHER_DIR=$2 WORK_DIR=$3 - LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' \) | $SORT | $FILTER) + LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' -o -name 'JavaControlPanel' \) | $SORT | $FILTER) if [ -n "$LIBS" ]; then echo Libraries... @@ -1218,7 +1227,12 @@ fi if [ "$CMP_LIBS" = "true" ]; then if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then + echo -n "J2SDK " compare_all_libs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk + if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then + echo -n "J2RE " + compare_all_libs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re + fi fi if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then echo -n "Bundle " diff --git a/common/bin/compare_exceptions.sh.incl b/common/bin/compare_exceptions.sh.incl index c9fc3cc6c86..654c684f43d 100644 --- a/common/bin/compare_exceptions.sh.incl +++ b/common/bin/compare_exceptions.sh.incl @@ -881,6 +881,7 @@ ACCEPTED_JARZIP_CONTENTS=" KNOWN_BIN_DIFF=" ./jre/lib/libJObjC.dylib +./lib/libJObjC.dylib " ACCEPTED_BIN_DIFF=" @@ -932,26 +933,34 @@ ACCEPTED_BIN_DIFF=" ./jre/bin/tnameserv ./jre/lib/libsaproc.dylib ./jre/lib/server/libjvm.dylib +./lib/libsaproc.dylib +./lib/server/libjvm.dylib +./lib/deploy/JavaControlPanel.prefPane/Contents/MacOS/JavaControlPanel " KNOWN_SIZE_DIFF=" ./jre/lib/libJObjC.dylib +./lib/libJObjC.dylib " SORT_SYMBOLS=" ./jre/lib/libJObjC.dylib +./lib/libJObjC.dylib " KNOWN_SYM_DIFF=" ./jre/lib/libJObjC.dylib +./lib/libJObjC.dylib " KNOWN_ELF_DIFF=" ./jre/lib/libJObjC.dylib +./lib/libJObjC.dylib " KNOWN_DIS_DIFF=" ./jre/lib/libJObjC.dylib +./lib/libJObjC.dylib " fi From 56d387a2ef06f968b58cb834240957aaa4129283 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 14 Nov 2012 10:07:38 -0800 Subject: [PATCH 16/94] 8003412: javac needs to understand java.lang.annotation.Native Reviewed-by: mcimadamore --- .../com/sun/tools/javac/code/Symtab.java | 4 +- .../com/sun/tools/javac/jvm/JNIWriter.java | 9 ++- .../javac/nativeHeaders/NativeHeaderTest.java | 29 ++++++++- .../javahComparison/CompareTest.java | 2 +- .../javahComparison/TestClass4.java | 50 ++++++++++++++++ .../javahComparison/TestClass5.java | 60 +++++++++++++++++++ 6 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass4.java create mode 100644 langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass5.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java index 3002a9dfc2d..00d6b69db94 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java @@ -130,6 +130,7 @@ public class Symtab { public final Type methodHandleLookupType; public final Type methodTypeType; public final Type nativeHeaderType; + public final Type nativeHeaderType_old; public final Type throwableType; public final Type errorType; public final Type interruptedExceptionType; @@ -505,7 +506,8 @@ public class Symtab { List.of(exceptionType), methodClass), autoCloseableType.tsym); trustMeType = enterClass("java.lang.SafeVarargs"); - nativeHeaderType = enterClass("javax.tools.annotation.GenerateNativeHeader"); + nativeHeaderType = enterClass("java.lang.annotation.Native"); + nativeHeaderType_old = enterClass("javax.tools.annotation.GenerateNativeHeader"); lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory"); synthesizeEmptyInterfaceIfMissing(autoCloseableType); diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java index 765b79190d7..b1b8444bd6f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java @@ -157,13 +157,20 @@ public class JNIWriter { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; + /* temporary code for backwards compatibility */ for (Attribute.Compound a: c.annotations.getAttributes()) { - if (a.type.tsym == syms.nativeHeaderType.tsym) + if (a.type.tsym == syms.nativeHeaderType_old.tsym) return true; } + /* end of temporary code for backwards compatibility */ + for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; + for (Attribute.Compound a: i.sym.annotations.getAttributes()) { + if (a.type.tsym == syms.nativeHeaderType.tsym) + return true; + } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { diff --git a/langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java b/langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java index ba7c0055468..ecc79ea790a 100644 --- a/langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java +++ b/langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 7150368 + * @bug 7150368 8003412 * @summary javac should include basic ability to generate native headers */ @@ -125,7 +125,7 @@ public class NativeHeaderTest { } @Test - void annoTest(RunKind rk, GenKind gk) throws Exception { + void oldAnnoTest(RunKind rk, GenKind gk) throws Exception { List files = new ArrayList(); files.add(createFile("p/C.java", "@javax.tools.annotation.GenerateNativeHeader class C { }")); @@ -136,7 +136,18 @@ public class NativeHeaderTest { } @Test - void annoNestedClassTest(RunKind rk, GenKind gk) throws Exception { + void annoTest(RunKind rk, GenKind gk) throws Exception { + List files = new ArrayList(); + files.add(createFile("p/C.java", + "class C { @java.lang.annotation.Native public static final int i = 1907; }")); + + Set expect = createSet("C.h"); + + test(rk, gk, files, expect); + } + + @Test + void oldAnnoNestedClassTest(RunKind rk, GenKind gk) throws Exception { List files = new ArrayList(); files.add(createFile("p/C.java", "class C { @javax.tools.annotation.GenerateNativeHeader class Inner { } }")); @@ -147,6 +158,18 @@ public class NativeHeaderTest { test(rk, gk, files, expect); } + @Test + void annoNestedClassTest(RunKind rk, GenKind gk) throws Exception { + List files = new ArrayList(); + files.add(createFile("p/C.java", + "class C { class Inner { @java.lang.annotation.Native public static final int i = 1907; } }")); + + Set expect = createSet("C_Inner.h"); + if (gk == GenKind.FULL) expect.add("C.h"); + + test(rk, gk, files, expect); + } + /** * The worker method for each test case. * Compile the files and verify that exactly the expected set of header files diff --git a/langtools/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java b/langtools/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java index 4d12c936e7d..47d42e51b19 100644 --- a/langtools/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java +++ b/langtools/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 7150368 + * @bug 7150368 8003412 * @summary javac should include basic ability to generate native headers */ diff --git a/langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass4.java b/langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass4.java new file mode 100644 index 00000000000..bb2c808c4a5 --- /dev/null +++ b/langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass4.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.annotation.Native; + +public class TestClass4 { + @Native + public static final byte b = 1; + + @Native + public static final short s = 2; + + @Native + public static final int i = 3; + + @Native + public static final long l = 4; + + @Native + public static final float f = 5.0f; + + @Native + public static final double d = 6.0; + + @Native + public static final Object o = null; + + @Native + public static final String t = "8"; +} diff --git a/langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass5.java b/langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass5.java new file mode 100644 index 00000000000..95388ab87c2 --- /dev/null +++ b/langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass5.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.annotation.Native; + +public class TestClass5 { + @Native + public static final int tc5 = 1; + + public class Inner1 { + @Native + public static final int tc5i1 = 2; + + public class Inner1A { + @Native + public static final int tc5i1i1a = 3; + } + + public class Inner1B { + @Native + public static final int tc5i1i1b = 4; + } + } + + public class Inner2 { + @Native + public static final int tc521 = 5; + + public class Inner2A { + @Native + public static final int tc5i2i2a = 6; + } + + public class Inner2B { + @Native + public static final int tc5i2i2b = 7; + } + } +} + From 5bf5ff88120b0aebcb13d528faedf99d5e3796c1 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 14 Nov 2012 10:13:28 -0800 Subject: [PATCH 17/94] 8001875: build-infra: We must be able to force static linking of stdc++ Ensure that we build with static linking when requested, or do not build at all Reviewed-by: ohair, tbell --- common/autoconf/generated-configure.sh | 66 +++++++++++++++----------- common/autoconf/libraries.m4 | 43 +++++++++-------- 2 files changed, 62 insertions(+), 47 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index e8bc95efd4c..bc2c8885977 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -1035,7 +1035,7 @@ with_alsa with_alsa_include with_alsa_lib with_zlib -enable_static_link_stdc++ +with_stdc++lib with_num_cores with_memory_size with_sjavac_server_java @@ -1712,9 +1712,6 @@ Optional Features: --disable-macosx-runtime-support disable the use of MacOSX Java runtime support framework [enabled] - --disable-static-link-stdc++ - disable static linking of the C++ runtime on Linux - [enabled] --enable-sjavac use sjavac to do fast incremental compiles [disabled] --disable-precompiled-headers @@ -1796,6 +1793,10 @@ Optional Packages: --with-alsa-lib specify directory for the alsa library --with-zlib use zlib from build system or OpenJDK source (system, bundled) [bundled] + --with-stdc++lib=,, + force linking of the C++ runtime on Linux to either + static or dynamic, default is static with dynamic as + fallback --with-num-cores number of cores in the build system, e.g. --with-num-cores=8 [probed] --with-memory-size memory (in MB) available in the build system, e.g. @@ -3067,7 +3068,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1352751880 +DATE_WHEN_GENERATED=1352916731 ############################################################################### # @@ -33006,12 +33007,19 @@ LIBS="$save_LIBS" # statically link libstdc++ before C++ ABI is stablized on Linux unless # dynamic build is configured on command line. # -# Check whether --enable-static-link-stdc++ was given. -if test "${enable_static_link_stdc+++set}" = set; then - enableval=$enable_static_link_stdc++; -else - enable_static_link_stdc__=yes +# Check whether --with-stdc++lib was given. +if test "${with_stdc++lib+set}" = set; then + withval=$with_stdc++lib; + if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \ + && test "x$with_stdc__lib" != xdefault; then + { { $as_echo "$as_me:$LINENO: error: Bad parameter value --with-stdc++lib=$with_stdc__lib!" >&5 +$as_echo "$as_me: error: Bad parameter value --with-stdc++lib=$with_stdc__lib!" >&2;} + { (exit 1); exit 1; }; } + fi + +else + with_stdc__lib=default fi @@ -33157,38 +33165,40 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:$LINENO: result: $has_static_libstdcxx" >&5 $as_echo "$has_static_libstdcxx" >&6; } - if test "x$has_static_libcxx" = xno && test "x$has_dynamic_libcxx" = xno; then - { { $as_echo "$as_me:$LINENO: error: I cannot link to stdc++! Neither dynamically nor statically." >&5 -$as_echo "$as_me: error: I cannot link to stdc++! Neither dynamically nor statically." >&2;} + if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then + { { $as_echo "$as_me:$LINENO: error: Cannot link to stdc++, neither dynamically nor statically!" >&5 +$as_echo "$as_me: error: Cannot link to stdc++, neither dynamically nor statically!" >&2;} { (exit 1); exit 1; }; } fi - if test "x$enable_static_link_stdc__" = xyes && test "x$has_static_libstdcxx" = xno; then - { $as_echo "$as_me:$LINENO: Static linking of libstdc++ was not possible reverting to dynamic linking." >&5 -$as_echo "$as_me: Static linking of libstdc++ was not possible reverting to dynamic linking." >&6;} - enable_static_link_stdc__=no + if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then + { { $as_echo "$as_me:$LINENO: error: Static linking of libstdc++ was not possible!" >&5 +$as_echo "$as_me: error: Static linking of libstdc++ was not possible!" >&2;} + { (exit 1); exit 1; }; } fi - if test "x$enable_static_link_stdc__" = xno && test "x$has_dynamic_libstdcxx" = xno; then - { $as_echo "$as_me:$LINENO: Dynamic linking of libstdc++ was not possible reverting to static linking." >&5 -$as_echo "$as_me: Dynamic linking of libstdc++ was not possible reverting to static linking." >&6;} - enable_static_link_stdc__=yes + if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then + { { $as_echo "$as_me:$LINENO: error: Dynamic linking of libstdc++ was not possible!" >&5 +$as_echo "$as_me: error: Dynamic linking of libstdc++ was not possible!" >&2;} + { (exit 1); exit 1; }; } fi { $as_echo "$as_me:$LINENO: checking how to link with libstdc++" >&5 $as_echo_n "checking how to link with libstdc++... " >&6; } - if test "x$enable_static_link_stdc__" = xyes; then - LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS" - LDCXX="$CC" - STATIC_CXX_SETTING="STATIC_CXX=true" - { $as_echo "$as_me:$LINENO: result: static" >&5 -$as_echo "static" >&6; } - else + # If dynamic was requested, it's available since it would fail above otherwise. + # If dynamic wasn't requested, go with static unless it isn't available. + if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno; then LIBCXX="$LIBCXX -lstdc++" LDCXX="$CXX" STATIC_CXX_SETTING="STATIC_CXX=false" { $as_echo "$as_me:$LINENO: result: dynamic" >&5 $as_echo "dynamic" >&6; } + else + LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS" + LDCXX="$CC" + STATIC_CXX_SETTING="STATIC_CXX=true" + { $as_echo "$as_me:$LINENO: result: static" >&5 +$as_echo "static" >&6; } fi fi diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 index aebdf8b93fb..e1fea0726d6 100644 --- a/common/autoconf/libraries.m4 +++ b/common/autoconf/libraries.m4 @@ -601,11 +601,16 @@ AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP], # statically link libstdc++ before C++ ABI is stablized on Linux unless # dynamic build is configured on command line. # -AC_ARG_ENABLE([static-link-stdc++], [AS_HELP_STRING([--disable-static-link-stdc++], - [disable static linking of the C++ runtime on Linux @<:@enabled@:>@])],, - [ - enable_static_link_stdc__=yes - ]) +AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=,,], + [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])], + [ + if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \ + && test "x$with_stdc__lib" != xdefault; then + AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!]) + fi + ], + [with_stdc__lib=default] +) if test "x$OPENJDK_TARGET_OS" = xlinux; then # Test if -lstdc++ works. @@ -636,31 +641,31 @@ if test "x$OPENJDK_TARGET_OS" = xlinux; then AC_LANG_POP(C++) AC_MSG_RESULT([$has_static_libstdcxx]) - if test "x$has_static_libcxx" = xno && test "x$has_dynamic_libcxx" = xno; then - AC_MSG_ERROR([I cannot link to stdc++! Neither dynamically nor statically.]) + if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then + AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!]) fi - if test "x$enable_static_link_stdc__" = xyes && test "x$has_static_libstdcxx" = xno; then - AC_MSG_NOTICE([Static linking of libstdc++ was not possible reverting to dynamic linking.]) - enable_static_link_stdc__=no + if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then + AC_MSG_ERROR([Static linking of libstdc++ was not possible!]) fi - if test "x$enable_static_link_stdc__" = xno && test "x$has_dynamic_libstdcxx" = xno; then - AC_MSG_NOTICE([Dynamic linking of libstdc++ was not possible reverting to static linking.]) - enable_static_link_stdc__=yes + if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then + AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!]) fi AC_MSG_CHECKING([how to link with libstdc++]) - if test "x$enable_static_link_stdc__" = xyes; then - LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS" - LDCXX="$CC" - STATIC_CXX_SETTING="STATIC_CXX=true" - AC_MSG_RESULT([static]) - else + # If dynamic was requested, it's available since it would fail above otherwise. + # If dynamic wasn't requested, go with static unless it isn't available. + if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno; then LIBCXX="$LIBCXX -lstdc++" LDCXX="$CXX" STATIC_CXX_SETTING="STATIC_CXX=false" AC_MSG_RESULT([dynamic]) + else + LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS" + LDCXX="$CC" + STATIC_CXX_SETTING="STATIC_CXX=true" + AC_MSG_RESULT([static]) fi fi AC_SUBST(STATIC_CXX_SETTING) From 9359ccee627ad8510247ff05515e48639602f966 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 14 Nov 2012 10:16:45 -0800 Subject: [PATCH 18/94] 8001941: build-infra: --disable-precompiled-headers does not seem to work With this fix the flag will do what it advertises Reviewed-by: ohair, tbell --- common/autoconf/build-performance.m4 | 9 ++++----- common/autoconf/generated-configure.sh | 9 ++++----- common/autoconf/hotspot-spec.gmk.in | 2 ++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/autoconf/build-performance.m4 b/common/autoconf/build-performance.m4 index 0838e867028..0d1d8b92157 100644 --- a/common/autoconf/build-performance.m4 +++ b/common/autoconf/build-performance.m4 @@ -204,7 +204,7 @@ AC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS], # AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers], [disable using precompiled headers when compiling C++ @<:@enabled@:>@])], - [ENABLE_PRECOMPH=${enable_precompiled-headers}], [ENABLE_PRECOMPH=yes]) + [ENABLE_PRECOMPH=${enable_precompiled_headers}], [ENABLE_PRECOMPH=yes]) USE_PRECOMPILED_HEADER=1 if test "x$ENABLE_PRECOMPH" = xno; then @@ -214,17 +214,16 @@ fi if test "x$ENABLE_PRECOMPH" = xyes; then # Check that the compiler actually supports precomp headers. if test "x$GCC" = xyes; then - AC_MSG_CHECKING([that precompiled headers work]) + AC_MSG_CHECKING([that precompiled headers work]) echo "int alfa();" > conftest.h - $CXX -x c++-header conftest.h -o conftest.hpp.gch + $CXX -x c++-header conftest.h -o conftest.hpp.gch 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD if test ! -f conftest.hpp.gch; then - echo Precompiled header is not working! USE_PRECOMPILED_HEADER=0 AC_MSG_RESULT([no]) else AC_MSG_RESULT([yes]) fi - rm -f conftest.h + rm -f conftest.h conftest.hpp.gch fi fi diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index bc2c8885977..59dc6dd310c 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3068,7 +3068,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1352916731 +DATE_WHEN_GENERATED=1352916966 ############################################################################### # @@ -33656,7 +33656,7 @@ fi # # Check whether --enable-precompiled-headers was given. if test "${enable_precompiled_headers+set}" = set; then - enableval=$enable_precompiled_headers; ENABLE_PRECOMPH=${enable_precompiled-headers} + enableval=$enable_precompiled_headers; ENABLE_PRECOMPH=${enable_precompiled_headers} else ENABLE_PRECOMPH=yes fi @@ -33673,9 +33673,8 @@ if test "x$ENABLE_PRECOMPH" = xyes; then { $as_echo "$as_me:$LINENO: checking that precompiled headers work" >&5 $as_echo_n "checking that precompiled headers work... " >&6; } echo "int alfa();" > conftest.h - $CXX -x c++-header conftest.h -o conftest.hpp.gch + $CXX -x c++-header conftest.h -o conftest.hpp.gch 2>&5 >&5 if test ! -f conftest.hpp.gch; then - echo Precompiled header is not working! USE_PRECOMPILED_HEADER=0 { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } @@ -33683,7 +33682,7 @@ $as_echo "no" >&6; } { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } fi - rm -f conftest.h + rm -f conftest.h conftest.hpp.gch fi fi diff --git a/common/autoconf/hotspot-spec.gmk.in b/common/autoconf/hotspot-spec.gmk.in index 68cc8e4eea7..884a911a26d 100644 --- a/common/autoconf/hotspot-spec.gmk.in +++ b/common/autoconf/hotspot-spec.gmk.in @@ -95,6 +95,8 @@ EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@ EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@ +USE_PRECOMPILED_HEADER=@USE_PRECOMPILED_HEADER@ + # Sneak this in via the spec.gmk file, since we don't want to mess around too much with the Hotspot make files. # This is needed to get the LOG setting to work properly. include $(SRC_ROOT)/common/makefiles/MakeBase.gmk From 0f6c2bcdde6c347484038328242c91a7885d41f8 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 14 Nov 2012 10:18:51 -0800 Subject: [PATCH 19/94] 8003317: build-infra: Configure fails when current dir is part of a symlink Call macro for removing symbolic links on a copy of the CURDIR variable before comparing Reviewed-by: ohair, tbell --- common/autoconf/basics.m4 | 8 +++- common/autoconf/generated-configure.sh | 53 +++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index bd058af26e8..2275ca4f312 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -345,7 +345,13 @@ AC_ARG_WITH(conf-name, [AS_HELP_STRING([--with-conf-name], [ CONF_NAME=${with_conf_name} ]) # Test from where we are running configure, in or outside of src root. -if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" || test "x$CURDIR" = "x$SRC_ROOT/common/makefiles" ; then +# To enable comparison of directories, CURDIR needs to be symlink free +# just like SRC_ROOT already is +NOSYM_CURDIR="$CURDIR" +BASIC_REMOVE_SYMBOLIC_LINKS(NOSYM_CURDIR) +if test "x$NOSYM_CURDIR" = "x$SRC_ROOT" || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common" \ + || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/autoconf" \ + || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/makefiles" ; then # We are running configure from the src root. # Create a default ./build/target-variant-debuglevel output root. if test "x${CONF_NAME}" = x; then diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 59dc6dd310c..c6803908a23 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3068,7 +3068,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1352916966 +DATE_WHEN_GENERATED=1352917083 ############################################################################### # @@ -7137,7 +7137,56 @@ fi # Test from where we are running configure, in or outside of src root. -if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" || test "x$CURDIR" = "x$SRC_ROOT/common/makefiles" ; then +# To enable comparison of directories, CURDIR needs to be symlink free +# just like SRC_ROOT already is +NOSYM_CURDIR="$CURDIR" + + if test "x$OPENJDK_BUILD_OS" != xwindows; then + # Follow a chain of symbolic links. Use readlink + # where it exists, else fall back to horribly + # complicated shell code. + if test "x$READLINK_TESTED" != yes; then + # On MacOSX there is a readlink tool with a different + # purpose than the GNU readlink tool. Check the found readlink. + ISGNU=`$READLINK --help 2>&1 | $GREP GNU` + if test "x$ISGNU" = x; then + # A readlink that we do not know how to use. + # Are there other non-GNU readlinks out there? + READLINK_TESTED=yes + READLINK= + fi + fi + + if test "x$READLINK" != x; then + NOSYM_CURDIR=`$READLINK -f $NOSYM_CURDIR` + else + STARTDIR=$PWD + COUNTER=0 + sym_link_dir=`$DIRNAME $NOSYM_CURDIR` + sym_link_file=`$BASENAME $NOSYM_CURDIR` + while test $COUNTER -lt 20; do + ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` + if test "x$ISLINK" == x; then + # This is not a symbolic link! We are done! + break + fi + # The link might be relative! We have to use cd to travel safely. + cd $sym_link_dir + # ... and we must get the to the absolute path, not one using symbolic links. + cd `pwd -P` + cd `$DIRNAME $ISLINK` + sym_link_dir=`$THEPWDCMD` + sym_link_file=`$BASENAME $ISLINK` + let COUNTER=COUNTER+1 + done + cd $STARTDIR + NOSYM_CURDIR=$sym_link_dir/$sym_link_file + fi + fi + +if test "x$NOSYM_CURDIR" = "x$SRC_ROOT" || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common" \ + || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/autoconf" \ + || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/makefiles" ; then # We are running configure from the src root. # Create a default ./build/target-variant-debuglevel output root. if test "x${CONF_NAME}" = x; then From 23c574fe3ad1c3d67569f625d63e8837fcc841f7 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 14 Nov 2012 10:20:25 -0800 Subject: [PATCH 20/94] 8003327: build-infra: "/bin/sh: : cannot execute" on solaris Fix quoting inside cut command used in the pipeline Reviewed-by: ohair, tbell --- common/makefiles/MakeHelpers.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/makefiles/MakeHelpers.gmk b/common/makefiles/MakeHelpers.gmk index 0a441f88cff..f76ad374b2b 100644 --- a/common/makefiles/MakeHelpers.gmk +++ b/common/makefiles/MakeHelpers.gmk @@ -142,7 +142,7 @@ endef define TargetExit $(call RecordEndTime,$(patsubst %-only,%,$@)) $(BUILD_LOG_WRAPPER) $(PRINTF) "## Finished $(patsubst %-only,%,$@) (build time %s)\n\n" \ - "`$(CAT) $(BUILDTIMESDIR)/build_time_diff_$(patsubst %-only,%,$@) | $(CUT) -f 1 -d " "`" + "`$(CAT) $(BUILDTIMESDIR)/build_time_diff_$(patsubst %-only,%,$@) | $(CUT) -f 1 -d ' '`" $(call CheckIfMakeAtEnd) endef From acd0ee7c35be81e8aa1caa225b489de9041cb3c5 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 14 Nov 2012 10:21:45 -0800 Subject: [PATCH 21/94] 8001906: build-infra: warning: [path] bad path element on Solaris Remove unnecesary -cp parameter from compile line Reviewed-by: ohair, tbell --- jdk/makefiles/CompileDemos.gmk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/makefiles/CompileDemos.gmk b/jdk/makefiles/CompileDemos.gmk index 7de9166cffe..bf67ff124bd 100644 --- a/jdk/makefiles/CompileDemos.gmk +++ b/jdk/makefiles/CompileDemos.gmk @@ -166,9 +166,9 @@ $(eval $(call SetupDemo,SampleTree,jfc,,SampleTree,,,README*)) $(eval $(call SetupDemo,SwingApplet,jfc,,SwingApplet,,,README* *.html)) $(eval $(call SetupDemo,TableExample,jfc,,TableExample,,,README*)) $(eval $(call SetupDemo,TransparentRuler,jfc,,transparentruler.Ruler,,,README*)) -$(eval $(call SetupDemo,jconsole-plugin,scripting,-cp $(JDK_OUTPUTDIR)/lib/jconsole.jar,,,,*.xml *.txt,,,,Main-Class: \n)) +$(eval $(call SetupDemo,jconsole-plugin,scripting,,,,,*.xml *.txt,,,,Main-Class: \n)) $(eval $(call SetupDemo,FullThreadDump,management,,FullThreadDump,,,README*)) -$(eval $(call SetupDemo,JTop,management,-cp $(JDK_OUTPUTDIR)/lib/jconsole.jar,JTop,,,README*)) +$(eval $(call SetupDemo,JTop,management,,JTop,,,README*)) $(eval $(call SetupDemo,MemoryMonitor,management,,MemoryMonitor,,,README*)) $(eval $(call SetupDemo,VerboseGC,management,,VerboseGC,,,README*)) $(eval $(call SetupDemo,zipfs,nio,,,,,README* *.java,,,,Main-Class: \n)) From c78e1cbfac468528f848703d46c2511c69f70795 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 14 Nov 2012 17:23:10 -0800 Subject: [PATCH 22/94] 7021614: extend com.sun.source API to support parsing javadoc comments Reviewed-by: ksrini, strarup --- langtools/make/build.xml | 15 +- .../com/sun/source/doctree/AttributeTree.java | 42 + .../com/sun/source/doctree/AuthorTree.java | 40 + .../com/sun/source/doctree/BlockTagTree.java | 36 + .../com/sun/source/doctree/CommentTree.java | 39 + .../sun/source/doctree/DeprecatedTree.java | 40 + .../sun/source/doctree/DocCommentTree.java | 42 + .../com/sun/source/doctree/DocRootTree.java | 36 + .../com/sun/source/doctree/DocTree.java | 254 ++++ .../sun/source/doctree/DocTreeVisitor.java | 87 ++ .../sun/source/doctree/EndElementTree.java | 40 + .../com/sun/source/doctree/EntityTree.java | 41 + .../com/sun/source/doctree/ErroneousTree.java | 43 + .../sun/source/doctree/IdentifierTree.java | 40 + .../sun/source/doctree/InheritDocTree.java | 37 + .../com/sun/source/doctree/InlineTagTree.java | 36 + .../com/sun/source/doctree/LinkTree.java | 42 + .../com/sun/source/doctree/LiteralTree.java | 39 + .../com/sun/source/doctree/ParamTree.java | 42 + .../com/sun/source/doctree/ReferenceTree.java | 38 + .../com/sun/source/doctree/ReturnTree.java | 40 + .../com/sun/source/doctree/SeeTree.java | 43 + .../sun/source/doctree/SerialDataTree.java | 40 + .../sun/source/doctree/SerialFieldTree.java | 42 + .../com/sun/source/doctree/SerialTree.java | 40 + .../com/sun/source/doctree/SinceTree.java | 40 + .../sun/source/doctree/StartElementTree.java | 43 + .../com/sun/source/doctree/TextTree.java | 35 + .../com/sun/source/doctree/ThrowsTree.java | 44 + .../source/doctree/UnknownBlockTagTree.java | 40 + .../source/doctree/UnknownInlineTagTree.java | 40 + .../com/sun/source/doctree/ValueTree.java | 38 + .../com/sun/source/doctree/VersionTree.java | 41 + .../com/sun/source/doctree/package-info.java | 34 + .../classes/com/sun/source/tree/Tree.java | 4 +- .../com/sun/source/util/DocTreeScanner.java | 273 ++++ .../classes/com/sun/source/util/DocTrees.java | 89 ++ .../sun/source/util/SimpleDocTreeVisitor.java | 179 +++ .../classes/com/sun/source/util/Trees.java | 6 +- .../com/sun/tools/javac/api/JavacTrees.java | 378 ++++- .../com/sun/tools/javac/comp/Attr.java | 4 +- .../com/sun/tools/javac/comp/AttrContext.java | 1 + .../classes/com/sun/tools/javac/comp/Env.java | 3 +- .../com/sun/tools/javac/comp/Resolve.java | 2 +- .../tools/javac/parser/DocCommentParser.java | 1288 +++++++++++++++++ .../sun/tools/javac/parser/JavacParser.java | 14 +- .../tools/javac/parser/JavadocTokenizer.java | 6 +- ...entTable.java => LazyDocCommentTable.java} | 37 +- .../sun/tools/javac/parser/ParserFactory.java | 11 +- .../tools/javac/resources/compiler.properties | 48 + .../com/sun/tools/javac/tree/DCTree.java | 848 +++++++++++ .../sun/tools/javac/tree/DocCommentTable.java | 9 + .../com/sun/tools/javac/tree/DocPretty.java | 520 +++++++ .../sun/tools/javac/tree/DocTreeMaker.java | 277 ++++ .../classes/com/sun/tools/javadoc/DocEnv.java | 2 + .../com/sun/tools/javadoc/SeeTagImpl.java | 61 + .../test/tools/javac/diags/CheckExamples.java | 3 +- .../javac/diags/DocCommentProcessor.java | 114 ++ langtools/test/tools/javac/diags/Example.java | 9 +- .../test/tools/javac/diags/RunExamples.java | 2 +- .../tools/javac/diags/examples.not-yet.txt | 2 + .../tools/javac/diags/examples/BadEntity.java | 32 + .../javac/diags/examples/BadGreaterThan.java | 32 + .../javac/diags/examples/BadInlineTag.java | 32 + .../diags/examples/GreaterThanExpected.java | 34 + .../javac/diags/examples/MalformedHTML.java | 31 + .../diags/examples/MissingSemicolon.java | 32 + .../tools/javac/diags/examples/NoTagName.java | 32 + .../javac/diags/examples/RefBadParens.java | 32 + .../diags/examples/RefIdentifierExpected.java | 34 + .../javac/diags/examples/RefSyntaxError.java | 32 + .../diags/examples/RefUnexpectedInput.java | 32 + .../diags/examples/UnexpectedContent.java | 32 + .../diags/examples/UnterminatedInlineTag.java | 32 + .../diags/examples/UnterminatedSignature.java | 32 + .../test/tools/javac/doctree/AttrTest.java | 281 ++++ .../test/tools/javac/doctree/AuthorTest.java | 46 + .../test/tools/javac/doctree/BadTest.java | 52 + .../test/tools/javac/doctree/CodeTest.java | 133 ++ .../tools/javac/doctree/DeprecatedTest.java | 64 + .../tools/javac/doctree/DocCommentTester.java | 778 ++++++++++ .../test/tools/javac/doctree/DocRootTest.java | 84 ++ .../test/tools/javac/doctree/ElementTest.java | 250 ++++ .../test/tools/javac/doctree/EntityTest.java | 165 +++ .../tools/javac/doctree/ExceptionTest.java | 69 + .../javac/doctree/FirstSentenceTest.java | 198 +++ .../tools/javac/doctree/InheritDocTest.java | 84 ++ .../tools/javac/doctree/LinkPlainTest.java | 192 +++ .../test/tools/javac/doctree/LinkTest.java | 192 +++ .../test/tools/javac/doctree/LiteralTest.java | 134 ++ .../test/tools/javac/doctree/ParamTest.java | 68 + .../tools/javac/doctree/ReferenceTest.java | 214 +++ .../test/tools/javac/doctree/ReturnTest.java | 51 + .../test/tools/javac/doctree/SeeTest.java | 174 +++ .../tools/javac/doctree/SerialDataTest.java | 50 + .../tools/javac/doctree/SerialFieldTest.java | 74 + .../test/tools/javac/doctree/SerialTest.java | 97 ++ .../doctree/SimpleDocTreeVisitorTest.java | 166 +++ .../test/tools/javac/doctree/SinceTest.java | 53 + .../test/tools/javac/doctree/TagTest.java | 149 ++ .../tools/javac/doctree/ThrowableTest.java | 69 + .../test/tools/javac/doctree/ValueTest.java | 103 ++ .../test/tools/javac/doctree/VersionTest.java | 51 + 103 files changed, 10233 insertions(+), 38 deletions(-) create mode 100644 langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/CommentTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/DocRootTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/DocTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/EntityTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/InheritDocTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/LinkTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/ParamTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/SeeTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/SerialTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/SinceTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/TextTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/ValueTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/VersionTree.java create mode 100644 langtools/src/share/classes/com/sun/source/doctree/package-info.java create mode 100644 langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java create mode 100644 langtools/src/share/classes/com/sun/source/util/DocTrees.java create mode 100644 langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java create mode 100644 langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java rename langtools/src/share/classes/com/sun/tools/javac/parser/{SimpleDocCommentTable.java => LazyDocCommentTable.java} (67%) create mode 100644 langtools/src/share/classes/com/sun/tools/javac/tree/DCTree.java create mode 100644 langtools/src/share/classes/com/sun/tools/javac/tree/DocPretty.java create mode 100644 langtools/src/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java create mode 100644 langtools/test/tools/javac/diags/DocCommentProcessor.java create mode 100644 langtools/test/tools/javac/diags/examples/BadEntity.java create mode 100644 langtools/test/tools/javac/diags/examples/BadGreaterThan.java create mode 100644 langtools/test/tools/javac/diags/examples/BadInlineTag.java create mode 100644 langtools/test/tools/javac/diags/examples/GreaterThanExpected.java create mode 100644 langtools/test/tools/javac/diags/examples/MalformedHTML.java create mode 100644 langtools/test/tools/javac/diags/examples/MissingSemicolon.java create mode 100644 langtools/test/tools/javac/diags/examples/NoTagName.java create mode 100644 langtools/test/tools/javac/diags/examples/RefBadParens.java create mode 100644 langtools/test/tools/javac/diags/examples/RefIdentifierExpected.java create mode 100644 langtools/test/tools/javac/diags/examples/RefSyntaxError.java create mode 100644 langtools/test/tools/javac/diags/examples/RefUnexpectedInput.java create mode 100644 langtools/test/tools/javac/diags/examples/UnexpectedContent.java create mode 100644 langtools/test/tools/javac/diags/examples/UnterminatedInlineTag.java create mode 100644 langtools/test/tools/javac/diags/examples/UnterminatedSignature.java create mode 100644 langtools/test/tools/javac/doctree/AttrTest.java create mode 100644 langtools/test/tools/javac/doctree/AuthorTest.java create mode 100644 langtools/test/tools/javac/doctree/BadTest.java create mode 100644 langtools/test/tools/javac/doctree/CodeTest.java create mode 100644 langtools/test/tools/javac/doctree/DeprecatedTest.java create mode 100644 langtools/test/tools/javac/doctree/DocCommentTester.java create mode 100644 langtools/test/tools/javac/doctree/DocRootTest.java create mode 100644 langtools/test/tools/javac/doctree/ElementTest.java create mode 100644 langtools/test/tools/javac/doctree/EntityTest.java create mode 100644 langtools/test/tools/javac/doctree/ExceptionTest.java create mode 100644 langtools/test/tools/javac/doctree/FirstSentenceTest.java create mode 100644 langtools/test/tools/javac/doctree/InheritDocTest.java create mode 100644 langtools/test/tools/javac/doctree/LinkPlainTest.java create mode 100644 langtools/test/tools/javac/doctree/LinkTest.java create mode 100644 langtools/test/tools/javac/doctree/LiteralTest.java create mode 100644 langtools/test/tools/javac/doctree/ParamTest.java create mode 100644 langtools/test/tools/javac/doctree/ReferenceTest.java create mode 100644 langtools/test/tools/javac/doctree/ReturnTest.java create mode 100644 langtools/test/tools/javac/doctree/SeeTest.java create mode 100644 langtools/test/tools/javac/doctree/SerialDataTest.java create mode 100644 langtools/test/tools/javac/doctree/SerialFieldTest.java create mode 100644 langtools/test/tools/javac/doctree/SerialTest.java create mode 100644 langtools/test/tools/javac/doctree/SimpleDocTreeVisitorTest.java create mode 100644 langtools/test/tools/javac/doctree/SinceTest.java create mode 100644 langtools/test/tools/javac/doctree/TagTest.java create mode 100644 langtools/test/tools/javac/doctree/ThrowableTest.java create mode 100644 langtools/test/tools/javac/doctree/ValueTest.java create mode 100644 langtools/test/tools/javac/doctree/VersionTest.java diff --git a/langtools/make/build.xml b/langtools/make/build.xml index 52b13b7226a..be1c357852c 100644 --- a/langtools/make/build.xml +++ b/langtools/make/build.xml @@ -1,6 +1,6 @@ + style="${checkstyle.home}/contrib/checkstyle-simple.xsl"/> - + - + @@ -368,7 +368,7 @@ executable="${dist.bin.dir}/javac" srcdir="test/tools/javac/diags" destdir="${build.dir}/diag-examples/classes" - includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java" + includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java,DocCommentProcessor.java" sourcepath="" classpath="${dist.lib.dir}/javac.jar" includeAntRuntime="no" @@ -381,6 +381,7 @@ dir="test/tools/javac/diags" classpath="${build.dir}/diag-examples/classes;${dist.lib.dir}/javac.jar" classname="RunExamples"> + @@ -695,7 +696,7 @@ - + @@ -1005,7 +1006,7 @@ - + diff --git a/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java new file mode 100644 index 00000000000..26dd4c3995f --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; +import javax.lang.model.element.Name; + +/** + * A tree node for an attribute in an HTML element. + * + * @since 1.8 + */ +public interface AttributeTree extends DocTree { + enum ValueKind { EMPTY, UNQUOTED, SINGLE, DOUBLE }; + + Name getName(); + ValueKind getValueKind(); + List getValue(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java new file mode 100644 index 00000000000..d6580c5eaf2 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an @author block tag. + * + *

+ * @author name-text. + * + * @since 1.8 + */ +public interface AuthorTree extends BlockTagTree { + List getName(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java new file mode 100644 index 00000000000..9c72c1d973b --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +/** + * A tree node used as the base class for the different types of + * block tags. + * + * @since 1.8 + */ +public interface BlockTagTree extends DocTree { + String getTagName(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java new file mode 100644 index 00000000000..cd89cf5ca0d --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +/** + * An embedded HTML comment. + * + *

+ * {@literal } + * + * @since 1.8 + */ +public interface CommentTree extends DocTree { + String getBody(); +} + diff --git a/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java new file mode 100644 index 00000000000..c24baacc7ee --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an @deprecated block tag. + * + *

+ * @deprecated deprecated text. + * + * @since 1.8 + */ +public interface DeprecatedTree extends BlockTagTree { + List getBody(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java new file mode 100644 index 00000000000..d59cfffc2db --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * The top level representation of a documentation comment. + * + *

+ * first-sentence body block-tags + * + * @since 1.8 + */ +public interface DocCommentTree extends DocTree { + List getFirstSentence(); + List getBody(); + List getBlockTags(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocRootTree.java b/langtools/src/share/classes/com/sun/source/doctree/DocRootTree.java new file mode 100644 index 00000000000..05205fb0faf --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/DocRootTree.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +/** + * A tree node for an @docroot inline tag. + * + *

+ * {@docroot} + * + * @since 1.8 + */ +public interface DocRootTree extends InlineTagTree { } diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocTree.java b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java new file mode 100644 index 00000000000..a28cdcbe852 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +/** + * Common interface for all nodes in a documentation syntax tree. + * + * @since 1.8 + */ +public interface DocTree { + enum Kind { + /** + * Used for instances of {@link AttributeTree} + * representing an HTML attribute. + */ + ATTRIBUTE, + + /** + * Used for instances of {@link AuthorTree} + * representing an @author tag. + */ + AUTHOR("author"), + + /** + * Used for instances of {@link LiteralTree} + * representing an @code tag. + */ + CODE("code"), + + /** + * Used for instances of {@link CommentTree} + * representing an HTML comment. + */ + COMMENT, + + /** + * Used for instances of {@link DeprecatedTree} + * representing an @deprecated tag. + */ + DEPRECATED("deprecated"), + + /** + * Used for instances of {@link DocCommentTree} + * representing a complete doc comment. + */ + DOC_COMMENT, + + /** + * Used for instances of {@link DocRootTree} + * representing an @docRoot tag. + */ + DOC_ROOT("docRoot"), + + /** + * Used for instances of {@link EndElementTree} + * representing the end of an HTML element. + */ + END_ELEMENT, + + /** + * Used for instances of {@link EntityTree} + * representing an HTML entity. + */ + ENTITY, + + /** + * Used for instances of {@link ErroneousTree} + * representing some invalid text. + */ + ERRONEOUS, + + /** + * Used for instances of {@link ThrowsTree} + * representing an @exception tag. + */ + EXCEPTION("exception"), + + /** + * Used for instances of {@link IdentifierTree} + * representing an identifier. + */ + IDENTIFIER, + + /** + * Used for instances of {@link InheritDocTree} + * representing an @inheritDoc tag. + */ + INHERIT_DOC("inheritDoc"), + + /** + * Used for instances of {@link LinkTree} + * representing an @link tag. + */ + LINK("link"), + + /** + * Used for instances of {@link LinkTree} + * representing an @linkplain tag. + */ + LINK_PLAIN("linkplain"), + + /** + * Used for instances of {@link LiteralTree} + * representing an @literal tag. + */ + LITERAL("literal"), + + /** + * Used for instances of {@link ParamTree} + * representing an @param tag. + */ + PARAM("param"), + + /** + * Used for instances of {@link ReferenceTree} + * representing a reference to a element in the + * Java programming language. + */ + REFERENCE, + + /** + * Used for instances of {@link ReturnTree} + * representing an @return tag. + */ + RETURN("return"), + + /** + * Used for instances of {@link SeeTree} + * representing an @see tag. + */ + SEE("see"), + + /** + * Used for instances of {@link SerialTree} + * representing an @serial tag. + */ + SERIAL("serial"), + + /** + * Used for instances of {@link SerialDataTree} + * representing an @serialData tag. + */ + SERIAL_DATA("serialData"), + + /** + * Used for instances of {@link SerialFieldTree} + * representing an @serialField tag. + */ + SERIAL_FIELD("serialField"), + + /** + * Used for instances of {@link SinceTree} + * representing an @since tag. + */ + SINCE("since"), + + /** + * Used for instances of {@link EndElementTree} + * representing the start of an HTML element. + */ + START_ELEMENT, + + /** + * Used for instances of {@link TextTree} + * representing some documentation text. + */ + TEXT, + + /** + * Used for instances of {@link ThrowsTree} + * representing an @throws tag. + */ + THROWS("throws"), + + /** + * Used for instances of {@link UnknownBlockTagTree} + * representing an unknown block tag. + */ + UNKNOWN_BLOCK_TAG, + + /** + * Used for instances of {@link UnknownInlineTagTree} + * representing an unknown inline tag. + */ + UNKNOWN_INLINE_TAG, + + /** + * Used for instances of {@link ValueTree} + * representing an @value tag. + */ + VALUE("value"), + + /** + * Used for instances of {@link VersionTree} + * representing an @version tag. + */ + VERSION("version"), + + /** + * An implementation-reserved node. This is the not the node + * you are looking for. + */ + OTHER; + + public final String tagName; + + Kind() { + tagName = null; + } + + Kind(String tagName) { + this.tagName = tagName; + } + }; + + /** + * Gets the kind of this tree. + * + * @return the kind of this tree. + */ + Kind getKind(); + + /** + * Accept method used to implement the visitor pattern. The + * visitor pattern is used to implement operations on trees. + * + * @param result type of this operation. + * @param type of additional data. + */ + R accept(DocTreeVisitor visitor, D data); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java new file mode 100644 index 00000000000..c7feb40d244 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + + +/** + * A visitor of trees, in the style of the visitor design pattern. + * Classes implementing this interface are used to operate + * on a tree when the kind of tree is unknown at compile time. + * When a visitor is passed to an tree's {@link DocTree#accept + * accept} method, the visitXYZ method most applicable + * to that tree is invoked. + * + *

Classes implementing this interface may or may not throw a + * {@code NullPointerException} if the additional parameter {@code p} + * is {@code null}; see documentation of the implementing class for + * details. + * + *

WARNING: It is possible that methods will be added to + * this interface to accommodate new, currently unknown, doc comment + * structures added to future versions of the Java™ programming + * language. Therefore, visitor classes directly implementing this + * interface may be source incompatible with future versions of the + * platform. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @since 1.8 + */ +public interface DocTreeVisitor { + R visitAttribute(AttributeTree node, P p); + R visitAuthor(AuthorTree node, P p); + R visitComment(CommentTree node, P p); + R visitDeprecated(DeprecatedTree node, P p); + R visitDocComment(DocCommentTree node, P p); + R visitDocRoot(DocRootTree node, P p); + R visitEndElement(EndElementTree node, P p); + R visitEntity(EntityTree node, P p); + R visitErroneous(ErroneousTree node, P p); + R visitIdentifier(IdentifierTree node, P p); + R visitInheritDoc(InheritDocTree node, P p); + R visitLink(LinkTree node, P p); + R visitLiteral(LiteralTree node, P p); + R visitParam(ParamTree node, P p); + R visitReference(ReferenceTree node, P p); + R visitReturn(ReturnTree node, P p); + R visitSee(SeeTree node, P p); + R visitSerial(SerialTree node, P p); + R visitSerialData(SerialDataTree node, P p); + R visitSerialField(SerialFieldTree node, P p); + R visitSince(SinceTree node, P p); + R visitStartElement(StartElementTree node, P p); + R visitText(TextTree node, P p); + R visitThrows(ThrowsTree node, P p); + R visitUnknownBlockTag(UnknownBlockTagTree node, P p); + R visitUnknownInlineTag(UnknownInlineTagTree node, P p); + R visitValue(ValueTree node, P p); + R visitVersion(VersionTree node, P p); + R visitOther(DocTree node, P p); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java new file mode 100644 index 00000000000..2584f798c6c --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import javax.lang.model.element.Name; + +/** + * A tree node for the end of an HTML element. + * + *

+ * </ name > + * + * @since 1.8 + */ +public interface EndElementTree extends DocTree { + Name getName(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java new file mode 100644 index 00000000000..9c6ad50aee0 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import javax.lang.model.element.Name; + + +/** + * A tree node for an HTML entity. + * + *

+ * & name ; + * + * @since 1.8 + */ +public interface EntityTree extends DocTree { + Name getName(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java new file mode 100644 index 00000000000..ca50acbbfc7 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.source.doctree; + +import javax.tools.Diagnostic; +import javax.tools.JavaFileObject; + +/** + * A tree node to stand in for a malformed text + * + * @since 1.8 + */ +public interface ErroneousTree extends TextTree { + /** + * Gets a diagnostic object giving details about + * the reason the body text is in error. + * + * @return a diagnostic + */ + Diagnostic getDiagnostic(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java new file mode 100644 index 00000000000..0be2ddf2a34 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import javax.lang.model.element.Name; + +/** + * An identifier in a documentation comment. + * + *

+ * name + * + * @since 1.8 + */ +public interface IdentifierTree extends DocTree { + Name getName(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/InheritDocTree.java b/langtools/src/share/classes/com/sun/source/doctree/InheritDocTree.java new file mode 100644 index 00000000000..8af74b6a330 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/InheritDocTree.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +/** + * + * A tree node for an @inheritDoc inline tag. + * + *

+ * {@inheritDoc} + * + * @since 1.8 + */ +public interface InheritDocTree extends InlineTagTree { } diff --git a/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java new file mode 100644 index 00000000000..a6cec5307c2 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +/** + * A tree node used as the base class for the different types of + * inline tags. + * + * @since 1.8 + */ +public interface InlineTagTree extends DocTree { + String getTagName(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java new file mode 100644 index 00000000000..41f28e0e95f --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an @link or @linkplain inline tag. + * + *

+ * {@link reference label}
+ * {@linkplain reference label } + * + * @since 1.8 + */ +public interface LinkTree extends InlineTagTree { + ReferenceTree getReference(); + List getLabel(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java new file mode 100644 index 00000000000..0531501fa41 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +/** + * + * A tree node for an @literal or @code inline tag. + * + *

+ * {@literal text} + * + * @since 1.8 + */ +public interface LiteralTree extends InlineTagTree { + TextTree getBody(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java new file mode 100644 index 00000000000..a7dcf6a6aac --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an @param block tag. + * + *

+ * @param parameter-name description + * + * @since 1.8 + */ +public interface ParamTree extends BlockTagTree { + boolean isTypeParameter(); + IdentifierTree getName(); + List getDescription(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java new file mode 100644 index 00000000000..1ab12de2498 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +/** + * A tree node to a reference to a Java language element. + * + *

+ * package.class#field + * + * @since 1.8 + */ +public interface ReferenceTree extends DocTree { + String getSignature(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java new file mode 100644 index 00000000000..5b0fe313ac7 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an @return block tag. + * + *

+ * @return description + * + * @since 1.8 + */ +public interface ReturnTree extends BlockTagTree { + List getDescription(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java new file mode 100644 index 00000000000..6d70194aacb --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * + * A tree node for an @see block tag. + * + *

+ * @see "string"
+ * @see <a href="URL#value"> label </a>
+ * @see reference + * + * @since 1.8 + */ +public interface SeeTree extends BlockTagTree { + List getReference(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java new file mode 100644 index 00000000000..02c2f26c943 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an @serialData block tag. + * + *

+ * @serialData data-description + * + * @since 1.8 + */ +public interface SerialDataTree extends BlockTagTree { + List getDescription(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java new file mode 100644 index 00000000000..eb47017c331 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an @serialData block tag. + * + *

+ * @serialField field-name field-type field-description + * + * @since 1.8 + */ +public interface SerialFieldTree extends BlockTagTree { + IdentifierTree getName(); + ReferenceTree getType(); + List getDescription(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java new file mode 100644 index 00000000000..5f5f6ccaa92 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an @serial block tag. + * + *

+ * @serial field-description | include | exclude + * + * @since 1.8 + */ +public interface SerialTree extends BlockTagTree { + List getDescription(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java new file mode 100644 index 00000000000..60090967e10 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an @since block tag. + * + *

+ * @since since-text + * + * @since 1.8 + */ +public interface SinceTree extends BlockTagTree { + List getBody(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java new file mode 100644 index 00000000000..f3d4f28ddbe --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; +import javax.lang.model.element.Name; + +/** + * A tree node for the start of an HTML element. + * + *

+ * < name [attributes] [/]> + * + * @since 1.8 + */ +public interface StartElementTree extends DocTree { + Name getName(); + List getAttributes(); + boolean isSelfClosing(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/TextTree.java b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java new file mode 100644 index 00000000000..5db02702a10 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +/** + * A tree node for plain text. + * + * @since 1.8 + */ +public interface TextTree extends DocTree { + String getBody(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java new file mode 100644 index 00000000000..795d3a38f62 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * + * A tree node for an @exception or @throws block tag. + * @exception is a synonym for @throws. + * + *

+ * @exception class-name description
+ * @throws class-name description + * + * @since 1.8 + */ +public interface ThrowsTree extends BlockTagTree { + ReferenceTree getExceptionName(); + List getDescription(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java new file mode 100644 index 00000000000..f985dc39d12 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an unrecognized inline tag. + * + *

+ * @name content + * + * @since 1.8 + * + */ +public interface UnknownBlockTagTree extends BlockTagTree { + List getContent(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java new file mode 100644 index 00000000000..9ab78173592 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.source.doctree; + +import java.util.List; + +/** + * A tree node for an unrecognized inline tag. + * + *

+ * {@name content} + * + * @since 1.8 + * + */ +public interface UnknownInlineTagTree extends InlineTagTree { + List getContent(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java new file mode 100644 index 00000000000..3f61f2519b4 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +/** + * A tree node for an @value inline tag. + * + *

+ * { @value reference } + * + * @since 1.8 + */ +public interface ValueTree extends InlineTagTree { + ReferenceTree getReference(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java new file mode 100644 index 00000000000..4595ec04a5e --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.doctree; + +import java.util.List; + +/** + * + * A tree node for an @version block tag. + * + *

+ * @version version-text + * + * @since 1.8 + */ +public interface VersionTree extends BlockTagTree { + List getBody(); +} diff --git a/langtools/src/share/classes/com/sun/source/doctree/package-info.java b/langtools/src/share/classes/com/sun/source/doctree/package-info.java new file mode 100644 index 00000000000..8b84ed3ec71 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/doctree/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides interfaces to represent documentation comments as abstract syntax + * trees (AST). + * + * @author Jonathan Gibbons + * @since 1.8 + * @see http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags + */ +package com.sun.source.doctree; diff --git a/langtools/src/share/classes/com/sun/source/tree/Tree.java b/langtools/src/share/classes/com/sun/source/tree/Tree.java index a558e9e5999..4693b84b52b 100644 --- a/langtools/src/share/classes/com/sun/source/tree/Tree.java +++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. 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 @@ -610,7 +610,7 @@ public interface Tree { * visitor pattern is used to implement operations on trees. * * @param result type of this operation. - * @param type of additonal data. + * @param type of additional data. */ R accept(TreeVisitor visitor, D data); } diff --git a/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java new file mode 100644 index 00000000000..4d23b2266be --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.util; + +import com.sun.source.doctree.*; + + +/** + * A TreeVisitor that visits all the child tree nodes. + * To visit nodes of a particular type, just override the + * corresponding visitXYZ method. + * Inside your method, call super.visitXYZ to visit descendant + * nodes. + * + *

The default implementation of the visitXYZ methods will determine + * a result as follows: + *

    + *
  • If the node being visited has no children, the result will be null. + *
  • If the node being visited has one child, the result will be the + * result of calling {@code scan} on that child. The child may be a simple node + * or itself a list of nodes. + *
  • If the node being visited has more than one child, the result will + * be determined by calling {@code scan} each child in turn, and then combining the + * result of each scan after the first with the cumulative result + * so far, as determined by the {@link #reduce} method. Each child may be either + * a simple node of a list of nodes. The default behavior of the {@code reduce} + * method is such that the result of the visitXYZ method will be the result of + * the last child scanned. + *
+ * + *

Here is an example to count the number of erroneous nodes in a tree: + *

+ *   class CountErrors extends DocTreeScanner {
+ *      {@literal @}Override
+ *      public Integer visitErroneous(ErroneousTree node, Void p) {
+ *          return 1;
+ *      }
+ *      {@literal @}Override
+ *      public Integer reduce(Integer r1, Integer r2) {
+ *          return (r1 == null ? 0 : r1) + (r2 == null ? 0 : r2);
+ *      }
+ *   }
+ * 
+ * + * @since 1.8 + */ +public class DocTreeScanner implements DocTreeVisitor { + + /** + * Scan a single node. + */ + public R scan(DocTree node, P p) { + return (node == null) ? null : node.accept(this, p); + } + + private R scanAndReduce(DocTree node, P p, R r) { + return reduce(scan(node, p), r); + } + + /** + * Scan a list of nodes. + */ + public R scan(Iterable nodes, P p) { + R r = null; + if (nodes != null) { + boolean first = true; + for (DocTree node : nodes) { + r = (first ? scan(node, p) : scanAndReduce(node, p, r)); + first = false; + } + } + return r; + } + + private R scanAndReduce(Iterable nodes, P p, R r) { + return reduce(scan(nodes, p), r); + } + + /** + * Reduces two results into a combined result. + * The default implementation is to return the first parameter. + * The general contract of the method is that it may take any action whatsoever. + */ + public R reduce(R r1, R r2) { + return r1; + } + + +/* *************************************************************************** + * Visitor methods + ****************************************************************************/ + + @Override + public R visitAttribute(AttributeTree node, P p) { + return null; + } + + @Override + public R visitAuthor(AuthorTree node, P p) { + return scan(node.getName(), p); + } + + @Override + public R visitComment(CommentTree node, P p) { + return null; + } + + @Override + public R visitDeprecated(DeprecatedTree node, P p) { + return scan(node.getBody(), p); + } + + @Override + public R visitDocComment(DocCommentTree node, P p) { + R r = scan(node.getFirstSentence(), p); + r = scanAndReduce(node.getBody(), p, r); + r = scanAndReduce(node.getBlockTags(), p, r); + return r; + } + + @Override + public R visitDocRoot(DocRootTree node, P p) { + return null; + } + + @Override + public R visitEndElement(EndElementTree node, P p) { + return null; + } + + @Override + public R visitEntity(EntityTree node, P p) { + return null; + } + + @Override + public R visitErroneous(ErroneousTree node, P p) { + return null; + } + + @Override + public R visitIdentifier(IdentifierTree node, P p) { + return null; + } + + @Override + public R visitInheritDoc(InheritDocTree node, P p) { + return null; + } + + @Override + public R visitLink(LinkTree node, P p) { + R r = scan(node.getReference(), p); + r = scanAndReduce(node.getLabel(), p, r); + return r; + } + + @Override + public R visitLiteral(LiteralTree node, P p) { + return null; + } + + @Override + public R visitParam(ParamTree node, P p) { + R r = scan(node.getName(), p); + r = scanAndReduce(node.getDescription(), p, r); + return r; + } + + @Override + public R visitReference(ReferenceTree node, P p) { + return null; + } + + @Override + public R visitReturn(ReturnTree node, P p) { + return scan(node.getDescription(), p); + } + + @Override + public R visitSee(SeeTree node, P p) { + return scan(node.getReference(), p); + } + + @Override + public R visitSerial(SerialTree node, P p) { + return scan(node.getDescription(), p); + } + + @Override + public R visitSerialData(SerialDataTree node, P p) { + return scan(node.getDescription(), p); + } + + @Override + public R visitSerialField(SerialFieldTree node, P p) { + R r = scan(node.getName(), p); + r = scanAndReduce(node.getType(), p, r); + r = scanAndReduce(node.getDescription(), p, r); + return r; + } + + @Override + public R visitSince(SinceTree node, P p) { + return scan(node.getBody(), p); + } + + @Override + public R visitStartElement(StartElementTree node, P p) { + return scan(node.getAttributes(), p); + } + + @Override + public R visitText(TextTree node, P p) { + return null; + } + + @Override + public R visitThrows(ThrowsTree node, P p) { + R r = scan(node.getExceptionName(), p); + r = scanAndReduce(node.getDescription(), p, r); + return r; + } + + @Override + public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) { + return scan(node.getContent(), p); + } + + @Override + public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) { + return scan(node.getContent(), p); + } + + @Override + public R visitValue(ValueTree node, P p) { + return scan(node.getReference(), p); + } + + @Override + public R visitVersion(VersionTree node, P p) { + return scan(node.getBody(), p); + } + + @Override + public R visitOther(DocTree node, P p) { + return null; + } + +} diff --git a/langtools/src/share/classes/com/sun/source/util/DocTrees.java b/langtools/src/share/classes/com/sun/source/util/DocTrees.java new file mode 100644 index 00000000000..68abf3f5de3 --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/util/DocTrees.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.util; + +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.Element; +import javax.tools.JavaCompiler.CompilationTask; + +import com.sun.source.doctree.DocCommentTree; +import com.sun.source.doctree.ReferenceTree; +import javax.tools.Diagnostic; + +/** + * Provides access to syntax trees for doc comments. + * + * @since 1.8 + */ +public abstract class DocTrees extends Trees { + /** + * Gets a DocTrees object for a given CompilationTask. + * @param task the compilation task for which to get the Trees object + * @throws IllegalArgumentException if the task does not support the Trees API. + */ + public static DocTrees instance(CompilationTask task) { + if (!task.getClass().getName().equals("com.sun.tools.javac.api.JavacTaskImpl")) + throw new IllegalArgumentException(); + return (DocTrees) getJavacTrees(CompilationTask.class, task); + } + + /** + * Gets a DocTrees object for a given ProcessingEnvironment. + * @param env the processing environment for which to get the Trees object + * @throws IllegalArgumentException if the env does not support the Trees API. + */ + public static DocTrees instance(ProcessingEnvironment env) { + if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) + throw new IllegalArgumentException(); + return (DocTrees) getJavacTrees(ProcessingEnvironment.class, env); + } + + /** + * Gets the doc comment tree, if any, for the Tree node identified by a given TreePath. + * Returns null if no doc comment was found. + */ + public abstract DocCommentTree getDocCommentTree(TreePath path); + + /** + * Gets the language model element referred to by a ReferenceTree that + * appears on the declaration identified by the given path. + */ + public abstract Element getElement(TreePath path, ReferenceTree reference); + + /** + * Prints a message of the specified kind at the location of the + * tree within the provided compilation unit + * + * @param kind the kind of message + * @param msg the message, or an empty string if none + * @param t the tree to use as a position hint + * @param root the compilation unit that contains tree + */ + public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg, + com.sun.source.doctree.DocTree t, + com.sun.source.doctree.DocCommentTree c, + com.sun.source.tree.CompilationUnitTree root); +} diff --git a/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java new file mode 100644 index 00000000000..a1be626b82e --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.util; + +import com.sun.source.doctree.*; + +/** + * A simple visitor for tree nodes. + * + * @since 1.8 + */ +public class SimpleDocTreeVisitor implements DocTreeVisitor { + protected final R DEFAULT_VALUE; + + protected SimpleDocTreeVisitor() { + DEFAULT_VALUE = null; + } + + protected SimpleDocTreeVisitor(R defaultValue) { + DEFAULT_VALUE = defaultValue; + } + + protected R defaultAction(DocTree node, P p) { + return DEFAULT_VALUE; + } + + public final R visit(DocTree node, P p) { + return (node == null) ? null : node.accept(this, p); + } + + public final R visit(Iterable nodes, P p) { + R r = null; + if (nodes != null) { + for (DocTree node : nodes) + r = visit(node, p); + } + return r; + } + + public R visitAttribute(AttributeTree node, P p) { + return defaultAction(node, p); + } + + public R visitAuthor(AuthorTree node, P p) { + return defaultAction(node, p); + } + + public R visitComment(CommentTree node, P p) { + return defaultAction(node, p); + } + + public R visitDeprecated(DeprecatedTree node, P p) { + return defaultAction(node, p); + } + + public R visitDocComment(DocCommentTree node, P p) { + return defaultAction(node, p); + } + + public R visitDocRoot(DocRootTree node, P p) { + return defaultAction(node, p); + } + + public R visitEndElement(EndElementTree node, P p) { + return defaultAction(node, p); + } + + public R visitEntity(EntityTree node, P p) { + return defaultAction(node, p); + } + + public R visitErroneous(ErroneousTree node, P p) { + return defaultAction(node, p); + } + + public R visitIdentifier(IdentifierTree node, P p) { + return defaultAction(node, p); + } + + public R visitInheritDoc(InheritDocTree node, P p) { + return defaultAction(node, p); + } + + public R visitLink(LinkTree node, P p) { + return defaultAction(node, p); + } + + public R visitLiteral(LiteralTree node, P p) { + return defaultAction(node, p); + } + + public R visitParam(ParamTree node, P p) { + return defaultAction(node, p); + } + + public R visitReference(ReferenceTree node, P p) { + return defaultAction(node, p); + } + + public R visitReturn(ReturnTree node, P p) { + return defaultAction(node, p); + } + + public R visitSee(SeeTree node, P p) { + return defaultAction(node, p); + } + + public R visitSerial(SerialTree node, P p) { + return defaultAction(node, p); + } + + public R visitSerialData(SerialDataTree node, P p) { + return defaultAction(node, p); + } + + public R visitSerialField(SerialFieldTree node, P p) { + return defaultAction(node, p); + } + + public R visitSince(SinceTree node, P p) { + return defaultAction(node, p); + } + + public R visitStartElement(StartElementTree node, P p) { + return defaultAction(node, p); + } + + public R visitText(TextTree node, P p) { + return defaultAction(node, p); + } + + public R visitThrows(ThrowsTree node, P p) { + return defaultAction(node, p); + } + + public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) { + return defaultAction(node, p); + } + + public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) { + return defaultAction(node, p); + } + + public R visitValue(ValueTree node, P p) { + return defaultAction(node, p); + } + + public R visitVersion(VersionTree node, P p) { + return defaultAction(node, p); + } + + public R visitOther(DocTree node, P p) { + return defaultAction(node, p); + } + +} diff --git a/langtools/src/share/classes/com/sun/source/util/Trees.java b/langtools/src/share/classes/com/sun/source/util/Trees.java index a787061f495..139066ebbd7 100644 --- a/langtools/src/share/classes/com/sun/source/util/Trees.java +++ b/langtools/src/share/classes/com/sun/source/util/Trees.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. 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 @@ -26,6 +26,7 @@ package com.sun.source.util; import java.lang.reflect.Method; + import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; @@ -73,7 +74,7 @@ public abstract class Trees { return getJavacTrees(ProcessingEnvironment.class, env); } - private static Trees getJavacTrees(Class argType, Object arg) { + static Trees getJavacTrees(Class argType, Object arg) { try { ClassLoader cl = arg.getClass().getClassLoader(); Class c = Class.forName("com.sun.tools.javac.api.JavacTrees", false, cl); @@ -168,6 +169,7 @@ public abstract class Trees { /** * Gets the doc comment, if any, for the Tree node identified by a given TreePath. * Returns null if no doc comment was found. + * @see DocTrees#getDocCommentTree(TreePath) */ public abstract String getDocComment(TreePath path); diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java index 174b3ffa971..13fa76c8d08 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -26,6 +26,8 @@ package com.sun.tools.javac.api; import java.io.IOException; +import java.util.HashSet; +import java.util.Set; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.AnnotationMirror; @@ -40,19 +42,31 @@ import javax.tools.Diagnostic; import javax.tools.JavaCompiler; import javax.tools.JavaFileObject; +import com.sun.source.doctree.DocCommentTree; +import com.sun.source.doctree.ReferenceTree; import com.sun.source.tree.CatchTree; import com.sun.source.tree.CompilationUnitTree; import com.sun.source.tree.Scope; import com.sun.source.tree.Tree; +import com.sun.source.util.DocTrees; import com.sun.source.util.JavacTask; import com.sun.source.util.SourcePositions; import com.sun.source.util.TreePath; -import com.sun.source.util.Trees; import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.ClassSymbol; +import com.sun.tools.javac.code.Symbol.MethodSymbol; +import com.sun.tools.javac.code.Symbol.PackageSymbol; import com.sun.tools.javac.code.Symbol.TypeSymbol; +import com.sun.tools.javac.code.Symbol.VarSymbol; +import com.sun.tools.javac.code.Type; +import com.sun.tools.javac.code.Type.ArrayType; +import com.sun.tools.javac.code.Type.ClassType; +import com.sun.tools.javac.code.Type.ErrorType; import com.sun.tools.javac.code.Type.UnionClassType; +import com.sun.tools.javac.code.Types; +import com.sun.tools.javac.code.Types.TypeRelation; import com.sun.tools.javac.comp.Attr; import com.sun.tools.javac.comp.AttrContext; import com.sun.tools.javac.comp.Enter; @@ -61,6 +75,9 @@ import com.sun.tools.javac.comp.MemberEnter; import com.sun.tools.javac.comp.Resolve; import com.sun.tools.javac.model.JavacElements; import com.sun.tools.javac.processing.JavacProcessingEnvironment; +import com.sun.tools.javac.tree.DCTree; +import com.sun.tools.javac.tree.DCTree.DCDocComment; +import com.sun.tools.javac.tree.DCTree.DCReference; import com.sun.tools.javac.tree.EndPosTable; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.*; @@ -71,8 +88,12 @@ import com.sun.tools.javac.util.Assert; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.JCDiagnostic; import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Name; +import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Pair; +import static com.sun.tools.javac.code.TypeTag.*; /** * Provides an implementation of Trees. @@ -84,7 +105,7 @@ import com.sun.tools.javac.util.Pair; * * @author Peter von der Ahé */ -public class JavacTrees extends Trees { +public class JavacTrees extends DocTrees { // in a world of a single context per compilation, these would all be final private Resolve resolve; @@ -95,6 +116,8 @@ public class JavacTrees extends Trees { private TreeMaker treeMaker; private JavacElements elements; private JavacTaskImpl javacTaskImpl; + private Names names; + private Types types; // called reflectively from Trees.instance(CompilationTask task) public static JavacTrees instance(JavaCompiler.CompilationTask task) { @@ -134,6 +157,8 @@ public class JavacTrees extends Trees { resolve = Resolve.instance(context); treeMaker = TreeMaker.instance(context); memberEnter = MemberEnter.instance(context); + names = Names.instance(context); + types = Types.instance(context); JavacTask t = context.get(JavacTask.class); if (t instanceof JavacTaskImpl) @@ -229,6 +254,324 @@ public class JavacTrees extends Trees { return sym; } + @Override + public Element getElement(TreePath path, ReferenceTree reference) { + if (!(reference instanceof DCReference)) + return null; + DCReference ref = (DCReference) reference; + + Env env = getAttrContext(path); + + Log.DeferredDiagnosticHandler deferredDiagnosticHandler = + new Log.DeferredDiagnosticHandler(log); + try { + final ClassSymbol tsym; + final Name memberName; + if (ref.qualifierExpression == null) { + tsym = env.enclClass.sym; + memberName = ref.memberName; + } else { + // See if the qualifierExpression is a type or package name. + // javac does not provide the exact method required, so + // we first check if qualifierExpression identifies a type, + // and if not, then we check to see if it identifies a package. + Type t = attr.attribType(ref.qualifierExpression, env); + if (t.isErroneous()) { + if (ref.memberName == null) { + // Attr/Resolve assume packages exist and create symbols as needed + // so use getPackageElement to restrict search to existing packages + PackageSymbol pck = elements.getPackageElement(ref.qualifierExpression.toString()); + if (pck != null) { + return pck; + } else if (ref.qualifierExpression.hasTag(JCTree.Tag.IDENT)) { + // fixup: allow "identifier" instead of "#identifier" + // for compatibility with javadoc + tsym = env.enclClass.sym; + memberName = ((JCIdent) ref.qualifierExpression).name; + } else + return null; + } else { + return null; + } + } else { + tsym = (ClassSymbol) t.tsym; + memberName = ref.memberName; + } + } + + if (memberName == null) + return tsym; + + final List paramTypes; + if (ref.paramTypes == null) + paramTypes = null; + else { + ListBuffer lb = new ListBuffer(); + for (List l = ref.paramTypes; l.nonEmpty(); l = l.tail) { + JCTree tree = l.head; + Type t = attr.attribType(tree, env); + lb.add(t); + } + paramTypes = lb.toList(); + } + + Symbol msym = (memberName == tsym.name) + ? findConstructor(tsym, paramTypes) + : findMethod(tsym, memberName, paramTypes); + if (paramTypes != null) { + // explicit (possibly empty) arg list given, so cannot be a field + return msym; + } + + VarSymbol vsym = (ref.paramTypes != null) ? null : findField(tsym, memberName); + // prefer a field over a method with no parameters + if (vsym != null && + (msym == null || + types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) { + return vsym; + } else { + return msym; + } + } finally { + log.popDiagnosticHandler(deferredDiagnosticHandler); + } + } + + /** @see com.sun.tools.javadoc.ClassDocImpl#findField */ + private VarSymbol findField(ClassSymbol tsym, Name fieldName) { + return searchField(tsym, fieldName, new HashSet()); + } + + /** @see com.sun.tools.javadoc.ClassDocImpl#searchField */ + private VarSymbol searchField(ClassSymbol tsym, Name fieldName, Set searched) { + if (searched.contains(tsym)) { + return null; + } + searched.add(tsym); + + for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(fieldName); + e.scope != null; e = e.next()) { + if (e.sym.kind == Kinds.VAR) { + return (VarSymbol)e.sym; + } + } + + //### If we found a VarSymbol above, but which did not pass + //### the modifier filter, we should return failure here! + + ClassSymbol encl = tsym.owner.enclClass(); + if (encl != null) { + VarSymbol vsym = searchField(encl, fieldName, searched); + if (vsym != null) { + return vsym; + } + } + + // search superclass + Type superclass = tsym.getSuperclass(); + if (superclass.tsym != null) { + VarSymbol vsym = searchField((ClassSymbol) superclass.tsym, fieldName, searched); + if (vsym != null) { + return vsym; + } + } + + // search interfaces + List intfs = tsym.getInterfaces(); + for (List l = intfs; l.nonEmpty(); l = l.tail) { + Type intf = l.head; + if (intf.isErroneous()) continue; + VarSymbol vsym = searchField((ClassSymbol) intf.tsym, fieldName, searched); + if (vsym != null) { + return vsym; + } + } + + return null; + } + + /** @see com.sun.tools.javadoc.ClassDocImpl#findConstructor */ + MethodSymbol findConstructor(ClassSymbol tsym, List paramTypes) { + for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(names.init); + e.scope != null; e = e.next()) { + if (e.sym.kind == Kinds.MTH) { + if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) { + return (MethodSymbol) e.sym; + } + } + } + return null; + } + + /** @see com.sun.tools.javadoc.ClassDocImpl#findMethod */ + private MethodSymbol findMethod(ClassSymbol tsym, Name methodName, List paramTypes) { + return searchMethod(tsym, methodName, paramTypes, new HashSet()); + } + + /** @see com.sun.tools.javadoc.ClassDocImpl#searchMethod */ + private MethodSymbol searchMethod(ClassSymbol tsym, Name methodName, + List paramTypes, Set searched) { + //### Note that this search is not necessarily what the compiler would do! + + // do not match constructors + if (methodName == names.init) + return null; + + if (searched.contains(tsym)) + return null; + searched.add(tsym); + + // search current class + com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(methodName); + + //### Using modifier filter here isn't really correct, + //### but emulates the old behavior. Instead, we should + //### apply the normal rules of visibility and inheritance. + + if (paramTypes == null) { + // If no parameters specified, we are allowed to return + // any method with a matching name. In practice, the old + // code returned the first method, which is now the last! + // In order to provide textually identical results, we + // attempt to emulate the old behavior. + MethodSymbol lastFound = null; + for (; e.scope != null; e = e.next()) { + if (e.sym.kind == Kinds.MTH) { + if (e.sym.name == methodName) { + lastFound = (MethodSymbol)e.sym; + } + } + } + if (lastFound != null) { + return lastFound; + } + } else { + for (; e.scope != null; e = e.next()) { + if (e.sym != null && + e.sym.kind == Kinds.MTH) { + if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) { + return (MethodSymbol) e.sym; + } + } + } + } + + //### If we found a MethodSymbol above, but which did not pass + //### the modifier filter, we should return failure here! + + // search superclass + Type superclass = tsym.getSuperclass(); + if (superclass.tsym != null) { + MethodSymbol msym = searchMethod((ClassSymbol) superclass.tsym, methodName, paramTypes, searched); + if (msym != null) { + return msym; + } + } + + // search interfaces + List intfs = tsym.getInterfaces(); + for (List l = intfs; l.nonEmpty(); l = l.tail) { + Type intf = l.head; + if (intf.isErroneous()) continue; + MethodSymbol msym = searchMethod((ClassSymbol) intf.tsym, methodName, paramTypes, searched); + if (msym != null) { + return msym; + } + } + + // search enclosing class + ClassSymbol encl = tsym.owner.enclClass(); + if (encl != null) { + MethodSymbol msym = searchMethod(encl, methodName, paramTypes, searched); + if (msym != null) { + return msym; + } + } + + return null; + } + + /** @see com.sun.tools.javadoc.ClassDocImpl */ + private boolean hasParameterTypes(MethodSymbol method, List paramTypes) { + if (paramTypes == null) + return true; + + if (method.params().size() != paramTypes.size()) + return false; + + List methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); + + return (Type.isErroneous(paramTypes)) + ? fuzzyMatch(paramTypes, methodParamTypes) + : types.isSameTypes(paramTypes, methodParamTypes); + } + + boolean fuzzyMatch(List paramTypes, List methodParamTypes) { + List l1 = paramTypes; + List l2 = methodParamTypes; + while (l1.nonEmpty()) { + if (!fuzzyMatch(l1.head, l2.head)) + return false; + l1 = l1.tail; + l2 = l2.tail; + } + return true; + } + + boolean fuzzyMatch(Type paramType, Type methodParamType) { + Boolean b = fuzzyMatcher.visit(paramType, methodParamType); + return (b == Boolean.TRUE); + } + + TypeRelation fuzzyMatcher = new TypeRelation() { + @Override + public Boolean visitType(Type t, Type s) { + if (t == s) + return true; + + if (s.isPartial()) + return visit(s, t); + + switch (t.getTag()) { + case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT: + case DOUBLE: case BOOLEAN: case VOID: case BOT: case NONE: + return t.getTag() == s.getTag(); + + default: + throw new AssertionError("fuzzyMatcher " + t.getTag()); + } + } + + @Override + public Boolean visitArrayType(ArrayType t, Type s) { + if (t == s) + return true; + + if (s.isPartial()) + return visit(s, t); + + return s.getTag() == ARRAY + && visit(t.elemtype, types.elemtype(s)); + } + + @Override + public Boolean visitClassType(ClassType t, Type s) { + if (t == s) + return true; + + if (s.isPartial()) + return visit(s, t); + + return t.tsym == s.tsym; + } + + @Override + public Boolean visitErrorType(ErrorType t, Type s) { + return s.getTag() == CLASS + && t.tsym.name == ((ClassType) s).tsym.name; + } + }; + public TypeMirror getTypeMirror(TreePath path) { Tree t = path.getLeaf(); return ((JCTree)t).type; @@ -250,6 +593,18 @@ public class JavacTrees extends Trees { return null; } + public DocCommentTree getDocCommentTree(TreePath path) { + CompilationUnitTree t = path.getCompilationUnit(); + Tree leaf = path.getLeaf(); + if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) { + JCCompilationUnit cu = (JCCompilationUnit) t; + if (cu.docComments != null) { + return cu.docComments.getCommentTree((JCTree) leaf); + } + } + return null; + } + public boolean isAccessible(Scope scope, TypeElement type) { if (scope instanceof JavacScope && type instanceof ClassSymbol) { Env env = ((JavacScope) scope).env; @@ -418,14 +773,27 @@ public class JavacTrees extends Trees { public void printMessage(Diagnostic.Kind kind, CharSequence msg, com.sun.source.tree.Tree t, com.sun.source.tree.CompilationUnitTree root) { + printMessage(kind, msg, ((JCTree) t).pos(), root); + } + + public void printMessage(Diagnostic.Kind kind, CharSequence msg, + com.sun.source.doctree.DocTree t, + com.sun.source.doctree.DocCommentTree c, + com.sun.source.tree.CompilationUnitTree root) { + printMessage(kind, msg, ((DCTree) t).pos((DCDocComment) c), root); + } + + private void printMessage(Diagnostic.Kind kind, CharSequence msg, + JCDiagnostic.DiagnosticPosition pos, + com.sun.source.tree.CompilationUnitTree root) { JavaFileObject oldSource = null; JavaFileObject newSource = null; - JCDiagnostic.DiagnosticPosition pos = null; newSource = root.getSourceFile(); - if (newSource != null) { + if (newSource == null) { + pos = null; + } else { oldSource = log.useSource(newSource); - pos = ((JCTree) t).pos(); } try { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index c2695df6bdd..c3cc1f01806 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -616,13 +616,13 @@ public class Attr extends JCTree.Visitor { /** Derived visitor method: attribute an expression tree with * no constraints on the computed type. */ - Type attribExpr(JCTree tree, Env env) { + public Type attribExpr(JCTree tree, Env env) { return attribTree(tree, env, unknownExprInfo); } /** Derived visitor method: attribute a type tree. */ - Type attribType(JCTree tree, Env env) { + public Type attribType(JCTree tree, Env env) { Type result = attribType(tree, env, Type.noType); return result; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java b/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java index cbc79e223bd..2a43e8fdc54 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java @@ -109,6 +109,7 @@ public class AttrContext { pendingResolutionPhase.isVarargsRequired(); } + @Override public String toString() { return "AttrContext[" + scope.toString() + "]"; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Env.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Env.java index f61ed700e0b..c788055d15d 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Env.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Env.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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 @@ -122,6 +122,7 @@ public class Env implements Iterable> { return env1; } + @Override public String toString() { return "Env[" + info + (outer == null ? "" : ",outer=" + outer) + "]"; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index cbc5bccb9aa..e2242c3f2e9 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -1731,7 +1731,7 @@ public class Resolve { /** Find an unqualified identifier which matches a specified kind set. * @param env The current environment. - * @param name The indentifier's name. + * @param name The identifier's name. * @param kind Indicates the possible symbol kinds * (a subset of VAL, TYP, PCK). */ diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java new file mode 100644 index 00000000000..4d422058d08 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java @@ -0,0 +1,1288 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.javac.parser; + +import com.sun.tools.javac.util.Filter; +import java.text.BreakIterator; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Locale; +import java.util.Map; +import java.util.Queue; +import java.util.Set; + +import com.sun.source.doctree.AttributeTree.ValueKind; +import com.sun.tools.javac.parser.DocCommentParser.TagParser.Kind; +import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.parser.Tokens.TokenKind; +import com.sun.tools.javac.tree.DCTree; +import com.sun.tools.javac.tree.DCTree.DCAttribute; +import com.sun.tools.javac.tree.DCTree.DCDocComment; +import com.sun.tools.javac.tree.DCTree.DCEndElement; +import com.sun.tools.javac.tree.DCTree.DCErroneous; +import com.sun.tools.javac.tree.DCTree.DCIdentifier; +import com.sun.tools.javac.tree.DCTree.DCReference; +import com.sun.tools.javac.tree.DCTree.DCStartElement; +import com.sun.tools.javac.tree.DCTree.DCText; +import com.sun.tools.javac.tree.DocTreeMaker; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.util.DiagnosticSource; +import com.sun.tools.javac.util.JCDiagnostic; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Name; +import com.sun.tools.javac.util.Names; +import com.sun.tools.javac.util.Options; +import com.sun.tools.javac.util.Position; +import static com.sun.tools.javac.util.LayoutCharacters.*; + +/** + * + *

This is NOT part of any supported API. + * 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. + */ +public class DocCommentParser { + static class ParseException extends Exception { + private static final long serialVersionUID = 0; + ParseException(String key) { + super(key); + } + } + + final ParserFactory fac; + final DiagnosticSource diagSource; + final Comment comment; + final DocTreeMaker m; + final Names names; + + BreakIterator sentenceBreaker; + + /** The input buffer, index of most recent character read, + * index of one past last character in buffer. + */ + protected char[] buf; + protected int bp; + protected int buflen; + + /** The current character. + */ + protected char ch; + + int textStart = -1; + int lastNonWhite = -1; + boolean newline = true; + + Map tagParsers; + + DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { + this.fac = fac; + this.diagSource = diagSource; + this.comment = comment; + names = fac.names; + m = fac.docTreeMaker; + + Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; + + Options options = fac.options; + boolean useBreakIterator = options.isSet("breakIterator"); + if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) + sentenceBreaker = BreakIterator.getSentenceInstance(locale); + + initTagParsers(); + } + + DCDocComment parse() { + String c = comment.getText(); + buf = new char[c.length() + 1]; + c.getChars(0, c.length(), buf, 0); + buf[buf.length - 1] = EOI; + buflen = buf.length - 1; + bp = -1; + nextChar(); + + List body = blockContent(); + List tags = blockTags(); + + // split body into first sentence and body + ListBuffer fs = new ListBuffer(); + loop: + for (; body.nonEmpty(); body = body.tail) { + DCTree t = body.head; + switch (t.getKind()) { + case TEXT: + String s = ((DCText) t).getBody(); + int i = getSentenceBreak(s); + if (i > 0) { + int i0 = i; + while (i0 > 0 && isWhitespace(s.charAt(i0 - 1))) + i0--; + fs.add(m.at(t.pos).Text(s.substring(0, i0))); + int i1 = i; + while (i1 < s.length() && isWhitespace(s.charAt(i1))) + i1++; + body = body.tail; + if (i1 < s.length()) + body = body.prepend(m.at(t.pos + i1).Text(s.substring(i1))); + break loop; + } else if (body.tail.nonEmpty()) { + if (isSentenceBreak(body.tail.head)) { + int i0 = s.length() - 1; + while (i0 > 0 && isWhitespace(s.charAt(i0))) + i0--; + fs.add(m.at(t.pos).Text(s.substring(0, i0 + 1))); + body = body.tail; + break loop; + } + } + break; + + case START_ELEMENT: + case END_ELEMENT: + if (isSentenceBreak(t)) + break loop; + break; + } + fs.add(t); + } + + @SuppressWarnings("unchecked") + DCTree first = getFirst(fs.toList(), body, tags); + int pos = (first == null) ? Position.NOPOS : first.pos; + + DCDocComment dc = m.at(pos).DocComment(comment, fs.toList(), body, tags); + return dc; + } + + void nextChar() { + ch = buf[bp < buflen ? ++bp : buflen]; + switch (ch) { + case '\f': case '\n': case '\r': + newline = true; + } + } + + /** + * Read block content, consisting of text, html and inline tags. + * Terminated by the end of input, or the beginning of the next block tag: + * i.e. @ as the first non-whitespace character on a line. + */ + @SuppressWarnings("fallthrough") + protected List blockContent() { + ListBuffer trees = new ListBuffer(); + textStart = -1; + + loop: + while (bp < buflen) { + switch (ch) { + case '\n': case '\r': case '\f': + newline = true; + // fallthrough + + case ' ': case '\t': + nextChar(); + break; + + case '&': + entity(trees); + break; + + case '<': + newline = false; + addPendingText(trees, bp - 1); + trees.add(html()); + if (textStart == -1) { + textStart = bp; + lastNonWhite = -1; + } + break; + + case '>': + newline = false; + addPendingText(trees, bp - 1); + trees.add(m.at(bp).Erroneous(newString(bp, bp+1), diagSource, "dc.bad.gt")); + nextChar(); + if (textStart == -1) { + textStart = bp; + lastNonWhite = -1; + } + break; + + case '{': + inlineTag(trees); + break; + + case '@': + if (newline) { + addPendingText(trees, lastNonWhite); + break loop; + } + // fallthrough + + default: + newline = false; + if (textStart == -1) + textStart = bp; + lastNonWhite = bp; + nextChar(); + } + } + + if (lastNonWhite != -1) + addPendingText(trees, lastNonWhite); + + return trees.toList(); + } + + /** + * Read a series of block tags, including their content. + * Standard tags parse their content appropriately. + * Non-standard tags are represented by {@link UnknownBlockTag}. + */ + protected List blockTags() { + ListBuffer tags = new ListBuffer(); + while (ch == '@') + tags.add(blockTag()); + return tags.toList(); + } + + /** + * Read a single block tag, including its content. + * Standard tags parse their content appropriately. + * Non-standard tags are represented by {@link UnknownBlockTag}. + */ + protected DCTree blockTag() { + int p = bp; + try { + nextChar(); + if (isIdentifierStart(ch)) { + int namePos = bp; + nextChar(); + while (isIdentifierPart(ch)) + nextChar(); + int nameLen = bp - namePos; + + Name name = names.fromChars(buf, namePos, nameLen); + TagParser tp = tagParsers.get(name); + if (tp == null) { + List content = blockContent(); + return m.at(p).UnknownBlockTag(name, content); + } else { + switch (tp.getKind()) { + case BLOCK: + return tp.parse(p); + case INLINE: + return erroneous("dc.bad.inline.tag", p); + } + } + } + blockContent(); + + return erroneous("dc.no.tag.name", p); + } catch (ParseException e) { + blockContent(); + return erroneous(e.getMessage(), p); + } + } + + protected void inlineTag(ListBuffer list) { + newline = false; + nextChar(); + if (ch == '@') { + addPendingText(list, bp - 2); + list.add(inlineTag()); + textStart = bp; + lastNonWhite = -1; + } else { + if (textStart == -1) + textStart = bp - 1; + lastNonWhite = bp; + } + } + + /** + * Read a single inline tag, including its content. + * Standard tags parse their content appropriately. + * Non-standard tags are represented by {@link UnknownBlockTag}. + * Malformed tags may be returned as {@link Erroneous}. + */ + protected DCTree inlineTag() { + int p = bp - 1; + try { + nextChar(); + if (isIdentifierStart(ch)) { + int namePos = bp; + nextChar(); + while (isIdentifierPart(ch)) + nextChar(); + int nameLen = bp - namePos; + skipWhitespace(); + + Name name = names.fromChars(buf, namePos, nameLen); + TagParser tp = tagParsers.get(name); + if (tp == null) { + DCTree text = inlineText(); + if (text != null) { + nextChar(); + return m.at(p).UnknownInlineTag(name, List.of(text)); + } + } else if (tp.getKind() == TagParser.Kind.INLINE) { + DCTree tree = tp.parse(p); + if (tree != null) { + return tree; + } + } else { + inlineText(); // skip content + nextChar(); + } + } + return erroneous("dc.no.tag.name", p); + } catch (ParseException e) { + return erroneous(e.getMessage(), p); + } + } + + /** + * Read plain text content of an inline tag. + * Matching pairs of { } are skipped; the text is terminated by the first + * unmatched }. It is an error if the beginning of the next tag is detected. + */ + protected DCTree inlineText() throws ParseException { + skipWhitespace(); + int pos = bp; + int depth = 1; + + loop: + while (bp < buflen) { + switch (ch) { + case '\n': case '\r': case '\f': + newline = true; + break; + + case ' ': case '\t': + break; + + case '{': + newline = false; + lastNonWhite = bp; + depth++; + break; + + case '}': + if (--depth == 0) { + return m.at(pos).Text(newString(pos, bp)); + } + newline = false; + lastNonWhite = bp; + break; + + case '@': + if (newline) + break loop; + newline = false; + lastNonWhite = bp; + break; + + default: + newline = false; + lastNonWhite = bp; + break; + } + nextChar(); + } + throw new ParseException("dc.unterminated.inline.tag"); + } + + /** + * Read Java class name, possibly followed by member + * Matching pairs of < > are skipped. The text is terminated by the first + * unmatched }. It is an error if the beginning of the next tag is detected. + */ + // TODO: boolean allowMember should be enum FORBID, ALLOW, REQUIRE + // TODO: improve quality of parse to forbid bad constructions. + @SuppressWarnings("fallthrough") + protected DCReference reference(boolean allowMember) throws ParseException { + int pos = bp; + int depth = 0; + + // scan to find the end of the signature, by looking for the first + // whitespace not enclosed in () or <>, or the end of the tag + loop: + while (bp < buflen) { + switch (ch) { + case '\n': case '\r': case '\f': + newline = true; + // fallthrough + + case ' ': case '\t': + if (depth == 0) + break loop; + break; + + case '(': + case '<': + newline = false; + depth++; + break; + + case ')': + case '>': + newline = false; + --depth; + break; + + case '}': + if (bp == pos) + return null; + newline = false; + break loop; + + case '@': + if (newline) + break loop; + // fallthrough + + default: + newline = false; + + } + nextChar(); + } + + if (depth != 0) + throw new ParseException("dc.unterminated.signature"); + + String sig = newString(pos, bp); + + // Break sig apart into qualifiedExpr member paramTypes. + JCTree qualExpr; + Name member; + List paramTypes; + + Log.DeferredDiagnosticHandler deferredDiagnosticHandler + = new Log.DeferredDiagnosticHandler(fac.log); + + try { + int hash = sig.indexOf("#"); + int lparen = sig.indexOf("(", hash + 1); + if (hash == -1) { + if (lparen == -1) { + qualExpr = parseType(sig); + member = null; + } else { + qualExpr = null; + member = parseMember(sig.substring(0, lparen)); + } + } else { + qualExpr = (hash == 0) ? null : parseType(sig.substring(0, hash)); + if (lparen == -1) + member = parseMember(sig.substring(hash + 1)); + else + member = parseMember(sig.substring(hash + 1, lparen)); + } + + if (lparen < 0) { + paramTypes = null; + } else { + int rparen = sig.indexOf(")", lparen); + if (rparen != sig.length() - 1) + throw new ParseException("dc.ref.bad.parens"); + paramTypes = parseParams(sig.substring(lparen + 1, rparen)); + } + + if (!deferredDiagnosticHandler.getDiagnostics().isEmpty()) + throw new ParseException("dc.ref.syntax.error"); + + } finally { + fac.log.popDiagnosticHandler(deferredDiagnosticHandler); + } + + return m.at(pos).Reference(sig, qualExpr, member, paramTypes); + } + + JCTree parseType(String s) throws ParseException { + JavacParser p = fac.newParser(s, false, false, false); + JCTree tree = p.parseType(); + if (p.token().kind != TokenKind.EOF) + throw new ParseException("dc.ref.unexpected.input"); + return tree; + } + + Name parseMember(String s) throws ParseException { + JavacParser p = fac.newParser(s, false, false, false); + Name name = p.ident(); + if (p.token().kind != TokenKind.EOF) + throw new ParseException("dc.ref.unexpected.input"); + return name; + } + + List parseParams(String s) throws ParseException { + if (s.trim().isEmpty()) + return List.nil(); + + JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); + ListBuffer paramTypes = new ListBuffer(); + paramTypes.add(p.parseType()); + + if (p.token().kind == TokenKind.IDENTIFIER) + p.nextToken(); + + while (p.token().kind == TokenKind.COMMA) { + p.nextToken(); + paramTypes.add(p.parseType()); + + if (p.token().kind == TokenKind.IDENTIFIER) + p.nextToken(); + } + + if (p.token().kind != TokenKind.EOF) + throw new ParseException("dc.ref.unexpected.input"); + + return paramTypes.toList(); + } + + /** + * Read Java identifier + * Matching pairs of { } are skipped; the text is terminated by the first + * unmatched }. It is an error if the beginning of the next tag is detected. + */ + @SuppressWarnings("fallthrough") + protected DCIdentifier identifier() throws ParseException { + skipWhitespace(); + int pos = bp; + + if (isJavaIdentifierStart(ch)) { + nextChar(); + while (isJavaIdentifierPart(ch)) + nextChar(); + return m.at(pos).Identifier(names.fromChars(buf, pos, bp - pos)); + } + + throw new ParseException("dc.identifier.expected"); + } + + /** + * Read a quoted string. + * It is an error if the beginning of the next tag is detected. + */ + @SuppressWarnings("fallthrough") + protected DCText quotedString() { + int pos = bp; + nextChar(); + + loop: + while (bp < buflen) { + switch (ch) { + case '\n': case '\r': case '\f': + newline = true; + break; + + case ' ': case '\t': + break; + + case '"': + nextChar(); + // trim trailing white-space? + return m.at(pos).Text(newString(pos, bp)); + + case '@': + if (newline) + break loop; + + } + nextChar(); + } + return null; + } + + /** + * Read general text content of an inline tag, including HTML entities and elements. + * Matching pairs of { } are skipped; the text is terminated by the first + * unmatched }. It is an error if the beginning of the next tag is detected. + */ + @SuppressWarnings("fallthrough") + protected List inlineContent() { + ListBuffer trees = new ListBuffer(); + + skipWhitespace(); + int pos = bp; + int depth = 1; + textStart = -1; + + loop: + while (bp < buflen) { + + switch (ch) { + case '\n': case '\r': case '\f': + newline = true; + // fall through + + case ' ': case '\t': + nextChar(); + break; + + case '&': + entity(trees); + break; + + case '<': + newline = false; + addPendingText(trees, bp - 1); + trees.add(html()); + break; + + case '{': + newline = false; + depth++; + nextChar(); + break; + + case '}': + newline = false; + if (--depth == 0) { + addPendingText(trees, bp - 1); + nextChar(); + return trees.toList(); + } + nextChar(); + break; + + case '@': + if (newline) + break loop; + // fallthrough + + default: + if (textStart == -1) + textStart = bp; + nextChar(); + break; + } + } + + return List.of(erroneous("dc.unterminated.inline.tag", pos)); + } + + protected void entity(ListBuffer list) { + newline = false; + addPendingText(list, bp - 1); + list.add(entity()); + if (textStart == -1) { + textStart = bp; + lastNonWhite = -1; + } + } + + /** + * Read an HTML entity. + * {@literal &identifier; } or {@literal &#digits; } or {@literal &#xhex-digits; } + */ + protected DCTree entity() { + int p = bp; + nextChar(); + int namep = bp; + boolean checkSemi = false; + if (ch == '#') { + nextChar(); + if (isDecimalDigit(ch)) { + nextChar(); + while (isDecimalDigit(ch)) + nextChar(); + checkSemi = true; + } else if (ch == 'x' || ch == 'X') { + nextChar(); + if (isHexDigit(ch)) { + nextChar(); + while (isHexDigit(ch)) + nextChar(); + checkSemi = true; + } + } + } else if (isIdentifierStart(ch)) { + nextChar(); + while (isIdentifierPart(ch)) + nextChar(); + checkSemi = true; + } + + if (checkSemi && ch == ';') { + nextChar(); + return m.at(p).Entity(names.fromChars(buf, namep, bp - namep - 1)); + } else { + String code = checkSemi ? "dc.missing.semicolon" : "dc.bad.entity"; + return erroneous(code, p); + } + } + + /** + * Read the start or end of an HTML tag, or an HTML comment + * {@literal } or {@literal } + */ + protected DCTree html() { + int p = bp; + nextChar(); + if (isIdentifierStart(ch)) { + int namePos = bp; + nextChar(); + while (isIdentifierPart(ch)) + nextChar(); + int nameLen = bp - namePos; + List attrs = htmlAttrs(); + if (attrs != null) { + boolean selfClosing = false; + if (ch == '/') { + nextChar(); + selfClosing = true; + } + if (ch == '>') { + nextChar(); + Name name = names.fromChars(buf, namePos, nameLen); + return m.at(p).StartElement(name, attrs, selfClosing); + } + } + } else if (ch == '/') { + nextChar(); + if (isIdentifierStart(ch)) { + int namePos = bp; + nextChar(); + while (isIdentifierPart(ch)) + nextChar(); + int nameLen = bp - namePos; + skipWhitespace(); + if (ch == '>') { + nextChar(); + Name name = names.fromChars(buf, namePos, nameLen); + return m.at(p).EndElement(name); + } + } + } else if (ch == '!') { + nextChar(); + if (ch == '-') { + nextChar(); + if (ch == '-') { + nextChar(); + while (bp < buflen) { + int dash = 0; + while (ch == '-') { + dash++; + nextChar(); + } + // strictly speaking, a comment should not contain "--" + // so dash > 2 is an error, dash == 2 implies ch == '>' + if (dash >= 2 && ch == '>') { + nextChar(); + return m.at(p).Comment(newString(p, bp)); + } + + nextChar(); + } + } + } + } + + bp = p + 1; + ch = buf[bp]; + return erroneous("dc.malformed.html", p); + } + + /** + * Read a series of HTML attributes, terminated by {@literal > }. + * Each attribute is of the form {@literal identifier[=value] }. + * "value" may be unquoted, single-quoted, or double-quoted. + */ + protected List htmlAttrs() { + ListBuffer attrs = new ListBuffer(); + skipWhitespace(); + + loop: + while (isIdentifierStart(ch)) { + int namePos = bp; + nextChar(); + while (isIdentifierPart(ch)) + nextChar(); + int nameLen = bp - namePos; + skipWhitespace(); + List value = null; + ValueKind vkind = ValueKind.EMPTY; + if (ch == '=') { + ListBuffer v = new ListBuffer(); + nextChar(); + skipWhitespace(); + if (ch == '\'' || ch == '"') { + vkind = (ch == '\'') ? ValueKind.SINGLE : ValueKind.DOUBLE; + char quote = ch; + nextChar(); + textStart = bp; + while (bp < buflen && ch != quote) { + if (newline && ch == '@') { + attrs.add(erroneous("dc.unterminated.string", namePos)); + // No point trying to read more. + // In fact, all attrs get discarded by the caller + // and superseded by a malformed.html node because + // the html tag itself is not terminated correctly. + break loop; + } + attrValueChar(v); + } + addPendingText(v, bp - 1); + nextChar(); + } else { + vkind = ValueKind.UNQUOTED; + textStart = bp; + while (bp < buflen && !isUnquotedAttrValueTerminator(ch)) { + attrValueChar(v); + } + addPendingText(v, bp - 1); + } + skipWhitespace(); + value = v.toList(); + } + Name name = names.fromChars(buf, namePos, nameLen); + DCAttribute attr = m.at(namePos).Attribute(name, vkind, value); + attrs.add(attr); + } + + return attrs.toList(); + } + + protected void attrValueChar(ListBuffer list) { + switch (ch) { + case '&': + entity(list); + break; + + case '{': + inlineTag(list); + break; + + default: + nextChar(); + } + } + + protected void addPendingText(ListBuffer list, int textEnd) { + if (textStart != -1 && textStart <= textEnd) { + list.add(m.at(textStart).Text(newString(textStart, textEnd + 1))); + textStart = -1; + } + } + + protected DCErroneous erroneous(String code, int pos) { + int i = bp - 1; + loop: + while (i > 0) { + switch (buf[i]) { + case '\f': case '\n': case '\r': + newline = true; + break; + case '\t': case ' ': + break; + default: + break loop; + } + i--; + } + textStart = -1; + return m.at(pos).Erroneous(newString(pos, i + 1), diagSource, code); + } + + @SuppressWarnings("unchecked") + T getFirst(List... lists) { + for (List list: lists) { + if (list.nonEmpty()) + return list.head; + } + return null; + } + + protected boolean isIdentifierStart(char ch) { + return Character.isUnicodeIdentifierStart(ch); + } + + protected boolean isIdentifierPart(char ch) { + return Character.isUnicodeIdentifierPart(ch); + } + + protected boolean isJavaIdentifierStart(char ch) { + return Character.isJavaIdentifierStart(ch); + } + + protected boolean isJavaIdentifierPart(char ch) { + return Character.isJavaIdentifierPart(ch); + } + + protected boolean isDecimalDigit(char ch) { + return ('0' <= ch && ch <= '9'); + } + + protected boolean isHexDigit(char ch) { + return ('0' <= ch && ch <= '9') + || ('a' <= ch && ch <= 'f') + || ('A' <= ch && ch <= 'F'); + } + + protected boolean isUnquotedAttrValueTerminator(char ch) { + switch (ch) { + case '\f': case '\n': case '\r': case '\t': + case ' ': + case '"': case '\'': case '`': + case '=': case '<': case '>': + return true; + default: + return false; + } + } + + protected boolean isWhitespace(char ch) { + return Character.isWhitespace(ch); + } + + protected void skipWhitespace() { + while (isWhitespace(ch)) + nextChar(); + } + + protected int getSentenceBreak(String s) { + if (sentenceBreaker != null) { + sentenceBreaker.setText(s); + int i = sentenceBreaker.next(); + return (i == s.length()) ? -1 : i; + } + + // scan for period followed by whitespace + boolean period = false; + for (int i = 0; i < s.length(); i++) { + switch (s.charAt(i)) { + case '.': + period = true; + break; + + case ' ': + case '\f': + case '\n': + case '\r': + case '\t': + if (period) + return i; + break; + + default: + period = false; + break; + } + } + return -1; + } + + + Set htmlBlockTags = new HashSet(Arrays.asList( + "h1", "h2", "h3", "h4", "h5", "h6", "p", "pre")); + + protected boolean isSentenceBreak(Name n) { + return htmlBlockTags.contains(n.toString().toLowerCase()); + } + + protected boolean isSentenceBreak(DCTree t) { + switch (t.getKind()) { + case START_ELEMENT: + return isSentenceBreak(((DCStartElement) t).getName()); + + case END_ELEMENT: + return isSentenceBreak(((DCEndElement) t).getName()); + } + return false; + } + + /** + * @param start position of first character of string + * @param end position of character beyond last character to be included + */ + String newString(int start, int end) { + return new String(buf, start, end - start); + } + + static abstract class TagParser { + enum Kind { INLINE, BLOCK } + + Kind kind; + DCTree.Kind treeKind; + + TagParser(Kind k, DCTree.Kind tk) { + kind = k; + treeKind = tk; + } + + Kind getKind() { + return kind; + } + + DCTree.Kind getTreeKind() { + return treeKind; + } + + abstract DCTree parse(int pos) throws ParseException; + } + + /** + * @see Javadoc Tags + */ + private void initTagParsers() { + TagParser[] parsers = { + // @author name-text + new TagParser(Kind.BLOCK, DCTree.Kind.AUTHOR) { + public DCTree parse(int pos) { + List name = blockContent(); + return m.at(pos).Author(name); + } + }, + + // {@code text} + new TagParser(Kind.INLINE, DCTree.Kind.CODE) { + public DCTree parse(int pos) throws ParseException { + DCTree text = inlineText(); + nextChar(); + return m.at(pos).Code((DCText) text); + } + }, + + // @deprecated deprecated-text + new TagParser(Kind.BLOCK, DCTree.Kind.DEPRECATED) { + public DCTree parse(int pos) { + List reason = blockContent(); + return m.at(pos).Deprecated(reason); + } + }, + + // {@docRoot} + new TagParser(Kind.INLINE, DCTree.Kind.DOC_ROOT) { + public DCTree parse(int pos) throws ParseException { + if (ch == '}') { + nextChar(); + return m.at(pos).DocRoot(); + } + inlineText(); // skip unexpected content + nextChar(); + throw new ParseException("dc.unexpected.content"); + } + }, + + // @exception class-name description + new TagParser(Kind.BLOCK, DCTree.Kind.EXCEPTION) { + public DCTree parse(int pos) throws ParseException { + skipWhitespace(); + DCReference ref = reference(false); + List description = blockContent(); + return m.at(pos).Exception(ref, description); + } + }, + + // {@inheritDoc} + new TagParser(Kind.INLINE, DCTree.Kind.INHERIT_DOC) { + public DCTree parse(int pos) throws ParseException { + if (ch == '}') { + nextChar(); + return m.at(pos).InheritDoc(); + } + inlineText(); // skip unexpected content + nextChar(); + throw new ParseException("dc.unexpected.content"); + } + }, + + // {@link package.class#member label} + new TagParser(Kind.INLINE, DCTree.Kind.LINK) { + public DCTree parse(int pos) throws ParseException { + DCReference ref = reference(true); + List label = inlineContent(); + return m.at(pos).Link(ref, label); + } + }, + + // {@linkplain package.class#member label} + new TagParser(Kind.INLINE, DCTree.Kind.LINK_PLAIN) { + public DCTree parse(int pos) throws ParseException { + DCReference ref = reference(true); + List label = inlineContent(); + return m.at(pos).LinkPlain(ref, label); + } + }, + + // {@literal text} + new TagParser(Kind.INLINE, DCTree.Kind.LITERAL) { + public DCTree parse(int pos) throws ParseException { + DCTree text = inlineText(); + nextChar(); + return m.at(pos).Literal((DCText) text); + } + }, + + // @param parameter-name description + new TagParser(Kind.BLOCK, DCTree.Kind.PARAM) { + public DCTree parse(int pos) throws ParseException { + skipWhitespace(); + + boolean typaram = false; + if (ch == '<') { + typaram = true; + nextChar(); + } + + DCIdentifier id = identifier(); + + if (typaram) { + if (ch != '>') + throw new ParseException("dc.gt.expected"); + nextChar(); + } + + skipWhitespace(); + List desc = blockContent(); + return m.at(pos).Param(typaram, id, desc); + } + }, + + // @return description + new TagParser(Kind.BLOCK, DCTree.Kind.RETURN) { + public DCTree parse(int pos) { + List description = blockContent(); + return m.at(pos).Return(description); + } + }, + + // @see reference | quoted-string | HTML + new TagParser(Kind.BLOCK, DCTree.Kind.SEE) { + public DCTree parse(int pos) throws ParseException { + skipWhitespace(); + switch (ch) { + case '"': + DCText string = quotedString(); + if (string != null) { + skipWhitespace(); + if (ch == '@') + return m.at(pos).See(List.of(string)); + } + break; + + case '<': + List html = blockContent(); + if (html != null) + return m.at(pos).See(html); + break; + + default: + if (isJavaIdentifierStart(ch) || ch == '#') { + DCReference ref = reference(true); + List description = blockContent(); + return m.at(pos).See(description.prepend(ref)); + } + } + throw new ParseException("dc.unexpected.content"); + } + }, + + // @serialData data-description + new TagParser(Kind.BLOCK, DCTree.Kind.SERIAL_DATA) { + public DCTree parse(int pos) { + List description = blockContent(); + return m.at(pos).SerialData(description); + } + }, + + // @serialField field-name field-type description + new TagParser(Kind.BLOCK, DCTree.Kind.SERIAL_FIELD) { + public DCTree parse(int pos) throws ParseException { + skipWhitespace(); + DCIdentifier name = identifier(); + skipWhitespace(); + DCReference type = reference(false); + List description = null; + if (isWhitespace(ch)) { + skipWhitespace(); + description = blockContent(); + } + return m.at(pos).SerialField(name, type, description); + } + }, + + // @serial field-description | include | exclude + new TagParser(Kind.BLOCK, DCTree.Kind.SERIAL) { + public DCTree parse(int pos) { + List description = blockContent(); + return m.at(pos).Serial(description); + } + }, + + // @since since-text + new TagParser(Kind.BLOCK, DCTree.Kind.SINCE) { + public DCTree parse(int pos) { + List description = blockContent(); + return m.at(pos).Since(description); + } + }, + + // @throws class-name description + new TagParser(Kind.BLOCK, DCTree.Kind.THROWS) { + public DCTree parse(int pos) throws ParseException { + skipWhitespace(); + DCReference ref = reference(false); + List description = blockContent(); + return m.at(pos).Throws(ref, description); + } + }, + + // {@value package.class#field} + new TagParser(Kind.INLINE, DCTree.Kind.VALUE) { + public DCTree parse(int pos) throws ParseException { + DCReference ref = reference(true); + skipWhitespace(); + if (ch == '}') { + nextChar(); + return m.at(pos).Value(ref); + } + nextChar(); + throw new ParseException("dc.unexpected.content"); + } + }, + + // @version version-text + new TagParser(Kind.BLOCK, DCTree.Kind.VERSION) { + public DCTree parse(int pos) { + List description = blockContent(); + return m.at(pos).Version(description); + } + }, + }; + + tagParsers = new HashMap(); + for (TagParser p: parsers) + tagParsers.put(names.fromString(p.getTreeKind().tagName), p); + + } +} diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index 5f491e0e7e0..bfa1433304b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -47,8 +47,8 @@ import static com.sun.tools.javac.parser.Tokens.TokenKind.EQ; import static com.sun.tools.javac.parser.Tokens.TokenKind.GT; import static com.sun.tools.javac.parser.Tokens.TokenKind.IMPORT; import static com.sun.tools.javac.parser.Tokens.TokenKind.LT; -import static com.sun.tools.javac.util.ListBuffer.lb; import static com.sun.tools.javac.tree.JCTree.Tag.*; +import static com.sun.tools.javac.util.ListBuffer.lb; /** The parser maps a token sequence into an abstract syntax * tree. It operates by recursive descent, with code derived @@ -128,7 +128,7 @@ public class JavacParser implements Parser { this.allowDefaultMethods = source.allowDefaultMethods() && fac.options.isSet("allowDefaultMethods"); //pre-lambda guard this.keepDocComments = keepDocComments; - docComments = newDocCommentTable(keepDocComments); + docComments = newDocCommentTable(keepDocComments, fac); this.keepLineMap = keepLineMap; this.errorTree = F.Erroneous(); endPosTable = newEndPosTable(keepEndPositions); @@ -140,8 +140,8 @@ public class JavacParser implements Parser { : new EmptyEndPosTable(); } - protected DocCommentTable newDocCommentTable(boolean keepDocComments) { - return keepDocComments ? new SimpleDocCommentTable() : null; + protected DocCommentTable newDocCommentTable(boolean keepDocComments, ParserFactory fac) { + return keepDocComments ? new LazyDocCommentTable(fac) : null; } /** Switch: Should generics be recognized? @@ -232,7 +232,11 @@ public class JavacParser implements Parser { protected Token token; - protected void nextToken() { + public Token token() { + return token; + } + + public void nextToken() { S.nextToken(); token = S.token(); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java index 86fb786b260..d52a62ef704 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java @@ -234,10 +234,12 @@ public class JavadocTokenizer extends JavaTokenizer { // If we find an exact match for pos, the other item in the pair // gives the source pos; otherwise, compute the source position // relative to the best match found in the array. + if (pos == Position.NOPOS) + return Position.NOPOS; if (pos < 0 || pos >= docComment.length()) - throw new StringIndexOutOfBoundsException(); + throw new StringIndexOutOfBoundsException(String.valueOf(pos)); if (docPosns == null) - return -1; + return Position.NOPOS; int start = 0; int end = docPosns.length; while (start < end - 2) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/SimpleDocCommentTable.java b/langtools/src/share/classes/com/sun/tools/javac/parser/LazyDocCommentTable.java similarity index 67% rename from langtools/src/share/classes/com/sun/tools/javac/parser/SimpleDocCommentTable.java rename to langtools/src/share/classes/com/sun/tools/javac/parser/LazyDocCommentTable.java index 3f6019ee906..fded5459319 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/SimpleDocCommentTable.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/LazyDocCommentTable.java @@ -29,8 +29,10 @@ import java.util.HashMap; import java.util.Map; import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.tree.DCTree.DCDocComment; import com.sun.tools.javac.tree.DocCommentTable; import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.util.DiagnosticSource; /** @@ -40,11 +42,24 @@ import com.sun.tools.javac.tree.JCTree; * This code and its internal interfaces are subject to change or * deletion without notice. */ -public class SimpleDocCommentTable implements DocCommentTable { - Map table; +public class LazyDocCommentTable implements DocCommentTable { + private static class Entry { + final Comment comment; + DCDocComment tree; - SimpleDocCommentTable() { - table = new HashMap(); + Entry(Comment c) { + comment = c; + } + } + + ParserFactory fac; + DiagnosticSource diagSource; + Map table; + + LazyDocCommentTable(ParserFactory fac) { + this.fac = fac; + diagSource = fac.log.currentSource(); + table = new HashMap(); } public boolean hasComment(JCTree tree) { @@ -52,7 +67,8 @@ public class SimpleDocCommentTable implements DocCommentTable { } public Comment getComment(JCTree tree) { - return table.get(tree); + Entry e = table.get(tree); + return (e == null) ? null : e.comment; } public String getCommentText(JCTree tree) { @@ -60,8 +76,17 @@ public class SimpleDocCommentTable implements DocCommentTable { return (c == null) ? null : c.getText(); } + public DCDocComment getCommentTree(JCTree tree) { + Entry e = table.get(tree); + if (e == null) + return null; + if (e.tree == null) + e.tree = new DocCommentParser(fac, diagSource, e.comment).parse(); + return e.tree; + } + public void putComment(JCTree tree, Comment c) { - table.put(tree, c); + table.put(tree, new Entry(c)); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java b/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java index aa50922b054..d72de9d6c9e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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 @@ -25,7 +25,10 @@ package com.sun.tools.javac.parser; +import java.util.Locale; + import com.sun.tools.javac.code.Source; +import com.sun.tools.javac.tree.DocTreeMaker; import com.sun.tools.javac.tree.TreeMaker; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Log; @@ -54,26 +57,30 @@ public class ParserFactory { } final TreeMaker F; + final DocTreeMaker docTreeMaker; final Log log; final Tokens tokens; final Source source; final Names names; final Options options; final ScannerFactory scannerFactory; + final Locale locale; protected ParserFactory(Context context) { super(); context.put(parserFactoryKey, this); this.F = TreeMaker.instance(context); + this.docTreeMaker = DocTreeMaker.instance(context); this.log = Log.instance(context); this.names = Names.instance(context); this.tokens = Tokens.instance(context); this.source = Source.instance(context); this.options = Options.instance(context); this.scannerFactory = ScannerFactory.instance(context); + this.locale = context.get(Locale.class); } - public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) { + public JavacParser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) { Lexer lexer = scannerFactory.newScanner(input, keepDocComments); return new JavacParser(this, lexer, keepDocComments, keepLineMap, keepEndPos); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index a9b3d1a2680..e742ce983ec 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -2336,4 +2336,52 @@ compiler.misc.where.description.typevar.1=\ compiler.misc.where.description.intersection.1=\ where {0} are intersection types: +### +# errors related to doc comments + +compiler.err.dc.bad.entity=\ + bad HTML entity + +compiler.err.dc.bad.gt=\ + bad use of ''>'' + +compiler.err.dc.bad.inline.tag=\ + incorrect use of inline tag + +compiler.err.dc.identifier.expected=\ + identifier expected + +compiler.err.dc.malformed.html=\ + malformed HTML + +compiler.err.dc.missing.semicolon=\ + semicolon missing + +compiler.err.dc.no.tag.name=\ + no tag name after '@' + +compiler.err.dc.gt.expected=\ + ''>'' expected + +compiler.err.dc.ref.bad.parens=\ + '')'' missing in reference + +compiler.err.dc.ref.syntax.error=\ + syntax error in reference + +compiler.err.dc.ref.unexpected.input=\ + unexpected text + +compiler.err.dc.unexpected.content=\ + unexpected content + +compiler.err.dc.unterminated.inline.tag=\ + unterminated inline tag + +compiler.err.dc.unterminated.signature=\ + unterminated signature + +compiler.err.dc.unterminated.string=\ + unterminated string + diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/DCTree.java b/langtools/src/share/classes/com/sun/tools/javac/tree/DCTree.java new file mode 100644 index 00000000000..81ac170c918 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/DCTree.java @@ -0,0 +1,848 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.javac.tree; + + +import javax.tools.Diagnostic; + +import com.sun.source.doctree.*; +import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.util.Assert; +import com.sun.tools.javac.util.DiagnosticSource; +import com.sun.tools.javac.util.JCDiagnostic; +import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.Name; +import javax.tools.JavaFileObject; + +/** + *

This is NOT part of any supported API. + * 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. + */ +public abstract class DCTree implements DocTree { + + /** + * The position in the comment string. + * Use {@link #getSourcePosition getSourcePosition} to convert + * it to a position in the source file. + * + * TODO: why not simply translate all these values into + * source file positions? Is it useful to have string-offset + * positions as well? + */ + public int pos; + + public long getSourcePosition(DCDocComment dc) { + return dc.comment.getSourcePos(pos); + } + + public JCDiagnostic.DiagnosticPosition pos(DCDocComment dc) { + return new SimpleDiagnosticPosition(dc.comment.getSourcePos(pos)); + } + + public static class DCDocComment extends DCTree implements DocCommentTree { + final Comment comment; // required for the implicit source pos table + + public final List firstSentence; + public final List body; + public final List tags; + + public DCDocComment(Comment comment, + List firstSentence, List body, List tags) { + this.comment = comment; + this.firstSentence = firstSentence; + this.body = body; + this.tags = tags; + } + + public Kind getKind() { + return Kind.DOC_COMMENT; + } + + public R accept(DocTreeVisitor v, D d) { + return v.visitDocComment(this, d); + } + + public List getFirstSentence() { + return firstSentence; + } + + public List getBody() { + return body; + } + + public List getBlockTags() { + return tags; + } + + } + + public static abstract class DCBlockTag extends DCTree implements InlineTagTree { + public String getTagName() { + return getKind().tagName; + } + } + + public static abstract class DCInlineTag extends DCTree implements InlineTagTree { + public String getTagName() { + return getKind().tagName; + } + } + + public static class DCAttribute extends DCTree implements AttributeTree { + public final Name name; + public final ValueKind vkind; + public final List value; + + DCAttribute(Name name, ValueKind vkind, List value) { + Assert.check((vkind == ValueKind.EMPTY) ? (value == null) : (value != null)); + this.name = name; + this.vkind = vkind; + this.value = value; + } + + @Override + public Kind getKind() { + return Kind.ATTRIBUTE; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitAttribute(this, d); + } + + @Override + public Name getName() { + return name; + } + + @Override + public ValueKind getValueKind() { + return vkind; + } + + @Override + public List getValue() { + return value; + } + } + + public static class DCAuthor extends DCInlineTag implements AuthorTree { + public final List name; + + DCAuthor(List name) { + this.name = name; + } + + @Override + public Kind getKind() { + return Kind.AUTHOR; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitAuthor(this, d); + } + + @Override + public List getName() { + return name; + } + } + + public static class DCComment extends DCTree implements CommentTree { + public final String body; + + DCComment(String body) { + this.body = body; + } + + @Override + public Kind getKind() { + return Kind.COMMENT; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitComment(this, d); + } + + @Override + public String getBody() { + return body; + } + } + + public static class DCDeprecated extends DCBlockTag implements DeprecatedTree { + public final List body; + + DCDeprecated(List body) { + this.body = body; + } + + @Override + public Kind getKind() { + return Kind.DEPRECATED; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitDeprecated(this, d); + } + + @Override + public List getBody() { + return body; + } + } + + public static class DCDocRoot extends DCInlineTag implements DocRootTree { + + @Override + public Kind getKind() { + return Kind.DOC_ROOT; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitDocRoot(this, d); + } + } + + public static class DCEndElement extends DCTree implements EndElementTree { + public final Name name; + + DCEndElement(Name name) { + this.name = name; + } + + @Override + public Kind getKind() { + return Kind.END_ELEMENT; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitEndElement(this, d); + } + + @Override + public Name getName() { + return name; + } + } + + public static class DCEntity extends DCTree implements EntityTree { + public final Name name; + + DCEntity(Name name) { + this.name = name; + } + + @Override + public Kind getKind() { + return Kind.ENTITY; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitEntity(this, d); + } + + @Override + public Name getName() { + return name; + } + } + + public static class DCErroneous extends DCTree implements ErroneousTree, JCDiagnostic.DiagnosticPosition { + public final String body; + public final JCDiagnostic diag; + + DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) { + this.body = body; + this.diag = diags.error(diagSource, this, code, args); + } + + @Override + public Kind getKind() { + return Kind.ERRONEOUS; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitErroneous(this, d); + } + + @Override + public String getBody() { + return body; + } + + @Override + public Diagnostic getDiagnostic() { + return diag; + } + + @Override + public JCTree getTree() { + return null; + } + + @Override + public int getStartPosition() { + return pos; + } + + @Override + public int getPreferredPosition() { + return pos + body.length() - 1; + } + + @Override + public int getEndPosition(EndPosTable endPosTable) { + return pos + body.length(); + } + } + + public static class DCIdentifier extends DCTree implements IdentifierTree { + public final Name name; + + DCIdentifier(Name name) { + this.name = name; + } + + @Override + public Kind getKind() { + return Kind.IDENTIFIER; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitIdentifier(this, d); + } + + @Override + public Name getName() { + return name; + } + } + + public static class DCInheritDoc extends DCInlineTag implements InheritDocTree { + @Override + public Kind getKind() { + return Kind.INHERIT_DOC; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitInheritDoc(this, d); + } + } + + public static class DCLink extends DCInlineTag implements LinkTree { + public final Kind kind; + public final DCReference ref; + public final List label; + + DCLink(Kind kind, DCReference ref, List label) { + Assert.check(kind == Kind.LINK || kind == Kind.LINK_PLAIN); + this.kind = kind; + this.ref = ref; + this.label = label; + } + + @Override + public Kind getKind() { + return kind; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitLink(this, d); + } + + @Override + public ReferenceTree getReference() { + return ref; + } + + @Override + public List getLabel() { + return label; + } + } + + public static class DCLiteral extends DCInlineTag implements LiteralTree { + public final Kind kind; + public final DCText body; + + DCLiteral(Kind kind, DCText body) { + Assert.check(kind == Kind.CODE || kind == Kind.LITERAL); + this.kind = kind; + this.body = body; + } + + @Override + public Kind getKind() { + return kind; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitLiteral(this, d); + } + + @Override + public DCText getBody() { + return body; + } + } + + public static class DCParam extends DCBlockTag implements ParamTree { + public final boolean isTypeParameter; + public final DCIdentifier name; + public final List description; + + DCParam(boolean isTypeParameter, DCIdentifier name, List description) { + this.isTypeParameter = isTypeParameter; + this.name = name; + this.description = description; + } + + @Override + public Kind getKind() { + return Kind.PARAM; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitParam(this, d); + } + + @Override + public boolean isTypeParameter() { + return isTypeParameter; + } + + @Override + public IdentifierTree getName() { + return name; + } + + @Override + public List getDescription() { + return description; + } + } + + public static class DCReference extends DCTree implements ReferenceTree { + public final String signature; + + // The following are not directly exposed through ReferenceTree + // use DocTrees.getElement(TreePath,ReferenceTree) + public final JCTree qualifierExpression; + public final Name memberName; + public final List paramTypes; + + + DCReference(String signature, JCTree qualExpr, Name member, List paramTypes) { + this.signature = signature; + qualifierExpression = qualExpr; + memberName = member; + this.paramTypes = paramTypes; + } + + @Override + public Kind getKind() { + return Kind.REFERENCE; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitReference(this, d); + } + + @Override + public String getSignature() { + return signature; + } + } + + public static class DCReturn extends DCBlockTag implements ReturnTree { + public final List description; + + DCReturn(List description) { + this.description = description; + } + + @Override + public Kind getKind() { + return Kind.RETURN; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitReturn(this, d); + } + + @Override + public List getDescription() { + return description; + } + } + + public static class DCSee extends DCBlockTag implements SeeTree { + public final List reference; + + DCSee(List reference) { + this.reference = reference; + } + + @Override + public Kind getKind() { + return Kind.SEE; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitSee(this, d); + } + + @Override + public List getReference() { + return reference; + } + } + + public static class DCSerial extends DCBlockTag implements SerialTree { + public final List description; + + DCSerial(List description) { + this.description = description; + } + + @Override + public Kind getKind() { + return Kind.SERIAL; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitSerial(this, d); + } + + @Override + public List getDescription() { + return description; + } + } + + public static class DCSerialData extends DCBlockTag implements SerialDataTree { + public final List description; + + DCSerialData(List description) { + this.description = description; + } + + @Override + public Kind getKind() { + return Kind.SERIAL_DATA; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitSerialData(this, d); + } + + @Override + public List getDescription() { + return description; + } + } + + public static class DCSerialField extends DCBlockTag implements SerialFieldTree { + public final DCIdentifier name; + public final DCReference type; + public final List description; + + DCSerialField(DCIdentifier name, DCReference type, List description) { + this.description = description; + this.name = name; + this.type = type; + } + + @Override + public Kind getKind() { + return Kind.SERIAL_FIELD; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitSerialField(this, d); + } + + @Override + public List getDescription() { + return description; + } + + @Override + public IdentifierTree getName() { + return name; + } + + @Override + public ReferenceTree getType() { + return type; + } + } + + public static class DCSince extends DCInlineTag implements SinceTree { + public final List body; + + DCSince(List body) { + this.body = body; + } + + @Override + public Kind getKind() { + return Kind.SINCE; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitSince(this, d); + } + + @Override + public List getBody() { + return body; + } + } + + public static class DCStartElement extends DCTree implements StartElementTree { + public final Name name; + public final List attrs; + public final boolean selfClosing; + + DCStartElement(Name name, List attrs, boolean selfClosing) { + this.name = name; + this.attrs = attrs; + this.selfClosing = selfClosing; + } + + @Override + public Kind getKind() { + return Kind.START_ELEMENT; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitStartElement(this, d); + } + + @Override + public Name getName() { + return name; + } + + @Override + public List getAttributes() { + return attrs; + } + + @Override + public boolean isSelfClosing() { + return selfClosing; + } + } + + public static class DCText extends DCTree implements TextTree { + public final String text; + + DCText(String text) { + this.text = text; + } + + @Override + public Kind getKind() { + return Kind.TEXT; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitText(this, d); + } + + @Override + public String getBody() { + return text; + } + } + + public static class DCThrows extends DCBlockTag implements ThrowsTree { + public final Kind kind; + public final DCReference name; + public final List description; + + DCThrows(Kind kind, DCReference name, List description) { + Assert.check(kind == Kind.EXCEPTION || kind == Kind.THROWS); + this.kind = kind; + this.name = name; + this.description = description; + } + + @Override + public Kind getKind() { + return kind; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitThrows(this, d); + } + + @Override + public ReferenceTree getExceptionName() { + return name; + } + + @Override + public List getDescription() { + return description; + } + } + + public static class DCUnknownBlockTag extends DCBlockTag implements UnknownBlockTagTree { + public final Name name; + public final List content; + + DCUnknownBlockTag(Name name, List content) { + this.name = name; + this.content = content; + } + + @Override + public Kind getKind() { + return Kind.UNKNOWN_BLOCK_TAG; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitUnknownBlockTag(this, d); + } + + @Override + public String getTagName() { + return name.toString(); + } + + @Override + public List getContent() { + return content; + } + } + + public static class DCUnknownInlineTag extends DCInlineTag implements UnknownInlineTagTree { + public final Name name; + public final List content; + + DCUnknownInlineTag(Name name, List content) { + this.name = name; + this.content = content; + } + + @Override + public Kind getKind() { + return Kind.UNKNOWN_INLINE_TAG; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitUnknownInlineTag(this, d); + } + + @Override + public String getTagName() { + return name.toString(); + } + + @Override + public List getContent() { + return content; + } + } + + public static class DCValue extends DCInlineTag implements ValueTree { + public final DCReference ref; + + DCValue(DCReference ref) { + this.ref = ref; + } + + @Override + public Kind getKind() { + return Kind.VALUE; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitValue(this, d); + } + + @Override + public ReferenceTree getReference() { + return ref; + } + } + + public static class DCVersion extends DCBlockTag implements VersionTree { + public final List body; + + DCVersion(List body) { + this.body = body; + } + + @Override + public Kind getKind() { + return Kind.VERSION; + } + + @Override + public R accept(DocTreeVisitor v, D d) { + return v.visitVersion(this, d); + } + + @Override + public List getBody() { + return body; + } + } + +} diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java b/langtools/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java index 0d77a3868ec..1d88afdc2ab 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java @@ -24,7 +24,9 @@ */ package com.sun.tools.javac.tree; +import com.sun.source.doctree.ErroneousTree; import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.tree.DCTree.DCDocComment; /** * A table giving the doc comment, if any, for any tree node. @@ -50,6 +52,13 @@ public interface DocCommentTable { */ public String getCommentText(JCTree tree); + /** + * Get the parsed form of the doc comment as a DocTree. If any errors + * are detected during parsing, they will be reported via + * {@link ErroneousTree ErroneousTree} nodes within the resulting tree. + */ + public DCDocComment getCommentTree(JCTree tree); + /** * Set the Comment to be associated with a tree node. */ diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/DocPretty.java b/langtools/src/share/classes/com/sun/tools/javac/tree/DocPretty.java new file mode 100644 index 00000000000..6d4dbc5abe1 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/DocPretty.java @@ -0,0 +1,520 @@ +/* + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.javac.tree; + +import java.io.Writer; + +import com.sun.source.doctree.*; +import com.sun.source.doctree.AttributeTree.ValueKind; +import com.sun.tools.javac.util.Convert; +import java.io.IOException; +import java.util.List; + +/** + * Prints out a doc comment tree. + * + *

This is NOT part of any supported API. + * 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. + */ +public class DocPretty implements DocTreeVisitor { + + /** + * The output stream on which trees are printed. + */ + final Writer out; + + /** + * The left margin. + */ + int lmargin = 0; + + public DocPretty(Writer out) { + this.out = out; + } + + /** Visitor method: print expression tree. + */ + public void print(DocTree tree) throws IOException { + try { + if (tree == null) + print("/*missing*/"); + else { + tree.accept(this, null); + } + } catch (UncheckedIOException ex) { + throw new IOException(ex.getMessage(), ex); + } + } + + /** + * Print string, replacing all non-ascii character with unicode escapes. + */ + protected void print(Object s) throws IOException { + out.write(Convert.escapeUnicode(s.toString())); + } + + /** + * Print list. + */ + protected void print(List list) throws IOException { + for (DocTree t: list) { + print(t); + } + } + + /** + * Print list., with separators + */ + protected void print(List list, String sep) throws IOException { + if (list.isEmpty()) + return; + boolean first = true; + for (DocTree t: list) { + if (!first) + print(sep); + print(t); + first = false; + } + } + + /** Print new line. + */ + protected void println() throws IOException { + out.write(lineSep); + } + + protected void printTagName(DocTree node) throws IOException { + out.write("@"); + out.write(node.getKind().tagName); + } + + final String lineSep = System.getProperty("line.separator"); + + /************************************************************************** + * Traversal methods + *************************************************************************/ + + /** Exception to propagate IOException through visitXXX methods */ + private static class UncheckedIOException extends Error { + static final long serialVersionUID = -4032692679158424751L; + UncheckedIOException(IOException e) { + super(e.getMessage(), e); + } + } + + + public Void visitAttribute(AttributeTree node, Void p) { + try { + print(node.getName()); + String quote; + switch (node.getValueKind()) { + case EMPTY: + quote = null; + break; + case UNQUOTED: + quote = ""; + break; + case SINGLE: + quote = "'"; + break; + case DOUBLE: + quote = "\""; + break; + default: + throw new AssertionError(); + } + if (quote != null) { + print("=" + quote); + print(node.getValue()); + print(quote); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitAuthor(AuthorTree node, Void p) { + try { + printTagName(node); + print(" "); + print(node.getName()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitComment(CommentTree node, Void p) { + try { + print(node.getBody()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitDeprecated(DeprecatedTree node, Void p) { + try { + printTagName(node); + if (!node.getBody().isEmpty()) { + print(" "); + print(node.getBody()); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitDocComment(DocCommentTree node, Void p) { + try { + List fs = node.getFirstSentence(); + List b = node.getBody(); + List t = node.getBlockTags(); + print(fs); + if (!fs.isEmpty() && !b.isEmpty()) + print(" "); + print(b); + if ((!fs.isEmpty() || !b.isEmpty()) && !t.isEmpty()) + print("\n"); + print(t, "\n"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitDocRoot(DocRootTree node, Void p) { + try { + print("{"); + printTagName(node); + print("}"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitEndElement(EndElementTree node, Void p) { + try { + print(""); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitEntity(EntityTree node, Void p) { + try { + print("&"); + print(node.getName()); + print(";"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitErroneous(ErroneousTree node, Void p) { + try { + print(node.getBody()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitIdentifier(IdentifierTree node, Void p) { + try { + print(node.getName()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitInheritDoc(InheritDocTree node, Void p) { + try { + print("{"); + printTagName(node); + print("}"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitLink(LinkTree node, Void p) { + try { + print("{"); + printTagName(node); + print(" "); + print(node.getReference()); + if (!node.getLabel().isEmpty()) { + print(" "); + print(node.getLabel()); + } + print("}"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitLiteral(LiteralTree node, Void p) { + try { + print("{"); + printTagName(node); + print(" "); + print(node.getBody()); + print("}"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitParam(ParamTree node, Void p) { + try { + printTagName(node); + print(" "); + if (node.isTypeParameter()) print("<"); + print(node.getName()); + if (node.isTypeParameter()) print(">"); + if (!node.getDescription().isEmpty()) { + print(" "); + print(node.getDescription()); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitReference(ReferenceTree node, Void p) { + try { + print(node.getSignature()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitReturn(ReturnTree node, Void p) { + try { + printTagName(node); + print(" "); + print(node.getDescription()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitSee(SeeTree node, Void p) { + try { + printTagName(node); + boolean first = true; + boolean needSep = true; + for (DocTree t: node.getReference()) { + if (needSep) print(" "); + needSep = (first && (t instanceof ReferenceTree)); + first = false; + print(t); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitSerial(SerialTree node, Void p) { + try { + printTagName(node); + if (!node.getDescription().isEmpty()) { + print(" "); + print(node.getDescription()); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitSerialData(SerialDataTree node, Void p) { + try { + printTagName(node); + if (!node.getDescription().isEmpty()) { + print(" "); + print(node.getDescription()); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitSerialField(SerialFieldTree node, Void p) { + try { + printTagName(node); + print(" "); + print(node.getName()); + print(" "); + print(node.getType()); + if (!node.getDescription().isEmpty()) { + print(" "); + print(node.getDescription()); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitSince(SinceTree node, Void p) { + try { + printTagName(node); + print(" "); + print(node.getBody()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitStartElement(StartElementTree node, Void p) { + try { + print("<"); + print(node.getName()); + List attrs = node.getAttributes(); + if (!attrs.isEmpty()) { + print(" "); + print(attrs); + DocTree last = node.getAttributes().get(attrs.size() - 1); + if (node.isSelfClosing() && last instanceof AttributeTree + && ((AttributeTree) last).getValueKind() == ValueKind.UNQUOTED) + print(" "); + } + if (node.isSelfClosing()) + print("/"); + print(">"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitText(TextTree node, Void p) { + try { + print(node.getBody()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitThrows(ThrowsTree node, Void p) { + try { + printTagName(node); + print(" "); + print(node.getExceptionName()); + if (!node.getDescription().isEmpty()) { + print(" "); + print(node.getDescription()); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) { + try { + print("@"); + print(node.getTagName()); + print(" "); + print(node.getContent()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitUnknownInlineTag(UnknownInlineTagTree node, Void p) { + try { + print("{"); + print("@"); + print(node.getTagName()); + print(" "); + print(node.getContent()); + print("}"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitValue(ValueTree node, Void p) { + try { + print("{"); + printTagName(node); + if (node.getReference() != null) { + print(" "); + print(node.getReference()); + } + print("}"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitVersion(VersionTree node, Void p) { + try { + printTagName(node); + print(" "); + print(node.getBody()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } + + public Void visitOther(DocTree node, Void p) { + try { + print("(UNKNOWN: " + node + ")"); + println(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return null; + } +} diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java b/langtools/src/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java new file mode 100644 index 00000000000..1060db84c6c --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.javac.tree; + +import com.sun.source.doctree.AttributeTree.ValueKind; +import com.sun.source.doctree.DocTree.Kind; + +import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.tree.DCTree.*; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.DiagnosticSource; +import com.sun.tools.javac.util.JCDiagnostic; +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.Name; +import com.sun.tools.javac.util.Position; + +/** + * + *

This is NOT part of any supported API. + * 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. + */ +public class DocTreeMaker { + + /** The context key for the tree factory. */ + protected static final Context.Key treeMakerKey = + new Context.Key(); + + /** Get the TreeMaker instance. */ + public static DocTreeMaker instance(Context context) { + DocTreeMaker instance = context.get(treeMakerKey); + if (instance == null) + instance = new DocTreeMaker(context); + return instance; + } + + /** The position at which subsequent trees will be created. + */ + public int pos = Position.NOPOS; + + /** Access to diag factory for ErroneousTrees. */ + private final JCDiagnostic.Factory diags; + + /** Create a tree maker with NOPOS as initial position. + */ + protected DocTreeMaker(Context context) { + context.put(treeMakerKey, this); + diags = JCDiagnostic.Factory.instance(context); + this.pos = Position.NOPOS; + } + + /** Reassign current position. + */ + public DocTreeMaker at(int pos) { + this.pos = pos; + return this; + } + + /** Reassign current position. + */ + public DocTreeMaker at(DiagnosticPosition pos) { + this.pos = (pos == null ? Position.NOPOS : pos.getStartPosition()); + return this; + } + + public DCAttribute Attribute(Name name, ValueKind vkind, List value) { + DCAttribute tree = new DCAttribute(name, vkind, value); + tree.pos = pos; + return tree; + } + + public DCAuthor Author(List name) { + DCAuthor tree = new DCAuthor(name); + tree.pos = pos; + return tree; + } + + public DCLiteral Code(DCText text) { + DCLiteral tree = new DCLiteral(Kind.CODE, text); + tree.pos = pos; + return tree; + } + + public DCComment Comment(String text) { + DCComment tree = new DCComment(text); + tree.pos = pos; + return tree; + } + + public DCDeprecated Deprecated(List text) { + DCDeprecated tree = new DCDeprecated(text); + tree.pos = pos; + return tree; + } + + public DCDocComment DocComment(Comment comment, List firstSentence, List body, List tags) { + DCDocComment tree = new DCDocComment(comment, firstSentence, body, tags); + tree.pos = pos; + return tree; + } + + public DCDocRoot DocRoot() { + DCDocRoot tree = new DCDocRoot(); + tree.pos = pos; + return tree; + } + + public DCEndElement EndElement(Name name) { + DCEndElement tree = new DCEndElement(name); + tree.pos = pos; + return tree; + } + + public DCEntity Entity(Name name) { + DCEntity tree = new DCEntity(name); + tree.pos = pos; + return tree; + } + + public DCErroneous Erroneous(String text, DiagnosticSource diagSource, String code, Object... args) { + DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args); + tree.pos = pos; + return tree; + } + + public DCThrows Exception(DCReference name, List description) { + DCThrows tree = new DCThrows(Kind.EXCEPTION, name, description); + tree.pos = pos; + return tree; + } + + public DCIdentifier Identifier(Name name) { + DCIdentifier tree = new DCIdentifier(name); + tree.pos = pos; + return tree; + } + + public DCInheritDoc InheritDoc() { + DCInheritDoc tree = new DCInheritDoc(); + tree.pos = pos; + return tree; + } + + public DCLink Link(DCReference ref, List label) { + DCLink tree = new DCLink(Kind.LINK, ref, label); + tree.pos = pos; + return tree; + } + + public DCLink LinkPlain(DCReference ref, List label) { + DCLink tree = new DCLink(Kind.LINK_PLAIN, ref, label); + tree.pos = pos; + return tree; + } + + public DCLiteral Literal(DCText text) { + DCLiteral tree = new DCLiteral(Kind.LITERAL, text); + tree.pos = pos; + return tree; + } + + public DCParam Param(boolean isTypeParameter, DCIdentifier name, List description) { + DCParam tree = new DCParam(isTypeParameter, name, description); + tree.pos = pos; + return tree; + } + + public DCReference Reference(String signature, + JCTree qualExpr, Name member, List paramTypes) { + DCReference tree = new DCReference(signature, qualExpr, member, paramTypes); + tree.pos = pos; + return tree; + } + + public DCReturn Return(List description) { + DCReturn tree = new DCReturn(description); + tree.pos = pos; + return tree; + } + + public DCSee See(List reference) { + DCSee tree = new DCSee(reference); + tree.pos = pos; + return tree; + } + + public DCSerial Serial(List description) { + DCSerial tree = new DCSerial(description); + tree.pos = pos; + return tree; + } + + public DCSerialData SerialData(List description) { + DCSerialData tree = new DCSerialData(description); + tree.pos = pos; + return tree; + } + + public DCSerialField SerialField(DCIdentifier name, DCReference type, List description) { + DCSerialField tree = new DCSerialField(name, type, description); + tree.pos = pos; + return tree; + } + + public DCSince Since(List text) { + DCSince tree = new DCSince(text); + tree.pos = pos; + return tree; + } + + public DCStartElement StartElement(Name name, List attrs, boolean selfClosing) { + DCStartElement tree = new DCStartElement(name, attrs, selfClosing); + tree.pos = pos; + return tree; + } + + public DCText Text(String text) { + DCText tree = new DCText(text); + tree.pos = pos; + return tree; + } + + public DCThrows Throws(DCReference name, List description) { + DCThrows tree = new DCThrows(Kind.THROWS, name, description); + tree.pos = pos; + return tree; + } + + public DCUnknownBlockTag UnknownBlockTag(Name name, List content) { + DCUnknownBlockTag tree = new DCUnknownBlockTag(name, content); + tree.pos = pos; + return tree; + } + + public DCUnknownInlineTag UnknownInlineTag(Name name, List content) { + DCUnknownInlineTag tree = new DCUnknownInlineTag(name, content); + tree.pos = pos; + return tree; + } + + public DCValue Value(DCReference ref) { + DCValue tree = new DCValue(ref); + tree.pos = pos; + return tree; + } + + public DCVersion Version(List text) { + DCVersion tree = new DCVersion(text); + tree.pos = pos; + return tree; + } +} diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java b/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java index 5cd43067526..6ccacdb735f 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java @@ -102,6 +102,7 @@ public class DocEnv { Check chk; Types types; JavaFileManager fileManager; + Context context; /** Allow documenting from class files? */ boolean docClasses = false; @@ -122,6 +123,7 @@ public class DocEnv { */ protected DocEnv(Context context) { context.put(docEnvKey, this); + this.context = context; messager = Messager.instance0(context); syms = Symtab.instance(context); diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java index e9b5b23c1fb..647b19627db 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java @@ -25,7 +25,14 @@ package com.sun.tools.javadoc; +import java.io.File; +import java.util.Locale; + import com.sun.javadoc.*; +import com.sun.tools.javac.code.Kinds; +import com.sun.tools.javac.code.Printer; +import com.sun.tools.javac.code.Symbol; +import com.sun.tools.javac.code.Type.CapturedType; import com.sun.tools.javac.util.*; /** @@ -75,9 +82,63 @@ class SeeTagImpl extends TagImpl implements SeeTag, LayoutCharacters { container = (ClassDocImpl)holder; } findReferenced(container); + if (showRef) showRef(); } } + private static final boolean showRef = false; + + private void showRef() { + Symbol sym; + if (referencedMember != null) { + if (referencedMember instanceof MethodDocImpl) + sym = ((MethodDocImpl) referencedMember).sym; + else if (referencedMember instanceof FieldDocImpl) + sym = ((FieldDocImpl) referencedMember).sym; + else + sym = ((ConstructorDocImpl) referencedMember).sym; + } else if (referencedClass != null) { + sym = ((ClassDocImpl) referencedClass).tsym; + } else if (referencedPackage != null) { + sym = ((PackageDocImpl) referencedPackage).sym; + } else + return; + + final JavacMessages messages = JavacMessages.instance(docenv().context); + Locale locale = Locale.getDefault(); + Printer printer = new Printer() { + int count; + @Override + protected String localize(Locale locale, String key, Object... args) { + return messages.getLocalizedString(locale, key, args); + } + @Override + protected String capturedVarId(CapturedType t, Locale locale) { + return "CAP#" + (++count); + } + }; + + String s = text.replaceAll("\\s+", " "); // normalize white space + int sp = s.indexOf(" "); + int lparen = s.indexOf("("); + int rparen = s.indexOf(")"); + String seetext = (sp == -1) ? s + : (lparen == -1 || sp < lparen) ? s.substring(0, sp) + : s.substring(0, rparen + 1); + + File file = new File(holder.position().file().getAbsoluteFile().toURI().normalize()); + + StringBuilder sb = new StringBuilder(); + sb.append("+++ ").append(file).append(": ") + .append(name()).append(" ").append(seetext).append(": "); + sb.append(sym.getKind()).append(" "); + if (sym.kind == Kinds.MTH || sym.kind == Kinds.VAR) + sb.append(printer.visit(sym.owner, locale)).append("."); + sb.append(printer.visit(sym, locale)); + + System.err.println(sb); + } + /** * get the class name part of @see, For instance, * if the comment is @see String#startsWith(java.lang.String) . diff --git a/langtools/test/tools/javac/diags/CheckExamples.java b/langtools/test/tools/javac/diags/CheckExamples.java index 9bf63ee5892..add2cc31f8d 100644 --- a/langtools/test/tools/javac/diags/CheckExamples.java +++ b/langtools/test/tools/javac/diags/CheckExamples.java @@ -25,9 +25,10 @@ * @test * @bug 6968063 7127924 * @summary provide examples of code that generate diagnostics - * @build Example CheckExamples + * @build Example CheckExamples DocCommentProcessor * @run main/othervm CheckExamples */ + /* * See CR 7127924 for info on why othervm is used. */ diff --git a/langtools/test/tools/javac/diags/DocCommentProcessor.java b/langtools/test/tools/javac/diags/DocCommentProcessor.java new file mode 100644 index 00000000000..bb41985b0e8 --- /dev/null +++ b/langtools/test/tools/javac/diags/DocCommentProcessor.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.*; + +import javax.annotation.processing.*; +import javax.lang.model.*; +import javax.lang.model.element.*; + +import com.sun.source.doctree.DocCommentTree; +import com.sun.source.doctree.ErroneousTree; +import com.sun.source.tree.ClassTree; +import com.sun.source.tree.MethodTree; +import com.sun.source.tree.VariableTree; +import com.sun.source.util.DocTreeScanner; +import com.sun.source.util.DocTrees; +import com.sun.source.util.TreePath; +import com.sun.source.util.TreePathScanner; +import com.sun.source.util.TreeScanner; +import com.sun.tools.javac.tree.DocPretty; +import java.io.PrintWriter; +import javax.tools.Diagnostic; + +/** + * Standard annotation processor for use by examples to + * scan DocCommentTree nodes looking for ErroneousTree, + * on which to call {@code getMessage}. + */ +@SupportedAnnotationTypes("*") +public class DocCommentProcessor extends AbstractProcessor { + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public void init(ProcessingEnvironment pEnv) { + super.init(pEnv); + trees = DocTrees.instance(pEnv); + messager = pEnv.getMessager(); + } + + @Override + public boolean process(Set annos, RoundEnvironment rEnv) { + for (Element e : rEnv.getRootElements()) { + new DocCommentScanner().scan(e); + } + return true; + } + + class DocCommentScanner extends TreePathScanner { + public void scan(Element e) { + scan(trees.getPath(e), null); + } + + @Override + public Void visitClass(ClassTree tree, Void ignore) { + check(); + return super.visitClass(tree, ignore); + } + + @Override + public Void visitMethod(MethodTree tree, Void ignore) { + check(); + return super.visitMethod(tree, ignore); + } + + @Override + public Void visitVariable(VariableTree tree, Void ignore) { + check(); + return super.visitVariable(tree, ignore); + } + + private void check() { + DocCommentTree dc = trees.getDocCommentTree(getCurrentPath()); + if (dc == null) + return; + + DocTreeScanner s = new DocTreeScanner() { + @Override + public Void visitErroneous(ErroneousTree tree, Void ignore) { + messager.printMessage(Diagnostic.Kind.NOTE, tree.getDiagnostic().getMessage(null)); + return null; + } + }; + + s.scan(dc, null); + } + + } + + private DocTrees trees; + private Messager messager; +} diff --git a/langtools/test/tools/javac/diags/Example.java b/langtools/test/tools/javac/diags/Example.java index 45f9ef83ef6..61007440203 100644 --- a/langtools/test/tools/javac/diags/Example.java +++ b/langtools/test/tools/javac/diags/Example.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. 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 @@ -209,6 +209,13 @@ class Example implements Comparable { opts.add("-classpath"); // avoid using -processorpath for now opts.add(classesDir.getPath()); createAnnotationServicesFile(classesDir, procFiles); + } else if (options != null) { + int i = options.indexOf("-processor"); + // check for built-in anno-processor(s) + if (i != -1 && options.get(i + 1).equals("DocCommentProcessor")) { + opts.add("-classpath"); + opts.add(System.getProperty("test.classes")); + } } if (srcPathDir != null) { diff --git a/langtools/test/tools/javac/diags/RunExamples.java b/langtools/test/tools/javac/diags/RunExamples.java index 08e161c3e7b..287dd441d4e 100644 --- a/langtools/test/tools/javac/diags/RunExamples.java +++ b/langtools/test/tools/javac/diags/RunExamples.java @@ -25,7 +25,7 @@ * @test * @bug 6968063 7127924 * @summary provide examples of code that generate diagnostics - * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples + * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples DocCommentProcessor * @run main/othervm RunExamples */ /* diff --git a/langtools/test/tools/javac/diags/examples.not-yet.txt b/langtools/test/tools/javac/diags/examples.not-yet.txt index 0ed45f26fa2..061825ac0d2 100644 --- a/langtools/test/tools/javac/diags/examples.not-yet.txt +++ b/langtools/test/tools/javac/diags/examples.not-yet.txt @@ -3,6 +3,7 @@ compiler.err.already.defined.this.unit # seems to be masked by compiler.err.annotation.value.not.allowable.type # cannot happen: precluded by complete type-specific tests compiler.err.cant.read.file # (apt.JavaCompiler?) compiler.err.cant.select.static.class.from.param.type +compiler.err.dc.unterminated.string # cannot happen compiler.err.illegal.char.for.encoding compiler.err.invalid.containedby.annotation # should not happen compiler.err.invalid.containedby.annotation.invalid.value # "can't" happen @@ -105,3 +106,4 @@ compiler.warn.unchecked.cast.to.type # DEAD, replaced by comp compiler.warn.unexpected.archive.file # Paths: zip file with unknown extn compiler.warn.unknown.enum.constant # in bad class file compiler.warn.unknown.enum.constant.reason # in bad class file + diff --git a/langtools/test/tools/javac/diags/examples/BadEntity.java b/langtools/test/tools/javac/diags/examples/BadEntity.java new file mode 100644 index 00000000000..bfff5c8c4fd --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/BadEntity.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.dc.bad.entity +// key: compiler.note.note +// key: compiler.note.proc.messager +// run: backdoor +// options: -processor DocCommentProcessor -proc:only + +/** & */ +class BadEntity { } + diff --git a/langtools/test/tools/javac/diags/examples/BadGreaterThan.java b/langtools/test/tools/javac/diags/examples/BadGreaterThan.java new file mode 100644 index 00000000000..f9be624369c --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/BadGreaterThan.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.dc.bad.gt +// key: compiler.note.note +// key: compiler.note.proc.messager +// run: backdoor +// options: -processor DocCommentProcessor -proc:only + +/** > */ +class BadGreaterThan { } + diff --git a/langtools/test/tools/javac/diags/examples/BadInlineTag.java b/langtools/test/tools/javac/diags/examples/BadInlineTag.java new file mode 100644 index 00000000000..902cf6660ea --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/BadInlineTag.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.dc.bad.inline.tag +// key: compiler.note.note +// key: compiler.note.proc.messager +// run: backdoor +// options: -processor DocCommentProcessor -proc:only + +/** @inheritDoc */ +class BadInlineTag { } + diff --git a/langtools/test/tools/javac/diags/examples/GreaterThanExpected.java b/langtools/test/tools/javac/diags/examples/GreaterThanExpected.java new file mode 100644 index 00000000000..60b20227f58 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/GreaterThanExpected.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.dc.gt.expected +// key: compiler.note.note +// key: compiler.note.proc.messager +// run: backdoor +// options: -processor DocCommentProcessor -proc:only + +class GreaterThanExpected { + /** @param void m(T t) { } +} + diff --git a/langtools/test/tools/javac/diags/examples/MalformedHTML.java b/langtools/test/tools/javac/diags/examples/MalformedHTML.java new file mode 100644 index 00000000000..522c1883a59 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/MalformedHTML.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.dc.malformed.html +// key: compiler.note.note +// key: compiler.note.proc.messager +// run: backdoor +// options: -processor DocCommentProcessor -proc:only + +/** foo + */ + void unquoted_attr() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + StartElement[START_ELEMENT, pos:1 + name:a + attributes: 1 + Attribute[ATTRIBUTE, pos:4 + name: name + vkind: UNQUOTED + value: 1 + Text[TEXT, pos:9, unquoted] + ] + ] + Text[TEXT, pos:18, foo] + EndElement[END_ELEMENT, pos:21, a] + body: empty + block tags: empty +] +*/ + + /** + * foo + */ + void double_quoted_attr() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + StartElement[START_ELEMENT, pos:1 + name:a + attributes: 1 + Attribute[ATTRIBUTE, pos:4 + name: name + vkind: DOUBLE + value: 1 + Text[TEXT, pos:10, double_quoted] + ] + ] + Text[TEXT, pos:25, foo] + EndElement[END_ELEMENT, pos:28, a] + body: empty + block tags: empty +] +*/ + + /** + * foo + */ + void single_quoted_attr() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + StartElement[START_ELEMENT, pos:1 + name:a + attributes: 1 + Attribute[ATTRIBUTE, pos:4 + name: name + vkind: SINGLE + value: 1 + Text[TEXT, pos:10, single_quoted] + ] + ] + Text[TEXT, pos:25, foo] + EndElement[END_ELEMENT, pos:28, a] + body: empty + block tags: empty +] +*/ + + /** + *


+ */ + void numeric_attr() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + StartElement[START_ELEMENT, pos:1 + name:hr + attributes: 1 + Attribute[ATTRIBUTE, pos:5 + name: size + vkind: DOUBLE + value: 1 + Text[TEXT, pos:11, 3] + ] + ] + body: empty + block tags: empty +] +*/ + + /** + * + */ + void docRoot_attr() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + StartElement[START_ELEMENT, pos:1 + name:a + attributes: 1 + Attribute[ATTRIBUTE, pos:4 + name: href + vkind: DOUBLE + value: 2 + DocRoot[DOC_ROOT, pos:10] + Text[TEXT, pos:20, /index.html] + ] + ] + body: empty + block tags: empty +] +*/ + + /** + * + */ + void entity_attr() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + StartElement[START_ELEMENT, pos:1 + name:a + attributes: 1 + Attribute[ATTRIBUTE, pos:4 + name: name + vkind: DOUBLE + value: 3 + Text[TEXT, pos:10, abc] + Entity[ENTITY, pos:13, quot] + Text[TEXT, pos:19, def] + ] + ] + body: empty + block tags: empty +] +*/ + + /** + *
+ */ + void no_value_attr() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + StartElement[START_ELEMENT, pos:1 + name:hr + attributes: 1 + Attribute[ATTRIBUTE, pos:5 + name: noshade + vkind: EMPTY + value: null + ] + ] + body: empty + block tags: empty +] +*/ + + /** + * abc
+ */ + void self_closing_attr_1() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 2 + Text[TEXT, pos:1, abc_] + StartElement[START_ELEMENT, pos:5 + name:hr + attributes: 1 + Attribute[ATTRIBUTE, pos:9 + name: size + vkind: SINGLE + value: 1 + Text[TEXT, pos:15, 3] + ] + ] + body: empty + block tags: empty +] +*/ + + /** + * abc
+ */ + void self_closing_attr_2() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 2 + Text[TEXT, pos:1, abc_] + StartElement[START_ELEMENT, pos:5 + name:hr + attributes: 1 + Attribute[ATTRIBUTE, pos:9 + name: size + vkind: UNQUOTED + value: 1 + Text[TEXT, pos:14, 3] + ] + ] + body: empty + block tags: empty +] +*/ + + /** + * abc
files = new ArrayList(); + for (String arg: args) + files.add(new File(testSrc, arg)); + + JavacTool javac = JavacTool.create(); + StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); + + Iterable fos = fm.getJavaFileObjectsFromFiles(files); + + JavacTask t = javac.getTask(null, fm, null, null, null, fos); + final DocTrees trees = DocTrees.instance(t); + + final Checker[] checkers = { + new ASTChecker(this, trees), + new PosChecker(this, trees), + new PrettyChecker(this, trees) + }; + + DeclScanner d = new DeclScanner() { + @Override + public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) { + for (Checker c: checkers) + c.visitCompilationUnit(tree); + return super.visitCompilationUnit(tree, ignore); + } + + @Override + void visitDecl(Tree tree, Name name) { + TreePath path = getCurrentPath(); + String dc = trees.getDocComment(path); + if (dc != null) { + for (Checker c : checkers) { + try { + System.err.println(path.getLeaf().getKind() + + " " + name + + " " + c.getClass().getSimpleName()); + + c.check(path, name); + + System.err.println(); + } catch (Exception e) { + error("Exception " + e); + e.printStackTrace(System.err); + } + } + } + } + }; + + Iterable units = t.parse(); + for (CompilationUnitTree unit: units) { + d.scan(unit, null); + } + + if (errors > 0) + throw new Exception(errors + " errors occurred"); + } + + static abstract class DeclScanner extends TreePathScanner { + abstract void visitDecl(Tree tree, Name name); + + @Override + public Void visitClass(ClassTree tree, Void ignore) { + super.visitClass(tree, ignore); + visitDecl(tree, tree.getSimpleName()); + return null; + } + + @Override + public Void visitMethod(MethodTree tree, Void ignore) { + super.visitMethod(tree, ignore); + visitDecl(tree, tree.getName()); + return null; + } + + @Override + public Void visitVariable(VariableTree tree, Void ignore) { + super.visitVariable(tree, ignore); + visitDecl(tree, tree.getName()); + return null; + } + } + + /** + * Base class for checkers to check the doc comment on a declaration + * (when present.) + */ + abstract class Checker { + final DocTrees trees; + + Checker(DocTrees trees) { + this.trees = trees; + } + + void visitCompilationUnit(CompilationUnitTree tree) { } + + abstract void check(TreePath tree, Name name) throws Exception; + + void error(String msg) { + DocCommentTester.this.error(msg); + } + } + + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + int errors; + + /** + * Verify the structure of the DocTree AST by comparing it against golden text. + */ + static class ASTChecker extends Checker { + Printer printer = new Printer(); + String source; + + ASTChecker(DocCommentTester test, DocTrees t) { + test.super(t); + } + + @Override + void visitCompilationUnit(CompilationUnitTree tree) { + try { + source = tree.getSourceFile().getCharContent(true).toString(); + } catch (IOException e) { + source = ""; + } + } + + void check(TreePath path, Name name) { + StringWriter out = new StringWriter(); + DocCommentTree dc = trees.getDocCommentTree(path); + printer.print(dc, out); + out.flush(); + String found = out.toString(); + + // Look for the first block comment after the first occurrence of name + int start = source.indexOf("\n/*\n", findName(source, name)); + int end = source.indexOf("\n*/\n", start); + String expect = source.substring(start + 4, end + 1); + if (!found.equals(expect)) { + System.err.println("Expect:\n" + expect); + System.err.println("Found:\n" + found); + error("AST mismatch for " + name); + } + } + + /** + * This main program is to set up the golden comments used by this + * checker. + * Usage: + * java DocCommentTester$ASTChecker -o dir file... + * The given files are written to the output directory with their + * golden comments updated. The intent is that the files should + * then be compared with the originals, e.g. with meld, and if the + * changes are approved, the new files can be used to replace the old. + */ + public static void main(String... args) throws Exception { + List files = new ArrayList(); + File o = null; + for (int i = 0; i < args.length; i++) { + String arg = args[i]; + if (arg.equals("-o")) + o = new File(args[++i]); + else if (arg.startsWith("-")) + throw new IllegalArgumentException(arg); + else { + files.add(new File(arg)); + } + } + + if (o == null) + throw new IllegalArgumentException("no output dir specified"); + final File outDir = o; + + JavacTool javac = JavacTool.create(); + StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); + Iterable fos = fm.getJavaFileObjectsFromFiles(files); + + JavacTask t = javac.getTask(null, fm, null, null, null, fos); + final DocTrees trees = DocTrees.instance(t); + + DeclScanner d = new DeclScanner() { + Printer p = new Printer(); + String source; + + @Override + public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) { + System.err.println("processing " + tree.getSourceFile().getName()); + try { + source = tree.getSourceFile().getCharContent(true).toString(); + } catch (IOException e) { + source = ""; + } + + // remove existing gold by removing all block comments after the first '{'. + int start = source.indexOf("{"); + while ((start = source.indexOf("\n/*\n", start)) != -1) { + int end = source.indexOf("\n*/\n"); + source = source.substring(0, start + 1) + source.substring(end + 4); + } + + // process decls in compilation unit + super.visitCompilationUnit(tree, ignore); + + // write the modified source + File f = new File(tree.getSourceFile().getName()); + File outFile = new File(outDir, f.getName()); + try { + FileWriter out = new FileWriter(outFile); + try { + out.write(source); + } finally { + out.close(); + } + } catch (IOException e) { + System.err.println("Can't write " + tree.getSourceFile().getName() + + " to " + outFile + ": " + e); + } + return null; + } + + @Override + void visitDecl(Tree tree, Name name) { + DocTree dc = trees.getDocCommentTree(getCurrentPath()); + if (dc != null) { + StringWriter out = new StringWriter(); + p.print(dc, out); + String found = out.toString(); + + // Look for the empty line after the first occurrence of name + int pos = source.indexOf("\n\n", findName(source, name)); + + // Insert the golden comment + source = source.substring(0, pos) + + "\n/*\n" + + found + + "*/" + + source.substring(pos); + } + } + + }; + + Iterable units = t.parse(); + for (CompilationUnitTree unit: units) { + d.scan(unit, null); + } + } + + static int findName(String source, Name name) { + Pattern p = Pattern.compile("\\s" + name + "[(;]"); + Matcher m = p.matcher(source); + if (!m.find()) + throw new Error("cannot find " + name); + return m.start(); + } + + static class Printer implements DocTreeVisitor { + PrintWriter out; + + void print(DocTree tree, Writer out) { + this.out = (out instanceof PrintWriter) + ? (PrintWriter) out : new PrintWriter(out); + tree.accept(this, null); + this.out.flush(); + } + + public Void visitAttribute(AttributeTree node, Void p) { + header(node); + indent(+1); + print("name", node.getName().toString()); + print("vkind", node.getValueKind().toString()); + print("value", node.getValue()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitAuthor(AuthorTree node, Void p) { + header(node); + indent(+1); + print("name", node.getName()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitComment(CommentTree node, Void p) { + header(node, compress(node.getBody())); + return null; + } + + public Void visitDeprecated(DeprecatedTree node, Void p) { + header(node); + indent(+1); + print("body", node.getBody()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitDocComment(DocCommentTree node, Void p) { + header(node); + indent(+1); + print("firstSentence", node.getFirstSentence()); + print("body", node.getBody()); + print("block tags", node.getBlockTags()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitDocRoot(DocRootTree node, Void p) { + header(node, ""); + return null; + } + + public Void visitEndElement(EndElementTree node, Void p) { + header(node, node.getName().toString()); + return null; + } + + public Void visitEntity(EntityTree node, Void p) { + header(node, node.getName().toString()); + return null; + } + + public Void visitErroneous(ErroneousTree node, Void p) { + header(node); + indent(+1); + print("code", ((DCErroneous) node).diag.getCode()); + print("body", compress(node.getBody())); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitIdentifier(IdentifierTree node, Void p) { + header(node, compress(node.getName().toString())); + return null; + } + + public Void visitInheritDoc(InheritDocTree node, Void p) { + header(node, ""); + return null; + } + + public Void visitLink(LinkTree node, Void p) { + header(node); + indent(+1); + print("reference", node.getReference()); + print("body", node.getLabel()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitLiteral(LiteralTree node, Void p) { + header(node, compress(node.getBody().getBody())); + return null; + } + + public Void visitParam(ParamTree node, Void p) { + header(node); + indent(+1); + print("name", node.getName()); + print("description", node.getDescription()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitReference(ReferenceTree node, Void p) { + header(node, compress(node.getSignature())); + return null; + } + + public Void visitReturn(ReturnTree node, Void p) { + header(node); + indent(+1); + print("description", node.getDescription()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitSee(SeeTree node, Void p) { + header(node); + indent(+1); + print("reference", node.getReference()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitSerial(SerialTree node, Void p) { + header(node); + indent(+1); + print("description", node.getDescription()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitSerialData(SerialDataTree node, Void p) { + header(node); + indent(+1); + print("description", node.getDescription()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitSerialField(SerialFieldTree node, Void p) { + header(node); + indent(+1); + print("name", node.getName()); + print("type", node.getType()); + print("description", node.getDescription()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitSince(SinceTree node, Void p) { + header(node); + indent(+1); + print("body", node.getBody()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitStartElement(StartElementTree node, Void p) { + header(node); + indent(+1); + indent(); + out.println("name:" + node.getName()); + print("attributes", node.getAttributes()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitText(TextTree node, Void p) { + header(node, compress(node.getBody())); + return null; + } + + public Void visitThrows(ThrowsTree node, Void p) { + header(node); + indent(+1); + print("exceptionName", node.getExceptionName()); + print("description", node.getDescription()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) { + header(node); + indent(+1); + indent(); + out.println("tag:" + node.getTagName()); + print("content", node.getContent()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitUnknownInlineTag(UnknownInlineTagTree node, Void p) { + header(node); + indent(+1); + indent(); + out.println("tag:" + node.getTagName()); + print("content", node.getContent()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitValue(ValueTree node, Void p) { + header(node); + indent(+1); + print("reference", node.getReference()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitVersion(VersionTree node, Void p) { + header(node); + indent(+1); + print("body", node.getBody()); + indent(-1); + indent(); + out.println("]"); + return null; + } + + public Void visitOther(DocTree node, Void p) { + throw new UnsupportedOperationException("Not supported yet."); + } + + void header(DocTree node) { + indent(); + out.println(simpleClassName(node) + "[" + node.getKind() + ", pos:" + ((DCTree) node).pos); + } + + void header(DocTree node, String rest) { + indent(); + out.println(simpleClassName(node) + "[" + node.getKind() + ", pos:" + ((DCTree) node).pos + + (rest.isEmpty() ? "" : ", " + rest) + + "]"); + } + + String simpleClassName(DocTree node) { + return node.getClass().getSimpleName().replaceAll("DC(.*)", "$1"); + } + + void print(String name, DocTree item) { + indent(); + if (item == null) + out.println(name + ": null"); + else { + out.println(name + ":"); + indent(+1); + item.accept(this, null); + indent(-1); + } + } + + void print(String name, String s) { + indent(); + out.println(name + ": " + s); + } + + void print(String name, List list) { + indent(); + if (list == null) + out.println(name + ": null"); + else if (list.isEmpty()) + out.println(name + ": empty"); + else { + out.println(name + ": " + list.size()); + indent(+1); + for (DocTree tree: list) { + tree.accept(this, null); + } + indent(-1); + } + } + + int indent = 0; + + void indent() { + for (int i = 0; i < indent; i++) { + out.print(" "); + } + } + + void indent(int n) { + indent += n; + } + + String compress(String s) { + s = s.replace("\n", "|").replace(" ", "_"); + return (s.length() < 32) + ? s + : s.substring(0, 16) + "..." + s.substring(16); + } + + String quote(String s) { + if (s.contains("\"")) + return "'" + s + "'"; + else if (s.contains("'") || s.contains(" ")) + return '"' + s + '"'; + else + return s; + } + + + } + } + + /** + * Verify the reported tree positions by comparing the characters found + * at and after the reported position with the beginning of the pretty- + * printed text. + */ + static class PosChecker extends Checker { + PosChecker(DocCommentTester test, DocTrees t) { + test.super(t); + } + + @Override + void check(TreePath path, Name name) throws Exception { + JavaFileObject fo = path.getCompilationUnit().getSourceFile(); + final CharSequence cs = fo.getCharContent(true); + + final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path); + DCTree t = (DCTree) trees.getDocCommentTree(path); + + DocTreeScanner scanner = new DocTreeScanner() { + @Override + public Void scan(DocTree node, Void ignore) { + if (node != null) { + try { + String expect = getExpectText(node); + long pos = ((DCTree) node).getSourcePosition(dc); + String found = getFoundText(cs, (int) pos, expect.length()); + if (!found.equals(expect)) { + System.err.println("expect: " + expect); + System.err.println("found: " + found); + error("mismatch"); + } + + } catch (StringIndexOutOfBoundsException e) { + error(node.getClass() + ": " + e.toString()); + e.printStackTrace(); + } + } + return super.scan(node, ignore); + } + }; + + scanner.scan(t, null); + } + + String getExpectText(DocTree t) { + StringWriter sw = new StringWriter(); + DocPretty p = new DocPretty(sw); + try { p.print(t); } catch (IOException never) { } + String s = sw.toString(); + if (s.length() <= 1) + return s; + int ws = s.replaceAll("\\s+", " ").indexOf(" "); + if (ws != -1) s = s.substring(0, ws); + return (s.length() < 5) ? s : s.substring(0, 5); + } + + String getFoundText(CharSequence cs, int pos, int len) { + return (pos == -1) ? "" : cs.subSequence(pos, Math.min(pos + len, cs.length())).toString(); + } + } + + /** + * Verify the pretty printed text against a normalized form of the + * original doc comment. + */ + static class PrettyChecker extends Checker { + + PrettyChecker(DocCommentTester test, DocTrees t) { + test.super(t); + } + + @Override + void check(TreePath path, Name name) throws Exception { + String raw = trees.getDocComment(path); + String normRaw = normalize(raw); + + StringWriter out = new StringWriter(); + DocPretty dp = new DocPretty(out); + dp.print(trees.getDocCommentTree(path)); + String pretty = out.toString(); + + if (!pretty.equals(normRaw)) { + error("mismatch"); + System.err.println("*** expected:"); + System.err.println(normRaw.replace(" ", "_")); + System.err.println("*** found:"); + System.err.println(pretty.replace(" ", "_")); + // throw new Error(); + } + } + + /** + * Normalize white space in places where the tree does not preserve it. + */ + String normalize(String s) { + return s.trim() + .replaceFirst("\\.\\s++([^@])", ". $1") + .replaceFirst("\\.\\s*\\n *@", ".\n@") + .replaceFirst("\\s+<(/?p|pre|h[1-6])>", " <$1>") + .replaceAll("\\{@docRoot\\s+\\}", "{@docRoot}") + .replaceAll("\\{@inheritDoc\\s+\\}", "{@inheritDoc}") + .replaceAll("(\\{@value\\s+[^}]+)\\s+(\\})", "$1$2") + .replaceAll("\n[ \t]+@", "\n@"); + } + + } + +} + diff --git a/langtools/test/tools/javac/doctree/DocRootTest.java b/langtools/test/tools/javac/doctree/DocRootTest.java new file mode 100644 index 00000000000..2c3f9a7014b --- /dev/null +++ b/langtools/test/tools/javac/doctree/DocRootTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester DocRootTest.java + */ + +class DocRootTest { + /** abc {@docRoot} */ + void standard() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 2 + Text[TEXT, pos:0, abc_] + DocRoot[DOC_ROOT, pos:4] + body: empty + block tags: empty +] +*/ + + /** abc {@docRoot } */ + void standard_ws1() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 2 + Text[TEXT, pos:0, abc_] + DocRoot[DOC_ROOT, pos:4] + body: empty + block tags: empty +] +*/ + + /** abc {@docRoot } */ + void standard_ws2() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 2 + Text[TEXT, pos:0, abc_] + DocRoot[DOC_ROOT, pos:4] + body: empty + block tags: empty +] +*/ + + /** abc {@docRoot junk} */ + void error() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 2 + Text[TEXT, pos:0, abc_] + Erroneous[ERRONEOUS, pos:4 + code: compiler.err.dc.unexpected.content + body: {@docRoot_junk} + ] + body: empty + block tags: empty +] +*/ + +} diff --git a/langtools/test/tools/javac/doctree/ElementTest.java b/langtools/test/tools/javac/doctree/ElementTest.java new file mode 100644 index 00000000000..2228a767699 --- /dev/null +++ b/langtools/test/tools/javac/doctree/ElementTest.java @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester ElementTest.java + */ + +class ElementTest { + /** + *

para

+ */ + void simple() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: 3 + StartElement[START_ELEMENT, pos:1 + name:p + attributes: empty + ] + Text[TEXT, pos:4, para] + EndElement[END_ELEMENT, pos:8, p] + block tags: empty +] +*/ + + /** + * abc
+ */ + void self_closing() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 2 + Text[TEXT, pos:1, abc_] + StartElement[START_ELEMENT, pos:5 + name:hr + attributes: empty + ] + body: empty + block tags: empty +] +*/ + + /** + * abc < def + */ + void bad_lt() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Erroneous[ERRONEOUS, pos:5 + code: compiler.err.dc.malformed.html + body: < + ] + Text[TEXT, pos:6, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc > def + */ + void bad_gt() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Erroneous[ERRONEOUS, pos:5 + code: compiler.err.dc.bad.gt + body: > + ] + Text[TEXT, pos:6, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc

def + */ + void bad_chars_start(); +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 5 + Text[TEXT, pos:1, abc_] + Erroneous[ERRONEOUS, pos:5 + code: compiler.err.dc.malformed.html + body: < + ] + Text[TEXT, pos:6, p_123] + Erroneous[ERRONEOUS, pos:11 + code: compiler.err.dc.bad.gt + body: > + ] + Text[TEXT, pos:12, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc

def + */ + void bad_chars_end(); +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 5 + Text[TEXT, pos:1, abc_] + Erroneous[ERRONEOUS, pos:5 + code: compiler.err.dc.malformed.html + body: < + ] + Text[TEXT, pos:6, /p_123] + Erroneous[ERRONEOUS, pos:12 + code: compiler.err.dc.bad.gt + body: > + ] + Text[TEXT, pos:13, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc
+ * def + */ + void comment() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc|_] + Comment[COMMENT, pos:6, ] + Text[TEXT, pos:22, |_def] + body: empty + block tags: empty +] +*/ + +} diff --git a/langtools/test/tools/javac/doctree/EntityTest.java b/langtools/test/tools/javac/doctree/EntityTest.java new file mode 100644 index 00000000000..1a19f544a86 --- /dev/null +++ b/langtools/test/tools/javac/doctree/EntityTest.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester EntityTest.java + */ + +class EntityTest { + /** + * abc < def + */ + public void name() { } +/* +DocComment[DOC_COMMENT, pos:2 + firstSentence: 3 + Text[TEXT, pos:2, abc_] + Entity[ENTITY, pos:6, lt] + Text[TEXT, pos:10, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc   def + */ + public void decimal_value() { } +/* +DocComment[DOC_COMMENT, pos:2 + firstSentence: 3 + Text[TEXT, pos:2, abc_] + Entity[ENTITY, pos:6, #160] + Text[TEXT, pos:12, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc   def + */ + public void lower_hex_value() { } +/* +DocComment[DOC_COMMENT, pos:2 + firstSentence: 3 + Text[TEXT, pos:2, abc_] + Entity[ENTITY, pos:6, #xa0] + Text[TEXT, pos:12, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc   def + */ + public void upper_hex_value() { } +/* +DocComment[DOC_COMMENT, pos:2 + firstSentence: 3 + Text[TEXT, pos:2, abc_] + Entity[ENTITY, pos:6, #XA0] + Text[TEXT, pos:12, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc & def + */ + public void bad_amp() { } +/* +DocComment[DOC_COMMENT, pos:2 + firstSentence: 3 + Text[TEXT, pos:2, abc_] + Erroneous[ERRONEOUS, pos:6 + code: compiler.err.dc.bad.entity + body: & + ] + Text[TEXT, pos:7, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc &1 def + */ + public void bad_entity_name() { } +/* +DocComment[DOC_COMMENT, pos:2 + firstSentence: 3 + Text[TEXT, pos:2, abc_] + Erroneous[ERRONEOUS, pos:6 + code: compiler.err.dc.bad.entity + body: & + ] + Text[TEXT, pos:7, 1_def] + body: empty + block tags: empty +] +*/ + + /** + * abc .3; def + */ + public void bad_entity_decimal_value() { } +/* +DocComment[DOC_COMMENT, pos:2 + firstSentence: 3 + Text[TEXT, pos:2, abc_] + Erroneous[ERRONEOUS, pos:6 + code: compiler.err.dc.missing.semicolon + body: + ] + Text[TEXT, pos:11, .3;_def] + body: empty + block tags: empty +] +*/ + + /** + * abc Īzc; def + */ + public void bad_entity_hex_value() { } +/* +DocComment[DOC_COMMENT, pos:2 + firstSentence: 3 + Text[TEXT, pos:2, abc_] + Erroneous[ERRONEOUS, pos:6 + code: compiler.err.dc.missing.semicolon + body: Ī + ] + Text[TEXT, pos:13, zc;_def] + body: empty + block tags: empty +] +*/ + +} diff --git a/langtools/test/tools/javac/doctree/ExceptionTest.java b/langtools/test/tools/javac/doctree/ExceptionTest.java new file mode 100644 index 00000000000..6e02abe446a --- /dev/null +++ b/langtools/test/tools/javac/doctree/ExceptionTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester ExceptionTest.java + */ + +class ExceptionTest { + /** + * @exception Exception + */ + void exception() throws Exception { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Throws[EXCEPTION, pos:1 + exceptionName: + Reference[REFERENCE, pos:12, Exception] + description: empty + ] +] +*/ + + /** + * @exception Exception text + */ + void exception_text() throws Exception { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Throws[EXCEPTION, pos:1 + exceptionName: + Reference[REFERENCE, pos:12, Exception] + description: 1 + Text[TEXT, pos:22, text] + ] +] +*/ + +} + diff --git a/langtools/test/tools/javac/doctree/FirstSentenceTest.java b/langtools/test/tools/javac/doctree/FirstSentenceTest.java new file mode 100644 index 00000000000..b91528d26f6 --- /dev/null +++ b/langtools/test/tools/javac/doctree/FirstSentenceTest.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester FirstSentenceTest.java + */ + +class FirstSentenceTest { + /** */ + void empty() { } +/* +DocComment[DOC_COMMENT, pos:-1 + firstSentence: empty + body: empty + block tags: empty +] +*/ + + /** abc def ghi */ + void no_terminator() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 1 + Text[TEXT, pos:0, abc_def_ghi] + body: empty + block tags: empty +] +*/ + + /** + * abc def ghi. + */ + void no_body() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc_def_ghi.] + body: empty + block tags: empty +] +*/ + + /** + * abc def ghi. jkl mno pqr. + */ + void dot_space() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc_def_ghi.] + body: 1 + Text[TEXT, pos:14, jkl_mno_pqr.] + block tags: empty +] +*/ + + /** + * abc def ghi. + * jkl mno pqr + */ + void dot_newline() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc_def_ghi.] + body: 1 + Text[TEXT, pos:15, jkl_mno_pqr] + block tags: empty +] +*/ + + /** + * abc def ghi + *

jkl mno pqr + */ + void dot_p() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc_def_ghi] + body: 2 + StartElement[START_ELEMENT, pos:14 + name:p + attributes: empty + ] + Text[TEXT, pos:17, jkl_mno_pqr] + block tags: empty +] +*/ + + /** + * abc def ghi + *

jkl mno pqr + */ + void dot_end_p() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc_def_ghi] + body: 2 + EndElement[END_ELEMENT, pos:14, p] + Text[TEXT, pos:18, jkl_mno_pqr] + block tags: empty +] +*/ + + /** + * abc < ghi. jkl mno pqr. + */ + void entity() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Entity[ENTITY, pos:5, lt] + Text[TEXT, pos:9, _ghi.] + body: 1 + Text[TEXT, pos:15, jkl_mno_pqr.] + block tags: empty +] +*/ + + /** + * abc {@code code} ghi. jkl mno pqr. + */ + void inline_tag() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Literal[CODE, pos:5, code] + Text[TEXT, pos:17, _ghi.] + body: 1 + Text[TEXT, pos:23, jkl_mno_pqr.] + block tags: empty +] +*/ + + /** + * abc def ghi + * @author jjg + */ + void block_tag() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc_def_ghi] + body: empty + block tags: 1 + Author[AUTHOR, pos:14 + name: 1 + Text[TEXT, pos:22, jjg] + ] +] +*/ + + /** + * @author jjg + */ + void just_tag() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Author[AUTHOR, pos:1 + name: 1 + Text[TEXT, pos:9, jjg] + ] +] +*/ + +} + diff --git a/langtools/test/tools/javac/doctree/InheritDocTest.java b/langtools/test/tools/javac/doctree/InheritDocTest.java new file mode 100644 index 00000000000..542c738e5ac --- /dev/null +++ b/langtools/test/tools/javac/doctree/InheritDocTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester InheritDocTest.java + */ + +class InheritDocTest { + /** abc {@inheritDoc} */ + void standard() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 2 + Text[TEXT, pos:0, abc_] + InheritDoc[INHERIT_DOC, pos:4] + body: empty + block tags: empty +] +*/ + + /** abc {@inheritDoc } */ + void standard_ws1() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 2 + Text[TEXT, pos:0, abc_] + InheritDoc[INHERIT_DOC, pos:4] + body: empty + block tags: empty +] +*/ + + /** abc {@inheritDoc } */ + void standard_ws2() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 2 + Text[TEXT, pos:0, abc_] + InheritDoc[INHERIT_DOC, pos:4] + body: empty + block tags: empty +] +*/ + + /** abc {@inheritDoc junk} */ + void error() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 2 + Text[TEXT, pos:0, abc_] + Erroneous[ERRONEOUS, pos:4 + code: compiler.err.dc.unexpected.content + body: {@inheritDoc_junk} + ] + body: empty + block tags: empty +] +*/ + +} diff --git a/langtools/test/tools/javac/doctree/LinkPlainTest.java b/langtools/test/tools/javac/doctree/LinkPlainTest.java new file mode 100644 index 00000000000..87d95c14c3d --- /dev/null +++ b/langtools/test/tools/javac/doctree/LinkPlainTest.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester LinkPlainTest.java + */ + +class LinkPlainTest { + /** + * abc {@linkplain String} def + */ + void simple_name() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK_PLAIN, pos:5 + reference: + Reference[REFERENCE, pos:17, String] + body: empty + ] + Text[TEXT, pos:24, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@linkplain String desc} def + */ + void simple_name_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK_PLAIN, pos:5 + reference: + Reference[REFERENCE, pos:17, String] + body: 1 + Text[TEXT, pos:24, desc] + ] + Text[TEXT, pos:29, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@linkplain java.lang.String desc} def + */ + void pkg_name_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK_PLAIN, pos:5 + reference: + Reference[REFERENCE, pos:17, java.lang.String] + body: 1 + Text[TEXT, pos:34, desc] + ] + Text[TEXT, pos:39, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@linkplain java.lang.String#isEmpty desc} def + */ + void method_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK_PLAIN, pos:5 + reference: + Reference[REFERENCE, pos:17, java.lang.String#isEmpty] + body: 1 + Text[TEXT, pos:42, desc] + ] + Text[TEXT, pos:47, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@linkplain java.lang.String#isEmpty() desc} def + */ + void method_0_args_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK_PLAIN, pos:5 + reference: + Reference[REFERENCE, pos:17, java.lang.String#isEmpty()] + body: 1 + Text[TEXT, pos:44, desc] + ] + Text[TEXT, pos:49, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@linkplain java.lang.String#substring(int) desc} def + */ + void method_1_args_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK_PLAIN, pos:5 + reference: + Reference[REFERENCE, pos:17, java.lang.String#substring(int)] + body: 1 + Text[TEXT, pos:49, desc] + ] + Text[TEXT, pos:54, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@linkplain java.lang.String#substring(int, int) desc} def + */ + void method_2_args_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK_PLAIN, pos:5 + reference: + Reference[REFERENCE, pos:17, java.lang.String...#substring(int,_int)] + body: 1 + Text[TEXT, pos:54, desc] + ] + Text[TEXT, pos:59, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@linkplain java.util.List desc} def + */ + void pkg_name_typarams_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK_PLAIN, pos:5 + reference: + Reference[REFERENCE, pos:17, java.util.List] + body: 1 + Text[TEXT, pos:35, desc] + ] + Text[TEXT, pos:40, _def] + body: empty + block tags: empty +] +*/ + +} diff --git a/langtools/test/tools/javac/doctree/LinkTest.java b/langtools/test/tools/javac/doctree/LinkTest.java new file mode 100644 index 00000000000..5881e62557a --- /dev/null +++ b/langtools/test/tools/javac/doctree/LinkTest.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester LinkTest.java + */ + +class LinkTest { + /** + * abc {@link String} def + */ + void simple_name() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK, pos:5 + reference: + Reference[REFERENCE, pos:12, String] + body: empty + ] + Text[TEXT, pos:19, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@link String desc} def + */ + void simple_name_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK, pos:5 + reference: + Reference[REFERENCE, pos:12, String] + body: 1 + Text[TEXT, pos:19, desc] + ] + Text[TEXT, pos:24, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@link java.lang.String desc} def + */ + void pkg_name_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK, pos:5 + reference: + Reference[REFERENCE, pos:12, java.lang.String] + body: 1 + Text[TEXT, pos:29, desc] + ] + Text[TEXT, pos:34, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@link java.lang.String#isEmpty desc} def + */ + void method_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK, pos:5 + reference: + Reference[REFERENCE, pos:12, java.lang.String#isEmpty] + body: 1 + Text[TEXT, pos:37, desc] + ] + Text[TEXT, pos:42, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@link java.lang.String#isEmpty() desc} def + */ + void method_0_args_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK, pos:5 + reference: + Reference[REFERENCE, pos:12, java.lang.String#isEmpty()] + body: 1 + Text[TEXT, pos:39, desc] + ] + Text[TEXT, pos:44, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@link java.lang.String#substring(int) desc} def + */ + void method_1_args_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK, pos:5 + reference: + Reference[REFERENCE, pos:12, java.lang.String#substring(int)] + body: 1 + Text[TEXT, pos:44, desc] + ] + Text[TEXT, pos:49, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@link java.lang.String#substring(int, int) desc} def + */ + void method_2_args_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK, pos:5 + reference: + Reference[REFERENCE, pos:12, java.lang.String...#substring(int,_int)] + body: 1 + Text[TEXT, pos:49, desc] + ] + Text[TEXT, pos:54, _def] + body: empty + block tags: empty +] +*/ + + /** + * abc {@link java.util.List desc} def + */ + void pkg_name_typarams_desc() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Link[LINK, pos:5 + reference: + Reference[REFERENCE, pos:12, java.util.List] + body: 1 + Text[TEXT, pos:30, desc] + ] + Text[TEXT, pos:35, _def] + body: empty + block tags: empty +] +*/ + +} diff --git a/langtools/test/tools/javac/doctree/LiteralTest.java b/langtools/test/tools/javac/doctree/LiteralTest.java new file mode 100644 index 00000000000..1228c4347b0 --- /dev/null +++ b/langtools/test/tools/javac/doctree/LiteralTest.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester LiteralTest.java + */ + +class LiteralTest { + /** {@literal if (a < b) { }} */ + void minimal() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 1 + Literal[LITERAL, pos:0, if_(a_<_b)_{_}] + body: empty + block tags: empty +] +*/ + + /** [{@literal if (a < b) { }}] */ + void in_brackets() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 3 + Text[TEXT, pos:0, [] + Literal[LITERAL, pos:1, if_(a_<_b)_{_}] + Text[TEXT, pos:26, ]] + body: empty + block tags: empty +] +*/ + + /** [ {@literal if (a < b) { }} ] */ + void in_brackets_with_whitespace() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 3 + Text[TEXT, pos:0, [_] + Literal[LITERAL, pos:2, if_(a_<_b)_{_}] + Text[TEXT, pos:27, _]] + body: empty + block tags: empty +] +*/ + + /** + * {@literal {@literal nested} } + */ + void nested() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Literal[LITERAL, pos:1, {@literal_nested}_] + body: empty + block tags: empty +] +*/ + + /** + * {@literal if (a < b) { + * } + * } + */ + void embedded_newline() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Literal[LITERAL, pos:1, if_(a_<_b)_{|________}|_] + body: empty + block tags: empty +] +*/ + + + /** {@literal if (a < b) { } */ + void unterminated_1() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 1 + Erroneous[ERRONEOUS, pos:0 + code: compiler.err.dc.unterminated.inline.tag + body: {@literal_if_(a_<_b)_{_} + ] + body: empty + block tags: empty +] +*/ + + /** + * {@literal if (a < b) { } + * @author jjg */ + void unterminated_2() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Erroneous[ERRONEOUS, pos:1 + code: compiler.err.dc.unterminated.inline.tag + body: {@literal_if_(a_<_b)_{_} + ] + body: empty + block tags: 1 + Author[AUTHOR, pos:27 + name: 1 + Text[TEXT, pos:35, jjg] + ] +] +*/ + +} + diff --git a/langtools/test/tools/javac/doctree/ParamTest.java b/langtools/test/tools/javac/doctree/ParamTest.java new file mode 100644 index 00000000000..483e800f1b7 --- /dev/null +++ b/langtools/test/tools/javac/doctree/ParamTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester ParamTest.java + */ + +class ParamTest { + /** + * @param x + */ + void no_description(int x) { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Param[PARAM, pos:1 + name: + Identifier[IDENTIFIER, pos:8, x] + description: empty + ] +] +*/ + + /** + * @param x description + */ + void with_description(int x) { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Param[PARAM, pos:1 + name: + Identifier[IDENTIFIER, pos:8, x] + description: 1 + Text[TEXT, pos:10, description] + ] +] +*/ + +} diff --git a/langtools/test/tools/javac/doctree/ReferenceTest.java b/langtools/test/tools/javac/doctree/ReferenceTest.java new file mode 100644 index 00000000000..ee987ece007 --- /dev/null +++ b/langtools/test/tools/javac/doctree/ReferenceTest.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @summary check references in at-see and {at-link} tags + * @build ReferenceTest + * @compile -processor ReferenceTest -proc:only ReferenceTest.java + */ + +import com.sun.source.doctree.DocCommentTree; +import com.sun.source.doctree.DocTree; +import com.sun.source.doctree.LinkTree; +import com.sun.source.doctree.ReferenceTree; +import com.sun.source.doctree.SeeTree; +import com.sun.source.doctree.TextTree; +import com.sun.source.util.DocTreeScanner; +import com.sun.source.util.DocTrees; +import com.sun.source.util.TreePath; + +import java.util.List; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.ProcessingEnvironment; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic.Kind; + +/** + * {@link java.lang Package} + * {@link java.lang.ERROR Bad} + * + * {@link java.lang.String Class} + * {@link String Class} + * {@link java.lang.String#CASE_INSENSITIVE_ORDER Field} + * {@link java.lang.String#String Constructor} + * {@link java.lang.String#String(byte[]) Constructor} + * {@link java.lang.String#String(byte[] bytes) Constructor} + * {@link java.lang.String#String(byte[], String) Constructor} + * {@link java.lang.String#String(byte[] bytes, String charSetName) Constructor} + * {@link java.lang.String#isEmpty Method} + * {@link java.lang.String#isEmpty() Method} + * {@link java.lang.String#ERROR Bad} + * {@link java.lang.String#equals(Object) Method} + * + * {@link AbstractProcessor Class} + * + * {@link List#add(Object) Method} + * + * {@link #trees Field} + * {@link #getSupportedSourceVersion Method} + * {@link #init(ProcessingEnvironment Method} + * + * @see java.lang Package + * @see java.lang.ERROR Bad + * + * @see java.lang.String Class + * @see String Class + * @see java.lang.String#CASE_INSENSITIVE_ORDER Field + * @see java.lang.String#String Constructor + * @see java.lang.String#String(byte[]) Constructor + * @see java.lang.String#String(byte[] bytes) Constructor + * @see java.lang.String#String(byte[],String) Constructor + * @see java.lang.String#String(byte[] bytes, String charsetName) Constructor + * @see java.lang.String#isEmpty Method + * @see java.lang.String#isEmpty() Method + * @see java.lang.String#ERROR Bad + * @see java.lang.String#equals(Object) Method + * + * @see AbstractProcessor Class + * + * @see List#add(Object) Method + * + * @see #trees Field + * @see #getSupportedSourceVersion Method + * @see #init(ProcessingEnvironment) Method + * + * @see java.io.BufferedInputStream#BufferedInputStream(InputStream) Constructor + */ +@SupportedAnnotationTypes("*") +public class ReferenceTest extends AbstractProcessor { + DocTrees trees; + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public void init(ProcessingEnvironment pEnv) { + super.init(pEnv); + trees = DocTrees.instance(pEnv); + } + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + for (Element e: roundEnv.getRootElements()) { + new DocCommentScanner(trees.getPath(e)).scan(); + } + return true; + } + + class DocCommentScanner extends DocTreeScanner { + TreePath path; + DocCommentTree dc; + + DocCommentScanner(TreePath path) { + this.path = path; + } + + void scan() { + dc = trees.getDocCommentTree(path); + scan(dc, null); + } + + @Override + public Void visitLink(LinkTree tree, Void ignore) { + checkReference(tree.getReference(), tree.getLabel()); + return null; + } + + @Override + public Void visitSee(SeeTree tree, Void ignore) { + List refLabel = tree.getReference(); + if (refLabel.size() > 1 && (refLabel.get(0) instanceof ReferenceTree)) { + ReferenceTree ref = (ReferenceTree) refLabel.get(0); + List label = refLabel.subList(1, refLabel.size()); + checkReference(ref, label); + } + return null; + } + + void checkReference(ReferenceTree tree, List label) { + String sig = tree.getSignature(); + + Element found = trees.getElement(path, tree); + if (found == null) { + System.err.println(sig + " NOT FOUND"); + } else { + System.err.println(sig + " found " + found.getKind() + " " + found); + } + + String expect = "UNKNOWN"; + if (label.size() > 0 && label.get(0) instanceof TextTree) + expect = ((TextTree) label.get(0)).getBody(); + + if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { + error(tree, "Unexpected value found: " + found +", expected: " + expect); + } + } + + void error(DocTree tree, String msg) { + trees.printMessage(Kind.ERROR, msg, tree, dc, path.getCompilationUnit()); + } + } +} + +/** + * @see ReferenceTestExtras Class + * @see #ReferenceTestExtras Field + * @see #ReferenceTestExtras() Constructor + * + * @see #X Field + * @see #X() Method + * + * @see #m Method + * + * @see #varargs(int...) Method + * @see #varargs(int... args) Method + * @see #varargs(int[]) Method + * @see #varargs(int[] args) Method + */ +class ReferenceTestExtras { + int ReferenceTestExtras; // field + ReferenceTestExtras() { } // constructor + void ReferenceTestExtras() { } // method + + int X; + void X() { } + static class X { } + + void m() { } + void m(int i) { } + void m(int i, int j) { } + + void varargs(int... args) { } +} + + diff --git a/langtools/test/tools/javac/doctree/ReturnTest.java b/langtools/test/tools/javac/doctree/ReturnTest.java new file mode 100644 index 00000000000..e79a91faf44 --- /dev/null +++ b/langtools/test/tools/javac/doctree/ReturnTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester ReturnTest.java + */ + +class ReturnTest { + /** + * @return something + */ + int an_int() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Return[RETURN, pos:1 + description: 1 + Text[TEXT, pos:9, something] + ] +] +*/ + +} + + diff --git a/langtools/test/tools/javac/doctree/SeeTest.java b/langtools/test/tools/javac/doctree/SeeTest.java new file mode 100644 index 00000000000..bb2734814d9 --- /dev/null +++ b/langtools/test/tools/javac/doctree/SeeTest.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester SeeTest.java + */ + +class SeeTest { + /** + * abc. + * @see "String" + */ + void quoted_text() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc.] + body: empty + block tags: 1 + Erroneous[ERRONEOUS, pos:7 + code: compiler.err.dc.unexpected.content + body: @see_"String" + ] +] +*/ + + /** + * abc. + * @see
url + */ + void url() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc.] + body: empty + block tags: 1 + See[SEE, pos:7 + reference: 3 + StartElement[START_ELEMENT, pos:12 + name:a + attributes: 1 + Attribute[ATTRIBUTE, pos:15 + name: href + vkind: DOUBLE + value: 1 + Text[TEXT, pos:21, url] + ] + ] + Text[TEXT, pos:26, url] + EndElement[END_ELEMENT, pos:29, a] + ] +] +*/ + + /** + * abc. + * @see String text + */ + void string() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc.] + body: empty + block tags: 1 + See[SEE, pos:7 + reference: 2 + Reference[REFERENCE, pos:12, String] + Text[TEXT, pos:19, text] + ] +] +*/ + + /** + * abc. + * @see java.lang.String text + */ + void j_l_string() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc.] + body: empty + block tags: 1 + See[SEE, pos:7 + reference: 2 + Reference[REFERENCE, pos:12, java.lang.String] + Text[TEXT, pos:29, text] + ] +] +*/ + + /** + * abc. + * @see java.lang.String#length text + */ + void j_l_string_length() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc.] + body: empty + block tags: 1 + See[SEE, pos:7 + reference: 2 + Reference[REFERENCE, pos:12, java.lang.String#length] + Text[TEXT, pos:36, text] + ] +] +*/ + + /** + * abc. + * @see java.lang.String#matches(String regex) text + */ + void j_l_string_matches() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc.] + body: empty + block tags: 1 + See[SEE, pos:7 + reference: 2 + Reference[REFERENCE, pos:12, java.lang.String...#matches(String_regex)] + Text[TEXT, pos:51, text] + ] +] +*/ + + /** + * abc. + * @see 123 text + */ + void bad_numeric() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc.] + body: empty + block tags: 1 + Erroneous[ERRONEOUS, pos:7 + code: compiler.err.dc.unexpected.content + body: @see_123_text + ] +] +*/ + +} diff --git a/langtools/test/tools/javac/doctree/SerialDataTest.java b/langtools/test/tools/javac/doctree/SerialDataTest.java new file mode 100644 index 00000000000..f68be7453b1 --- /dev/null +++ b/langtools/test/tools/javac/doctree/SerialDataTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester SerialDataTest.java + */ + +class SerialDataTest { + /** + * @serialData description + */ + void writeObject(ObjectOutputStream stream) { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + SerialData[SERIAL_DATA, pos:1 + description: 1 + Text[TEXT, pos:13, description] + ] +] +*/ + +} + diff --git a/langtools/test/tools/javac/doctree/SerialFieldTest.java b/langtools/test/tools/javac/doctree/SerialFieldTest.java new file mode 100644 index 00000000000..aeffcbc9ebc --- /dev/null +++ b/langtools/test/tools/javac/doctree/SerialFieldTest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester SerialFieldTest.java + */ + +class SerialFieldTest { + + /** + * @serialField field String + */ + String f1; +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + SerialField[SERIAL_FIELD, pos:1 + name: + Identifier[IDENTIFIER, pos:14, field] + type: + Reference[REFERENCE, pos:20, String] + description: empty + ] +] +*/ + + /** + * @serialField field String f2 is a String + */ + String f2; +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + SerialField[SERIAL_FIELD, pos:1 + name: + Identifier[IDENTIFIER, pos:14, field] + type: + Reference[REFERENCE, pos:20, String] + description: 1 + Text[TEXT, pos:27, f2_is_a_String] + ] +] +*/ + +} + diff --git a/langtools/test/tools/javac/doctree/SerialTest.java b/langtools/test/tools/javac/doctree/SerialTest.java new file mode 100644 index 00000000000..14f025c4910 --- /dev/null +++ b/langtools/test/tools/javac/doctree/SerialTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester SerialTest.java + */ + +class SerialTest { + /** + * @serial include + */ + void include() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Serial[SERIAL, pos:1 + description: 1 + Text[TEXT, pos:9, include] + ] +] +*/ + + /** + * @serial exclude + */ + void exclude() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Serial[SERIAL, pos:1 + description: 1 + Text[TEXT, pos:9, exclude] + ] +] +*/ + + /** + * @serial description + */ + void description() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Serial[SERIAL, pos:1 + description: 1 + Text[TEXT, pos:9, description] + ] +] +*/ + + /** + * @serial + */ + void empty() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Serial[SERIAL, pos:1 + description: empty + ] +] +*/ + +} + diff --git a/langtools/test/tools/javac/doctree/SimpleDocTreeVisitorTest.java b/langtools/test/tools/javac/doctree/SimpleDocTreeVisitorTest.java new file mode 100644 index 00000000000..8b0bf810012 --- /dev/null +++ b/langtools/test/tools/javac/doctree/SimpleDocTreeVisitorTest.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + */ + +import com.sun.source.doctree.DocCommentTree; +import com.sun.source.doctree.DocTree; +import com.sun.source.doctree.DocTreeVisitor; +import com.sun.source.tree.ClassTree; +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.MethodTree; +import com.sun.source.tree.Tree; +import com.sun.source.tree.VariableTree; +import com.sun.source.util.DocTreeScanner; +import com.sun.source.util.DocTrees; +import com.sun.source.util.JavacTask; +import com.sun.source.util.SimpleDocTreeVisitor; +import com.sun.source.util.TreePath; +import com.sun.source.util.TreePathScanner; +import com.sun.tools.javac.api.JavacTool; +import java.io.File; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import java.util.Set; +import javax.lang.model.element.Name; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; + +public class SimpleDocTreeVisitorTest { + public static void main(String... args) throws Exception { + SimpleDocTreeVisitorTest t = new SimpleDocTreeVisitorTest(); + t.run(); + } + + void run() throws Exception { + List files = new ArrayList(); + File testSrc = new File(System.getProperty("test.src")); + for (File f: testSrc.listFiles()) { + if (f.isFile() && f.getName().endsWith(".java")) + files.add(f); + } + + JavacTool javac = JavacTool.create(); + StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); + + Iterable fos = fm.getJavaFileObjectsFromFiles(files); + + JavacTask t = javac.getTask(null, fm, null, null, null, fos); + DocTrees trees = DocTrees.instance(t); + + Iterable units = t.parse(); + + Set found = EnumSet.noneOf(DocTree.Kind.class); + DeclScanner ds = new DeclScanner(trees, found); + for (CompilationUnitTree unit: units) { + ds.scan(unit, null); + } + + for (DocTree.Kind k: DocTree.Kind.values()) { + if (!found.contains(k) && k != DocTree.Kind.OTHER) + error("not found: " + k); + } + + if (errors > 0) + throw new Exception(errors + " errors occurred"); + } + + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + int errors; + + static class DeclScanner extends TreePathScanner { + DocTrees trees; + DocTreeScanner cs; + + DeclScanner(DocTrees trees, final Set found) { + this.trees = trees; + cs = new CommentScanner(found); + } + + @Override + public Void visitClass(ClassTree tree, Void ignore) { + super.visitClass(tree, ignore); + visitDecl(tree, tree.getSimpleName()); + return null; + } + + @Override + public Void visitMethod(MethodTree tree, Void ignore) { + super.visitMethod(tree, ignore); + visitDecl(tree, tree.getName()); + return null; + } + + @Override + public Void visitVariable(VariableTree tree, Void ignore) { + super.visitVariable(tree, ignore); + visitDecl(tree, tree.getName()); + return null; + } + + void visitDecl(Tree tree, Name name) { + TreePath path = getCurrentPath(); + DocCommentTree dc = trees.getDocCommentTree(path); + if (dc != null) + cs.scan(dc, null); + } + } + + static class CommentScanner extends DocTreeScanner { + DocTreeVisitor visitor; + + CommentScanner(Set found) { + visitor = new Visitor(found); + } + + @Override + public Void scan(DocTree tree, Void ignore) { + if (tree != null) + tree.accept(visitor, ignore); + return super.scan(tree, ignore); + } + } + + static class Visitor extends SimpleDocTreeVisitor { + Set found; + + Visitor(Set found) { + this.found = found; + } + + @Override + public Void defaultAction(DocTree tree, Void ignore) { + found.add(tree.getKind()); + return null; + } + } +} diff --git a/langtools/test/tools/javac/doctree/SinceTest.java b/langtools/test/tools/javac/doctree/SinceTest.java new file mode 100644 index 00000000000..d2f3ae2aafb --- /dev/null +++ b/langtools/test/tools/javac/doctree/SinceTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester SinceTest.java + */ + +class SinceTest { + /** + * abc. + * @since then & now. + */ + void standard() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, abc.] + body: empty + block tags: 1 + Since[SINCE, pos:7 + body: 3 + Text[TEXT, pos:14, then_] + Entity[ENTITY, pos:19, amp] + Text[TEXT, pos:24, _now.] + ] +] +*/ + +} diff --git a/langtools/test/tools/javac/doctree/TagTest.java b/langtools/test/tools/javac/doctree/TagTest.java new file mode 100644 index 00000000000..5657accf915 --- /dev/null +++ b/langtools/test/tools/javac/doctree/TagTest.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester TagTest.java + */ + +class TagTest { + /** + * @author jjg + */ + void simple_standard_block() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Author[AUTHOR, pos:1 + name: 1 + Text[TEXT, pos:9, jjg] + ] +] +*/ + + /** + * @ abc + */ + void no_name_block() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Erroneous[ERRONEOUS, pos:1 + code: compiler.err.dc.no.tag.name + body: @_abc + ] +] +*/ + + /** + * @abc def ghi + */ + void unknown_name_block() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + UnknownBlockTag[UNKNOWN_BLOCK_TAG, pos:1 + tag:abc + content: 1 + Text[TEXT, pos:6, def_ghi] + ] +] +*/ + + /** + * {@link String} + */ + void simple_standard_inline() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Link[LINK, pos:1 + reference: + Reference[REFERENCE, pos:8, String] + body: empty + ] + body: empty + block tags: empty +] +*/ + + /** + * {@ abc} + */ + void no_name_inline() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 2 + Erroneous[ERRONEOUS, pos:1 + code: compiler.err.dc.no.tag.name + body: {@ + ] + Text[TEXT, pos:3, _abc}] + body: empty + block tags: empty +] +*/ + + /** + * {@abc def ghi} + */ + void unknown_name_inline() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + UnknownInlineTag[UNKNOWN_INLINE_TAG, pos:1 + tag:abc + content: 1 + Text[TEXT, pos:7, def_ghi] + ] + body: empty + block tags: empty +] +*/ + + /** + * {@abc def ghi + */ + void unterminated_standard_inline() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Erroneous[ERRONEOUS, pos:1 + code: compiler.err.dc.unterminated.inline.tag + body: {@abc_def_ghi + ] + body: empty + block tags: empty +] +*/ + +} diff --git a/langtools/test/tools/javac/doctree/ThrowableTest.java b/langtools/test/tools/javac/doctree/ThrowableTest.java new file mode 100644 index 00000000000..31e49e7772c --- /dev/null +++ b/langtools/test/tools/javac/doctree/ThrowableTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester ThrowableTest.java + */ + +class ThrowableTest { + /** + * @throws Exception + */ + void exception() throws Exception { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Throws[THROWS, pos:1 + exceptionName: + Reference[REFERENCE, pos:9, Exception] + description: empty + ] +] +*/ + + /** + * @throws Exception text + */ + void exception_text() throws Exception { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Throws[THROWS, pos:1 + exceptionName: + Reference[REFERENCE, pos:9, Exception] + description: 1 + Text[TEXT, pos:19, text] + ] +] +*/ + +} + diff --git a/langtools/test/tools/javac/doctree/ValueTest.java b/langtools/test/tools/javac/doctree/ValueTest.java new file mode 100644 index 00000000000..1e144175d0c --- /dev/null +++ b/langtools/test/tools/javac/doctree/ValueTest.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester ValueTest.java + */ + +class ValueTest { + /** + * abc {@value} + */ + int no_ref() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 2 + Text[TEXT, pos:1, abc_] + Value[VALUE, pos:5 + reference: null + ] + body: empty + block tags: empty +] +*/ + + /** + * abc {@value java.awt.Color#RED} + */ + int typical() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 2 + Text[TEXT, pos:1, abc_] + Value[VALUE, pos:5 + reference: + Reference[REFERENCE, pos:13, java.awt.Color#RED] + ] + body: empty + block tags: empty +] +*/ + + /** + * abc {@value java.awt.Color#RED } + */ + int trailing_ws() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 2 + Text[TEXT, pos:1, abc_] + Value[VALUE, pos:5 + reference: + Reference[REFERENCE, pos:13, java.awt.Color#RED] + ] + body: empty + block tags: empty +] +*/ + + /** + * abc {@value java.awt.Color#RED junk} + */ + int trailing_junk() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + Text[TEXT, pos:1, abc_] + Erroneous[ERRONEOUS, pos:5 + code: compiler.err.dc.unexpected.content + body: {@value_java.awt.Color#RED_j + ] + Text[TEXT, pos:33, unk}] + body: empty + block tags: empty +] +*/ + +} + + diff --git a/langtools/test/tools/javac/doctree/VersionTest.java b/langtools/test/tools/javac/doctree/VersionTest.java new file mode 100644 index 00000000000..cbd6b8f131d --- /dev/null +++ b/langtools/test/tools/javac/doctree/VersionTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7021614 + * @summary extend com.sun.source API to support parsing javadoc comments + * @build DocCommentTester + * @run main DocCommentTester VersionTest.java + */ + +class VersionTest { + /** + * @version 1.2 + */ + void version() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: empty + body: empty + block tags: 1 + Version[VERSION, pos:1 + body: 1 + Text[TEXT, pos:10, 1.2] + ] +] +*/ + +} + + From bbe12c2488a342d9103a9c700a05f992f2cb0e98 Mon Sep 17 00:00:00 2001 From: Peter Levart Date: Wed, 14 Nov 2012 22:37:38 -0500 Subject: [PATCH 23/94] 8003259: NPG: Build with gcc 4.7.2 broken by 7045397 Qualify calls with this pointers to make gcc accept this code. Reviewed-by: coleenp, andrew --- hotspot/src/share/vm/memory/binaryTreeDictionary.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/memory/binaryTreeDictionary.cpp b/hotspot/src/share/vm/memory/binaryTreeDictionary.cpp index f79d149f1e5..e0fde430bfb 100644 --- a/hotspot/src/share/vm/memory/binaryTreeDictionary.cpp +++ b/hotspot/src/share/vm/memory/binaryTreeDictionary.cpp @@ -239,7 +239,7 @@ TreeList* TreeList::remove_chunk_repla } else { if (nextTC == NULL) { // Removing chunk at tail of list - link_tail(prevFC); + this->link_tail(prevFC); } // Chunk is interior to the list prevFC->link_after(nextTC); @@ -296,7 +296,7 @@ void TreeList::return_chunk_at_tail(TreeChunklink_after(chunk); - link_tail(chunk); + this->link_tail(chunk); assert(!tail() || size() == tail()->size(), "Wrong sized chunk in list"); FreeList_t::increment_count(); @@ -323,7 +323,7 @@ void TreeList::return_chunk_at_head(TreeChunklink_after(fc); } else { assert(tail() == NULL, "List is inconsistent"); - link_tail(chunk); + this->link_tail(chunk); } head()->link_after(chunk); assert(!head() || size() == head()->size(), "Wrong sized chunk in list"); @@ -940,7 +940,7 @@ class AscendTreeCensusClosure : public TreeCensusClosure { void do_tree(TreeList* tl) { if (tl != NULL) { do_tree(tl->left()); - do_list(tl); + this->do_list(tl); do_tree(tl->right()); } } @@ -952,7 +952,7 @@ class DescendTreeCensusClosure : public TreeCensusClosure { void do_tree(TreeList* tl) { if (tl != NULL) { do_tree(tl->right()); - do_list(tl); + this->do_list(tl); do_tree(tl->left()); } } @@ -1022,7 +1022,7 @@ class DescendTreeSearchClosure : public TreeSearchClosure { bool do_tree(TreeList* tl) { if (tl != NULL) { if (do_tree(tl->right())) return true; - if (do_list(tl)) return true; + if (this->do_list(tl)) return true; if (do_tree(tl->left())) return true; } return false; From ed633a2108a737d594f9928ca6ef164a3d133d7a Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 15 Nov 2012 09:18:36 -0800 Subject: [PATCH 24/94] 8000800: javadoc uses static non-final fields Reviewed-by: bpatel --- .../html/AbstractExecutableMemberWriter.java | 18 ++-- .../formats/html/AbstractIndexWriter.java | 3 +- .../formats/html/AbstractMemberWriter.java | 26 +++--- .../formats/html/AbstractTreeWriter.java | 2 +- .../formats/html/AllClassesFrameWriter.java | 5 +- ...nnotationTypeOptionalMemberWriterImpl.java | 14 ++-- ...nnotationTypeRequiredMemberWriterImpl.java | 22 ++--- .../html/AnnotationTypeWriterImpl.java | 16 ++-- .../doclets/formats/html/ClassUseWriter.java | 20 ++--- .../doclets/formats/html/ClassWriterImpl.java | 50 +++++------ .../formats/html/ConfigurationImpl.java | 20 +---- .../html/ConstantsSummaryWriterImpl.java | 8 +- .../formats/html/ConstructorWriterImpl.java | 28 +++---- .../formats/html/EnumConstantWriterImpl.java | 22 ++--- .../doclets/formats/html/FieldWriterImpl.java | 30 +++---- .../doclets/formats/html/HtmlDoclet.java | 32 ++++--- .../formats/html/HtmlDocletWriter.java | 35 ++++---- .../formats/html/HtmlSerialFieldWriter.java | 8 +- .../formats/html/HtmlSerialMethodWriter.java | 2 +- .../doclets/formats/html/LinkFactoryImpl.java | 10 +-- .../doclets/formats/html/LinkInfoImpl.java | 67 +++++++++++---- .../formats/html/MethodWriterImpl.java | 40 ++++----- .../formats/html/NestedClassWriterImpl.java | 28 +++---- .../formats/html/PackageFrameWriter.java | 4 +- .../formats/html/PackageUseWriter.java | 4 +- .../formats/html/PackageWriterImpl.java | 3 +- .../html/SerializedFormWriterImpl.java | 13 +-- .../formats/html/SourceToHTMLConverter.java | 66 ++++++++------- .../formats/html/TagletWriterImpl.java | 34 ++++---- .../formats/html/WriterFactoryImpl.java | 37 ++++---- .../doclets/formats/html/markup/DocType.java | 30 ++----- .../formats/html/markup/HtmlDocWriter.java | 2 +- .../internal/toolkit/AbstractDoclet.java | 4 +- .../internal/toolkit/Configuration.java | 14 +++- .../toolkit/builders/AbstractBuilder.java | 38 ++++++++- .../builders/AbstractMemberBuilder.java | 6 +- .../builders/AnnotationTypeBuilder.java | 37 ++++---- .../AnnotationTypeOptionalMemberBuilder.java | 37 ++++---- .../AnnotationTypeRequiredMemberBuilder.java | 43 +++++----- .../toolkit/builders/BuilderFactory.java | 49 ++++++----- .../toolkit/builders/ClassBuilder.java | 55 ++++++------ .../builders/ConstantsSummaryBuilder.java | 30 ++++--- .../toolkit/builders/ConstructorBuilder.java | 68 ++++++++------- .../toolkit/builders/EnumConstantBuilder.java | 55 ++++++------ .../toolkit/builders/FieldBuilder.java | 55 ++++++------ .../toolkit/builders/LayoutParser.java | 11 +-- .../builders/MemberSummaryBuilder.java | 84 ++++++++++--------- .../toolkit/builders/MethodBuilder.java | 58 +++++++------ .../builders/PackageSummaryBuilder.java | 37 ++++---- .../builders/SerializedFormBuilder.java | 18 ++-- .../toolkit/taglets/InheritDocTaglet.java | 10 ++- .../toolkit/taglets/TagletWriter.java | 6 +- .../doclets/internal/toolkit/util/Util.java | 70 ++++++++++------ .../com/sun/tools/javadoc/ParamTagImpl.java | 2 +- .../test/com/sun/javadoc/MetaTag/MetaTag.java | 11 +-- .../testHtmlDocument/TestHtmlDocument.java | 4 +- 56 files changed, 791 insertions(+), 710 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java index 6633b78dc82..314183dd1fa 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java @@ -45,7 +45,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*; public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter { public AbstractExecutableMemberWriter(SubWriterHolderWriter writer, - ClassDoc classdoc) { + ClassDoc classdoc) { super(writer, classdoc); } @@ -61,7 +61,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite * @return the display length required to write this information. */ protected int addTypeParameters(ExecutableMemberDoc member, Content htmltree) { - LinkInfoImpl linkInfo = new LinkInfoImpl( + LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER_TYPE_PARAMS, member, false); String typeParameters = writer.getTypeParameterLinks(linkInfo); if (linkInfo.displayLength > 0) { @@ -129,8 +129,8 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite boolean isVarArg, Content tree) { if (param.type() != null) { Content link = new RawHtml(writer.getLink(new LinkInfoImpl( - LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, param.type(), - isVarArg))); + configuration, LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, + param.type(), isVarArg))); tree.addContent(link); } if(param.name().length() > 0) { @@ -161,7 +161,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite htmltree.addContent("("); Parameter[] params = member.parameters(); String indent = makeSpace(writer.displayLength); - if (configuration().linksource) { + if (configuration.linksource) { //add spaces to offset indentation changes caused by link. indent+= makeSpace(member.name().length()); } @@ -212,7 +212,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite protected void addExceptions(ExecutableMemberDoc member, Content htmltree) { Type[] exceptions = member.thrownExceptionTypes(); if(exceptions.length > 0) { - LinkInfoImpl memberTypeParam = new LinkInfoImpl( + LinkInfoImpl memberTypeParam = new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER, member, false); int retlen = getReturnTypeLength(member); writer.getTypeParameterLinks(memberTypeParam); @@ -224,7 +224,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite htmltree.addContent(indent); htmltree.addContent("throws "); indent += " "; - Content link = new RawHtml(writer.getLink(new LinkInfoImpl( + Content link = new RawHtml(writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER, exceptions[0]))); htmltree.addContent(link); for(int i = 1; i < exceptions.length; i++) { @@ -232,7 +232,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite htmltree.addContent(DocletConstants.NL); htmltree.addContent(indent); Content exceptionLink = new RawHtml(writer.getLink(new LinkInfoImpl( - LinkInfoImpl.CONTEXT_MEMBER, exceptions[i]))); + configuration, LinkInfoImpl.CONTEXT_MEMBER, exceptions[i]))); htmltree.addContent(exceptionLink); } } @@ -246,7 +246,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite return rettype.typeName().length() + rettype.dimension().length(); } else { - LinkInfoImpl linkInfo = new LinkInfoImpl( + LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER, rettype); writer.getLink(linkInfo); return linkInfo.displayLength; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java index 3db480cfcdf..62dabe3ec17 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java @@ -140,7 +140,8 @@ public class AbstractIndexWriter extends HtmlDocletWriter { */ protected void addDescription(ClassDoc cd, Content dlTree) { Content link = new RawHtml( - getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true))); + getLink(new LinkInfoImpl(configuration, + LinkInfoImpl.CONTEXT_INDEX, cd, true))); Content dt = HtmlTree.DT(link); dt.addContent(" - "); addClassInfo(cd, dt); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java index df2e8af8d79..262abc8e50f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java @@ -49,15 +49,17 @@ import com.sun.tools.doclets.internal.toolkit.util.*; */ public abstract class AbstractMemberWriter { - protected boolean printedSummaryHeader = false; + protected final ConfigurationImpl configuration; protected final SubWriterHolderWriter writer; protected final ClassDoc classdoc; public final boolean nodepr; - public AbstractMemberWriter(SubWriterHolderWriter writer, - ClassDoc classdoc) { + protected boolean printedSummaryHeader = false; + + public AbstractMemberWriter(SubWriterHolderWriter writer, ClassDoc classdoc) { + this.configuration = writer.configuration; this.writer = writer; - this.nodepr = configuration().nodeprecated; + this.nodepr = configuration.nodeprecated; this.classdoc = classdoc; } @@ -281,11 +283,11 @@ public abstract class AbstractMemberWriter { code.addContent(new HtmlTree(HtmlTag.BR)); } code.addContent(new RawHtml( - writer.getLink(new LinkInfoImpl( + writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type)))); } else { code.addContent(new RawHtml( - writer.getLink(new LinkInfoImpl( + writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type)))); } @@ -305,7 +307,7 @@ public abstract class AbstractMemberWriter { } else if (member.isPrivate()) { code.addContent("private "); } else if (!member.isPublic()) { // Package private - code.addContent(configuration().getText("doclet.Package_private")); + code.addContent(configuration.getText("doclet.Package_private")); code.addContent(" "); } if (member.isMethod() && ((MethodDoc)member).isAbstract()) { @@ -389,7 +391,7 @@ public abstract class AbstractMemberWriter { String tableSummary, String[] tableHeader, Content contentTree) { if (deprmembers.size() > 0) { Content table = HtmlTree.TABLE(0, 3, 0, tableSummary, - writer.getTableCaption(configuration().getText(headingKey))); + writer.getTableCaption(configuration.getText(headingKey))); table.addContent(writer.getSummaryTableHeader(tableHeader, "col")); Content tbody = new HtmlTree(HtmlTag.TBODY); for (int i = 0; i < deprmembers.size(); i++) { @@ -507,8 +509,8 @@ public abstract class AbstractMemberWriter { } protected void serialWarning(SourcePosition pos, String key, String a1, String a2) { - if (configuration().serialwarn) { - ConfigurationImpl.getInstance().getDocletSpecificMsg().warning(pos, key, a1, a2); + if (configuration.serialwarn) { + configuration.getDocletSpecificMsg().warning(pos, key, a1, a2); } } @@ -516,10 +518,6 @@ public abstract class AbstractMemberWriter { return nodepr? Util.excludeDeprecatedMembers(members): members; } - public ConfigurationImpl configuration() { - return writer.configuration; - } - /** * Add the member summary for the given class. * diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java index 63786f474f0..53af067c6c9 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java @@ -138,7 +138,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter { for (int i = 0; i < interfaces.length; i++) { if (parent != interfaces[i]) { if (! (interfaces[i].isPublic() || - Util.isLinkable(interfaces[i], configuration()))) { + Util.isLinkable(interfaces[i], configuration))) { continue; } if (counter == 0) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java index af0f4a24f81..85b8ce9791c 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java @@ -159,10 +159,11 @@ public class AllClassesFrameWriter extends HtmlDocletWriter { String label = italicsClassName(cd, false); Content linkContent; if(wantFrames){ - linkContent = new RawHtml(getLink(new LinkInfoImpl( + linkContent = new RawHtml(getLink(new LinkInfoImpl(configuration, LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame"))); } else { - linkContent = new RawHtml(getLink(new LinkInfoImpl(cd, label))); + linkContent = new RawHtml(getLink(new LinkInfoImpl( + configuration, cd, label))); } Content li = HtmlTree.LI(linkContent); content.addContent(li); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java index 03e04e79946..cf8fba180a7 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java @@ -103,16 +103,16 @@ public class AnnotationTypeOptionalMemberWriterImpl extends * {@inheritDoc} */ public String getTableSummary() { - return configuration().getText("doclet.Member_Table_Summary", - configuration().getText("doclet.Annotation_Type_Optional_Member_Summary"), - configuration().getText("doclet.annotation_type_optional_members")); + return configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Annotation_Type_Optional_Member_Summary"), + configuration.getText("doclet.annotation_type_optional_members")); } /** * {@inheritDoc} */ public String getCaption() { - return configuration().getText("doclet.Annotation_Type_Optional_Members"); + return configuration.getText("doclet.Annotation_Type_Optional_Members"); } /** @@ -121,9 +121,9 @@ public class AnnotationTypeOptionalMemberWriterImpl extends public String[] getSummaryTableHeader(ProgramElementDoc member) { String[] header = new String[] { writer.getModifierTypeHeader(), - configuration().getText("doclet.0_and_1", - configuration().getText("doclet.Annotation_Type_Optional_Member"), - configuration().getText("doclet.Description")) + configuration.getText("doclet.0_and_1", + configuration.getText("doclet.Annotation_Type_Optional_Member"), + configuration.getText("doclet.Description")) }; return header; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java index 2fe1f662c1e..daee94e5bf9 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java @@ -52,7 +52,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter * @param annotationType the AnnotationType that holds this member. */ public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer, - AnnotationTypeDoc annotationType) { + AnnotationTypeDoc annotationType) { super(writer, annotationType); } @@ -106,11 +106,11 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter writer.addAnnotationInfo(member, pre); addModifiers(member, pre); Content link = new RawHtml( - writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, - getType(member)))); + writer.getLink(new LinkInfoImpl(configuration, + LinkInfoImpl.CONTEXT_MEMBER, getType(member)))); pre.addContent(link); pre.addContent(writer.getSpace()); - if (configuration().linksource) { + if (configuration.linksource) { Content memberName = new StringContent(member.name()); writer.addSrcLink(member, memberName, pre); } else { @@ -175,16 +175,16 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter * {@inheritDoc} */ public String getTableSummary() { - return configuration().getText("doclet.Member_Table_Summary", - configuration().getText("doclet.Annotation_Type_Required_Member_Summary"), - configuration().getText("doclet.annotation_type_required_members")); + return configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Annotation_Type_Required_Member_Summary"), + configuration.getText("doclet.annotation_type_required_members")); } /** * {@inheritDoc} */ public String getCaption() { - return configuration().getText("doclet.Annotation_Type_Required_Members"); + return configuration.getText("doclet.Annotation_Type_Required_Members"); } /** @@ -193,9 +193,9 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter public String[] getSummaryTableHeader(ProgramElementDoc member) { String[] header = new String[] { writer.getModifierTypeHeader(), - configuration().getText("doclet.0_and_1", - configuration().getText("doclet.Annotation_Type_Required_Member"), - configuration().getText("doclet.Description")) + configuration.getText("doclet.0_and_1", + configuration.getText("doclet.Annotation_Type_Required_Member"), + configuration.getText("doclet.Description")) }; return header; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java index 636522e0cc3..a86312e7660 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java @@ -65,10 +65,10 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter * @param prevType the previous class that was documented. * @param nextType the next class being documented. */ - public AnnotationTypeWriterImpl(AnnotationTypeDoc annotationType, - Type prevType, Type nextType) + public AnnotationTypeWriterImpl(ConfigurationImpl configuration, + AnnotationTypeDoc annotationType, Type prevType, Type nextType) throws Exception { - super(ConfigurationImpl.getInstance(), DocPath.forClass(annotationType)); + super(configuration, DocPath.forClass(annotationType)); this.annotationType = annotationType; configuration.currentcd = annotationType.asClassDoc(); this.prev = prevType; @@ -116,7 +116,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter public Content getNavLinkPrevious() { Content li; if (prev != null) { - Content prevLink = new RawHtml(getLink(new LinkInfoImpl( + Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS, prev.asClassDoc(), "", configuration.getText("doclet.Prev_Class"), true))); li = HtmlTree.LI(prevLink); @@ -134,7 +134,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter public Content getNavLinkNext() { Content li; if (next != null) { - Content nextLink = new RawHtml(getLink(new LinkInfoImpl( + Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS, next.asClassDoc(), "", configuration.getText("doclet.Next_Class"), true))); li = HtmlTree.LI(nextLink); @@ -162,7 +162,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent); div.addContent(pkgNameDiv); } - LinkInfoImpl linkInfo = new LinkInfoImpl( + LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_HEADER, annotationType, false); Content headerContent = new StringContent(header); Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, @@ -219,11 +219,11 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter Content pre = new HtmlTree(HtmlTag.PRE); addAnnotationInfo(annotationType, pre); pre.addContent(modifiers); - LinkInfoImpl linkInfo = new LinkInfoImpl( + LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false); Content annotationName = new StringContent(annotationType.name()); Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo)); - if (configuration().linksource) { + if (configuration.linksource) { addSrcLink(annotationType, annotationName, pre); pre.addContent(parameterLinks); } else { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java index 5f8001b6fb4..8e2e14fceb4 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java @@ -256,9 +256,9 @@ public class ClassUseWriter extends SubWriterHolderWriter { */ protected void addPackageList(Content contentTree) throws IOException { Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary, - getTableCaption(configuration().getText( + getTableCaption(configuration.getText( "doclet.ClassUse_Packages.that.use.0", - getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, + getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false))))); table.addContent(getSummaryTableHeader(packageTableHeader, "col")); Content tbody = new HtmlTree(HtmlTag.TBODY); @@ -287,14 +287,14 @@ public class ClassUseWriter extends SubWriterHolderWriter { protected void addPackageAnnotationList(Content contentTree) throws IOException { if ((!classdoc.isAnnotationType()) || pkgToPackageAnnotations == null || - pkgToPackageAnnotations.size() == 0) { + pkgToPackageAnnotations.isEmpty()) { return; } Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary, - getTableCaption(configuration().getText( + getTableCaption(configuration.getText( "doclet.ClassUse_PackageAnnotation", - getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, - false))))); + getLink(new LinkInfoImpl(configuration, + LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false))))); table.addContent(getSummaryTableHeader(packageTableHeader, "col")); Content tbody = new HtmlTree(HtmlTag.TBODY); Iterator it = pkgToPackageAnnotations.iterator(); @@ -333,7 +333,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name())); Content link = new RawHtml( configuration.getText("doclet.ClassUse_Uses.of.0.in.1", - getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, + getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false)), getPackageLinkString(pkg, Util.getPackageName(pkg), false))); Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link); @@ -368,7 +368,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { * @param contentTree the content tree to which the class use information will be added */ protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException { - String classLink = getLink(new LinkInfoImpl( + String classLink = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false)); String pkgLink = getPackageLinkString(pkg, Util.getPackageName(pkg), false); classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg.name()), @@ -477,8 +477,8 @@ public class ClassUseWriter extends SubWriterHolderWriter { */ protected Content getNavLinkClass() { Content linkContent = new RawHtml(getLink(new LinkInfoImpl( - LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, "", - configuration.getText("doclet.Class"), false))); + configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, + "", configuration.getText("doclet.Class"), false))); Content li = HtmlTree.LI(linkContent); return li; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java index 78d8ca88b2c..06ac230dc27 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java @@ -34,6 +34,7 @@ import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.builders.*; import com.sun.tools.doclets.internal.toolkit.taglets.*; import com.sun.tools.doclets.internal.toolkit.util.*; +import java.io.IOException; /** * Generate the Class Information Page. @@ -56,24 +57,25 @@ import com.sun.tools.doclets.internal.toolkit.util.*; public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWriter { - protected ClassDoc classDoc; + protected final ClassDoc classDoc; - protected ClassTree classtree; + protected final ClassTree classtree; - protected ClassDoc prev; + protected final ClassDoc prev; - protected ClassDoc next; + protected final ClassDoc next; /** + * @param configuration the configuration data for the doclet * @param classDoc the class being documented. * @param prevClass the previous class that was documented. * @param nextClass the next class being documented. * @param classTree the class tree for the given class. */ - public ClassWriterImpl (ClassDoc classDoc, + public ClassWriterImpl (ConfigurationImpl configuration, ClassDoc classDoc, ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) - throws Exception { - super(ConfigurationImpl.getInstance(), DocPath.forClass(classDoc)); + throws IOException { + super(configuration, DocPath.forClass(classDoc)); this.classDoc = classDoc; configuration.currentcd = classDoc; this.classtree = classTree; @@ -122,7 +124,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter public Content getNavLinkPrevious() { Content li; if (prev != null) { - Content prevLink = new RawHtml(getLink(new LinkInfoImpl( + Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS, prev, "", configuration.getText("doclet.Prev_Class"), true))); li = HtmlTree.LI(prevLink); @@ -140,7 +142,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter public Content getNavLinkNext() { Content li; if (next != null) { - Content nextLink = new RawHtml(getLink(new LinkInfoImpl( + Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS, next, "", configuration.getText("doclet.Next_Class"), true))); li = HtmlTree.LI(nextLink); @@ -168,8 +170,8 @@ public class ClassWriterImpl extends SubWriterHolderWriter Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent); div.addContent(pkgNameDiv); } - LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER, - classDoc, false); + LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, + LinkInfoImpl.CONTEXT_CLASS_HEADER, classDoc, false); //Let's not link to ourselves in the header. linkInfo.linkToSelf = false; Content headerContent = new StringContent(header); @@ -228,13 +230,13 @@ public class ClassWriterImpl extends SubWriterHolderWriter Content pre = new HtmlTree(HtmlTag.PRE); addAnnotationInfo(classDoc, pre); pre.addContent(modifiers); - LinkInfoImpl linkInfo = new LinkInfoImpl( + LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false); //Let's not link to ourselves in the signature. linkInfo.linkToSelf = false; Content className = new StringContent(classDoc.name()); Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo)); - if (configuration().linksource) { + if (configuration.linksource) { addSrcLink(classDoc, className, pre); pre.addContent(parameterLinks); } else { @@ -244,11 +246,11 @@ public class ClassWriterImpl extends SubWriterHolderWriter } if (!isInterface) { Type superclass = Util.getFirstVisibleSuperClass(classDoc, - configuration()); + configuration); if (superclass != null) { pre.addContent(DocletConstants.NL); pre.addContent("extends "); - Content link = new RawHtml(getLink(new LinkInfoImpl( + Content link = new RawHtml(getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME, superclass))); pre.addContent(link); @@ -260,7 +262,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter for (int i = 0; i < implIntfacs.length; i++) { ClassDoc classDoc = implIntfacs[i].asClassDoc(); if (! (classDoc.isPublic() || - Util.isLinkable(classDoc, configuration()))) { + Util.isLinkable(classDoc, configuration))) { continue; } if (counter == 0) { @@ -269,7 +271,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter } else { pre.addContent(", "); } - Content link = new RawHtml(getLink(new LinkInfoImpl( + Content link = new RawHtml(getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME, implIntfacs[i]))); pre.addContent(link); @@ -315,7 +317,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter do { sup = Util.getFirstVisibleSuperClass( type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(), - configuration()); + configuration); if (sup != null) { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.inheritance); @@ -345,7 +347,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter Content li = new HtmlTree(HtmlTag.LI); if (type.equals(classDoc)) { String typeParameters = getTypeParameterLinks( - new LinkInfoImpl(LinkInfoImpl.CONTEXT_TREE, + new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_TREE, classDoc, false)); if (configuration.shouldExcludeQualifier( classDoc.containingPackage().name())) { @@ -356,7 +358,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter li.addContent(new RawHtml(typeParameters)); } } else { - Content link = new RawHtml(getLink(new LinkInfoImpl( + Content link = new RawHtml(getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT, type instanceof ClassDoc ? (ClassDoc) type : type, configuration.getClassName(type.asClassDoc()), false))); @@ -504,8 +506,8 @@ public class ClassWriterImpl extends SubWriterHolderWriter Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); Content dd = new HtmlTree(HtmlTag.DD); - dd.addContent(new RawHtml(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass, - false)))); + dd.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration, + LinkInfoImpl.CONTEXT_CLASS, outerClass, false)))); dl.addContent(dd); classInfoTree.addContent(dl); } @@ -549,11 +551,11 @@ public class ClassWriterImpl extends SubWriterHolderWriter } if (typeList[i] instanceof ClassDoc) { Content link = new RawHtml(getLink( - new LinkInfoImpl(context, (ClassDoc)(typeList[i])))); + new LinkInfoImpl(configuration, context, (ClassDoc)(typeList[i])))); dd.addContent(link); } else { Content link = new RawHtml(getLink( - new LinkInfoImpl(context, (Type)(typeList[i])))); + new LinkInfoImpl(configuration, context, (Type)(typeList[i])))); dd.addContent(link); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java index fb6966b890a..c0d441b4b59 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java @@ -57,8 +57,6 @@ import com.sun.tools.doclets.internal.toolkit.util.*; */ public class ConfigurationImpl extends Configuration { - private static ConfigurationImpl instance = new ConfigurationImpl(); - /** * The build date. Note: For now, we will use * a version number instead of a date. @@ -183,31 +181,17 @@ public class ConfigurationImpl extends Configuration { /** * The classdoc for the class file getting generated. */ - public ClassDoc currentcd = null; // Set this classdoc in the - // ClassWriter. + public ClassDoc currentcd = null; // Set this classdoc in the ClassWriter. /** * Constructor. Initializes resource for the * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}. */ - private ConfigurationImpl() { + public ConfigurationImpl() { standardmessage = new MessageRetriever(this, "com.sun.tools.doclets.formats.html.resources.standard"); } - /** - * Reset to a fresh new ConfigurationImpl, to allow multiple invocations - * of javadoc within a single VM. It would be better not to be using - * static fields at all, but .... (sigh). - */ - public static void reset() { - instance = new ConfigurationImpl(); - } - - public static ConfigurationImpl getInstance() { - return instance; - } - /** * Return the build date for the doclet. */ diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java index ec98f180410..afc0aeb2d6f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java @@ -184,9 +184,9 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter */ public Content getConstantMembersHeader(ClassDoc cd) { //generate links backward only to public classes. - String classlink = (cd.isPublic() || cd.isProtected())? - getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd, - false)) : + String classlink = (cd.isPublic() || cd.isProtected()) ? + getLink(new LinkInfoImpl(configuration, + LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd, false)) : cd.qualifiedName(); String name = cd.containingPackage().name(); if (name.length() > 0) { @@ -260,7 +260,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter code.addContent(modifier); code.addContent(getSpace()); } - Content type = new RawHtml(getLink(new LinkInfoImpl( + Content type = new RawHtml(getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member.type()))); code.addContent(type); tdType.addContent(code); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java index 6e2a5ec5284..0725f1677ca 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java @@ -60,7 +60,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter ClassDoc classDoc) { super(writer, classDoc); VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc, - VisibleMemberMap.CONSTRUCTORS, configuration().nodeprecated); + VisibleMemberMap.CONSTRUCTORS, configuration.nodeprecated); List constructors = new ArrayList(visibleMemberMap.getMembersFor(classDoc)); for (int i = 0; i < constructors.size(); i++) { if ((constructors.get(i)).isProtected() || @@ -130,7 +130,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter Content pre = new HtmlTree(HtmlTag.PRE); writer.addAnnotationInfo(constructor, pre); addModifiers(constructor, pre); - if (configuration().linksource) { + if (configuration.linksource) { Content constructorName = new StringContent(constructor.name()); writer.addSrcLink(constructor, constructorName, pre); } else { @@ -217,16 +217,16 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter * {@inheritDoc} */ public String getTableSummary() { - return configuration().getText("doclet.Member_Table_Summary", - configuration().getText("doclet.Constructor_Summary"), - configuration().getText("doclet.constructors")); + return configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Constructor_Summary"), + configuration.getText("doclet.constructors")); } /** * {@inheritDoc} */ public String getCaption() { - return configuration().getText("doclet.Constructors"); + return configuration.getText("doclet.Constructors"); } /** @@ -236,17 +236,17 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter String[] header; if (foundNonPubConstructor) { header = new String[] { - configuration().getText("doclet.Modifier"), - configuration().getText("doclet.0_and_1", - configuration().getText("doclet.Constructor"), - configuration().getText("doclet.Description")) + configuration.getText("doclet.Modifier"), + configuration.getText("doclet.0_and_1", + configuration.getText("doclet.Constructor"), + configuration.getText("doclet.Description")) }; } else { header = new String[] { - configuration().getText("doclet.0_and_1", - configuration().getText("doclet.Constructor"), - configuration().getText("doclet.Description")) + configuration.getText("doclet.0_and_1", + configuration.getText("doclet.Constructor"), + configuration.getText("doclet.Description")) }; } return header; @@ -313,7 +313,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter code.addContent(writer.getSpace()); } else { code.addContent( - configuration().getText("doclet.Package_private")); + configuration.getText("doclet.Package_private")); } tdSummaryType.addContent(code); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java index b06255ad9a6..a37d8be9e5c 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java @@ -101,11 +101,11 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter Content pre = new HtmlTree(HtmlTag.PRE); writer.addAnnotationInfo(enumConstant, pre); addModifiers(enumConstant, pre); - Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, - enumConstant.type()))); + Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl( + configuration, LinkInfoImpl.CONTEXT_MEMBER, enumConstant.type()))); pre.addContent(enumConstantLink); pre.addContent(" "); - if (configuration().linksource) { + if (configuration.linksource) { Content enumConstantName = new StringContent(enumConstant.name()); writer.addSrcLink(enumConstant, enumConstantName, pre); } else { @@ -174,16 +174,16 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter * {@inheritDoc} */ public String getTableSummary() { - return configuration().getText("doclet.Member_Table_Summary", - configuration().getText("doclet.Enum_Constant_Summary"), - configuration().getText("doclet.enum_constants")); + return configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Enum_Constant_Summary"), + configuration.getText("doclet.enum_constants")); } /** * {@inheritDoc} */ public String getCaption() { - return configuration().getText("doclet.Enum_Constants"); + return configuration.getText("doclet.Enum_Constants"); } /** @@ -191,9 +191,9 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter */ public String[] getSummaryTableHeader(ProgramElementDoc member) { String[] header = new String[] { - configuration().getText("doclet.0_and_1", - configuration().getText("doclet.Enum_Constant"), - configuration().getText("doclet.Description")) + configuration.getText("doclet.0_and_1", + configuration.getText("doclet.Enum_Constant"), + configuration.getText("doclet.Description")) }; return header; } @@ -266,7 +266,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter return writer.getHyperLink((cd == null)? "enum_constant_summary": "enum_constants_inherited_from_class_" + - configuration().getClassName(cd), + configuration.getClassName(cd), writer.getResource("doclet.navEnum")); } else { return writer.getResource("doclet.navEnum"); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java index 10f076a08af..dc5515882bc 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java @@ -102,11 +102,11 @@ public class FieldWriterImpl extends AbstractMemberWriter Content pre = new HtmlTree(HtmlTag.PRE); writer.addAnnotationInfo(field, pre); addModifiers(field, pre); - Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, - field.type()))); + Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl( + configuration, LinkInfoImpl.CONTEXT_MEMBER, field.type()))); pre.addContent(fieldlink); pre.addContent(" "); - if (configuration().linksource) { + if (configuration.linksource) { Content fieldName = new StringContent(field.name()); writer.addSrcLink(field, fieldName, pre); } else { @@ -129,7 +129,7 @@ public class FieldWriterImpl extends AbstractMemberWriter ClassDoc holder = field.containingClass(); if (field.inlineTags().length > 0) { if (holder.equals(classdoc) || - (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) { + (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) { writer.addInlineComment(field, fieldDocTree); } else { Content link = new RawHtml( @@ -195,16 +195,16 @@ public class FieldWriterImpl extends AbstractMemberWriter * {@inheritDoc} */ public String getTableSummary() { - return configuration().getText("doclet.Member_Table_Summary", - configuration().getText("doclet.Field_Summary"), - configuration().getText("doclet.fields")); + return configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Field_Summary"), + configuration.getText("doclet.fields")); } /** * {@inheritDoc} */ public String getCaption() { - return configuration().getText("doclet.Fields"); + return configuration.getText("doclet.Fields"); } /** @@ -213,9 +213,9 @@ public class FieldWriterImpl extends AbstractMemberWriter public String[] getSummaryTableHeader(ProgramElementDoc member) { String[] header = new String[] { writer.getModifierTypeHeader(), - configuration().getText("doclet.0_and_1", - configuration().getText("doclet.Field"), - configuration().getText("doclet.Description")) + configuration.getText("doclet.0_and_1", + configuration.getText("doclet.Field"), + configuration.getText("doclet.Description")) }; return header; } @@ -232,7 +232,7 @@ public class FieldWriterImpl extends AbstractMemberWriter */ public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { inheritedTree.addContent(writer.getMarkerAnchor( - "fields_inherited_from_class_" + configuration().getClassName(cd))); + "fields_inherited_from_class_" + configuration.getClassName(cd))); } /** @@ -242,8 +242,8 @@ public class FieldWriterImpl extends AbstractMemberWriter Content classLink = new RawHtml(writer.getPreQualifiedClassLink( LinkInfoImpl.CONTEXT_MEMBER, cd, false)); Content label = new StringContent(cd.isClass() ? - configuration().getText("doclet.Fields_Inherited_From_Class") : - configuration().getText("doclet.Fields_Inherited_From_Interface")); + configuration.getText("doclet.Fields_Inherited_From_Class") : + configuration.getText("doclet.Fields_Inherited_From_Interface")); Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); labelHeading.addContent(writer.getSpace()); @@ -296,7 +296,7 @@ public class FieldWriterImpl extends AbstractMemberWriter return writer.getHyperLink((cd == null)? "field_summary": "fields_inherited_from_class_" + - configuration().getClassName(cd), + configuration.getClassName(cd), writer.getResource("doclet.navField")); } else { return writer.getResource("doclet.navField"); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java index 6a9f691cedd..3e12036ef16 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java @@ -46,14 +46,17 @@ import com.sun.tools.doclets.internal.toolkit.util.*; * */ public class HtmlDoclet extends AbstractDoclet { + // An instance will be created by validOptions, and used by start. + private static HtmlDoclet docletToStart = null; + public HtmlDoclet() { - configuration = (ConfigurationImpl) configuration(); + configuration = new ConfigurationImpl(); } /** * The global configuration information for this run. */ - public ConfigurationImpl configuration; + public final ConfigurationImpl configuration; /** * The "start" method as required by Javadoc. @@ -63,12 +66,16 @@ public class HtmlDoclet extends AbstractDoclet { * @return true if the doclet ran without encountering any errors. */ public static boolean start(RootDoc root) { - try { - HtmlDoclet doclet = new HtmlDoclet(); - return doclet.start(doclet, root); - } finally { - ConfigurationImpl.reset(); + // In typical use, options will have been set up by calling validOptions, + // which will create an HtmlDoclet for use here. + HtmlDoclet doclet; + if (docletToStart != null) { + doclet = docletToStart; + docletToStart = null; + } else { + doclet = new HtmlDoclet(); } + return doclet.start(doclet, root); } /** @@ -77,7 +84,7 @@ public class HtmlDoclet extends AbstractDoclet { * configuration. */ public Configuration configuration() { - return ConfigurationImpl.getInstance(); + return configuration; } /** @@ -220,6 +227,9 @@ public class HtmlDoclet extends AbstractDoclet { } } + public static final ConfigurationImpl sharedInstanceForOptions = + new ConfigurationImpl(); + /** * Check for doclet added options here. * @@ -228,7 +238,7 @@ public class HtmlDoclet extends AbstractDoclet { */ public static int optionLength(String option) { // Construct temporary configuration for check - return (ConfigurationImpl.getInstance()).optionLength(option); + return sharedInstanceForOptions.optionLength(option); } /** @@ -244,8 +254,8 @@ public class HtmlDoclet extends AbstractDoclet { */ public static boolean validOptions(String options[][], DocErrorReporter reporter) { - // Construct temporary configuration for check - return (ConfigurationImpl.getInstance()).validOptions(options, reporter); + docletToStart = new HtmlDoclet(); + return docletToStart.configuration.validOptions(options, reporter); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java index 0531db15abd..83388a6728e 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java @@ -82,7 +82,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { /** * The global configuration information for this run. */ - public ConfigurationImpl configuration; + public final ConfigurationImpl configuration; /** * To check whether annotation heading is printed or not. @@ -302,7 +302,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ public void printHtmlDocument(String[] metakeywords, boolean includeScript, Content body) throws IOException { - Content htmlDocType = DocType.Transitional(); + Content htmlDocType = DocType.TRANSITIONAL; Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); Content head = new HtmlTree(HtmlTag.HEAD); if (!configuration.notimestamp) { @@ -835,7 +835,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { String tableSummary, String[] tableHeader, Content contentTree) { if (deprPkgs.size() > 0) { Content table = HtmlTree.TABLE(0, 3, 0, tableSummary, - getTableCaption(configuration().getText(headingKey))); + getTableCaption(configuration.getText(headingKey))); table.addContent(getSummaryTableHeader(tableHeader, "col")); Content tbody = new HtmlTree(HtmlTag.TBODY); for (int i = 0; i < deprPkgs.size(); i++) { @@ -1079,7 +1079,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ public Content getQualifiedClassLink(int context, ClassDoc cd) { - return new RawHtml(getLink(new LinkInfoImpl(context, cd, + return new RawHtml(getLink(new LinkInfoImpl(configuration, context, cd, configuration.getClassName(cd), ""))); } @@ -1110,7 +1110,8 @@ public class HtmlDocletWriter extends HtmlDocWriter { if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) { classlink = getPkgName(cd); } - classlink += getLink(new LinkInfoImpl(context, cd, cd.name(), isStrong)); + classlink += getLink(new LinkInfoImpl(configuration, + context, cd, cd.name(), isStrong)); return classlink; } @@ -1130,7 +1131,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) { contentTree.addContent(getPkgName(cd)); } - contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl( + contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration, context, cd, cd.name(), isStrong)))); } @@ -1187,14 +1188,14 @@ public class HtmlDocletWriter extends HtmlDocWriter { public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc, String label, boolean strong) { if (! (doc.isIncluded() || - Util.isLinkable(classDoc, configuration()))) { + Util.isLinkable(classDoc, configuration))) { return label; } else if (doc instanceof ExecutableMemberDoc) { ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; - return getLink(new LinkInfoImpl(context, classDoc, + return getLink(new LinkInfoImpl(configuration, context, classDoc, getAnchor(emd), label, strong)); } else if (doc instanceof MemberDoc) { - return getLink(new LinkInfoImpl(context, classDoc, + return getLink(new LinkInfoImpl(configuration, context, classDoc, doc.name(), label, strong)); } else { return label; @@ -1215,14 +1216,14 @@ public class HtmlDocletWriter extends HtmlDocWriter { public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc, String label) { if (! (doc.isIncluded() || - Util.isLinkable(classDoc, configuration()))) { + Util.isLinkable(classDoc, configuration))) { return new StringContent(label); } else if (doc instanceof ExecutableMemberDoc) { ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; - return new RawHtml(getLink(new LinkInfoImpl(context, classDoc, + return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc, getAnchor(emd), label, false))); } else if (doc instanceof MemberDoc) { - return new RawHtml(getLink(new LinkInfoImpl(context, classDoc, + return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc, doc.name(), label, false))); } else { return new StringContent(label); @@ -1302,7 +1303,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { if (label.isEmpty()) { label = plainOrCodeText(plain, refClass.name()); } - return getLink(new LinkInfoImpl(refClass, label)); + return getLink(new LinkInfoImpl(configuration, refClass, label)); } else if (refMem == null) { // Must be a member reference since refClass is not null and refMemName is not null. // However, refMem is null, so this referenced member does not exist. @@ -1313,7 +1314,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { ClassDoc containing = refMem.containingClass(); if (see.text().trim().startsWith("#") && ! (containing.isPublic() || - Util.isLinkable(containing, configuration()))) { + Util.isLinkable(containing, configuration))) { // Since the link is relative and the holder is not even being // documented, this must be an inherited link. Redirect it. // The current class either overrides the referenced member or @@ -1502,7 +1503,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { StringBuilder textBuff = new StringBuilder(); while (lines.hasMoreTokens()) { StringBuilder line = new StringBuilder(lines.nextToken()); - Util.replaceTabs(configuration.sourcetab, line); + Util.replaceTabs(configuration, line); textBuff.append(line.toString()); } result.append(textBuff); @@ -1784,7 +1785,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { continue; } annotation = new StringBuilder(); - LinkInfoImpl linkInfo = new LinkInfoImpl( + LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc); linkInfo.label = "@" + annotationDoc.name(); annotation.append(getLink(linkInfo)); @@ -1835,7 +1836,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { if (annotationValue.value() instanceof Type) { Type type = (Type) annotationValue.value(); if (type.asClassDoc() != null) { - LinkInfoImpl linkInfo = new LinkInfoImpl( + LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_ANNOTATION, type); linkInfo.label = (type.asClassDoc().isIncluded() ? type.typeName() : diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java index b735b01f72f..bc0e1deb68d 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java @@ -130,7 +130,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl pre.addContent(fieldTypeStr); } else { Content fieldContent = new RawHtml(writer.getLink(new LinkInfoImpl( - LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType))); + configuration, LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType))); pre.addContent(fieldContent); } pre.addContent(fieldDimensions + " "); @@ -187,8 +187,8 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl */ public void addMemberTags(FieldDoc field, Content contentTree) { TagletOutputImpl output = new TagletOutputImpl(""); - TagletWriter.genTagOuput(configuration().tagletManager, field, - configuration().tagletManager.getCustomTags(field), + TagletWriter.genTagOuput(configuration.tagletManager, field, + configuration.tagletManager.getCustomTags(field), writer.getTagletWriterInstance(false), output); String outputString = output.toString().trim(); Content dlTags = new HtmlTree(HtmlTag.DL); @@ -208,7 +208,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl * @return true if overview details need to be printed */ public boolean shouldPrintOverview(FieldDoc field) { - if (!configuration().nocomment) { + if (!configuration.nocomment) { if(!field.commentText().isEmpty() || writer.hasSerializationOverviewTags(field)) return true; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java index 2b5bdcfe3a4..d71b4370cc6 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java @@ -148,7 +148,7 @@ public class HtmlSerialMethodWriter extends MethodWriterImpl implements public void addMemberTags(MethodDoc member, Content methodsContentTree) { TagletOutputImpl output = new TagletOutputImpl(""); TagletManager tagletManager = - ConfigurationImpl.getInstance().tagletManager; + configuration.tagletManager; TagletWriter.genTagOuput(tagletManager, member, tagletManager.getSerializedFormTags(), writer.getTagletWriterInstance(false), output); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java index f0d0707be0d..00451159ccd 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java @@ -74,7 +74,7 @@ public class LinkFactoryImpl extends LinkFactory { StringBuilder label = new StringBuilder( classLinkInfo.getClassLinkLabel(m_writer.configuration)); classLinkInfo.displayLength += label.length(); - Configuration configuration = ConfigurationImpl.getInstance(); + Configuration configuration = m_writer.configuration; LinkOutputImpl linkOutput = new LinkOutputImpl(); if (classDoc.isIncluded()) { if (configuration.isGeneratedDoc(classDoc)) { @@ -118,8 +118,8 @@ public class LinkFactoryImpl extends LinkFactory { */ protected LinkOutput getTypeParameterLink(LinkInfo linkInfo, Type typeParam) { - LinkInfoImpl typeLinkInfo = new LinkInfoImpl(linkInfo.getContext(), - typeParam); + LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration, + linkInfo.getContext(), typeParam); typeLinkInfo.excludeTypeBounds = linkInfo.excludeTypeBounds; typeLinkInfo.excludeTypeParameterLinks = linkInfo.excludeTypeParameterLinks; typeLinkInfo.linkToSelf = linkInfo.linkToSelf; @@ -135,10 +135,10 @@ public class LinkFactoryImpl extends LinkFactory { * @return the tool tip for the appropriate class. */ private String getClassToolTip(ClassDoc classDoc, boolean isTypeLink) { - Configuration configuration = ConfigurationImpl.getInstance(); + Configuration configuration = m_writer.configuration; if (isTypeLink) { return configuration.getText("doclet.Href_Type_Param_Title", - classDoc.name()); + classDoc.name()); } else if (classDoc.isInterface()){ return configuration.getText("doclet.Href_Interface_Title", Util.getPackageName(classDoc.containingPackage())); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java index ef5f38f5735..790543d32fd 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java @@ -198,6 +198,8 @@ public class LinkInfoImpl extends LinkInfo { */ public static final int CONTEXT_CLASS_USE_HEADER = 33; + public final ConfigurationImpl configuration; + /** * The integer indicating the location of the link. */ @@ -214,20 +216,22 @@ public class LinkInfoImpl extends LinkInfo { public String styleName =""; /** - * The valueof the target. + * The value of the target. */ public String target = ""; /** * Construct a LinkInfo object. * + * @param configuration the configuration data for the doclet * @param context the context of the link. * @param classDoc the class to link to. * @param label the label for the link. * @param target the value of the target attribute. */ - public LinkInfoImpl (int context, ClassDoc classDoc, String label, - String target){ + public LinkInfoImpl(ConfigurationImpl configuration, + int context, ClassDoc classDoc, String label, String target) { + this.configuration = configuration; this.classDoc = classDoc; this.label = label; this.target = target; @@ -237,6 +241,7 @@ public class LinkInfoImpl extends LinkInfo { /** * Construct a LinkInfo object. * + * @param configuration the configuration data for the doclet * @param context the context of the link. * @param classDoc the class to link to. * @param where the value of the marker #. @@ -244,8 +249,10 @@ public class LinkInfoImpl extends LinkInfo { * @param isStrong true if the link should be strong. * @param styleName String style of text defined in style sheet. */ - public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label, - boolean isStrong, String styleName){ + public LinkInfoImpl(ConfigurationImpl configuration, + int context, ClassDoc classDoc, String where, String label, + boolean isStrong, String styleName) { + this.configuration = configuration; this.classDoc = classDoc; this.where = where; this.label = label; @@ -257,14 +264,17 @@ public class LinkInfoImpl extends LinkInfo { /** * Construct a LinkInfo object. * + * @param configuration the configuration data for the doclet * @param context the context of the link. * @param classDoc the class to link to. * @param where the value of the marker #. * @param label the label for the link. * @param isStrong true if the link should be strong. */ - public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label, - boolean isStrong){ + public LinkInfoImpl(ConfigurationImpl configuration, + int context, ClassDoc classDoc, String where, String label, + boolean isStrong) { + this.configuration = configuration; this.classDoc = classDoc; this.where = where; this.label = label; @@ -275,10 +285,13 @@ public class LinkInfoImpl extends LinkInfo { /** * Construct a LinkInfo object. * + * @param configuration the configuration data for the doclet * @param classDoc the class to link to. * @param label the label for the link. */ - public LinkInfoImpl (ClassDoc classDoc, String label){ + public LinkInfoImpl(ConfigurationImpl configuration, + ClassDoc classDoc, String label) { + this.configuration = configuration; this.classDoc = classDoc; this.label = label; setContext(context); @@ -287,12 +300,15 @@ public class LinkInfoImpl extends LinkInfo { /** * Construct a LinkInfo object. * + * @param configuration the configuration data for the doclet * @param context the context of the link. * @param executableMemberDoc the member to link to. * @param isStrong true if the link should be strong. */ - public LinkInfoImpl (int context, ExecutableMemberDoc executableMemberDoc, - boolean isStrong){ + public LinkInfoImpl(ConfigurationImpl configuration, + int context, ExecutableMemberDoc executableMemberDoc, + boolean isStrong) { + this.configuration = configuration; this.executableMemberDoc = executableMemberDoc; this.isStrong = isStrong; setContext(context); @@ -301,11 +317,14 @@ public class LinkInfoImpl extends LinkInfo { /** * Construct a LinkInfo object. * + * @param configuration the configuration data for the doclet * @param context the context of the link. * @param classDoc the class to link to. * @param isStrong true if the link should be strong. */ - public LinkInfoImpl (int context, ClassDoc classDoc, boolean isStrong){ + public LinkInfoImpl(ConfigurationImpl configuration, + int context, ClassDoc classDoc, boolean isStrong) { + this.configuration = configuration; this.classDoc = classDoc; this.isStrong = isStrong; setContext(context); @@ -314,10 +333,13 @@ public class LinkInfoImpl extends LinkInfo { /** * Construct a LinkInfo object. * + * @param configuration the configuration data for the doclet * @param context the context of the link. * @param type the class to link to. */ - public LinkInfoImpl (int context, Type type){ + public LinkInfoImpl(ConfigurationImpl configuration, + int context, Type type) { + this.configuration = configuration; this.type = type; setContext(context); } @@ -325,11 +347,14 @@ public class LinkInfoImpl extends LinkInfo { /** * Construct a LinkInfo object. * + * @param configuration the configuration data for the doclet * @param context the context of the link. * @param type the class to link to. * @param isVarArg true if this is a link to a var arg. */ - public LinkInfoImpl (int context, Type type, boolean isVarArg){ + public LinkInfoImpl(ConfigurationImpl configuration, + int context, Type type, boolean isVarArg) { + this.configuration = configuration; this.type = type; this.isVarArg = isVarArg; setContext(context); @@ -338,13 +363,16 @@ public class LinkInfoImpl extends LinkInfo { /** * Construct a LinkInfo object. * + * @param configuration the configuration data for the doclet * @param context the context of the link. * @param type the class to link to. * @param label the label for the link. * @param isStrong true if the link should be strong. */ - public LinkInfoImpl (int context, Type type, String label, - boolean isStrong){ + public LinkInfoImpl(ConfigurationImpl configuration, + int context, Type type, String label, + boolean isStrong) { + this.configuration = configuration; this.type = type; this.label = label; this.isStrong = isStrong; @@ -354,13 +382,16 @@ public class LinkInfoImpl extends LinkInfo { /** * Construct a LinkInfo object. * + * @param configuration the configuration data for the doclet * @param context the context of the link. * @param classDoc the class to link to. * @param label the label for the link. * @param isStrong true if the link should be strong. */ - public LinkInfoImpl (int context, ClassDoc classDoc, String label, - boolean isStrong){ + public LinkInfoImpl(ConfigurationImpl configuration, + int context, ClassDoc classDoc, String label, + boolean isStrong) { + this.configuration = configuration; this.classDoc = classDoc; this.label = label; this.isStrong = isStrong; @@ -448,6 +479,6 @@ public class LinkInfoImpl extends LinkInfo { * desired place. */ public boolean isLinkable() { - return Util.isLinkable(classDoc, ConfigurationImpl.getInstance()); + return Util.isLinkable(classDoc, configuration); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java index 6b9ff239511..38b4dc0daa2 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java @@ -123,7 +123,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter addModifiers(method, pre); addTypeParameters(method, pre); addReturnType(method, pre); - if (configuration().linksource) { + if (configuration.linksource) { Content methodName = new StringContent(method.name()); writer.addSrcLink(method, methodName, pre); } else { @@ -149,7 +149,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter if (method.inlineTags().length > 0) { if (holder.asClassDoc().equals(classdoc) || (! (holderClassDoc.isPublic() || - Util.isLinkable(holderClassDoc, configuration())))) { + Util.isLinkable(holderClassDoc, configuration)))) { writer.addInlineComment(method, methodDocTree); } else { Content link = new RawHtml( @@ -215,16 +215,16 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter * {@inheritDoc} */ public String getTableSummary() { - return configuration().getText("doclet.Member_Table_Summary", - configuration().getText("doclet.Method_Summary"), - configuration().getText("doclet.methods")); + return configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Method_Summary"), + configuration.getText("doclet.methods")); } /** * {@inheritDoc} */ public String getCaption() { - return configuration().getText("doclet.Methods"); + return configuration.getText("doclet.Methods"); } /** @@ -233,9 +233,9 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter public String[] getSummaryTableHeader(ProgramElementDoc member) { String[] header = new String[] { writer.getModifierTypeHeader(), - configuration().getText("doclet.0_and_1", - configuration().getText("doclet.Method"), - configuration().getText("doclet.Description")) + configuration.getText("doclet.0_and_1", + configuration.getText("doclet.Method"), + configuration.getText("doclet.Description")) }; return header; } @@ -253,7 +253,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { inheritedTree.addContent(writer.getMarkerAnchor( "methods_inherited_from_class_" + - configuration().getClassName(cd))); + configuration.getClassName(cd))); } /** @@ -263,8 +263,8 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter Content classLink = new RawHtml(writer.getPreQualifiedClassLink( LinkInfoImpl.CONTEXT_MEMBER, cd, false)); Content label = new StringContent(cd.isClass() ? - configuration().getText("doclet.Methods_Inherited_From_Class") : - configuration().getText("doclet.Methods_Inherited_From_Interface")); + configuration.getText("doclet.Methods_Inherited_From_Class") : + configuration.getText("doclet.Methods_Inherited_From_Interface")); Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); labelHeading.addContent(writer.getSpace()); @@ -285,12 +285,12 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter */ protected static void addOverridden(HtmlDocletWriter writer, Type overriddenType, MethodDoc method, Content dl) { - if(writer.configuration.nocomment){ + if (writer.configuration.nocomment) { return; } ClassDoc holderClassDoc = overriddenType.asClassDoc(); if (! (holderClassDoc.isPublic() || - Util.isLinkable(holderClassDoc, writer.configuration()))) { + Util.isLinkable(holderClassDoc, writer.configuration))) { //This is an implementation detail that should not be documented. return; } @@ -303,7 +303,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter int context = LinkInfoImpl.CONTEXT_METHOD_OVERRIDES; if (method != null) { - if(overriddenType.asClassDoc().isAbstract() && method.isAbstract()){ + if (overriddenType.asClassDoc().isAbstract() && method.isAbstract()){ //Abstract method is implemented from abstract class, //not overridden label = writer.specifiedByLabel; @@ -312,11 +312,11 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter Content dt = HtmlTree.DT(HtmlTree.STRONG(label)); dl.addContent(dt); Content overriddenTypeLink = new RawHtml( - writer.getLink(new LinkInfoImpl(context, overriddenType))); + writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType))); Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink); String name = method.name(); Content methlink = new RawHtml(writer.getLink( - new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, + new LinkInfoImpl(writer.configuration, LinkInfoImpl.CONTEXT_MEMBER, overriddenType.asClassDoc(), writer.getAnchor(method), name, false))); Content codeMethLink = HtmlTree.CODE(methlink); @@ -362,7 +362,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter MethodDoc implementedMeth = implementedMethods[i]; Type intfac = implementedMethodsFinder.getMethodHolder(implementedMeth); Content intfaclink = new RawHtml(writer.getLink(new LinkInfoImpl( - LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac))); + writer.configuration, LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac))); Content codeIntfacLink = HtmlTree.CODE(intfaclink); Content dt = HtmlTree.DT(HtmlTree.STRONG(writer.specifiedByLabel)); dl.addContent(dt); @@ -389,7 +389,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter Type type = method.returnType(); if (type != null) { Content linkContent = new RawHtml(writer.getLink( - new LinkInfoImpl(LinkInfoImpl.CONTEXT_RETURN_TYPE, type))); + new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_RETURN_TYPE, type))); htmltree.addContent(linkContent); htmltree.addContent(writer.getSpace()); } @@ -403,7 +403,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter return writer.getHyperLink((cd == null)? "method_summary": "methods_inherited_from_class_" + - configuration().getClassName(cd), + configuration.getClassName(cd), writer.getResource("doclet.navMethod")); } else { return writer.getResource("doclet.navMethod"); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java index 5b9cda91b33..6ce42e57091 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java @@ -93,16 +93,16 @@ public class NestedClassWriterImpl extends AbstractMemberWriter * {@inheritDoc} */ public String getTableSummary() { - return configuration().getText("doclet.Member_Table_Summary", - configuration().getText("doclet.Nested_Class_Summary"), - configuration().getText("doclet.nested_classes")); + return configuration.getText("doclet.Member_Table_Summary", + configuration.getText("doclet.Nested_Class_Summary"), + configuration.getText("doclet.nested_classes")); } /** * {@inheritDoc} */ public String getCaption() { - return configuration().getText("doclet.Nested_Classes"); + return configuration.getText("doclet.Nested_Classes"); } /** @@ -113,17 +113,17 @@ public class NestedClassWriterImpl extends AbstractMemberWriter if (member.isInterface()) { header = new String[] { writer.getModifierTypeHeader(), - configuration().getText("doclet.0_and_1", - configuration().getText("doclet.Interface"), - configuration().getText("doclet.Description")) + configuration.getText("doclet.0_and_1", + configuration.getText("doclet.Interface"), + configuration.getText("doclet.Description")) }; } else { header = new String[] { writer.getModifierTypeHeader(), - configuration().getText("doclet.0_and_1", - configuration().getText("doclet.Class"), - configuration().getText("doclet.Description")) + configuration.getText("doclet.0_and_1", + configuration.getText("doclet.Class"), + configuration.getText("doclet.Description")) }; } return header; @@ -151,8 +151,8 @@ public class NestedClassWriterImpl extends AbstractMemberWriter Content classLink = new RawHtml(writer.getPreQualifiedClassLink( LinkInfoImpl.CONTEXT_MEMBER, cd, false)); Content label = new StringContent(cd.isInterface() ? - configuration().getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") : - configuration().getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class")); + configuration.getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") : + configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class")); Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); labelHeading.addContent(writer.getSpace()); @@ -166,7 +166,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member, Content tdSummary) { Content strong = HtmlTree.STRONG(new RawHtml( - writer.getLink(new LinkInfoImpl(context, (ClassDoc)member, false)))); + writer.getLink(new LinkInfoImpl(configuration, context, (ClassDoc)member, false)))); Content code = HtmlTree.CODE(strong); tdSummary.addContent(code); } @@ -177,7 +177,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter protected void addInheritedSummaryLink(ClassDoc cd, ProgramElementDoc member, Content linksTree) { linksTree.addContent(new RawHtml( - writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, + writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER, (ClassDoc)member, false)))); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java index e218a273d47..4535afaf55c 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java @@ -121,7 +121,7 @@ public class PackageFrameWriter extends HtmlDocletWriter { * @param contentTree the content tree to which the listing will be added */ protected void addClassListing(Content contentTree) { - Configuration config = configuration(); + Configuration config = configuration; if (packageDoc.isIncluded()) { addClassKindListing(packageDoc.interfaces(), getResource("doclet.Interfaces"), contentTree); @@ -181,7 +181,7 @@ public class PackageFrameWriter extends HtmlDocletWriter { contentTree.addContent(heading); printedHeader = true; } - Content link = new RawHtml (getLink(new LinkInfoImpl( + Content link = new RawHtml (getLink(new LinkInfoImpl(configuration, LinkInfoImpl.PACKAGE_FRAME, arr[i], (arr[i].isInterface() ? italicsText(arr[i].name()) : arr[i].name()),"classFrame"))); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java index 4545484e451..b8369ce6255 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java @@ -152,7 +152,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { */ protected void addPackageList(Content contentTree) throws IOException { Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary, - getTableCaption(configuration().getText( + getTableCaption(configuration.getText( "doclet.ClassUse_Packages.that.use.0", getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false)))); table.addContent(getSummaryTableHeader(packageTableHeader, "col")); @@ -197,7 +197,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { String tableSummary = configuration.getText("doclet.Use_Table_Summary", configuration.getText("doclet.classes")); Content table = HtmlTree.TABLE(0, 3, 0, tableSummary, - getTableCaption(configuration().getText( + getTableCaption(configuration.getText( "doclet.ClassUse_Classes.in.0.used.by.1", getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false), getPackageLinkString(usingPackage,Util.getPackageName(usingPackage), false)))); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java index 64f367e62e3..c1fcebf5f74 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java @@ -179,7 +179,8 @@ public class PackageWriterImpl extends HtmlDocletWriter continue; } Content classContent = new RawHtml(getLink(new LinkInfoImpl( - LinkInfoImpl.CONTEXT_PACKAGE, classes[i], false))); + configuration, LinkInfoImpl.CONTEXT_PACKAGE, classes[i], + false))); Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent); HtmlTree tr = HtmlTree.TR(tdClass); if (i%2 == 0) diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java index c1df94a8728..665d15c17bf 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java @@ -46,11 +46,13 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter implements SerializedFormWriter { /** + * @param configuration the configuration data for the doclet * @throws IOException * @throws DocletAbortException */ - public SerializedFormWriterImpl() throws IOException { - super(ConfigurationImpl.getInstance(), DocPaths.SERIALIZED_FORM); + public SerializedFormWriterImpl(ConfigurationImpl configuration) + throws IOException { + super(configuration, DocPaths.SERIALIZED_FORM); } /** @@ -126,15 +128,16 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter */ public Content getClassHeader(ClassDoc classDoc) { String classLink = (classDoc.isPublic() || classDoc.isProtected())? - getLink(new LinkInfoImpl(classDoc, + getLink(new LinkInfoImpl(configuration, classDoc, configuration.getClassName(classDoc))): classDoc.qualifiedName(); Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor( classDoc.qualifiedName())); String superClassLink = classDoc.superclassType() != null ? - getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIALIZED_FORM, - classDoc.superclassType())) : + getLink(new LinkInfoImpl(configuration, + LinkInfoImpl.CONTEXT_SERIALIZED_FORM, + classDoc.superclassType())) : null; //Print the heading. diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java index 299f4f53313..c151c3ad228 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java @@ -60,16 +60,24 @@ public class SourceToHTMLConverter { */ private static final Content NEW_LINE = new RawHtml(DocletConstants.NL); + private final ConfigurationImpl configuration; + + private final RootDoc rootDoc; + + private DocPath outputdir; + /** * Relative path from the documentation root to the file that is being * generated. */ - private static DocPath relativePath = DocPath.empty; + private DocPath relativePath = DocPath.empty; - /** - * Source is converted to HTML using static methods below. - */ - private SourceToHTMLConverter() {} + private SourceToHTMLConverter(ConfigurationImpl configuration, RootDoc rd, + DocPath outputdir) { + this.configuration = configuration; + this.rootDoc = rd; + this.outputdir = outputdir; + } /** * Convert the Classes in the given RootDoc to an HTML. @@ -80,36 +88,38 @@ public class SourceToHTMLConverter { */ public static void convertRoot(ConfigurationImpl configuration, RootDoc rd, DocPath outputdir) { - if (rd == null || outputdir == null) { + new SourceToHTMLConverter(configuration, rd, outputdir).generate(); + } + + void generate() { + if (rootDoc == null || outputdir == null) { return; } - PackageDoc[] pds = rd.specifiedPackages(); + PackageDoc[] pds = rootDoc.specifiedPackages(); for (int i = 0; i < pds.length; i++) { // If -nodeprecated option is set and the package is marked as deprecated, // do not convert the package files to HTML. if (!(configuration.nodeprecated && Util.isDeprecated(pds[i]))) - convertPackage(configuration, pds[i], outputdir); + convertPackage(pds[i], outputdir); } - ClassDoc[] cds = rd.specifiedClasses(); + ClassDoc[] cds = rootDoc.specifiedClasses(); for (int i = 0; i < cds.length; i++) { // If -nodeprecated option is set and the class is marked as deprecated // or the containing package is deprecated, do not convert the // package files to HTML. if (!(configuration.nodeprecated && (Util.isDeprecated(cds[i]) || Util.isDeprecated(cds[i].containingPackage())))) - convertClass(configuration, cds[i], outputdir); + convertClass(cds[i], outputdir); } } /** * Convert the Classes in the given Package to an HTML. * - * @param configuration the configuration. * @param pd the Package to convert. * @param outputdir the name of the directory to output to. */ - public static void convertPackage(ConfigurationImpl configuration, PackageDoc pd, - DocPath outputdir) { + public void convertPackage(PackageDoc pd, DocPath outputdir) { if (pd == null) { return; } @@ -120,19 +130,17 @@ public class SourceToHTMLConverter { // containing package deprecation since it is already check in // the calling method above. if (!(configuration.nodeprecated && Util.isDeprecated(cds[i]))) - convertClass(configuration, cds[i], outputdir); + convertClass(cds[i], outputdir); } } /** * Convert the given Class to an HTML. * - * @param configuration the configuration. * @param cd the class to convert. * @param outputdir the name of the directory to output to. */ - public static void convertClass(ConfigurationImpl configuration, ClassDoc cd, - DocPath outputdir) { + public void convertClass(ClassDoc cd, DocPath outputdir) { if (cd == null) { return; } @@ -164,7 +172,7 @@ public class SourceToHTMLConverter { try { while ((line = reader.readLine()) != null) { addLineNo(pre, lineno); - addLine(pre, line, configuration.sourcetab, lineno); + addLine(pre, line, lineno); lineno++; } } finally { @@ -173,7 +181,7 @@ public class SourceToHTMLConverter { addBlankLines(pre); Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre); body.addContent(div); - writeToFile(body, outputdir.resolve(DocPath.forClass(cd)), configuration); + writeToFile(body, outputdir.resolve(DocPath.forClass(cd))); } catch (IOException e) { e.printStackTrace(); } @@ -184,15 +192,13 @@ public class SourceToHTMLConverter { * * @param body the documentation content to be written to the file. * @param path the path for the file. - * @param configuration the Doclet configuration to pass notices to. */ - private static void writeToFile(Content body, DocPath path, - ConfigurationImpl configuration) throws IOException { - Content htmlDocType = DocType.Transitional(); + private void writeToFile(Content body, DocPath path) throws IOException { + Content htmlDocType = DocType.TRANSITIONAL; Content head = new HtmlTree(HtmlTag.HEAD); head.addContent(HtmlTree.TITLE(new StringContent( configuration.getText("doclet.Window_Source_title")))); - head.addContent(getStyleSheetProperties(configuration)); + head.addContent(getStyleSheetProperties()); Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head, body); Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree); @@ -210,10 +216,9 @@ public class SourceToHTMLConverter { /** * Returns a link to the stylesheet file. * - * @param configuration the doclet configuration for the current run of javadoc * @return an HtmlTree for the lINK tag which provides the stylesheet location */ - public static HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) { + public HtmlTree getStyleSheetProperties() { String filename = configuration.stylesheetfile; DocPath stylesheet; if (filename.length() > 0) { @@ -260,14 +265,13 @@ public class SourceToHTMLConverter { * * @param pre the content tree to which the line will be added. * @param line the string to format. - * @param tabLength the number of spaces for each tab. * @param currentLineNo the current number. */ - private static void addLine(Content pre, String line, int tabLength, - int currentLineNo) { + private void addLine(Content pre, String line, int currentLineNo) { if (line != null) { - StringBuilder lineBuffer = new StringBuilder(Util.escapeHtmlChars(line)); - Util.replaceTabs(tabLength, lineBuffer); + StringBuilder lineBuffer = new StringBuilder(line); + Util.replaceTabs(configuration, lineBuffer); + Util.escapeHtmlChars(lineBuffer); pre.addContent(new RawHtml(lineBuffer.toString())); Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo)); pre.addContent(anchor); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java index ce158d443d0..6f190dab9e5 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java @@ -46,11 +46,13 @@ import com.sun.tools.doclets.internal.toolkit.util.*; public class TagletWriterImpl extends TagletWriter { - private HtmlDocletWriter htmlWriter; + private final HtmlDocletWriter htmlWriter; + private final ConfigurationImpl configuration; public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) { + super(isFirstSentence); this.htmlWriter = htmlWriter; - this.isFirstSentence = isFirstSentence; + configuration = htmlWriter.configuration; } /** @@ -64,8 +66,8 @@ public class TagletWriterImpl extends TagletWriter { * {@inheritDoc} */ public TagletOutput getDocRootOutput() { - if (htmlWriter.configuration.docrootparent.length() > 0) - return new TagletOutputImpl(htmlWriter.configuration.docrootparent); + if (configuration.docrootparent.length() > 0) + return new TagletOutputImpl(configuration.docrootparent); else if (htmlWriter.pathToRoot.isEmpty()) return new TagletOutputImpl("."); else @@ -81,7 +83,7 @@ public class TagletWriterImpl extends TagletWriter { if (doc instanceof ClassDoc) { if (Util.isDeprecated((ProgramElementDoc) doc)) { output.append("" + - ConfigurationImpl.getInstance(). + configuration. getText("doclet.Deprecated") + " "); if (deprs.length > 0) { Tag[] commentTags = deprs[0].inlineTags(); @@ -97,7 +99,7 @@ public class TagletWriterImpl extends TagletWriter { MemberDoc member = (MemberDoc) doc; if (Util.isDeprecated((ProgramElementDoc) doc)) { output.append("" + - ConfigurationImpl.getInstance(). + configuration. getText("doclet.Deprecated") + " "); if (deprs.length > 0) { output.append(""); @@ -108,7 +110,7 @@ public class TagletWriterImpl extends TagletWriter { } else { if (Util.isDeprecated(member.containingClass())) { output.append("" + - ConfigurationImpl.getInstance(). + configuration. getText("doclet.Deprecated") + " "); } } @@ -120,7 +122,7 @@ public class TagletWriterImpl extends TagletWriter { * {@inheritDoc} */ public MessageRetriever getMsgRetriever() { - return htmlWriter.configuration.message; + return configuration.message; } /** @@ -147,7 +149,7 @@ public class TagletWriterImpl extends TagletWriter { */ public TagletOutput returnTagOutput(Tag returnTag) { TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "
" + - "" + htmlWriter.configuration.getText("doclet.Returns") + + "" + configuration.getText("doclet.Returns") + "" + "
" + "
" + htmlWriter.commentTagsToString(returnTag, null, returnTag.inlineTags(), false) + "
"); @@ -178,7 +180,7 @@ public class TagletWriterImpl extends TagletWriter { ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName() + "." + ((FieldDoc) holder).name(); DocLink link = constantsPath.fragment(whichConstant); result += htmlWriter.getHyperLinkString(link, - htmlWriter.configuration.getText("doclet.Constants_Summary"), + configuration.getText("doclet.Constants_Summary"), false); } if (holder.isClass() && ((ClassDoc)holder).isSerializable()) { @@ -189,7 +191,7 @@ public class TagletWriterImpl extends TagletWriter { DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM); DocLink link = serialPath.fragment(((ClassDoc)holder).qualifiedName()); result += htmlWriter.getHyperLinkString(link, - htmlWriter.configuration.getText("doclet.Serialized_Form"), false); + configuration.getText("doclet.Serialized_Form"), false); } } return result.equals("") ? null : new TagletOutputImpl(result + ""); @@ -200,7 +202,7 @@ public class TagletWriterImpl extends TagletWriter { return result + ", " + DocletConstants.NL; } else { return "
" + - htmlWriter.configuration().getText("doclet.See_Also") + "
"; + configuration.getText("doclet.See_Also") + "
"; } } @@ -234,7 +236,7 @@ public class TagletWriterImpl extends TagletWriter { */ public TagletOutput getThrowsHeader() { return new TagletOutputImpl(DocletConstants.NL + "
" + "" + - htmlWriter.configuration().getText("doclet.Throws") + "
"); + configuration.getText("doclet.Throws") + ""); } /** @@ -245,7 +247,7 @@ public class TagletWriterImpl extends TagletWriter { result += throwsTag.exceptionType() == null ? htmlWriter.codeText(throwsTag.exceptionName()) : htmlWriter.codeText( - htmlWriter.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, + htmlWriter.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER, throwsTag.exceptionType()))); TagletOutput text = new TagletOutputImpl( htmlWriter.commentTagsToString(throwsTag, null, @@ -263,7 +265,7 @@ public class TagletWriterImpl extends TagletWriter { public TagletOutput throwsTagOutput(Type throwsType) { return new TagletOutputImpl(DocletConstants.NL + "
" + htmlWriter.codeText(htmlWriter.getLink( - new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "
"); + new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + ""); } /** @@ -303,7 +305,7 @@ public class TagletWriterImpl extends TagletWriter { * {@inheritDoc} */ public Configuration configuration() { - return htmlWriter.configuration(); + return configuration; } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java index 573abe0462f..874e1fa486b 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java @@ -25,6 +25,8 @@ package com.sun.tools.doclets.formats.html; +import java.io.IOException; + import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; @@ -42,7 +44,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*; */ public class WriterFactoryImpl implements WriterFactory { - private ConfigurationImpl configuration; + private final ConfigurationImpl configuration; public WriterFactoryImpl(ConfigurationImpl configuration) { this.configuration = configuration; @@ -60,7 +62,7 @@ public class WriterFactoryImpl implements WriterFactory { */ public PackageSummaryWriter getPackageSummaryWriter(PackageDoc packageDoc, PackageDoc prevPkg, PackageDoc nextPkg) throws Exception { - return new PackageWriterImpl(ConfigurationImpl.getInstance(), packageDoc, + return new PackageWriterImpl(configuration, packageDoc, prevPkg, nextPkg); } @@ -68,9 +70,9 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ public ClassWriter getClassWriter(ClassDoc classDoc, ClassDoc prevClass, - ClassDoc nextClass, ClassTree classTree) - throws Exception { - return new ClassWriterImpl(classDoc, prevClass, nextClass, classTree); + ClassDoc nextClass, ClassTree classTree) throws IOException { + return new ClassWriterImpl(configuration, classDoc, + prevClass, nextClass, classTree); } /** @@ -79,7 +81,8 @@ public class WriterFactoryImpl implements WriterFactory { public AnnotationTypeWriter getAnnotationTypeWriter( AnnotationTypeDoc annotationType, Type prevType, Type nextType) throws Exception { - return new AnnotationTypeWriterImpl(annotationType, prevType, nextType); + return new AnnotationTypeWriterImpl(configuration, + annotationType, prevType, nextType); } /** @@ -106,7 +109,7 @@ public class WriterFactoryImpl implements WriterFactory { /** * {@inheritDoc} */ - public EnumConstantWriter getEnumConstantWriter(ClassWriter classWriter) + public EnumConstantWriterImpl getEnumConstantWriter(ClassWriter classWriter) throws Exception { return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getClassDoc()); @@ -115,7 +118,7 @@ public class WriterFactoryImpl implements WriterFactory { /** * {@inheritDoc} */ - public FieldWriter getFieldWriter(ClassWriter classWriter) + public FieldWriterImpl getFieldWriter(ClassWriter classWriter) throws Exception { return new FieldWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getClassDoc()); @@ -124,7 +127,7 @@ public class WriterFactoryImpl implements WriterFactory { /** * {@inheritDoc} */ - public MethodWriter getMethodWriter(ClassWriter classWriter) + public MethodWriterImpl getMethodWriter(ClassWriter classWriter) throws Exception { return new MethodWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getClassDoc()); @@ -133,7 +136,7 @@ public class WriterFactoryImpl implements WriterFactory { /** * {@inheritDoc} */ - public ConstructorWriter getConstructorWriter(ClassWriter classWriter) + public ConstructorWriterImpl getConstructorWriter(ClassWriter classWriter) throws Exception { return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getClassDoc()); @@ -143,20 +146,20 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ public MemberSummaryWriter getMemberSummaryWriter( - ClassWriter classWriter, int memberType) - throws Exception { + ClassWriter classWriter, int memberType) + throws Exception { switch (memberType) { case VisibleMemberMap.CONSTRUCTORS: - return (ConstructorWriterImpl) getConstructorWriter(classWriter); + return getConstructorWriter(classWriter); case VisibleMemberMap.ENUM_CONSTANTS: - return (EnumConstantWriterImpl) getEnumConstantWriter(classWriter); + return getEnumConstantWriter(classWriter); case VisibleMemberMap.FIELDS: - return (FieldWriterImpl) getFieldWriter(classWriter); + return getFieldWriter(classWriter); case VisibleMemberMap.INNERCLASSES: return new NestedClassWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getClassDoc()); case VisibleMemberMap.METHODS: - return (MethodWriterImpl) getMethodWriter(classWriter); + return getMethodWriter(classWriter); default: return null; } @@ -184,6 +187,6 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ public SerializedFormWriter getSerializedFormWriter() throws Exception { - return new SerializedFormWriterImpl(); + return new SerializedFormWriterImpl(configuration); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java index e923333dba2..0e586b4a4e0 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java @@ -41,13 +41,15 @@ import com.sun.tools.doclets.internal.toolkit.util.*; * * @author Bhavesh Patel */ -public class DocType extends Content{ +public class DocType extends Content { private String docType; - private static DocType transitional; + public static final DocType TRANSITIONAL = + new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd"); - private static DocType frameset; + public static final DocType FRAMESET = + new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd"); /** * Constructor to construct a DocType object. @@ -59,28 +61,6 @@ public class DocType extends Content{ "//EN\" \"" + dtd + "\">" + DocletConstants.NL; } - /** - * Construct and return a HTML 4.01 transitional DocType content - * - * @return a content tree for transitional DocType - */ - public static DocType Transitional() { - if (transitional == null) - transitional = new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd"); - return transitional; - } - - /** - * Construct and return a HTML 4.01 frameset DocType content - * - * @return a content tree for frameset DocType - */ - public static DocType Frameset() { - if (frameset == null) - frameset = new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd"); - return frameset; - } - /** * This method is not supported by the class. * diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java index 376bfdcfeb2..23e8bcae06e 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java @@ -254,7 +254,7 @@ public abstract class HtmlDocWriter extends HtmlWriter { */ public void printFramesetDocument(String title, boolean noTimeStamp, Content frameset) throws IOException { - Content htmlDocType = DocType.Frameset(); + Content htmlDocType = DocType.FRAMESET; Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); Content head = new HtmlTree(HtmlTag.HEAD); if (! noTimeStamp) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java index 4ae4cce1722..388c07093bc 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java @@ -51,8 +51,8 @@ public abstract class AbstractDoclet { /** * The only doclet that may use this toolkit is {@value} */ - private static final String TOOLKIT_DOCLET_NAME = new - com.sun.tools.doclets.formats.html.HtmlDoclet().getClass().getName(); + private static final String TOOLKIT_DOCLET_NAME = + com.sun.tools.doclets.formats.html.HtmlDoclet.class.getName(); /** * Verify that the only doclet that is using this toolkit is diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java index d94b7bef826..3438b0d1657 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java @@ -84,7 +84,9 @@ public abstract class Configuration { /** * The specified amount of space between tab stops. */ - public int sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH; + public int sourcetab; + + public String tabSpaces; /** * True if we should generate browsable sources. @@ -259,6 +261,7 @@ public abstract class Configuration { "com.sun.tools.doclets.internal.toolkit.resources.doclets"); excludedDocFileDirs = new HashSet(); excludedQualifiers = new HashSet(); + setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH); } /** @@ -382,7 +385,7 @@ public abstract class Configuration { } else if (opt.equals("-sourcetab")) { linksource = true; try { - sourcetab = Integer.parseInt(os[1]); + setTabWidth(Integer.parseInt(os[1])); } catch (NumberFormatException e) { //Set to -1 so that warning will be printed //to indicate what is valid argument. @@ -390,7 +393,7 @@ public abstract class Configuration { } if (sourcetab <= 0) { message.warning("doclet.sourcetab_warning"); - sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH; + setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH); } } else if (opt.equals("-notimestamp")) { notimestamp = true; @@ -767,4 +770,9 @@ public abstract class Configuration { * @return the {@link java.util.Comparator} used to sort members. */ public abstract Comparator getMemberComparator(); + + private void setTabWidth(int n) { + sourcetab = n; + tabSpaces = String.format("%" + n + "s", ""); + } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java index ef7b0d99ee3..56676ec86b8 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java @@ -52,18 +52,46 @@ import com.sun.tools.doclets.internal.toolkit.util.*; */ public abstract class AbstractBuilder { + public static class Context { + /** + * The configuration used in this run of the doclet. + */ + final Configuration configuration; + + /** + * Keep track of which packages we have seen for + * efficiency purposes. We don't want to copy the + * doc files multiple times for a single package. + */ + final Set containingPackagesSeen; + + /** + * Shared parser for the builder XML file + */ + final LayoutParser layoutParser; + + Context(Configuration configuration, + Set containingPackagesSeen, + LayoutParser layoutParser) { + this.configuration = configuration; + this.containingPackagesSeen = containingPackagesSeen; + this.layoutParser = layoutParser; + } + } /** * The configuration used in this run of the doclet. */ - protected Configuration configuration; + protected final Configuration configuration; /** * Keep track of which packages we have seen for * efficiency purposes. We don't want to copy the * doc files multiple times for a single package. */ - protected static Set containingPackagesSeen; + protected final Set containingPackagesSeen; + + protected final LayoutParser layoutParser; /** * True if we want to print debug output. @@ -75,8 +103,10 @@ public abstract class AbstractBuilder { * @param configuration the configuration used in this run * of the doclet. */ - public AbstractBuilder(Configuration configuration) { - this.configuration = configuration; + public AbstractBuilder(Context c) { + this.configuration = c.configuration; + this.containingPackagesSeen = c.containingPackagesSeen; + this.layoutParser = c.layoutParser; } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java index b7454d96879..5313f4f80b5 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java @@ -25,6 +25,8 @@ package com.sun.tools.doclets.internal.toolkit.builders; +import java.util.Set; + import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; @@ -48,8 +50,8 @@ public abstract class AbstractMemberBuilder extends AbstractBuilder { * @param configuration the configuration used in this run * of the doclet. */ - public AbstractMemberBuilder(Configuration configuration) { - super(configuration); + public AbstractMemberBuilder(Context context) { + super(context); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java index acde3af8d2f..1a9dec1f757 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java @@ -54,12 +54,12 @@ public class AnnotationTypeBuilder extends AbstractBuilder { /** * The annotation type being documented. */ - private AnnotationTypeDoc annotationTypeDoc; + private final AnnotationTypeDoc annotationTypeDoc; /** * The doclet specific writer. */ - private AnnotationTypeWriter writer; + private final AnnotationTypeWriter writer; /** * The content tree for the annotation documentation. @@ -69,38 +69,37 @@ public class AnnotationTypeBuilder extends AbstractBuilder { /** * Construct a new ClassBuilder. * - * @param configuration the current configuration of the - * doclet. + * @param context the build context. + * @param annotationTypeDoc the class being documented. + * @param writer the doclet specific writer. */ - private AnnotationTypeBuilder(Configuration configuration) { - super(configuration); + private AnnotationTypeBuilder(Context context, + AnnotationTypeDoc annotationTypeDoc, + AnnotationTypeWriter writer) { + super(context); + this.annotationTypeDoc = annotationTypeDoc; + this.writer = writer; } /** * Construct a new ClassBuilder. * - * @param configuration the current configuration of the doclet. + * @param context the build context. * @param annotationTypeDoc the class being documented. * @param writer the doclet specific writer. */ - public static AnnotationTypeBuilder getInstance(Configuration configuration, - AnnotationTypeDoc annotationTypeDoc, AnnotationTypeWriter writer) - throws Exception { - AnnotationTypeBuilder builder = new AnnotationTypeBuilder(configuration); - builder.configuration = configuration; - builder.annotationTypeDoc = annotationTypeDoc; - builder.writer = writer; - if(containingPackagesSeen == null) { - containingPackagesSeen = new HashSet(); - } - return builder; + public static AnnotationTypeBuilder getInstance(Context context, + AnnotationTypeDoc annotationTypeDoc, + AnnotationTypeWriter writer) + throws Exception { + return new AnnotationTypeBuilder(context, annotationTypeDoc, writer); } /** * {@inheritDoc} */ public void build() throws IOException { - build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree); + build(layoutParser.parseXML(ROOT), contentTree); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java index edcfbe2094f..9c28e9eae4d 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java @@ -25,8 +25,6 @@ package com.sun.tools.doclets.internal.toolkit.builders; -import java.util.*; - import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; @@ -44,43 +42,36 @@ import com.sun.tools.doclets.internal.toolkit.util.*; * @since 1.5 */ public class AnnotationTypeOptionalMemberBuilder extends - AnnotationTypeRequiredMemberBuilder { + AnnotationTypeRequiredMemberBuilder { /** * Construct a new AnnotationTypeMemberBuilder. * - * @param configuration the current configuration of the - * doclet. + * @param context the build context. + * @param classDoc the class whose members are being documented. + * @param writer the doclet specific writer. */ - private AnnotationTypeOptionalMemberBuilder(Configuration configuration) { - super(configuration); + private AnnotationTypeOptionalMemberBuilder(Context context, + ClassDoc classDoc, + AnnotationTypeOptionalMemberWriter writer) { + super(context, classDoc, writer, + VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL); } /** * Construct a new AnnotationTypeMemberBuilder. * - * @param configuration the current configuration of the doclet. - * @param classDoc the class whoses members are being documented. + * @param context the build context. + * @param classDoc the class whose members are being documented. * @param writer the doclet specific writer. */ public static AnnotationTypeOptionalMemberBuilder getInstance( - Configuration configuration, ClassDoc classDoc, + Context context, ClassDoc classDoc, AnnotationTypeOptionalMemberWriter writer) { - AnnotationTypeOptionalMemberBuilder builder = - new AnnotationTypeOptionalMemberBuilder(configuration); - builder.classDoc = classDoc; - builder.writer = writer; - builder.visibleMemberMap = new VisibleMemberMap(classDoc, - VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated); - builder.members = new ArrayList( - builder.visibleMemberMap.getMembersFor(classDoc)); - if (configuration.getMemberComparator() != null) { - Collections.sort(builder.members, - configuration.getMemberComparator()); - } - return builder; + return new AnnotationTypeOptionalMemberBuilder(context, + classDoc, writer); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java index 733eac39aa7..b44161dab81 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java @@ -74,37 +74,40 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { /** * Construct a new AnnotationTypeRequiredMemberBuilder. * - * @param configuration the current configuration of the - * doclet. + * @param context the build context. + * @param classDoc the class whose members are being documented. + * @param writer the doclet specific writer. */ - protected AnnotationTypeRequiredMemberBuilder(Configuration configuration) { - super(configuration); + protected AnnotationTypeRequiredMemberBuilder(Context context, + ClassDoc classDoc, + AnnotationTypeRequiredMemberWriter writer, + int memberType) { + super(context); + this.classDoc = classDoc; + this.writer = writer; + this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType, + configuration.nodeprecated); + this.members = new ArrayList( + this.visibleMemberMap.getMembersFor(classDoc)); + if (configuration.getMemberComparator() != null) { + Collections.sort(this.members, configuration.getMemberComparator()); + } } /** * Construct a new AnnotationTypeMemberBuilder. * - * @param configuration the current configuration of the doclet. - * @param classDoc the class whoses members are being documented. + * @param context the build context. + * @param classDoc the class whose members are being documented. * @param writer the doclet specific writer. */ public static AnnotationTypeRequiredMemberBuilder getInstance( - Configuration configuration, ClassDoc classDoc, + Context context, ClassDoc classDoc, AnnotationTypeRequiredMemberWriter writer) { - AnnotationTypeRequiredMemberBuilder builder = - new AnnotationTypeRequiredMemberBuilder(configuration); - builder.classDoc = classDoc; - builder.writer = writer; - builder.visibleMemberMap = new VisibleMemberMap(classDoc, - VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, configuration.nodeprecated); - builder.members = new ArrayList( - builder.visibleMemberMap.getMembersFor(classDoc)); - if (configuration.getMemberComparator() != null) { - Collections.sort(builder.members, - configuration.getMemberComparator()); - } - return builder; + return new AnnotationTypeRequiredMemberBuilder(context, classDoc, + writer, + VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java index 71fb5a36b1b..1936c72a9fa 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java @@ -25,6 +25,9 @@ package com.sun.tools.doclets.internal.toolkit.builders; +import java.util.HashSet; +import java.util.Set; + import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; @@ -46,12 +49,14 @@ public class BuilderFactory { /** * The current configuration of the doclet. */ - private Configuration configuration; + private final Configuration configuration; /** * The factory to retrieve the required writers from. */ - private WriterFactory writerFactory; + private final WriterFactory writerFactory; + + private final AbstractBuilder.Context context; /** * Construct a builder factory using the given configuration. @@ -61,6 +66,10 @@ public class BuilderFactory { public BuilderFactory (Configuration configuration) { this.configuration = configuration; this.writerFactory = configuration.getWriterFactory(); + + Set containingPackagesSeen = new HashSet(); + context = new AbstractBuilder.Context(configuration, containingPackagesSeen, + LayoutParser.getInstance(configuration)); } /** @@ -68,7 +77,7 @@ public class BuilderFactory { * @return the builder that builds the constant summary. */ public AbstractBuilder getConstantsSummaryBuider() throws Exception { - return ConstantsSummaryBuilder.getInstance(configuration, + return ConstantsSummaryBuilder.getInstance(context, writerFactory.getConstantsSummaryWriter()); } @@ -82,7 +91,7 @@ public class BuilderFactory { */ public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg, PackageDoc nextPkg) throws Exception { - return PackageSummaryBuilder.getInstance(configuration, pkg, + return PackageSummaryBuilder.getInstance(context, pkg, writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg)); } @@ -97,9 +106,9 @@ public class BuilderFactory { * writer is not supported by the doclet. */ public AbstractBuilder getClassBuilder(ClassDoc classDoc, - ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) + ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) throws Exception { - return ClassBuilder.getInstance(configuration, classDoc, + return ClassBuilder.getInstance(context, classDoc, writerFactory.getClassWriter(classDoc, prevClass, nextClass, classTree)); } @@ -117,9 +126,8 @@ public class BuilderFactory { AnnotationTypeDoc annotationType, Type prevType, Type nextType) throws Exception { - return AnnotationTypeBuilder.getInstance(configuration, annotationType, - writerFactory.getAnnotationTypeWriter(annotationType, prevType, - nextType)); + return AnnotationTypeBuilder.getInstance(context, annotationType, + writerFactory.getAnnotationTypeWriter(annotationType, prevType, nextType)); } /** @@ -129,7 +137,7 @@ public class BuilderFactory { */ public AbstractBuilder getMethodBuilder(ClassWriter classWriter) throws Exception { - return MethodBuilder.getInstance(configuration, + return MethodBuilder.getInstance(context, classWriter.getClassDoc(), writerFactory.getMethodWriter(classWriter)); } @@ -144,7 +152,7 @@ public class BuilderFactory { public AbstractBuilder getAnnotationTypeOptionalMemberBuilder( AnnotationTypeWriter annotationTypeWriter) throws Exception { - return AnnotationTypeOptionalMemberBuilder.getInstance(configuration, + return AnnotationTypeOptionalMemberBuilder.getInstance(context, annotationTypeWriter.getAnnotationTypeDoc(), writerFactory.getAnnotationTypeOptionalMemberWriter( annotationTypeWriter)); @@ -160,7 +168,7 @@ public class BuilderFactory { public AbstractBuilder getAnnotationTypeRequiredMemberBuilder( AnnotationTypeWriter annotationTypeWriter) throws Exception { - return AnnotationTypeRequiredMemberBuilder.getInstance(configuration, + return AnnotationTypeRequiredMemberBuilder.getInstance(context, annotationTypeWriter.getAnnotationTypeDoc(), writerFactory.getAnnotationTypeRequiredMemberWriter( annotationTypeWriter)); @@ -173,7 +181,7 @@ public class BuilderFactory { */ public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter) throws Exception { - return EnumConstantBuilder.getInstance(configuration, classWriter.getClassDoc(), + return EnumConstantBuilder.getInstance(context, classWriter.getClassDoc(), writerFactory.getEnumConstantWriter(classWriter)); } @@ -184,7 +192,7 @@ public class BuilderFactory { */ public AbstractBuilder getFieldBuilder(ClassWriter classWriter) throws Exception { - return FieldBuilder.getInstance(configuration, classWriter.getClassDoc(), + return FieldBuilder.getInstance(context, classWriter.getClassDoc(), writerFactory.getFieldWriter(classWriter)); } @@ -195,9 +203,9 @@ public class BuilderFactory { */ public AbstractBuilder getConstructorBuilder(ClassWriter classWriter) throws Exception { - return ConstructorBuilder.getInstance(configuration, - classWriter.getClassDoc(), writerFactory.getConstructorWriter( - classWriter)); + return ConstructorBuilder.getInstance(context, + classWriter.getClassDoc(), + writerFactory.getConstructorWriter(classWriter)); } /** @@ -207,7 +215,7 @@ public class BuilderFactory { */ public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter) throws Exception { - return MemberSummaryBuilder.getInstance(classWriter, configuration); + return MemberSummaryBuilder.getInstance(classWriter, context); } /** @@ -220,8 +228,7 @@ public class BuilderFactory { public AbstractBuilder getMemberSummaryBuilder( AnnotationTypeWriter annotationTypeWriter) throws Exception { - return MemberSummaryBuilder.getInstance(annotationTypeWriter, - configuration); + return MemberSummaryBuilder.getInstance(annotationTypeWriter, context); } /** @@ -231,6 +238,6 @@ public class BuilderFactory { */ public AbstractBuilder getSerializedFormBuilder() throws Exception { - return SerializedFormBuilder.getInstance(configuration); + return SerializedFormBuilder.getInstance(context); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java index 83b0b85dd4d..1f2e82a10ad 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java @@ -54,22 +54,22 @@ public class ClassBuilder extends AbstractBuilder { /** * The class being documented. */ - private ClassDoc classDoc; + private final ClassDoc classDoc; /** * The doclet specific writer. */ - private ClassWriter writer; + private final ClassWriter writer; /** * Keep track of whether or not this classdoc is an interface. */ - private boolean isInterface = false; + private final boolean isInterface; /** * Keep track of whether or not this classdoc is an enum. */ - private boolean isEnum = false; + private final boolean isEnum; /** * The content tree for the class documentation. @@ -79,44 +79,45 @@ public class ClassBuilder extends AbstractBuilder { /** * Construct a new ClassBuilder. * - * @param configuration the current configuration of the - * doclet. + * @param context the build context + * @param classDoc the class being documented. + * @param writer the doclet specific writer. */ - private ClassBuilder(Configuration configuration) { - super(configuration); + private ClassBuilder(Context context, + ClassDoc classDoc, ClassWriter writer) { + super(context); + this.classDoc = classDoc; + this.writer = writer; + if (classDoc.isInterface()) { + isInterface = true; + isEnum = false; + } else if (classDoc.isEnum()) { + isInterface = false; + isEnum = true; + Util.setEnumDocumentation(configuration, classDoc); + } else { + isInterface = false; + isEnum = false; + } } /** * Construct a new ClassBuilder. * - * @param configuration the current configuration of the doclet. + * @param context the build context * @param classDoc the class being documented. * @param writer the doclet specific writer. */ - public static ClassBuilder getInstance(Configuration configuration, - ClassDoc classDoc, ClassWriter writer) - throws Exception { - ClassBuilder builder = new ClassBuilder(configuration); - builder.configuration = configuration; - builder.classDoc = classDoc; - builder.writer = writer; - if (classDoc.isInterface()) { - builder.isInterface = true; - } else if (classDoc.isEnum()) { - builder.isEnum = true; - Util.setEnumDocumentation(configuration, classDoc); - } - if(containingPackagesSeen == null) { - containingPackagesSeen = new HashSet(); - } - return builder; + public static ClassBuilder getInstance(Context context, + ClassDoc classDoc, ClassWriter writer) { + return new ClassBuilder(context, classDoc, writer); } /** * {@inheritDoc} */ public void build() throws IOException { - build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree); + build(layoutParser.parseXML(ROOT), contentTree); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java index 6de9f78920f..bab4f0da24e 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java @@ -60,12 +60,12 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { /** * The writer used to write the results. */ - protected ConstantsSummaryWriter writer; + protected final ConstantsSummaryWriter writer; /** * The set of ClassDocs that have constant fields. */ - protected Set classDocsWithConstFields; + protected final Set classDocsWithConstFields; /** * The set of printed package headers. @@ -90,27 +90,25 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { /** * Construct a new ConstantsSummaryBuilder. * - * @param configuration the current configuration of the - * doclet. + * @param context the build context. + * @param writer the writer for the summary. */ - private ConstantsSummaryBuilder(Configuration configuration) { - super(configuration); + private ConstantsSummaryBuilder(Context context, + ConstantsSummaryWriter writer) { + super(context); + this.writer = writer; + this.classDocsWithConstFields = new HashSet(); } /** * Construct a ConstantsSummaryBuilder. * - * @param configuration the configuration used in this run - * of the doclet. + * @param context the build context. * @param writer the writer for the summary. */ - public static ConstantsSummaryBuilder getInstance( - Configuration configuration, ConstantsSummaryWriter writer) { - ConstantsSummaryBuilder builder = new ConstantsSummaryBuilder( - configuration); - builder.writer = writer; - builder.classDocsWithConstFields = new HashSet(); - return builder; + public static ConstantsSummaryBuilder getInstance(Context context, + ConstantsSummaryWriter writer) { + return new ConstantsSummaryBuilder(context, writer); } /** @@ -121,7 +119,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { //Doclet does not support this output. return; } - build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree); + build(layoutParser.parseXML(ROOT), contentTree); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java index 20f93081562..d4cb7061f6c 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java @@ -59,66 +59,64 @@ public class ConstructorBuilder extends AbstractMemberBuilder { /** * The class whose constructors are being documented. */ - private ClassDoc classDoc; + private final ClassDoc classDoc; /** * The visible constructors for the given class. */ - private VisibleMemberMap visibleMemberMap; + private final VisibleMemberMap visibleMemberMap; /** * The writer to output the constructor documentation. */ - private ConstructorWriter writer; + private final ConstructorWriter writer; /** * The constructors being documented. */ - private List constructors; + private final List constructors; /** * Construct a new ConstructorBuilder. * - * @param configuration the current configuration of the - * doclet. + * @param context the build context. + * @param classDoc the class whoses members are being documented. + * @param writer the doclet specific writer. */ - private ConstructorBuilder(Configuration configuration) { - super(configuration); + private ConstructorBuilder(Context context, + ClassDoc classDoc, + ConstructorWriter writer) { + super(context); + this.classDoc = classDoc; + this.writer = writer; + visibleMemberMap = + new VisibleMemberMap( + classDoc, + VisibleMemberMap.CONSTRUCTORS, + configuration.nodeprecated); + constructors = + new ArrayList(visibleMemberMap.getMembersFor(classDoc)); + for (int i = 0; i < constructors.size(); i++) { + if (constructors.get(i).isProtected() + || constructors.get(i).isPrivate()) { + writer.setFoundNonPubConstructor(true); + } + } + if (configuration.getMemberComparator() != null) { + Collections.sort(constructors,configuration.getMemberComparator()); + } } /** * Construct a new ConstructorBuilder. * - * @param configuration the current configuration of the doclet. + * @param context the build context. * @param classDoc the class whoses members are being documented. * @param writer the doclet specific writer. */ - public static ConstructorBuilder getInstance( - Configuration configuration, - ClassDoc classDoc, - ConstructorWriter writer) { - ConstructorBuilder builder = new ConstructorBuilder(configuration); - builder.classDoc = classDoc; - builder.writer = writer; - builder.visibleMemberMap = - new VisibleMemberMap( - classDoc, - VisibleMemberMap.CONSTRUCTORS, - configuration.nodeprecated); - builder.constructors = - new ArrayList(builder.visibleMemberMap.getMembersFor(classDoc)); - for (int i = 0; i < builder.constructors.size(); i++) { - if (builder.constructors.get(i).isProtected() - || builder.constructors.get(i).isPrivate()) { - writer.setFoundNonPubConstructor(true); - } - } - if (configuration.getMemberComparator() != null) { - Collections.sort( - builder.constructors, - configuration.getMemberComparator()); - } - return builder; + public static ConstructorBuilder getInstance(Context context, + ClassDoc classDoc, ConstructorWriter writer) { + return new ConstructorBuilder(context, classDoc, writer); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java index 36f5d397441..6ac59cd3034 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java @@ -48,22 +48,22 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { /** * The class whose enum constants are being documented. */ - private ClassDoc classDoc; + private final ClassDoc classDoc; /** * The visible enum constantss for the given class. */ - private VisibleMemberMap visibleMemberMap; + private final VisibleMemberMap visibleMemberMap; /** * The writer to output the enum constants documentation. */ - private EnumConstantWriter writer; + private final EnumConstantWriter writer; /** * The list of enum constants being documented. */ - private List enumConstants; + private final List enumConstants; /** * The index of the current enum constant that is being documented at this point @@ -74,40 +74,37 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { /** * Construct a new EnumConstantsBuilder. * - * @param configuration the current configuration of the - * doclet. + * @param context the build context. + * @param classDoc the class whoses members are being documented. + * @param writer the doclet specific writer. */ - private EnumConstantBuilder(Configuration configuration) { - super(configuration); + private EnumConstantBuilder(Context context, + ClassDoc classDoc, EnumConstantWriter writer) { + super(context); + this.classDoc = classDoc; + this.writer = writer; + visibleMemberMap = + new VisibleMemberMap( + classDoc, + VisibleMemberMap.ENUM_CONSTANTS, + configuration.nodeprecated); + enumConstants = + new ArrayList(visibleMemberMap.getMembersFor(classDoc)); + if (configuration.getMemberComparator() != null) { + Collections.sort(enumConstants, configuration.getMemberComparator()); + } } /** * Construct a new EnumConstantsBuilder. * - * @param configuration the current configuration of the doclet. + * @param context the build context. * @param classDoc the class whoses members are being documented. * @param writer the doclet specific writer. */ - public static EnumConstantBuilder getInstance( - Configuration configuration, - ClassDoc classDoc, - EnumConstantWriter writer) { - EnumConstantBuilder builder = new EnumConstantBuilder(configuration); - builder.classDoc = classDoc; - builder.writer = writer; - builder.visibleMemberMap = - new VisibleMemberMap( - classDoc, - VisibleMemberMap.ENUM_CONSTANTS, - configuration.nodeprecated); - builder.enumConstants = - new ArrayList(builder.visibleMemberMap.getMembersFor(classDoc)); - if (configuration.getMemberComparator() != null) { - Collections.sort( - builder.enumConstants, - configuration.getMemberComparator()); - } - return builder; + public static EnumConstantBuilder getInstance(Context context, + ClassDoc classDoc, EnumConstantWriter writer) { + return new EnumConstantBuilder(context, classDoc, writer); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java index 4f05027f672..a9dbec3bd74 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java @@ -48,22 +48,22 @@ public class FieldBuilder extends AbstractMemberBuilder { /** * The class whose fields are being documented. */ - private ClassDoc classDoc; + private final ClassDoc classDoc; /** * The visible fields for the given class. */ - private VisibleMemberMap visibleMemberMap; + private final VisibleMemberMap visibleMemberMap; /** * The writer to output the field documentation. */ - private FieldWriter writer; + private final FieldWriter writer; /** * The list of fields being documented. */ - private List fields; + private final List fields; /** * The index of the current field that is being documented at this point @@ -74,41 +74,40 @@ public class FieldBuilder extends AbstractMemberBuilder { /** * Construct a new FieldBuilder. * - * @param configuration the current configuration of the - * doclet. + * @param context the build context. + * @param classDoc the class whoses members are being documented. + * @param writer the doclet specific writer. */ - private FieldBuilder(Configuration configuration) { - super(configuration); + private FieldBuilder(Context context, + ClassDoc classDoc, + FieldWriter writer) { + super(context); + this.classDoc = classDoc; + this.writer = writer; + visibleMemberMap = + new VisibleMemberMap( + classDoc, + VisibleMemberMap.FIELDS, + configuration.nodeprecated); + fields = + new ArrayList(visibleMemberMap.getLeafClassMembers( + configuration)); + if (configuration.getMemberComparator() != null) { + Collections.sort(fields, configuration.getMemberComparator()); + } } /** * Construct a new FieldBuilder. * - * @param configuration the current configuration of the doclet. + * @param context the build context. * @param classDoc the class whoses members are being documented. * @param writer the doclet specific writer. */ - public static FieldBuilder getInstance( - Configuration configuration, + public static FieldBuilder getInstance(Context context, ClassDoc classDoc, FieldWriter writer) { - FieldBuilder builder = new FieldBuilder(configuration); - builder.classDoc = classDoc; - builder.writer = writer; - builder.visibleMemberMap = - new VisibleMemberMap( - classDoc, - VisibleMemberMap.FIELDS, - configuration.nodeprecated); - builder.fields = - new ArrayList(builder.visibleMemberMap.getLeafClassMembers( - configuration)); - if (configuration.getMemberComparator() != null) { - Collections.sort( - builder.fields, - configuration.getMemberComparator()); - } - return builder; + return new FieldBuilder(context, classDoc, writer); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java index f6e2f339dda..6c9b3067846 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java @@ -55,14 +55,10 @@ public class LayoutParser extends DefaultHandler { */ private Map xmlElementsMap; private XMLNode currentNode; - private Configuration configuration; - private static LayoutParser instance; + private final Configuration configuration; private String currentRoot; private boolean isParsing; - /** - * This class is a singleton. - */ private LayoutParser(Configuration configuration) { xmlElementsMap = new HashMap(); this.configuration = configuration; @@ -75,10 +71,7 @@ public class LayoutParser extends DefaultHandler { * @return an instance of the BuilderXML. */ public static LayoutParser getInstance(Configuration configuration) { - if (instance == null) { - instance = new LayoutParser(configuration); - } - return instance; + return new LayoutParser(configuration); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java index 2d81a4caefd..955950ffab5 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java @@ -53,7 +53,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * The visible members for the given class. */ - private VisibleMemberMap[] visibleMemberMaps; + private final VisibleMemberMap[] visibleMemberMaps; /** * The member summary writers for the given class. @@ -63,10 +63,27 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * The type being documented. */ - private ClassDoc classDoc; + private final ClassDoc classDoc; - private MemberSummaryBuilder(Configuration configuration) { - super(configuration); + /** + * Construct a new MemberSummaryBuilder. + * + * @param classWriter the writer for the class whose members are being + * summarized. + * @param context the build context. + */ + private MemberSummaryBuilder(Context context, ClassDoc classDoc) { + super(context); + this.classDoc = classDoc; + visibleMemberMaps = + new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES]; + for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) { + visibleMemberMaps[i] = + new VisibleMemberMap( + classDoc, + i, + configuration.nodeprecated); + } } /** @@ -74,14 +91,22 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { * * @param classWriter the writer for the class whose members are being * summarized. - * @param configuration the current configuration of the doclet. + * @param context the build context. */ public static MemberSummaryBuilder getInstance( - ClassWriter classWriter, Configuration configuration) + ClassWriter classWriter, Context context) throws Exception { - MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration); - builder.classDoc = classWriter.getClassDoc(); - builder.init(classWriter); + MemberSummaryBuilder builder = new MemberSummaryBuilder(context, + classWriter.getClassDoc()); + builder.memberSummaryWriters = + new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES]; + WriterFactory wf = context.configuration.getWriterFactory(); + for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) { + builder.memberSummaryWriters[i] = + builder.visibleMemberMaps[i].noVisibleMembers() ? + null : + wf.getMemberSummaryWriter(classWriter, i); + } return builder; } @@ -93,42 +118,21 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { * @param configuration the current configuration of the doclet. */ public static MemberSummaryBuilder getInstance( - AnnotationTypeWriter annotationTypeWriter, Configuration configuration) + AnnotationTypeWriter annotationTypeWriter, Context context) throws Exception { - MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration); - builder.classDoc = annotationTypeWriter.getAnnotationTypeDoc(); - builder.init(annotationTypeWriter); - return builder; - } - - private void init(Object writer) throws Exception { - visibleMemberMaps = - new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES]; - for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) { - visibleMemberMaps[i] = - new VisibleMemberMap( - classDoc, - i, - configuration.nodeprecated); - } - memberSummaryWriters = + MemberSummaryBuilder builder = new MemberSummaryBuilder(context, + annotationTypeWriter.getAnnotationTypeDoc()); + builder.memberSummaryWriters = new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES]; + WriterFactory wf = context.configuration.getWriterFactory(); for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) { - if (classDoc.isAnnotationType()) { - memberSummaryWriters[i] = - visibleMemberMaps[i].noVisibleMembers()? + builder.memberSummaryWriters[i] = + builder.visibleMemberMaps[i].noVisibleMembers()? null : - configuration.getWriterFactory().getMemberSummaryWriter( - (AnnotationTypeWriter) writer, i); - } else { - memberSummaryWriters[i] = - visibleMemberMaps[i].noVisibleMembers()? - null : - configuration.getWriterFactory().getMemberSummaryWriter( - (ClassWriter) writer, i); - } + wf.getMemberSummaryWriter( + annotationTypeWriter, i); } - + return builder; } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java index ed933351fe1..2c9b10c93ba 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java @@ -54,57 +54,61 @@ public class MethodBuilder extends AbstractMemberBuilder { /** * The class whose methods are being documented. */ - private ClassDoc classDoc; + private final ClassDoc classDoc; /** * The visible methods for the given class. */ - private VisibleMemberMap visibleMemberMap; + private final VisibleMemberMap visibleMemberMap; /** * The writer to output the method documentation. */ - private MethodWriter writer; + private final MethodWriter writer; /** * The methods being documented. */ private List methods; - private MethodBuilder(Configuration configuration) { - super(configuration); + + /** + * Construct a new MethodBuilder. + * + * @param context the build context. + * @param classDoc the class whoses members are being documented. + * @param writer the doclet specific writer. + */ + private MethodBuilder(Context context, + ClassDoc classDoc, + MethodWriter writer) { + super(context); + this.classDoc = classDoc; + this.writer = writer; + visibleMemberMap = new VisibleMemberMap( + classDoc, + VisibleMemberMap.METHODS, + configuration.nodeprecated); + methods = + new ArrayList(visibleMemberMap.getLeafClassMembers( + configuration)); + if (configuration.getMemberComparator() != null) { + Collections.sort(methods, configuration.getMemberComparator()); + } } /** * Construct a new MethodBuilder. * - * @param configuration the current configuration of the doclet. + * @param context the build context. * @param classDoc the class whoses members are being documented. * @param writer the doclet specific writer. * * @return an instance of a MethodBuilder. */ - public static MethodBuilder getInstance( - Configuration configuration, - ClassDoc classDoc, - MethodWriter writer) { - MethodBuilder builder = new MethodBuilder(configuration); - builder.classDoc = classDoc; - builder.writer = writer; - builder.visibleMemberMap = - new VisibleMemberMap( - classDoc, - VisibleMemberMap.METHODS, - configuration.nodeprecated); - builder.methods = - new ArrayList(builder.visibleMemberMap.getLeafClassMembers( - configuration)); - if (configuration.getMemberComparator() != null) { - Collections.sort( - builder.methods, - configuration.getMemberComparator()); - } - return builder; + public static MethodBuilder getInstance(Context context, + ClassDoc classDoc, MethodWriter writer) { + return new MethodBuilder(context, classDoc, writer); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java index 290d1fbc24f..a40968da070 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java @@ -52,40 +52,47 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * The package being documented. */ - private PackageDoc packageDoc; + private final PackageDoc packageDoc; /** * The doclet specific writer that will output the result. */ - private PackageSummaryWriter packageWriter; + private final PackageSummaryWriter packageWriter; /** * The content that will be added to the package summary documentation tree. */ private Content contentTree; - private PackageSummaryBuilder(Configuration configuration) { - super(configuration); + /** + * Construct a new PackageSummaryBuilder. + * + * @param context the build context. + * @param pkg the package being documented. + * @param packageWriter the doclet specific writer that will output the + * result. + */ + private PackageSummaryBuilder(Context context, + PackageDoc pkg, + PackageSummaryWriter packageWriter) { + super(context); + this.packageDoc = pkg; + this.packageWriter = packageWriter; } /** * Construct a new PackageSummaryBuilder. - * @param configuration the current configuration of the doclet. + * + * @param context the build context. * @param pkg the package being documented. * @param packageWriter the doclet specific writer that will output the * result. * * @return an instance of a PackageSummaryBuilder. */ - public static PackageSummaryBuilder getInstance( - Configuration configuration, - PackageDoc pkg, - PackageSummaryWriter packageWriter) { - PackageSummaryBuilder builder = - new PackageSummaryBuilder(configuration); - builder.packageDoc = pkg; - builder.packageWriter = packageWriter; - return builder; + public static PackageSummaryBuilder getInstance(Context context, + PackageDoc pkg, PackageSummaryWriter packageWriter) { + return new PackageSummaryBuilder(context, pkg, packageWriter); } /** @@ -96,7 +103,7 @@ public class PackageSummaryBuilder extends AbstractBuilder { //Doclet does not support this output. return; } - build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree); + build(layoutParser.parseXML(ROOT), contentTree); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java index 3b50d6c00e7..da424f66036 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java @@ -93,17 +93,21 @@ public class SerializedFormBuilder extends AbstractBuilder { */ private Content contentTree; - private SerializedFormBuilder(Configuration configuration) { - super(configuration); + + /** + * Construct a new SerializedFormBuilder. + * @param context the build context. + */ + private SerializedFormBuilder(Context context) { + super(context); } /** * Construct a new SerializedFormBuilder. - * @param configuration the current configuration of the doclet. + * @param context the build context. */ - public static SerializedFormBuilder getInstance(Configuration configuration) { - SerializedFormBuilder builder = new SerializedFormBuilder(configuration); - return builder; + public static SerializedFormBuilder getInstance(Context context) { + return new SerializedFormBuilder(context); } /** @@ -123,7 +127,7 @@ public class SerializedFormBuilder extends AbstractBuilder { } catch (Exception e) { throw new DocletAbortException(); } - build(LayoutParser.getInstance(configuration).parseXML(NAME), contentTree); + build(layoutParser.parseXML(NAME), contentTree); writer.close(); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java index e737f9c7698..65924bbad7f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java @@ -26,6 +26,7 @@ package com.sun.tools.doclets.internal.toolkit.taglets; import com.sun.javadoc.*; +import com.sun.tools.doclets.internal.toolkit.Configuration; import com.sun.tools.doclets.internal.toolkit.util.*; /** @@ -104,7 +105,7 @@ public class InheritDocTaglet extends BaseInlineTaglet { /** * Given a MethodDoc item, a Tag in the - * MethodDoc item and a String, replace all occurances + * MethodDoc item and a String, replace all occurrences * of @inheritDoc with documentation from it's superclass or superinterface. * * @param writer the writer that is writing the output. @@ -116,12 +117,13 @@ public class InheritDocTaglet extends BaseInlineTaglet { MethodDoc md, Tag holderTag, boolean isFirstSentence) { TagletOutput replacement = writer.getTagletOutputInstance(); + Configuration configuration = writer.configuration(); Taglet inheritableTaglet = holderTag == null ? - null : writer.configuration().tagletManager.getTaglet(holderTag.name()); + null : configuration.tagletManager.getTaglet(holderTag.name()); if (inheritableTaglet != null && !(inheritableTaglet instanceof InheritableTaglet)) { //This tag does not support inheritence. - writer.configuration().message.warning(md.position(), + configuration.message.warning(md.position(), "doclet.noInheritedDoc", md.name() + md.flatSignature()); } DocFinder.Output inheritedDoc = @@ -129,7 +131,7 @@ public class InheritDocTaglet extends BaseInlineTaglet { (InheritableTaglet) inheritableTaglet, holderTag, isFirstSentence, true)); if (inheritedDoc.isValidInheritDocTag == false) { - writer.configuration().message.warning(md.position(), + configuration.message.warning(md.position(), "doclet.noInheritedDoc", md.name() + md.flatSignature()); } else if (inheritedDoc.inlineTags.length > 0) { replacement = writer.commentTagsToOutput(inheritedDoc.holderTag, diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java index 2e594db8e77..4410f51ce1f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java @@ -46,7 +46,11 @@ public abstract class TagletWriter { /** * True if we only want to write the first sentence. */ - protected boolean isFirstSentence = false; + protected final boolean isFirstSentence; + + protected TagletWriter(boolean isFirstSentence) { + this.isFirstSentence = isFirstSentence; + } /** * @return an instance of the output object. diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java index 36c141aeba7..045d73e8671 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java @@ -45,13 +45,6 @@ import javax.tools.StandardLocation; */ public class Util { - /** - * A mapping between characters and their - * corresponding HTML escape character. - */ - public static final String[][] HTML_ESCAPE_CHARS = - {{"&", "&"}, {"<", "<"}, {">", ">"}}; - /** * Return array of class members whose documentation is to be generated. * If the member is deprecated do not include such a member in the @@ -424,18 +417,44 @@ public class Util { * return the result. * * @param s The string to check. - * @return the original string with all of the HTML characters - * escaped. - * - * @see #HTML_ESCAPE_CHARS + * @return the original string with all of the HTML characters escaped. */ public static String escapeHtmlChars(String s) { - String result = s; - for (int i = 0; i < HTML_ESCAPE_CHARS.length; i++) { - result = Util.replaceText(result, - HTML_ESCAPE_CHARS[i][0], HTML_ESCAPE_CHARS[i][1]); + for (int i = 0; i < s.length(); i++) { + char ch = s.charAt(i); + switch (ch) { + // only start building a new string if we need to + case '<': case '>': case '&': + StringBuilder sb = new StringBuilder(s.substring(0, i)); + for ( ; i < s.length(); i++) { + ch = s.charAt(i); + switch (ch) { + case '<': sb.append("<"); break; + case '>': sb.append(">"); break; + case '&': sb.append("&"); break; + default: sb.append(ch); break; + } + } + return sb.toString(); + } + } + return s; + } + + /** + * Escape all special html characters in a string buffer. + * + * @param sb The string buffer to update + */ + public static void escapeHtmlChars(StringBuilder sb) { + // scan backwards, replacing characters as needed. + for (int i = sb.length() - 1; i >= 0; i--) { + switch (sb.charAt(i)) { + case '<': sb.replace(i, i+1, "<"); break; + case '>': sb.replace(i, i+1, ">"); break; + case '&': sb.replace(i, i+1, "&"); break; + } } - return result; } /** @@ -579,22 +598,21 @@ public class Util { } /** - * Given a string, replace all tabs with the appropriate - * number of spaces. - * @param tabLength the length of each tab. - * @param s the String to scan. + * Replace all tabs with the appropriate number of spaces. + * @param configuration the doclet configuration defining the setting for the + * tab length. + * @param sb the StringBuilder in which to replace the tabs */ - public static void replaceTabs(int tabLength, StringBuilder s) { - if (whitespace == null || whitespace.length() < tabLength) - whitespace = String.format("%" + tabLength + "s", " "); + public static void replaceTabs(Configuration configuration, StringBuilder sb) { + int tabLength = configuration.sourcetab; + String whitespace = configuration.tabSpaces; int index = 0; - while ((index = s.indexOf("\t", index)) != -1) { + while ((index = sb.indexOf("\t", index)) != -1) { int spaceCount = tabLength - index % tabLength; - s.replace(index, index+1, whitespace.substring(0, spaceCount)); + sb.replace(index, index+1, whitespace.substring(0, spaceCount)); index += spaceCount; } } - private static String whitespace; /** * The documentation for values() and valueOf() in Enums are set by the diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java index 8033405365d..e8775393776 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java @@ -43,7 +43,7 @@ import com.sun.javadoc.*; */ class ParamTagImpl extends TagImpl implements ParamTag { - private static Pattern typeParamRE = Pattern.compile("<([^<>]+)>"); + private static final Pattern typeParamRE = Pattern.compile("<([^<>]+)>"); private final String parameterName; private final String parameterComment; diff --git a/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java b/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java index 6e0e7264d93..c2a43b5fab6 100644 --- a/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java +++ b/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. 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 @@ -24,9 +24,6 @@ import java.text.SimpleDateFormat; import java.util.Date; -import com.sun.tools.doclets.formats.html.ConfigurationImpl; -import com.sun.tools.doclets.internal.toolkit.Configuration; - /* * @test * @bug 4034096 4764726 6235799 @@ -135,13 +132,7 @@ public class MetaTag extends JavadocTester { */ public static void main(String[] args) { MetaTag tester = new MetaTag(); - Configuration config = ConfigurationImpl.getInstance(); - boolean defaultKeywordsSetting = config.keywords; - boolean defaultTimestampSetting = config.notimestamp; run(tester, ARGS, TEST, NEGATED_TEST); - //Variable needs to be reset because Configuration is a singleton. - config.keywords = defaultKeywordsSetting; - config.notimestamp = defaultTimestampSetting; run(tester, ARGS_NO_TIMESTAMP_NO_KEYWORDS, TEST2, NEGATED_TEST2); tester.printSummary(); } diff --git a/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java b/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java index d6e16e02beb..724630ba8ce 100644 --- a/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java +++ b/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. 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 @@ -60,7 +60,7 @@ public class TestHtmlDocument { // Generate the HTML output using the HTML document generation within doclet. public static String generateHtmlTree() { // Document type for the HTML document - DocType htmlDocType = DocType.Transitional(); + DocType htmlDocType = DocType.TRANSITIONAL; HtmlTree html = new HtmlTree(HtmlTag.HTML); HtmlTree head = new HtmlTree(HtmlTag.HEAD); HtmlTree title = new HtmlTree(HtmlTag.TITLE); From 4b288c8976106e1e8b6fd7643027544b0e50cdfa Mon Sep 17 00:00:00 2001 From: Bharadwaj Yadavalli Date: Thu, 15 Nov 2012 10:42:06 -0800 Subject: [PATCH 25/94] 8001077: remove ciMethod::will_link Removed will_link and changed all calls to is_loaded(). Reviewed-by: kvn --- hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 2 +- hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp | 2 +- hotspot/src/share/vm/ci/ciMethod.cpp | 19 ------------------- hotspot/src/share/vm/ci/ciMethod.hpp | 3 --- hotspot/src/share/vm/opto/doCall.cpp | 2 +- 5 files changed, 3 insertions(+), 25 deletions(-) diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 941dd120a01..70b69157530 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -1836,7 +1836,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) { // check if we could do inlining if (!PatchALot && Inline && klass->is_loaded() && (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized()) - && target->will_link(klass, callee_holder, code)) { + && target->is_loaded()) { // callee is known => check if we have static binding assert(target->is_loaded(), "callee must be known"); if (code == Bytecodes::_invokestatic || diff --git a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp index 70a714f42d1..32dc35d8059 100644 --- a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp +++ b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp @@ -282,7 +282,7 @@ void BCEscapeAnalyzer::invoke(StateInfo &state, Bytecodes::Code code, ciMethod* ciMethod* inline_target = NULL; if (target->is_loaded() && klass->is_loaded() && (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized()) - && target->will_link(klass, callee_holder, code)) { + && target->is_loaded()) { if (code == Bytecodes::_invokestatic || code == Bytecodes::_invokespecial || code == Bytecodes::_invokevirtual && target->is_final_method()) { diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp index 951183d60bd..ed1f4b8b24d 100644 --- a/hotspot/src/share/vm/ci/ciMethod.cpp +++ b/hotspot/src/share/vm/ci/ciMethod.cpp @@ -875,25 +875,6 @@ ciMethodData* ciMethod::method_data_or_null() { return md; } -// ------------------------------------------------------------------ -// ciMethod::will_link -// -// Will this method link in a specific calling context? -bool ciMethod::will_link(ciKlass* accessing_klass, - ciKlass* declared_method_holder, - Bytecodes::Code bc) { - if (!is_loaded()) { - // Method lookup failed. - return false; - } - - // The link checks have been front-loaded into the get_method - // call. This method (ciMethod::will_link()) will be removed - // in the future. - - return true; -} - // ------------------------------------------------------------------ // ciMethod::should_exclude // diff --git a/hotspot/src/share/vm/ci/ciMethod.hpp b/hotspot/src/share/vm/ci/ciMethod.hpp index ecbaacc45d3..cf8a622fa7c 100644 --- a/hotspot/src/share/vm/ci/ciMethod.hpp +++ b/hotspot/src/share/vm/ci/ciMethod.hpp @@ -241,9 +241,6 @@ class ciMethod : public ciMetadata { int resolve_vtable_index(ciKlass* caller, ciKlass* receiver); // Compilation directives - bool will_link(ciKlass* accessing_klass, - ciKlass* declared_method_holder, - Bytecodes::Code bc); bool should_exclude(); bool should_inline(); bool should_not_inline(); diff --git a/hotspot/src/share/vm/opto/doCall.cpp b/hotspot/src/share/vm/opto/doCall.cpp index 95d14884163..ba806d79c55 100644 --- a/hotspot/src/share/vm/opto/doCall.cpp +++ b/hotspot/src/share/vm/opto/doCall.cpp @@ -334,7 +334,7 @@ bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* kl return true; } - assert(dest_method->will_link(method()->holder(), klass, bc()), "dest_method: typeflow responsibility"); + assert(dest_method->is_loaded(), "dest_method: typeflow responsibility"); return false; } From 2aefbba0700eb03fccd6c1c9f7da14fa92092ef0 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 15 Nov 2012 14:41:31 -0800 Subject: [PATCH 26/94] 8003257: refactor javadoc tool option handling Reviewed-by: darcy --- .../classes/com/sun/tools/javadoc/DocEnv.java | 4 +- .../com/sun/tools/javadoc/DocLocale.java | 4 +- .../com/sun/tools/javadoc/DocletInvoker.java | 26 +- .../com/sun/tools/javadoc/JavadocTool.java | 21 +- .../com/sun/tools/javadoc/Messager.java | 225 ++---------- .../classes/com/sun/tools/javadoc/Start.java | 253 +++++--------- .../com/sun/tools/javadoc/ToolOption.java | 325 ++++++++++++++++++ 7 files changed, 453 insertions(+), 405 deletions(-) create mode 100644 langtools/src/share/classes/com/sun/tools/javadoc/ToolOption.java diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java b/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java index 6ccacdb735f..6b14caca675 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java @@ -211,8 +211,8 @@ public class DocEnv { public void setLocale(String localeName) { // create locale specifics doclocale = new DocLocale(this, localeName, breakiterator); - // reset Messager if locale has changed. - messager.reset(); + // update Messager if locale has changed. + messager.setLocale(doclocale.locale); } /** Check whether this member should be documented. */ diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/DocLocale.java b/langtools/src/share/classes/com/sun/tools/javadoc/DocLocale.java index 0f8ba32f0be..2be308da621 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/DocLocale.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocLocale.java @@ -49,7 +49,7 @@ class DocLocale { final String localeName; /** - * The locale to be used. If user doesen't provide this, + * The locale to be used. If user doesn't provide this, * then set it to default locale value. */ final Locale locale; @@ -98,7 +98,7 @@ class DocLocale { if (locale == null) { docenv.exit(); } else { - Locale.setDefault(locale); + Locale.setDefault(locale); // NOTE: updating global state } collator = Collator.getInstance(locale); sentenceBreaker = BreakIterator.getSentenceInstance(locale); diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java b/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java index 308b903c446..9627f5a7f8d 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java @@ -95,7 +95,7 @@ public class DocletInvoker { try { dc = appClassLoader.loadClass(docletClassName); } catch (ClassNotFoundException exc) { - messager.error(null, "main.doclet_class_not_found", docletClassName); + messager.error(Messager.NOPOS, "main.doclet_class_not_found", docletClassName); messager.exit(); } docletClass = dc; @@ -168,7 +168,7 @@ public class DocletInvoker { if (retVal instanceof Boolean) { return ((Boolean)retVal).booleanValue(); } else { - messager.error(null, "main.must_return_boolean", + messager.error(Messager.NOPOS, "main.must_return_boolean", docletClassName, methodName); return false; } @@ -192,7 +192,7 @@ public class DocletInvoker { if (retVal instanceof Integer) { return ((Integer)retVal).intValue(); } else { - messager.error(null, "main.must_return_int", + messager.error(Messager.NOPOS, "main.must_return_int", docletClassName, methodName); return -1; } @@ -217,7 +217,7 @@ public class DocletInvoker { if (retVal instanceof Boolean) { return ((Boolean)retVal).booleanValue(); } else { - messager.error(null, "main.must_return_boolean", + messager.error(Messager.NOPOS, "main.must_return_boolean", docletClassName, methodName); return false; } @@ -241,7 +241,7 @@ public class DocletInvoker { if (retVal instanceof LanguageVersion) { return (LanguageVersion)retVal; } else { - messager.error(null, "main.must_return_languageversion", + messager.error(Messager.NOPOS, "main.must_return_languageversion", docletClassName, methodName); return JAVA_1_1; } @@ -261,19 +261,19 @@ public class DocletInvoker { meth = docletClass.getMethod(methodName, paramTypes); } catch (NoSuchMethodException exc) { if (returnValueIfNonExistent == null) { - messager.error(null, "main.doclet_method_not_found", + messager.error(Messager.NOPOS, "main.doclet_method_not_found", docletClassName, methodName); throw new DocletInvokeException(); } else { return returnValueIfNonExistent; } } catch (SecurityException exc) { - messager.error(null, "main.doclet_method_not_accessible", + messager.error(Messager.NOPOS, "main.doclet_method_not_accessible", docletClassName, methodName); throw new DocletInvokeException(); } if (!Modifier.isStatic(meth.getModifiers())) { - messager.error(null, "main.doclet_method_must_be_static", + messager.error(Messager.NOPOS, "main.doclet_method_must_be_static", docletClassName, methodName); throw new DocletInvokeException(); } @@ -283,23 +283,23 @@ public class DocletInvoker { Thread.currentThread().setContextClassLoader(appClassLoader); return meth.invoke(null , params); } catch (IllegalArgumentException exc) { - messager.error(null, "main.internal_error_exception_thrown", + messager.error(Messager.NOPOS, "main.internal_error_exception_thrown", docletClassName, methodName, exc.toString()); throw new DocletInvokeException(); } catch (IllegalAccessException exc) { - messager.error(null, "main.doclet_method_not_accessible", + messager.error(Messager.NOPOS, "main.doclet_method_not_accessible", docletClassName, methodName); throw new DocletInvokeException(); } catch (NullPointerException exc) { - messager.error(null, "main.internal_error_exception_thrown", + messager.error(Messager.NOPOS, "main.internal_error_exception_thrown", docletClassName, methodName, exc.toString()); throw new DocletInvokeException(); } catch (InvocationTargetException exc) { Throwable err = exc.getTargetException(); if (err instanceof java.lang.OutOfMemoryError) { - messager.error(null, "main.out.of.memory"); + messager.error(Messager.NOPOS, "main.out.of.memory"); } else { - messager.error(null, "main.exception_thrown", + messager.error(Messager.NOPOS, "main.exception_thrown", docletClassName, methodName, exc.toString()); exc.getTargetException().printStackTrace(); } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java index 4bc1493fa33..df63f2c88ce 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java @@ -38,7 +38,6 @@ import javax.tools.StandardJavaFileManager; import javax.tools.StandardLocation; import com.sun.tools.javac.code.Symbol.CompletionFailure; -import com.sun.tools.javac.comp.Annotate; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; @@ -65,11 +64,9 @@ import com.sun.tools.javac.util.Position; public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { DocEnv docenv; - final Context context; final Messager messager; - final JavadocClassReader reader; - final JavadocEnter enter; - final Annotate annotate; + final JavadocClassReader javadocReader; + final JavadocEnter javadocEnter; /** * Construct a new JavaCompiler processor, using appropriately @@ -77,11 +74,9 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { */ protected JavadocTool(Context context) { super(context); - this.context = context; messager = Messager.instance0(context); - reader = JavadocClassReader.instance0(context); - enter = JavadocEnter.instance0(context); - annotate = Annotate.instance(context); + javadocReader = JavadocClassReader.instance0(context); + javadocEnter = JavadocEnter.instance0(context); } /** @@ -138,7 +133,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { docenv.setEncoding(encoding); docenv.docClasses = docClasses; docenv.legacyDoclet = legacyDoclet; - reader.sourceCompleter = docClasses ? null : this; + javadocReader.sourceCompleter = docClasses ? null : this; ListBuffer names = new ListBuffer(); ListBuffer classTrees = new ListBuffer(); @@ -156,7 +151,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { } else if (isValidPackageName(name)) { names = names.append(name); } else if (name.endsWith(".java")) { - docenv.error(null, "main.file_not_found", name); + docenv.error(null, "main.file_not_found", name); } else { docenv.error(null, "main.illegal_package_name", name); } @@ -179,7 +174,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { // Enter symbols for all files docenv.notice("main.Building_tree"); - enter.main(classTrees.toList().appendList(packTrees.toList())); + javadocEnter.main(classTrees.toList().appendList(packTrees.toList())); } } catch (Abort ex) {} @@ -240,7 +235,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { } if (!hasFiles) { - messager.warning(null, "main.no_source_files_for_package", + messager.warning(Messager.NOPOS, "main.no_source_files_for_package", name.replace(File.separatorChar, '.')); } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java b/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java index 64fa6dbeed8..b397816c86b 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java @@ -25,13 +25,15 @@ package com.sun.tools.javadoc; -import java.io.PrintWriter; // Access to 'javac' output streams +import java.io.PrintWriter; import java.text.MessageFormat; -import java.util.MissingResourceException; +import java.util.Locale; import java.util.ResourceBundle; import com.sun.javadoc.*; import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.JCDiagnostic; +import com.sun.tools.javac.util.JavacMessages; import com.sun.tools.javac.util.Log; /** @@ -51,6 +53,7 @@ import com.sun.tools.javac.util.Log; * @author Neal Gafter (rewrite) */ public class Messager extends Log implements DocErrorReporter { + public static final SourcePosition NOPOS = null; /** Get the current messager, which is also the compiler log. */ public static Messager instance0(Context context) { @@ -91,7 +94,9 @@ public class Messager extends Log implements DocErrorReporter { final String programName; - private ResourceBundle messageRB = null; + private Locale locale; + private final JavacMessages messages; + private final JCDiagnostic.Factory javadocDiags; /** The default writer for diagnostics */ @@ -121,6 +126,9 @@ public class Messager extends Log implements DocErrorReporter { PrintWriter warnWriter, PrintWriter noticeWriter) { super(context, errWriter, warnWriter, noticeWriter); + messages = JavacMessages.instance(context); + messages.add("com.sun.tools.javadoc.resources.javadoc"); + javadocDiags = new JCDiagnostic.Factory(messages, "javadoc"); this.programName = programName; } @@ -134,94 +142,18 @@ public class Messager extends Log implements DocErrorReporter { return Integer.MAX_VALUE; } - /** - * Reset resource bundle, eg. locale has changed. - */ - public void reset() { - messageRB = null; - } - - /** - * Get string from ResourceBundle, initialize ResourceBundle - * if needed. - */ - private String getString(String key) { - if (messageRB == null) { - try { - messageRB = ResourceBundle.getBundle( - "com.sun.tools.javadoc.resources.javadoc"); - } catch (MissingResourceException e) { - throw new Error("Fatal: Resource for javadoc is missing"); - } - } - return messageRB.getString(key); + public void setLocale(Locale locale) { + this.locale = locale; } /** * get and format message string from resource * * @param key selects message from resource + * @param args arguments for the message */ - String getText(String key) { - return getText(key, (String)null); - } - - /** - * get and format message string from resource - * - * @param key selects message from resource - * @param a1 first argument - */ - String getText(String key, String a1) { - return getText(key, a1, null); - } - - /** - * get and format message string from resource - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - */ - String getText(String key, String a1, String a2) { - return getText(key, a1, a2, null); - } - - /** - * get and format message string from resource - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - * @param a3 third argument - */ - String getText(String key, String a1, String a2, String a3) { - return getText(key, a1, a2, a3, null); - } - - /** - * get and format message string from resource - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - * @param a3 third argument - * @param a4 fourth argument - */ - String getText(String key, String a1, String a2, String a3, - String a4) { - try { - String message = getString(key); - String[] args = new String[4]; - args[0] = a1; - args[1] = a2; - args[2] = a3; - args[3] = a4; - return MessageFormat.format(message, (Object[])args); - } catch (MissingResourceException e) { - return "********** Resource for javadoc is broken. There is no " + - key + " key in resource."; - } + String getText(String key, Object... args) { + return messages.getLocalizedString(locale, key, args); } /** @@ -307,41 +239,8 @@ public class Messager extends Log implements DocErrorReporter { * * @param key selects message from resource */ - public void error(SourcePosition pos, String key) { - printError(pos, getText(key)); - } - - /** - * Print error message, increment error count. - * - * @param key selects message from resource - * @param a1 first argument - */ - public void error(SourcePosition pos, String key, String a1) { - printError(pos, getText(key, a1)); - } - - /** - * Print error message, increment error count. - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - */ - public void error(SourcePosition pos, String key, String a1, String a2) { - printError(pos, getText(key, a1, a2)); - } - - /** - * Print error message, increment error count. - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - * @param a3 third argument - */ - public void error(SourcePosition pos, String key, String a1, String a2, String a3) { - printError(pos, getText(key, a1, a2, a3)); + public void error(SourcePosition pos, String key, Object... args) { + printError(pos, getText(key, args)); } /** @@ -349,54 +248,8 @@ public class Messager extends Log implements DocErrorReporter { * * @param key selects message from resource */ - public void warning(SourcePosition pos, String key) { - printWarning(pos, getText(key)); - } - - /** - * Print warning message, increment warning count. - * - * @param key selects message from resource - * @param a1 first argument - */ - public void warning(SourcePosition pos, String key, String a1) { - printWarning(pos, getText(key, a1)); - } - - /** - * Print warning message, increment warning count. - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - */ - public void warning(SourcePosition pos, String key, String a1, String a2) { - printWarning(pos, getText(key, a1, a2)); - } - - /** - * Print warning message, increment warning count. - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - * @param a3 third argument - */ - public void warning(SourcePosition pos, String key, String a1, String a2, String a3) { - printWarning(pos, getText(key, a1, a2, a3)); - } - - /** - * Print warning message, increment warning count. - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - * @param a3 third argument - */ - public void warning(SourcePosition pos, String key, String a1, String a2, String a3, - String a4) { - printWarning(pos, getText(key, a1, a2, a3, a4)); + public void warning(SourcePosition pos, String key, Object... args) { + printWarning(pos, getText(key, args)); } /** @@ -404,41 +257,8 @@ public class Messager extends Log implements DocErrorReporter { * * @param key selects message from resource */ - public void notice(String key) { - printNotice(getText(key)); - } - - /** - * Print a message. - * - * @param key selects message from resource - * @param a1 first argument - */ - public void notice(String key, String a1) { - printNotice(getText(key, a1)); - } - - /** - * Print a message. - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - */ - public void notice(String key, String a1, String a2) { - printNotice(getText(key, a1, a2)); - } - - /** - * Print a message. - * - * @param key selects message from resource - * @param a1 first argument - * @param a2 second argument - * @param a3 third argument - */ - public void notice(String key, String a1, String a2, String a3) { - printNotice(getText(key, a1, a2, a3)); + public void notice(String key, Object... args) { + printNotice(getText(key, args)); } /** @@ -475,5 +295,4 @@ public class Messager extends Log implements DocErrorReporter { public void exit() { throw new ExitJavadoc(); } - } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/Start.java b/langtools/src/share/classes/com/sun/tools/javadoc/Start.java index e26070180d5..0dbab39b669 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/Start.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/Start.java @@ -29,7 +29,6 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; -import java.util.StringTokenizer; import com.sun.javadoc.*; import com.sun.tools.javac.main.CommandLine; @@ -53,7 +52,7 @@ import static com.sun.tools.javac.code.Flags.*; * @author Robert Field * @author Neal Gafter (rewrite) */ -class Start { +public class Start extends ToolOption.Helper { /** Context for this invocation. */ private final Context context; @@ -65,25 +64,12 @@ class Start { private static final String standardDocletClassName = "com.sun.tools.doclets.standard.Standard"; - private ListBuffer options = new ListBuffer(); - - private ModifierFilter showAccess = null; - private long defaultFilter = PUBLIC | PROTECTED; private final Messager messager; - String docLocale = ""; - - boolean breakiterator = false; - boolean quiet = false; - String encoding = null; - private DocletInvoker docletInvoker; - /* Treat warnings as errors. */ - private boolean rejectWarnings = false; - Start(String programName, PrintWriter errWriter, PrintWriter warnWriter, @@ -132,23 +118,58 @@ class Start { this(javadocName); } - /** - * Usage - */ - private void usage() { - messager.notice("main.usage"); + public Start(Context context) { + context.getClass(); // null check + this.context = context; + defaultDocletClassName = standardDocletClassName; + docletParentClassLoader = null; - // let doclet print usage information (does nothing on error) - if (docletInvoker != null) { - docletInvoker.optionLength("-help"); + Log log = context.get(Log.logKey); + if (log instanceof Messager) + messager = (Messager) log; + else { + PrintWriter out = context.get(Log.outKey); + messager = (out == null) ? new Messager(context, javadocName) + : new Messager(context, javadocName, out, out, out); } } /** * Usage */ - private void Xusage() { + @Override + void usage() { + usage(true); + } + + + /** + * Usage + */ + private void usage(boolean exit) { + // RFE: it would be better to replace the following with code to + // write a header, then help for each option, then a footer. + messager.notice("main.usage"); + + // let doclet print usage information (does nothing on error) + if (docletInvoker != null) { + docletInvoker.optionLength("-help"); + } + + if (exit) exit(); + } + + @Override + void Xusage() { + Xusage(true); + } + + /** + * Usage + */ + private void Xusage(boolean exit) { messager.notice("main.Xusage"); + if (exit) exit(); } /** @@ -167,18 +188,18 @@ class Start { try { failed = !parseAndExecute(argv); - } catch(Messager.ExitJavadoc exc) { + } catch (Messager.ExitJavadoc exc) { // ignore, we just exit this way } catch (OutOfMemoryError ee) { - messager.error(null, "main.out.of.memory"); + messager.error(Messager.NOPOS, "main.out.of.memory"); failed = true; } catch (Error ee) { ee.printStackTrace(System.err); - messager.error(null, "main.fatal.error"); + messager.error(Messager.NOPOS, "main.fatal.error"); failed = true; } catch (Exception ee) { ee.printStackTrace(System.err); - messager.error(null, "main.fatal.exception"); + messager.error(Messager.NOPOS, "main.fatal.exception"); failed = true; } finally { messager.exitNotice(); @@ -189,15 +210,6 @@ class Start { return failed ? 1 : 0; } - private void addToList(ListBuffer list, String str){ - StringTokenizer st = new StringTokenizer(str, ":"); - String current; - while(st.hasMoreTokens()){ - current = st.nextToken(); - list.append(current); - } - } - /** * Main program - internal */ @@ -210,7 +222,7 @@ class Start { try { argv = CommandLine.parse(argv); } catch (FileNotFoundException e) { - messager.error(null, "main.cant.read", e.getMessage()); + messager.error(Messager.NOPOS, "main.cant.read", e.getMessage()); exit(); } catch (IOException e) { e.printStackTrace(System.err); @@ -218,116 +230,29 @@ class Start { } setDocletInvoker(argv); - ListBuffer subPackages = new ListBuffer(); - ListBuffer excludedPackages = new ListBuffer(); - Options compOpts = Options.instance(context); - boolean docClasses = false; + compOpts = Options.instance(context); // Parse arguments for (int i = 0 ; i < argv.length ; i++) { String arg = argv[i]; - if (arg.equals("-subpackages")) { - oneArg(argv, i++); - addToList(subPackages, argv[i]); - } else if (arg.equals("-exclude")){ - oneArg(argv, i++); - addToList(excludedPackages, argv[i]); - } else if (arg.equals("-verbose")) { - setOption(arg); - compOpts.put("-verbose", ""); - } else if (arg.equals("-encoding")) { - oneArg(argv, i++); - encoding = argv[i]; - compOpts.put("-encoding", argv[i]); - } else if (arg.equals("-breakiterator")) { - breakiterator = true; - setOption("-breakiterator"); - } else if (arg.equals("-quiet")) { - quiet = true; - setOption("-quiet"); - } else if (arg.equals("-help")) { - usage(); - exit(); - } else if (arg.equals("-Xclasses")) { - setOption(arg); - docClasses = true; - } else if (arg.equals("-Xwerror")) { - setOption(arg); - rejectWarnings = true; - } else if (arg.equals("-private")) { - setOption(arg); - setFilter(ModifierFilter.ALL_ACCESS); - } else if (arg.equals("-package")) { - setOption(arg); - setFilter(PUBLIC | PROTECTED | - ModifierFilter.PACKAGE ); - } else if (arg.equals("-protected")) { - setOption(arg); - setFilter(PUBLIC | PROTECTED ); - } else if (arg.equals("-public")) { - setOption(arg); - setFilter(PUBLIC); - } else if (arg.equals("-source")) { - oneArg(argv, i++); - if (compOpts.get("-source") != null) { - usageError("main.option.already.seen", arg); - } - compOpts.put("-source", argv[i]); - } else if (arg.equals("-prompt")) { - compOpts.put("-prompt", "-prompt"); - messager.promptOnError = true; - } else if (arg.equals("-sourcepath")) { - oneArg(argv, i++); - if (compOpts.get("-sourcepath") != null) { - usageError("main.option.already.seen", arg); - } - compOpts.put("-sourcepath", argv[i]); - } else if (arg.equals("-classpath")) { - oneArg(argv, i++); - if (compOpts.get("-classpath") != null) { - usageError("main.option.already.seen", arg); - } - compOpts.put("-classpath", argv[i]); - } else if (arg.equals("-sysclasspath")) { - oneArg(argv, i++); - if (compOpts.get("-bootclasspath") != null) { - usageError("main.option.already.seen", arg); - } - compOpts.put("-bootclasspath", argv[i]); - } else if (arg.equals("-bootclasspath")) { - oneArg(argv, i++); - if (compOpts.get("-bootclasspath") != null) { - usageError("main.option.already.seen", arg); - } - compOpts.put("-bootclasspath", argv[i]); - } else if (arg.equals("-extdirs")) { - oneArg(argv, i++); - if (compOpts.get("-extdirs") != null) { - usageError("main.option.already.seen", arg); - } - compOpts.put("-extdirs", argv[i]); - } else if (arg.equals("-overview")) { - oneArg(argv, i++); - } else if (arg.equals("-doclet")) { - i++; // handled in setDocletInvoker - } else if (arg.equals("-docletpath")) { - i++; // handled in setDocletInvoker - } else if (arg.equals("-locale")) { - if (i != 0) + + ToolOption o = ToolOption.get(arg); + if (o != null) { + // hack: this restriction should be removed + if (o == ToolOption.LOCALE && i > 0) usageError("main.locale_first"); - oneArg(argv, i++); - docLocale = argv[i]; - } else if (arg.equals("-Xmaxerrs") || arg.equals("-Xmaxwarns")) { - oneArg(argv, i++); - if (compOpts.get(arg) != null) { - usageError("main.option.already.seen", arg); + + if (o.hasArg) { + oneArg(argv, i++); + o.process(this, argv[i]); + } else { + setOption(arg); + o.process(this); } - compOpts.put(arg, argv[i]); - } else if (arg.equals("-X")) { - Xusage(); - exit(); + } else if (arg.startsWith("-XD")) { + // hidden javac options String s = arg.substring("-XD".length()); int eq = s.indexOf('='); String key = (eq < 0) ? s : s.substring(0, eq); @@ -336,7 +261,7 @@ class Start { } // call doclet for its options // other arg starts with - is invalid - else if ( arg.startsWith("-") ) { + else if (arg.startsWith("-")) { int optionLength; optionLength = docletInvoker.optionLength(arg); if (optionLength < 0) { @@ -380,12 +305,18 @@ class Start { LanguageVersion languageVersion = docletInvoker.languageVersion(); RootDocImpl root = comp.getRootDocImpl( - docLocale, encoding, showAccess, - javaNames.toList(), options.toList(), breakiterator, - subPackages.toList(), excludedPackages.toList(), + docLocale, + encoding, + showAccess, + javaNames.toList(), + options.toList(), + breakiterator, + subPackages.toList(), + excludedPackages.toList(), docClasses, // legacy? - languageVersion == null || languageVersion == LanguageVersion.JAVA_1_1, quiet); + languageVersion == null || languageVersion == LanguageVersion.JAVA_1_1, + quiet); // release resources comp = null; @@ -437,15 +368,6 @@ class Start { docletParentClassLoader); } - private void setFilter(long filterBits) { - if (showAccess != null) { - messager.error(null, "main.incompatible.access.flags"); - usage(); - exit(); - } - showAccess = new ModifierFilter(filterBits); - } - /** * Set one arg option. * Error and exit if one argument is not provided. @@ -458,22 +380,10 @@ class Start { } } - private void usageError(String key) { - messager.error(null, key); - usage(); - exit(); - } - - private void usageError(String key, String a1) { - messager.error(null, key, a1); - usage(); - exit(); - } - - private void usageError(String key, String a1, String a2) { - messager.error(null, key, a1, a2); - usage(); - exit(); + @Override + void usageError(String key, Object... args) { + messager.error(Messager.NOPOS, key, args); + usage(true); } /** @@ -502,7 +412,6 @@ class Start { for (List i = arguments; i.nonEmpty(); i=i.tail) { args[k++] = i.head; } - options = options.append(args); + options.append(args); } - } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/ToolOption.java b/langtools/src/share/classes/com/sun/tools/javadoc/ToolOption.java new file mode 100644 index 00000000000..7b0936e77b8 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javadoc/ToolOption.java @@ -0,0 +1,325 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.javadoc; + +import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.javac.util.Options; +import java.util.StringTokenizer; + + +/** + * javadoc tool options. + * + *

This is NOT part of any supported API. + * 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. + */ +public enum ToolOption { + // ----- options for underlying compiler ----- + + BOOTCLASSPATH("-bootclasspath", true) { + @Override + public void process(Helper helper, String arg) { + helper.setCompilerOpt(opt, arg); + } + }, + + CLASSPATH("-classpath", true) { + @Override + public void process(Helper helper, String arg) { + helper.setCompilerOpt(opt, arg); + } + }, + + EXTDIRS("-extdirs", true) { + @Override + public void process(Helper helper, String arg) { + helper.setCompilerOpt(opt, arg); + } + }, + + SOURCEPATH("-sourcepath", true) { + @Override + public void process(Helper helper, String arg) { + helper.setCompilerOpt(opt, arg); + } + }, + + SYSCLASSPATH("-sysclasspath", true) { + @Override + public void process(Helper helper, String arg) { + helper.setCompilerOpt("-bootclasspath", arg); + } + }, + + ENCODING("-encoding", true) { + @Override + public void process(Helper helper, String arg) { + helper.encoding = arg; + helper.setCompilerOpt(opt, arg); + } + }, + + SOURCE("-source", true) { + @Override + public void process(Helper helper, String arg) { + helper.setCompilerOpt(opt, arg); + } + }, + + XMAXERRS("-Xmaxerrs", true) { + @Override + public void process(Helper helper, String arg) { + helper.setCompilerOpt(opt, arg); + } + }, + + XMAXWARNS("-Xmaxwarns", true) { + @Override + public void process(Helper helper, String arg) { + helper.setCompilerOpt(opt, arg); + } + }, + + // ----- doclet options ----- + + DOCLET("-doclet", true), // handled in setDocletInvoker + + DOCLETPATH("-docletpath", true), // handled in setDocletInvoker + + // ----- selection options ----- + + SUBPACKAGES("-subpackages", true) { + @Override + public void process(Helper helper, String arg) { + helper.addToList(helper.subPackages, arg); + } + }, + + EXCLUDE("-exclude", true) { + @Override + public void process(Helper helper, String arg) { + helper.addToList(helper.excludedPackages, arg); + } + }, + + // ----- filtering options ----- + + PACKAGE("-package") { + @Override + public void process(Helper helper) { + helper.setFilter( + Flags.PUBLIC | Flags.PROTECTED | ModifierFilter.PACKAGE); + } + }, + + PRIVATE("-private") { + @Override + public void process(Helper helper) { + helper.setFilter(ModifierFilter.ALL_ACCESS); + } + }, + + PROTECTED("-protected") { + @Override + public void process(Helper helper) { + helper.setFilter(Flags.PUBLIC | Flags.PROTECTED); + } + }, + + PUBLIC("-public") { + @Override + public void process(Helper helper) { + helper.setFilter(Flags.PUBLIC); + } + }, + + // ----- output control options ----- + + PROMPT("-prompt") { + @Override + public void process(Helper helper) { + helper.compOpts.put("-prompt", "-prompt"); + helper.promptOnError = true; + } + }, + + QUIET("-quiet") { + @Override + public void process(Helper helper) { + helper.quiet = true; + } + }, + + VERBOSE("-verbose") { + @Override + public void process(Helper helper) { + helper.compOpts.put("-verbose", ""); + } + }, + + XWERROR("-Xwerror") { + @Override + public void process(Helper helper) { + helper.rejectWarnings = true; + + } + }, + + // ----- other options ----- + + BREAKITERATOR("-breakiterator") { + @Override + public void process(Helper helper) { + helper.breakiterator = true; + } + }, + + LOCALE("-locale", true) { + @Override + public void process(Helper helper, String arg) { + helper.docLocale = arg; + } + }, + + OVERVIEW("-overview", true), + + XCLASSES("-Xclasses") { + @Override + public void process(Helper helper) { + helper.docClasses = true; + + } + }, + + // ----- help options ----- + + HELP("-help") { + @Override + public void process(Helper helper) { + helper.usage(); + } + }, + + X("-X") { + @Override + public void process(Helper helper) { + helper.Xusage(); + } + }; + + public final String opt; + public final boolean hasArg; + + ToolOption(String opt) { + this(opt, false); + } + + ToolOption(String opt, boolean hasArg) { + this.opt = opt; + this.hasArg = hasArg; + } + + void process(Helper helper, String arg) { } + + void process(Helper helper) { } + + static ToolOption get(String name) { + for (ToolOption o: values()) { + if (name.equals(o.opt)) + return o; + } + return null; + } + + static abstract class Helper { + /** List of decoded options. */ + final ListBuffer options = new ListBuffer(); + + /** Selected packages, from -subpackages. */ + final ListBuffer subPackages = new ListBuffer(); + + /** Excluded packages, from -exclude. */ + final ListBuffer excludedPackages = new ListBuffer(); + + /** javac options, set by various options. */ + Options compOpts; // = Options.instance(context) + + /* Encoding for javac, and files written? set by -encoding. */ + String encoding = null; + + /** Set by -breakiterator. */ + boolean breakiterator = false; + + /** Set by -quiet. */ + boolean quiet = false; + + /** Set by -Xclasses. */ + boolean docClasses = false; + + /** Set by -Xwerror. */ + boolean rejectWarnings = false; + + /** Set by -prompt. */ + boolean promptOnError; + + /** Set by -locale. */ + String docLocale = ""; + + /** Set by -public, private, -protected, -package. */ + ModifierFilter showAccess = null; + + abstract void usage(); + abstract void Xusage(); + + abstract void usageError(String msg, Object... args); + + protected void addToList(ListBuffer list, String str){ + StringTokenizer st = new StringTokenizer(str, ":"); + String current; + while(st.hasMoreTokens()){ + current = st.nextToken(); + list.append(current); + } + } + + protected void setFilter(long filterBits) { + if (showAccess != null) { + usageError("main.incompatible.access.flags"); + } + showAccess = new ModifierFilter(filterBits); + } + + private void setCompilerOpt(String opt, String arg) { + if (compOpts.get(opt) != null) { + usageError("main.option.already.seen", opt); + } + compOpts.put(opt, arg); + } + } +} From 2f70d7a0ffd018518c1b4949e592fcfcea82eeb5 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 15 Nov 2012 15:38:33 -0800 Subject: [PATCH 27/94] Added tag jdk8-b65 for changeset eb017c6fa58a --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index ebbc1b340c4..7c941a90365 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -186,3 +186,4 @@ e07f499b9dccb529ecf74172cf6ac11a195ec57a jdk8-b60 8a3fe0ae06a8cc21347da5a18384b0aa6c2349f5 jdk8-b62 3229597524cab4239325bc3602df6c486397a511 jdk8-b63 1c8370a55b305d35353346202bde042ba9e8a9fd jdk8-b64 +b772de306dc24c17f7bd1398531ddeb58723b804 jdk8-b65 From d757cb8b1114c11dfbeb84d3291123ca4bab3399 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 15 Nov 2012 15:38:38 -0800 Subject: [PATCH 28/94] Added tag jdk8-b65 for changeset 6bae6642a942 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index ef06cbb8075..792002fe95f 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -186,3 +186,4 @@ d54dc53e223ed9ce7d5f4d2cd02ad9d5def3c2db jdk8-b59 08afb9c6f44f11c3595b01fd0985db64b29834dd jdk8-b62 6ccbf67b68bfed1ab9c44ab8748a5bdc7df33506 jdk8-b63 54d599a5b4aad83c235d590652fc81f41c2824fb jdk8-b64 +5132f7900a8f0c30c3ca7f7a32f9433f4fee7745 jdk8-b65 From 64bb3ed664ceb24c5192b2fff9d7e73e09204a7d Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 15 Nov 2012 15:39:02 -0800 Subject: [PATCH 29/94] Added tag jdk8-b65 for changeset bbff420f1248 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 26548a12d24..60e39ef0b85 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -293,3 +293,4 @@ acabb5c282f59be7e3238920b2ea06b684ab68f7 jdk8-b63 8cb93eadfb6dcab88d91b8e2cd3e0e07d0ac4048 hs25-b08 5920f72e799c8133d1066c4a62fa1fafcb729966 jdk8-b64 b4ee7b773144a88af8b6b92e4384dea82cb948d8 hs25-b09 +0f7290a03b24bd562583fa325d3566c21c51fb94 jdk8-b65 From 18602b4eedb9f3b98944d7b0eb55a99235508348 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 15 Nov 2012 15:39:35 -0800 Subject: [PATCH 30/94] Added tag jdk8-b65 for changeset d94c92ed588c --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index ab79fb7def4..b8bde0dc729 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -186,3 +186,4 @@ af9e8b0f1900b631a8a0fcccff9f1514fe58c808 jdk8-b59 5d0fa0108d028c05753a47bcf2a598357dabf0c0 jdk8-b62 192d8a244bc36427757866e9fb3a08938c0e674c jdk8-b63 27ab79568c34abf80958d5fa8c04fd1740d243da jdk8-b64 +5cf3c69a93d6d088a1cdfa28031d4f0f9438c0de jdk8-b65 From aa988a211bd457922dab02a697bc6061561bfc90 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 15 Nov 2012 15:39:45 -0800 Subject: [PATCH 31/94] Added tag jdk8-b65 for changeset 2fbfa728248d --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 4f03309dc73..edda8bd532a 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -186,3 +186,4 @@ ae107401be116f9e384d3a23192f543828e03da5 jdk8-b59 d265b9b4c0f55c23a1c9fda02a8052fd9df2eec5 jdk8-b62 86989f702267debe16d13720d5ae7ae9839796f4 jdk8-b63 5ded18a14bcc80b2a253f2b84da0073a0ecac665 jdk8-b64 +fbe54291c9d337ea4dfef4d846f1d9a22f76249c jdk8-b65 From 6e2b60ce6569a8ae22bc90a15ec1bac9d1270c7c Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 15 Nov 2012 15:40:03 -0800 Subject: [PATCH 32/94] Added tag jdk8-b65 for changeset 3afebf1aaea2 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 4171aeb8e83..9ec2d1da2f1 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -186,3 +186,4 @@ cec8fa02f15634acd7d02d04b0b2d8c044cdbaaa jdk8-b60 50b8b17449d200c66bfd68fb4f3a9197432c9e2b jdk8-b62 f117a3e06f78a258074674ad17601f99bcb1ce0d jdk8-b63 26dbd73fb7662a29b3e47179fdc88a0bfa4e231e jdk8-b64 +130d3a54d28becaac0846137256c2684adb34c33 jdk8-b65 From b379df39d9bf7be1a277aa454da126879b989b03 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 15 Nov 2012 15:40:23 -0800 Subject: [PATCH 33/94] Added tag jdk8-b65 for changeset 0e685b019743 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 284a61930a2..19fa2d7fbb2 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -186,3 +186,4 @@ f299927fc31689385f67ab7322c18eb41d8bd71e jdk8-b59 b47bb81ba962ef80bb6f0b863c33a0afcfb0b49e jdk8-b62 92e6f2190ca0567c857f85c3fb7a2be5adf079d0 jdk8-b63 e6ee43b3e2473798b17a556e9f11eebe25ab81d4 jdk8-b64 +5f2faba89cac665e365c05074064ffc934a495eb jdk8-b65 From 6ef527a3e7e94c3ca1e4034b0280de0f0a63d156 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 15 Nov 2012 19:54:20 -0800 Subject: [PATCH 34/94] 8002079: update DocFile to use a JavaFileManager Reviewed-by: darcy --- .../formats/html/ConfigurationImpl.java | 22 ++ .../formats/html/markup/HtmlDocWriter.java | 3 +- .../internal/toolkit/Configuration.java | 8 +- .../internal/toolkit/util/DocFile.java | 238 +++---------- .../internal/toolkit/util/DocFileFactory.java | 99 ++++++ .../internal/toolkit/util/DocPath.java | 10 - .../toolkit/util/PathDocFileFactory.java | 315 ++++++++++++++++++ .../toolkit/util/SimpleDocFileFactory.java | 290 ++++++++++++++++ .../toolkit/util/StandardDocFileFactory.java | 315 ++++++++++++++++++ .../com/sun/tools/javadoc/RootDocImpl.java | 8 + 10 files changed, 1106 insertions(+), 202 deletions(-) create mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java create mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java create mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java create mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java index c0d441b4b59..7e727ceb112 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java @@ -28,9 +28,13 @@ package com.sun.tools.doclets.formats.html; import java.net.*; import java.util.*; +import javax.tools.JavaFileManager; + import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.util.Context; /** * Configure the output based on the command line options. @@ -195,6 +199,7 @@ public class ConfigurationImpl extends Configuration { /** * Return the build date for the doclet. */ + @Override public String getDocletSpecificBuildDate() { return BUILD_DATE; } @@ -205,6 +210,7 @@ public class ConfigurationImpl extends Configuration { * * @param options The array of option names and values. */ + @Override public void setSpecificDocletOptions(String[][] options) { for (int oi = 0; oi < options.length; ++oi) { String[] os = options[oi]; @@ -323,6 +329,7 @@ public class ConfigurationImpl extends Configuration { /** * {@inheritDoc} */ + @Override public boolean validOptions(String options[][], DocErrorReporter reporter) { boolean helpfile = false; @@ -411,6 +418,7 @@ public class ConfigurationImpl extends Configuration { /** * {@inheritDoc} */ + @Override public MessageRetriever getDocletSpecificMsg() { return standardmessage; } @@ -480,6 +488,7 @@ public class ConfigurationImpl extends Configuration { /** * {@inheritDoc} */ + @Override public WriterFactory getWriterFactory() { return new WriterFactoryImpl(this); } @@ -487,6 +496,7 @@ public class ConfigurationImpl extends Configuration { /** * {@inheritDoc} */ + @Override public Comparator getMemberComparator() { return null; } @@ -494,10 +504,22 @@ public class ConfigurationImpl extends Configuration { /** * {@inheritDoc} */ + @Override public Locale getLocale() { if (root instanceof com.sun.tools.javadoc.RootDocImpl) return ((com.sun.tools.javadoc.RootDocImpl)root).getLocale(); else return Locale.getDefault(); } + + /** + * {@inheritDoc} + */ + @Override + public JavaFileManager getFileManager() { + if (root instanceof com.sun.tools.javadoc.RootDocImpl) + return ((com.sun.tools.javadoc.RootDocImpl)root).getFileManager(); + else + return new JavacFileManager(new Context(), false, null); + } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java index 23e8bcae06e..36b55febcff 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java @@ -31,6 +31,7 @@ import java.util.*; import com.sun.javadoc.*; import com.sun.tools.doclets.formats.html.ConfigurationImpl; import com.sun.tools.doclets.internal.toolkit.*; +import com.sun.tools.doclets.internal.toolkit.util.DocFile; import com.sun.tools.doclets.internal.toolkit.util.DocLink; import com.sun.tools.doclets.internal.toolkit.util.DocPath; import com.sun.tools.doclets.internal.toolkit.util.DocPaths; @@ -63,7 +64,7 @@ public abstract class HtmlDocWriter extends HtmlWriter { throws IOException { super(configuration, filename); configuration.message.notice("doclet.Generating_0", - filename.resolveAgainst(configuration.destDirName)); + DocFile.createFileForOutput(configuration, filename).getPath()); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java index 3438b0d1657..033bd4b8444 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java @@ -32,6 +32,7 @@ import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory; import com.sun.tools.doclets.internal.toolkit.taglets.*; import com.sun.tools.doclets.internal.toolkit.util.*; +import javax.tools.JavaFileManager; /** * Configure the output based on the options. Doclets should sub-class @@ -752,7 +753,7 @@ public abstract class Configuration { * @return the input steam to the builder XML. * @throws FileNotFoundException when the given XML file cannot be found. */ - public InputStream getBuilderXML() throws FileNotFoundException { + public InputStream getBuilderXML() throws IOException { return builderXMLPath == null ? Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) : DocFile.createFileForInput(this, builderXMLPath).openInputStream(); @@ -763,6 +764,11 @@ public abstract class Configuration { */ public abstract Locale getLocale(); + /** + * Return the current file manager. + */ + public abstract JavaFileManager getFileManager(); + /** * Return the comparator that will be used to sort member documentation. * To no do any sorting, return null. diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java index 33781c73174..5f0c28dc603 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java @@ -25,30 +25,21 @@ package com.sun.tools.doclets.internal.toolkit.util; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStream; -import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; import javax.tools.JavaFileManager.Location; import javax.tools.StandardLocation; import com.sun.tools.doclets.internal.toolkit.Configuration; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; /** * Abstraction for handling files, which may be specified directly @@ -61,46 +52,36 @@ import com.sun.tools.doclets.internal.toolkit.Configuration; * * @since 8 */ -public class DocFile { +public abstract class DocFile { + + /** Create a DocFile for a directory. */ + public static DocFile createFileForDirectory(Configuration configuration, String file) { + return DocFileFactory.getFactory(configuration).createFileForDirectory(file); + } + + /** Create a DocFile for a file that will be opened for reading. */ + public static DocFile createFileForInput(Configuration configuration, String file) { + return DocFileFactory.getFactory(configuration).createFileForInput(file); + } + + /** Create a DocFile for a file that will be opened for writing. */ + public static DocFile createFileForOutput(Configuration configuration, DocPath path) { + return DocFileFactory.getFactory(configuration).createFileForOutput(path); + } - /** - * The doclet configuration. - * Provides access to options such as docencoding, output directory, etc. - */ private final Configuration configuration; /** * The location for this file. Maybe null if the file was created without * a location or path. */ - private final Location location; + protected final Location location; /** * The path relative to the (output) location. Maybe null if the file was * created without a location or path. */ - private final DocPath path; - - /** - * The file object itself. - * This is temporary, until we create different subtypes of DocFile. - */ - private final File file; - - /** Create a DocFile for a directory. */ - public static DocFile createFileForDirectory(Configuration configuration, String file) { - return new DocFile(configuration, new File(file)); - } - - /** Create a DocFile for a file that will be opened for reading. */ - public static DocFile createFileForInput(Configuration configuration, String file) { - return new DocFile(configuration, new File(file)); - } - - /** Create a DocFile for a file that will be opened for writing. */ - public static DocFile createFileForOutput(Configuration configuration, DocPath path) { - return new DocFile(configuration, StandardLocation.CLASS_OUTPUT, path); - } + protected final DocPath path; /** * List the directories and files found in subdirectories along the @@ -111,56 +92,32 @@ public class DocFile { * list files */ public static Iterable list(Configuration configuration, Location location, DocPath path) { - if (location != StandardLocation.SOURCE_PATH) - throw new IllegalArgumentException(); - - Set files = new LinkedHashSet(); - for (String s : configuration.sourcepath.split(File.pathSeparator)) { - if (s.isEmpty()) - continue; - File f = new File(s); - if (f.isDirectory()) { - f = new File(f, path.getPath()); - if (f.exists()) - files.add(new DocFile(configuration, f)); - } - } - return files; + return DocFileFactory.getFactory(configuration).list(location, path); } - /** Create a DocFile for a given file. */ - private DocFile(Configuration configuration, File file) { + /** Create a DocFile without a location or path */ + protected DocFile(Configuration configuration) { this.configuration = configuration; this.location = null; this.path = null; - this.file = file; } /** Create a DocFile for a given location and relative path. */ - private DocFile(Configuration configuration, Location location, DocPath path) { + protected DocFile(Configuration configuration, Location location, DocPath path) { this.configuration = configuration; this.location = location; this.path = path; - this.file = path.resolveAgainst(configuration.destDirName); } /** Open an input stream for the file. */ - public InputStream openInputStream() throws FileNotFoundException { - return new BufferedInputStream(new FileInputStream(file)); - } + public abstract InputStream openInputStream() throws IOException; /** * Open an output stream for the file. * The file must have been created with a location of * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. */ - public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { - if (location != StandardLocation.CLASS_OUTPUT) - throw new IllegalStateException(); - - createDirectoryForFile(file); - return new BufferedOutputStream(new FileOutputStream(file)); - } + public abstract OutputStream openOutputStream() throws IOException, UnsupportedEncodingException; /** * Open an writer for the file, using the encoding (if any) given in the @@ -168,28 +125,12 @@ public class DocFile { * The file must have been created with a location of * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. */ - public Writer openWriter() throws IOException, UnsupportedEncodingException { - if (location != StandardLocation.CLASS_OUTPUT) - throw new IllegalStateException(); - - createDirectoryForFile(file); - FileOutputStream fos = new FileOutputStream(file); - if (configuration.docencoding == null) { - return new BufferedWriter(new OutputStreamWriter(fos)); - } else { - return new BufferedWriter(new OutputStreamWriter(fos, configuration.docencoding)); - } - } + public abstract Writer openWriter() throws IOException, UnsupportedEncodingException; /** * Copy the contents of another file directly to this file. */ public void copyFile(DocFile fromFile) throws IOException { - if (location != StandardLocation.CLASS_OUTPUT) - throw new IllegalStateException(); - - createDirectoryForFile(file); - InputStream input = fromFile.openInputStream(); OutputStream output = openOutputStream(); try { @@ -215,20 +156,15 @@ public class DocFile { * separator */ public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) { - if (location != StandardLocation.CLASS_OUTPUT) - throw new IllegalStateException(); - - if (file.exists() && !overwrite) + if (exists() && !overwrite) return; - createDirectoryForFile(file); - try { InputStream in = Configuration.class.getResourceAsStream(resource.getPath()); if (in == null) return; - OutputStream out = new FileOutputStream(file); + OutputStream out = openOutputStream(); try { if (!replaceNewLine) { byte[] buf = new byte[2048]; @@ -265,68 +201,37 @@ public class DocFile { } /** Return true if the file can be read. */ - public boolean canRead() { - return file.canRead(); - } + public abstract boolean canRead(); /** Return true if the file can be written. */ - public boolean canWrite() { - return file.canRead(); - } + public abstract boolean canWrite(); /** Return true if the file exists. */ - public boolean exists() { - return file.exists(); - } + public abstract boolean exists(); /** Return the base name (last component) of the file name. */ - public String getName() { - return file.getName(); - } + public abstract String getName(); /** Return the file system path for this file. */ - public String getPath() { - return file.getPath(); - } + public abstract String getPath(); - /** Return true is file has an absolute path name. */ - boolean isAbsolute() { - return file.isAbsolute(); - } + /** Return true if file has an absolute path name. */ + public abstract boolean isAbsolute(); - /** Return true is file identifies a directory. */ - public boolean isDirectory() { - return file.isDirectory(); - } + /** Return true if file identifies a directory. */ + public abstract boolean isDirectory(); - /** Return true is file identifies a file. */ - public boolean isFile() { - return file.isFile(); - } + /** Return true if file identifies a file. */ + public abstract boolean isFile(); /** Return true if this file is the same as another. */ - public boolean isSameFile(DocFile other) { - try { - return file.exists() - && file.getCanonicalFile().equals(other.file.getCanonicalFile()); - } catch (IOException e) { - return false; - } - } + public abstract boolean isSameFile(DocFile other); /** If the file is a directory, list its contents. */ - public Iterable list() { - List files = new ArrayList(); - for (File f: file.listFiles()) { - files.add(new DocFile(configuration, f)); - } - return files; - } + public abstract Iterable list() throws IOException; /** Create the file as a directory, including any parent directories. */ - public boolean mkdirs() { - return file.mkdirs(); - } + public abstract boolean mkdirs(); /** * Derive a new file by resolving a relative path against this file. @@ -334,9 +239,7 @@ public class DocFile { * If this file has a path set, the new file will have a corresponding * new path. */ - public DocFile resolve(DocPath p) { - return resolve(p.getPath()); - } + public abstract DocFile resolve(DocPath p); /** * Derive a new file by resolving a relative path against this file. @@ -344,56 +247,11 @@ public class DocFile { * If this file has a path set, the new file will have a corresponding * new path. */ - public DocFile resolve(String p) { - if (location == null && path == null) { - return new DocFile(configuration, new File(file, p)); - } else { - return new DocFile(configuration, location, path.resolve(p)); - } - } + public abstract DocFile resolve(String p); /** * Resolve a relative file against the given output location. * @param locn Currently, only SOURCE_OUTPUT is supported. */ - public DocFile resolveAgainst(StandardLocation locn) { - if (locn != StandardLocation.CLASS_OUTPUT) - throw new IllegalArgumentException(); - return new DocFile(configuration, - new File(configuration.destDirName, file.getPath())); - } - - /** - * Given a path string create all the directories in the path. For example, - * if the path string is "java/applet", the method will create directory - * "java" and then "java/applet" if they don't exist. The file separator - * string "/" is platform dependent system property. - * - * @param path Directory path string. - */ - private void createDirectoryForFile(File file) { - File dir = file.getParentFile(); - if (dir == null || dir.exists() || dir.mkdirs()) - return; - - configuration.message.error( - "doclet.Unable_to_create_directory_0", dir.getPath()); - throw new DocletAbortException(); - } - - /** Return a string to identify the contents of this object, - * for debugging purposes. - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("DocFile["); - if (location != null) - sb.append("locn:").append(location).append(","); - if (path != null) - sb.append("path:").append(path.getPath()).append(","); - sb.append("file:").append(file); - sb.append("]"); - return sb.toString(); - } + public abstract DocFile resolveAgainst(StandardLocation locn); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java new file mode 100644 index 00000000000..276c2d2646d --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.doclets.internal.toolkit.util; + +import java.util.Map; +import java.util.WeakHashMap; + +import javax.tools.JavaFileManager; +import javax.tools.JavaFileManager.Location; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; + +import com.sun.tools.doclets.internal.toolkit.Configuration; + +/** + * Factory for DocFile objects. + * + *

This is NOT part of any supported API. + * 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. + * + * @since 1.8 + */ +abstract class DocFileFactory { + private static Map factories = + new WeakHashMap(); + + /** + * Get the appropriate factory, based on the file manager given in the + * configuration. + */ + static synchronized DocFileFactory getFactory(Configuration configuration) { + DocFileFactory f = factories.get(configuration); + if (f == null) { + JavaFileManager fm = configuration.getFileManager(); + if (fm instanceof StandardJavaFileManager) + f = new StandardDocFileFactory(configuration); + else { + try { + Class pathFileManagerClass = + Class.forName("com.sun.tools.javac.nio.PathFileManager"); + if (pathFileManagerClass.isAssignableFrom(fm.getClass())) + f = new PathDocFileFactory(configuration); + } catch (Throwable t) { + throw new IllegalStateException(t); + } + } + } + return f; + } + + protected Configuration configuration; + + protected DocFileFactory(Configuration configuration) { + this.configuration = configuration; + } + + /** Create a DocFile for a directory. */ + abstract DocFile createFileForDirectory(String file); + + /** Create a DocFile for a file that will be opened for reading. */ + abstract DocFile createFileForInput(String file); + + /** Create a DocFile for a file that will be opened for writing. */ + abstract DocFile createFileForOutput(DocPath path); + + /** + * List the directories and files found in subdirectories along the + * elements of the given location. + * @param location currently, only {@link StandardLocation#SOURCE_PATH} is supported. + * @param path the subdirectory of the directories of the location for which to + * list files + */ + abstract Iterable list(Location location, DocPath path); +} diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java index fb7d1fa96d7..055d449a862 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java @@ -27,7 +27,6 @@ package com.sun.tools.doclets.internal.toolkit.util; import com.sun.javadoc.ClassDoc; import com.sun.javadoc.PackageDoc; -import java.io.File; /** * Abstraction for immutable relative paths. @@ -158,15 +157,6 @@ public class DocPath { return new DocPath(path + "/" + p.getPath()); } - /** - * Get the file created by evaluating the path against a specified directory. - */ - // Temporary: this signature should not use String for dir. - // Eventually, this should involve javax.tools.Location. - public File resolveAgainst(String dir) { - return dir.isEmpty() ? new File(path) : new File(dir, path); - } - /** * Return the inverse path for this path. * For example, if the path is a/b/c, the inverse path is ../../.. diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java new file mode 100644 index 00000000000..801a88aa227 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java @@ -0,0 +1,315 @@ +/* + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.tools.doclets.internal.toolkit.util; + + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import javax.tools.FileObject; +import javax.tools.JavaFileManager.Location; +import javax.tools.JavaFileObject; +import javax.tools.StandardLocation; + +import com.sun.tools.doclets.internal.toolkit.Configuration; +import com.sun.tools.javac.nio.PathFileManager; + + +/** + * Implementation of DocFileFactory using a {@link PathFileManager}. + * + *

This is NOT part of any supported API. + * 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. + * + * @since 1.8 + */ +class PathDocFileFactory extends DocFileFactory { + private final PathFileManager fileManager; + private final Path destDir; + + public PathDocFileFactory(Configuration configuration) { + super(configuration); + fileManager = (PathFileManager) configuration.getFileManager(); + + if (!configuration.destDirName.isEmpty() + || !fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { + try { + String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName; + Path dir = fileManager.getDefaultFileSystem().getPath(dirName); + fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(dir)); + } catch (IOException e) { + throw new DocletAbortException(); + } + } + + destDir = fileManager.getLocation(StandardLocation.CLASS_OUTPUT).iterator().next(); + } + + public DocFile createFileForDirectory(String file) { + return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file)); + } + + public DocFile createFileForInput(String file) { + return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file)); + } + + public DocFile createFileForOutput(DocPath path) { + return new StandardDocFile(StandardLocation.CLASS_OUTPUT, path); + } + + @Override + Iterable list(Location location, DocPath path) { + if (location != StandardLocation.SOURCE_PATH) + throw new IllegalArgumentException(); + + Set files = new LinkedHashSet(); + if (fileManager.hasLocation(location)) { + for (Path f: fileManager.getLocation(location)) { + if (Files.isDirectory(f)) { + f = f.resolve(path.getPath()); + if (Files.exists(f)) + files.add(new StandardDocFile(f)); + } + } + } + return files; + } + + class StandardDocFile extends DocFile { + private Path file; + + /** Create a StandardDocFile for a given file. */ + private StandardDocFile(Path file) { + super(configuration); + this.file = file; + } + + /** Create a StandardDocFile for a given location and relative path. */ + private StandardDocFile(Location location, DocPath path) { + super(configuration, location, path); + this.file = destDir.resolve(path.getPath()); + } + + /** Open an input stream for the file. */ + public InputStream openInputStream() throws IOException { + JavaFileObject fo = getJavaFileObjectForInput(file); + return new BufferedInputStream(fo.openInputStream()); + } + + /** + * Open an output stream for the file. + * The file must have been created with a location of + * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + */ + public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { + if (location != StandardLocation.CLASS_OUTPUT) + throw new IllegalStateException(); + + OutputStream out = getFileObjectForOutput(path).openOutputStream(); + return new BufferedOutputStream(out); + } + + /** + * Open an writer for the file, using the encoding (if any) given in the + * doclet configuration. + * The file must have been created with a location of + * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + */ + public Writer openWriter() throws IOException, UnsupportedEncodingException { + if (location != StandardLocation.CLASS_OUTPUT) + throw new IllegalStateException(); + + OutputStream out = getFileObjectForOutput(path).openOutputStream(); + if (configuration.docencoding == null) { + return new BufferedWriter(new OutputStreamWriter(out)); + } else { + return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding)); + } + } + + /** Return true if the file can be read. */ + public boolean canRead() { + return Files.isReadable(file); + } + + /** Return true if the file can be written. */ + public boolean canWrite() { + return Files.isWritable(file); + } + + /** Return true if the file exists. */ + public boolean exists() { + return Files.exists(file); + } + + /** Return the base name (last component) of the file name. */ + public String getName() { + return file.getFileName().toString(); + } + + /** Return the file system path for this file. */ + public String getPath() { + return file.toString(); + } + + /** Return true is file has an absolute path name. */ + public boolean isAbsolute() { + return file.isAbsolute(); + } + + /** Return true is file identifies a directory. */ + public boolean isDirectory() { + return Files.isDirectory(file); + } + + /** Return true is file identifies a file. */ + public boolean isFile() { + return Files.isRegularFile(file); + } + + /** Return true if this file is the same as another. */ + public boolean isSameFile(DocFile other) { + if (!(other instanceof StandardDocFile)) + return false; + + try { + return Files.isSameFile(file, ((StandardDocFile) other).file); + } catch (IOException e) { + return false; + } + } + + /** If the file is a directory, list its contents. */ + public Iterable list() throws IOException { + List files = new ArrayList(); + for (Path f: Files.newDirectoryStream(file)) { + files.add(new StandardDocFile(f)); + } + return files; + } + + /** Create the file as a directory, including any parent directories. */ + public boolean mkdirs() { + try { + Files.createDirectories(file); + return true; + } catch (IOException e) { + return false; + } + } + + /** + * Derive a new file by resolving a relative path against this file. + * The new file will inherit the configuration and location of this file + * If this file has a path set, the new file will have a corresponding + * new path. + */ + public DocFile resolve(DocPath p) { + return resolve(p.getPath()); + } + + /** + * Derive a new file by resolving a relative path against this file. + * The new file will inherit the configuration and location of this file + * If this file has a path set, the new file will have a corresponding + * new path. + */ + public DocFile resolve(String p) { + if (location == null && path == null) { + return new StandardDocFile(file.resolve(p)); + } else { + return new StandardDocFile(location, path.resolve(p)); + } + } + + /** + * Resolve a relative file against the given output location. + * @param locn Currently, only SOURCE_OUTPUT is supported. + */ + public DocFile resolveAgainst(StandardLocation locn) { + if (locn != StandardLocation.CLASS_OUTPUT) + throw new IllegalArgumentException(); + return new StandardDocFile(destDir.resolve(file)); + } + + /** Return a string to identify the contents of this object, + * for debugging purposes. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("PathDocFile["); + if (location != null) + sb.append("locn:").append(location).append(","); + if (path != null) + sb.append("path:").append(path.getPath()).append(","); + sb.append("file:").append(file); + sb.append("]"); + return sb.toString(); + } + + private JavaFileObject getJavaFileObjectForInput(Path file) { + return fileManager.getJavaFileObjects(file).iterator().next(); + } + + private FileObject getFileObjectForOutput(DocPath path) throws IOException { + // break the path into a package-part and the rest, by finding + // the position of the last '/' before an invalid character for a + // package name, such as the "." before an extension or the "-" + // in filenames like package-summary.html, doc-files or src-html. + String p = path.getPath(); + int lastSep = -1; + for (int i = 0; i < p.length(); i++) { + char ch = p.charAt(i); + if (ch == '/') { + lastSep = i; + } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch) + || !Character.isJavaIdentifierPart(ch)) { + break; + } + } + String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep); + String rest = p.substring(lastSep + 1); + return fileManager.getFileForOutput(location, pkg, rest, null); + } + } + +} diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java new file mode 100644 index 00000000000..0ffdd04df44 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java @@ -0,0 +1,290 @@ +/* + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.doclets.internal.toolkit.util; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import javax.tools.JavaFileManager.Location; +import javax.tools.StandardLocation; + +import com.sun.tools.doclets.internal.toolkit.Configuration; + +/** + * Implementation of DocFileFactory that just uses java.io.File API, + * and does not use a JavaFileManager.. + * + *

This is NOT part of any supported API. + * 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. + * + * @since 1.8 + */ +class SimpleDocFileFactory extends DocFileFactory { + + public SimpleDocFileFactory(Configuration configuration) { + super(configuration); + } + + public DocFile createFileForDirectory(String file) { + return new SimpleDocFile(new File(file)); + } + + public DocFile createFileForInput(String file) { + return new SimpleDocFile(new File(file)); + } + + public DocFile createFileForOutput(DocPath path) { + return new SimpleDocFile(StandardLocation.CLASS_OUTPUT, path); + } + + @Override + Iterable list(Location location, DocPath path) { + if (location != StandardLocation.SOURCE_PATH) + throw new IllegalArgumentException(); + + Set files = new LinkedHashSet(); + for (String s : configuration.sourcepath.split(File.pathSeparator)) { + if (s.isEmpty()) + continue; + File f = new File(s); + if (f.isDirectory()) { + f = new File(f, path.getPath()); + if (f.exists()) + files.add(new SimpleDocFile(f)); + } + } + return files; + } + + class SimpleDocFile extends DocFile { + private File file; + + /** Create a DocFile for a given file. */ + private SimpleDocFile(File file) { + super(configuration); + this.file = file; + } + + /** Create a DocFile for a given location and relative path. */ + private SimpleDocFile(Location location, DocPath path) { + super(configuration, location, path); + String destDirName = configuration.destDirName; + this.file = destDirName.isEmpty() ? new File(path.getPath()) + : new File(destDirName, path.getPath()); + } + + /** Open an input stream for the file. */ + public InputStream openInputStream() throws FileNotFoundException { + return new BufferedInputStream(new FileInputStream(file)); + } + + /** + * Open an output stream for the file. + * The file must have been created with a location of + * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + */ + public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { + if (location != StandardLocation.CLASS_OUTPUT) + throw new IllegalStateException(); + + createDirectoryForFile(file); + return new BufferedOutputStream(new FileOutputStream(file)); + } + + /** + * Open an writer for the file, using the encoding (if any) given in the + * doclet configuration. + * The file must have been created with a location of + * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + */ + public Writer openWriter() throws IOException, UnsupportedEncodingException { + if (location != StandardLocation.CLASS_OUTPUT) + throw new IllegalStateException(); + + createDirectoryForFile(file); + FileOutputStream fos = new FileOutputStream(file); + if (configuration.docencoding == null) { + return new BufferedWriter(new OutputStreamWriter(fos)); + } else { + return new BufferedWriter(new OutputStreamWriter(fos, configuration.docencoding)); + } + } + + /** Return true if the file can be read. */ + public boolean canRead() { + return file.canRead(); + } + + /** Return true if the file can be written. */ + public boolean canWrite() { + return file.canRead(); + } + + /** Return true if the file exists. */ + public boolean exists() { + return file.exists(); + } + + /** Return the base name (last component) of the file name. */ + public String getName() { + return file.getName(); + } + + /** Return the file system path for this file. */ + public String getPath() { + return file.getPath(); + } + + /** Return true is file has an absolute path name. */ + public boolean isAbsolute() { + return file.isAbsolute(); + } + + /** Return true is file identifies a directory. */ + public boolean isDirectory() { + return file.isDirectory(); + } + + /** Return true is file identifies a file. */ + public boolean isFile() { + return file.isFile(); + } + + /** Return true if this file is the same as another. */ + public boolean isSameFile(DocFile other) { + if (!(other instanceof SimpleDocFile)) + return false; + + try { + return file.exists() + && file.getCanonicalFile().equals(((SimpleDocFile)other).file.getCanonicalFile()); + } catch (IOException e) { + return false; + } + } + + /** If the file is a directory, list its contents. */ + public Iterable list() { + List files = new ArrayList(); + for (File f: file.listFiles()) { + files.add(new SimpleDocFile(f)); + } + return files; + } + + /** Create the file as a directory, including any parent directories. */ + public boolean mkdirs() { + return file.mkdirs(); + } + + /** + * Derive a new file by resolving a relative path against this file. + * The new file will inherit the configuration and location of this file + * If this file has a path set, the new file will have a corresponding + * new path. + */ + public DocFile resolve(DocPath p) { + return resolve(p.getPath()); + } + + /** + * Derive a new file by resolving a relative path against this file. + * The new file will inherit the configuration and location of this file + * If this file has a path set, the new file will have a corresponding + * new path. + */ + public DocFile resolve(String p) { + if (location == null && path == null) { + return new SimpleDocFile(new File(file, p)); + } else { + return new SimpleDocFile(location, path.resolve(p)); + } + } + + /** + * Resolve a relative file against the given output location. + * @param locn Currently, only SOURCE_OUTPUT is supported. + */ + public DocFile resolveAgainst(StandardLocation locn) { + if (locn != StandardLocation.CLASS_OUTPUT) + throw new IllegalArgumentException(); + return new SimpleDocFile( + new File(configuration.destDirName, file.getPath())); + } + + /** + * Given a path string create all the directories in the path. For example, + * if the path string is "java/applet", the method will create directory + * "java" and then "java/applet" if they don't exist. The file separator + * string "/" is platform dependent system property. + * + * @param path Directory path string. + */ + private void createDirectoryForFile(File file) { + File dir = file.getParentFile(); + if (dir == null || dir.exists() || dir.mkdirs()) + return; + + configuration.message.error( + "doclet.Unable_to_create_directory_0", dir.getPath()); + throw new DocletAbortException(); + } + + /** Return a string to identify the contents of this object, + * for debugging purposes. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("DocFile["); + if (location != null) + sb.append("locn:").append(location).append(","); + if (path != null) + sb.append("path:").append(path.getPath()).append(","); + sb.append("file:").append(file); + sb.append("]"); + return sb.toString(); + } + + } +} diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java new file mode 100644 index 00000000000..4b7fb570e3e --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java @@ -0,0 +1,315 @@ +/* + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.doclets.internal.toolkit.util; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedWriter; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import javax.tools.FileObject; +import javax.tools.JavaFileManager.Location; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; + +import com.sun.tools.doclets.internal.toolkit.Configuration; +import com.sun.tools.javac.util.Assert; + +/** + * Implementation of DocFileFactory using a {@link StandardJavaFileManager}. + * + *

This is NOT part of any supported API. + * 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. + * + * @since 1.8 + */ +class StandardDocFileFactory extends DocFileFactory { + private final StandardJavaFileManager fileManager; + private final File destDir; + + public StandardDocFileFactory(Configuration configuration) { + super(configuration); + fileManager = (StandardJavaFileManager) configuration.getFileManager(); + + if (!configuration.destDirName.isEmpty() + || !fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { + try { + String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName; + File dir = new File(dirName); + fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(dir)); + } catch (IOException e) { + throw new DocletAbortException(); + } + } + + destDir = fileManager.getLocation(StandardLocation.CLASS_OUTPUT).iterator().next(); + } + + public DocFile createFileForDirectory(String file) { + return new StandardDocFile(new File(file)); + } + + public DocFile createFileForInput(String file) { + return new StandardDocFile(new File(file)); + } + + public DocFile createFileForOutput(DocPath path) { + return new StandardDocFile(StandardLocation.CLASS_OUTPUT, path); + } + + @Override + Iterable list(Location location, DocPath path) { + if (location != StandardLocation.SOURCE_PATH) + throw new IllegalArgumentException(); + + Set files = new LinkedHashSet(); + if (fileManager.hasLocation(location)) { + for (File f: fileManager.getLocation(location)) { + if (f.isDirectory()) { + f = new File(f, path.getPath()); + if (f.exists()) + files.add(new StandardDocFile(f)); + } + } + } + return files; + } + + private static File newFile(File dir, String path) { + return (dir == null) ? new File(path) : new File(dir, path); + } + + class StandardDocFile extends DocFile { + private File file; + + + /** Create a StandardDocFile for a given file. */ + private StandardDocFile(File file) { + super(configuration); + this.file = file; + } + + /** Create a StandardDocFile for a given location and relative path. */ + private StandardDocFile(Location location, DocPath path) { + super(configuration, location, path); + Assert.check(location == StandardLocation.CLASS_OUTPUT); + this.file = newFile(destDir, path.getPath()); + } + + /** Open an input stream for the file. */ + public InputStream openInputStream() throws IOException { + JavaFileObject fo = getJavaFileObjectForInput(file); + return new BufferedInputStream(fo.openInputStream()); + } + + /** + * Open an output stream for the file. + * The file must have been created with a location of + * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + */ + public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { + if (location != StandardLocation.CLASS_OUTPUT) + throw new IllegalStateException(); + + OutputStream out = getFileObjectForOutput(path).openOutputStream(); + return new BufferedOutputStream(out); + } + + /** + * Open an writer for the file, using the encoding (if any) given in the + * doclet configuration. + * The file must have been created with a location of + * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + */ + public Writer openWriter() throws IOException, UnsupportedEncodingException { + if (location != StandardLocation.CLASS_OUTPUT) + throw new IllegalStateException(); + + OutputStream out = getFileObjectForOutput(path).openOutputStream(); + if (configuration.docencoding == null) { + return new BufferedWriter(new OutputStreamWriter(out)); + } else { + return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding)); + } + } + + /** Return true if the file can be read. */ + public boolean canRead() { + return file.canRead(); + } + + /** Return true if the file can be written. */ + public boolean canWrite() { + return file.canWrite(); + } + + /** Return true if the file exists. */ + public boolean exists() { + return file.exists(); + } + + /** Return the base name (last component) of the file name. */ + public String getName() { + return file.getName(); + } + + /** Return the file system path for this file. */ + public String getPath() { + return file.getPath(); + } + + /** Return true is file has an absolute path name. */ + public boolean isAbsolute() { + return file.isAbsolute(); + } + + /** Return true is file identifies a directory. */ + public boolean isDirectory() { + return file.isDirectory(); + } + + /** Return true is file identifies a file. */ + public boolean isFile() { + return file.isFile(); + } + + /** Return true if this file is the same as another. */ + public boolean isSameFile(DocFile other) { + if (!(other instanceof StandardDocFile)) + return false; + + try { + return file.exists() + && file.getCanonicalFile().equals(((StandardDocFile) other).file.getCanonicalFile()); + } catch (IOException e) { + return false; + } + } + + /** If the file is a directory, list its contents. */ + public Iterable list() { + List files = new ArrayList(); + for (File f: file.listFiles()) { + files.add(new StandardDocFile(f)); + } + return files; + } + + /** Create the file as a directory, including any parent directories. */ + public boolean mkdirs() { + return file.mkdirs(); + } + + /** + * Derive a new file by resolving a relative path against this file. + * The new file will inherit the configuration and location of this file + * If this file has a path set, the new file will have a corresponding + * new path. + */ + public DocFile resolve(DocPath p) { + return resolve(p.getPath()); + } + + /** + * Derive a new file by resolving a relative path against this file. + * The new file will inherit the configuration and location of this file + * If this file has a path set, the new file will have a corresponding + * new path. + */ + public DocFile resolve(String p) { + if (location == null && path == null) { + return new StandardDocFile(new File(file, p)); + } else { + return new StandardDocFile(location, path.resolve(p)); + } + } + + /** + * Resolve a relative file against the given output location. + * @param locn Currently, only SOURCE_OUTPUT is supported. + */ + public DocFile resolveAgainst(StandardLocation locn) { + if (locn != StandardLocation.CLASS_OUTPUT) + throw new IllegalArgumentException(); + return new StandardDocFile(newFile(destDir, file.getPath())); + } + + /** Return a string to identify the contents of this object, + * for debugging purposes. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("StandardDocFile["); + if (location != null) + sb.append("locn:").append(location).append(","); + if (path != null) + sb.append("path:").append(path.getPath()).append(","); + sb.append("file:").append(file); + sb.append("]"); + return sb.toString(); + } + + private JavaFileObject getJavaFileObjectForInput(File file) { + return fileManager.getJavaFileObjects(file).iterator().next(); + } + + private FileObject getFileObjectForOutput(DocPath path) throws IOException { + // break the path into a package-part and the rest, by finding + // the position of the last '/' before an invalid character for a + // package name, such as the "." before an extension or the "-" + // in filenames like package-summary.html, doc-files or src-html. + String p = path.getPath(); + int lastSep = -1; + for (int i = 0; i < p.length(); i++) { + char ch = p.charAt(i); + if (ch == '/') { + lastSep = i; + } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch) + || !Character.isJavaIdentifierPart(ch)) { + break; + } + } + String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep); + String rest = p.substring(lastSep + 1); + return fileManager.getFileForOutput(location, pkg, rest, null); + } + } +} diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java index d6eba2e8f3e..bb9364d192c 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java @@ -27,6 +27,7 @@ package com.sun.tools.javadoc; import java.io.IOException; import java.util.Locale; +import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; @@ -368,4 +369,11 @@ public class RootDocImpl extends DocImpl implements RootDoc { public Locale getLocale() { return env.doclocale.locale; } + + /** + * Return the current file manager. + */ + public JavaFileManager getFileManager() { + return env.fileManager; + } } From b3a3f7cdf351a6317e3fa939be328b061a312522 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 15 Nov 2012 23:07:24 -0800 Subject: [PATCH 35/94] 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar Reviewed-by: darcy --- .../formats/html/ConfigurationImpl.java | 13 +- .../internal/toolkit/Configuration.java | 8 +- .../toolkit/taglets/TagletManager.java | 33 ++- .../internal/toolkit/util/DocFile.java | 18 +- .../internal/toolkit/util/DocFileFactory.java | 1 + .../doclets/internal/toolkit/util/Extern.java | 4 +- .../toolkit/util/PathDocFileFactory.java | 24 +- .../toolkit/util/SimpleDocFileFactory.java | 18 +- .../toolkit/util/StandardDocFileFactory.java | 65 +++--- .../tools/javac/api/ClientCodeWrapper.java | 2 +- .../sun/tools/javac/api/JavacTaskImpl.java | 6 +- .../tools/javac/nio/JavacPathFileManager.java | 8 +- .../util/AbstractDiagnosticFormatter.java | 4 +- .../com/sun/tools/javadoc/DocletInvoker.java | 58 +++-- .../com/sun/tools/javadoc/JavadocTool.java | 14 +- .../com/sun/tools/javadoc/Messager.java | 34 +++ .../classes/com/sun/tools/javadoc/Start.java | 79 ++++++- .../tools/javadoc/api/JavadocTaskImpl.java | 100 +++++++++ .../sun/tools/javadoc/api/JavadocTool.java | 171 ++++++++++++++ .../javadoc/resources/javadoc.properties | 5 + .../javax/tools/DocumentationTool.java | 183 +++++++++++++++ .../classes/javax/tools/JavaCompiler.java | 2 +- .../classes/javax/tools/ToolProvider.java | 15 +- .../test/tools/javadoc/CheckResourceKeys.java | 7 + .../test/tools/javadoc/api/basic/APITest.java | 209 ++++++++++++++++++ .../javadoc/api/basic/DocletPathTest.java | 110 +++++++++ .../api/basic/GetSourceVersionsTest.java | 61 +++++ .../api/basic/GetTask_DiagListenerTest.java | 88 ++++++++ .../api/basic/GetTask_DocletClassTest.java | 157 +++++++++++++ .../api/basic/GetTask_FileManagerTest.java | 111 ++++++++++ .../api/basic/GetTask_FileObjectsTest.java | 130 +++++++++++ .../api/basic/GetTask_OptionsTest.java | 94 ++++++++ .../javadoc/api/basic/GetTask_WriterTest.java | 78 +++++++ .../api/basic/IsSupportedOptionTest.java | 67 ++++++ .../api/basic/JavadocTaskImplTest.java | 108 +++++++++ .../test/tools/javadoc/api/basic/RunTest.java | 103 +++++++++ .../javadoc/api/basic/TagletPathTest.java | 106 +++++++++ .../javadoc/api/basic/Task_reuseTest.java | 93 ++++++++ .../test/tools/javadoc/api/basic/pkg/C.java | 27 +++ .../api/basic/taglets/UnderlineTaglet.java | 152 +++++++++++++ 40 files changed, 2449 insertions(+), 117 deletions(-) create mode 100644 langtools/src/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java create mode 100644 langtools/src/share/classes/com/sun/tools/javadoc/api/JavadocTool.java create mode 100644 langtools/src/share/classes/javax/tools/DocumentationTool.java create mode 100644 langtools/test/tools/javadoc/api/basic/APITest.java create mode 100644 langtools/test/tools/javadoc/api/basic/DocletPathTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/GetSourceVersionsTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/GetTask_DiagListenerTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/GetTask_DocletClassTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/GetTask_FileObjectsTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/GetTask_OptionsTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/IsSupportedOptionTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/JavadocTaskImplTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/RunTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/TagletPathTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/Task_reuseTest.java create mode 100644 langtools/test/tools/javadoc/api/basic/pkg/C.java create mode 100644 langtools/test/tools/javadoc/api/basic/taglets/UnderlineTaglet.java diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java index 7e727ceb112..a6244a0335f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java @@ -517,9 +517,14 @@ public class ConfigurationImpl extends Configuration { */ @Override public JavaFileManager getFileManager() { - if (root instanceof com.sun.tools.javadoc.RootDocImpl) - return ((com.sun.tools.javadoc.RootDocImpl)root).getFileManager(); - else - return new JavacFileManager(new Context(), false, null); + if (fileManager == null) { + if (root instanceof com.sun.tools.javadoc.RootDocImpl) + fileManager = ((com.sun.tools.javadoc.RootDocImpl)root).getFileManager(); + else + fileManager = new JavacFileManager(new Context(), false, null); + } + return fileManager; } + + private JavaFileManager fileManager; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java index 033bd4b8444..13099d24be9 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java @@ -78,7 +78,7 @@ public abstract class Configuration { /** * This is true if option "-serialwarn" is used. Defualt value is false to - * supress excessive warnings about serial tag. + * suppress excessive warnings about serial tag. */ public boolean serialwarn = false; @@ -446,7 +446,7 @@ public abstract class Configuration { /** * Initialize the taglet manager. The strings to initialize the simple custom tags should * be in the following format: "[tag name]:[location str]:[heading]". - * @param customTagStrs the set two dimentional arrays of strings. These arrays contain + * @param customTagStrs the set two dimensional arrays of strings. These arrays contain * either -tag or -taglet arguments. */ private void initTagletManager(Set customTagStrs) { @@ -457,11 +457,11 @@ public abstract class Configuration { for (Iterator it = customTagStrs.iterator(); it.hasNext(); ) { args = it.next(); if (args[0].equals("-taglet")) { - tagletManager.addCustomTag(args[1], tagletpath); + tagletManager.addCustomTag(args[1], getFileManager(), tagletpath); continue; } String[] tokens = tokenize(args[1], - TagletManager.SIMPLE_TAGLET_OPT_SEPERATOR, 3); + TagletManager.SIMPLE_TAGLET_OPT_SEPARATOR, 3); if (tokens.length == 1) { String tagName = args[1]; if (tagletManager.isKnownCustomTag(tagName)) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java index 4637b92a9ca..66cdce9132f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java @@ -30,6 +30,9 @@ import java.lang.reflect.*; import java.net.*; import java.util.*; +import javax.tools.DocumentationTool; +import javax.tools.JavaFileManager; + import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.util.*; @@ -48,16 +51,16 @@ import com.sun.tools.doclets.internal.toolkit.util.*; public class TagletManager { /** - * The default seperator for the simple tag option. + * The default separator for the simple tag option. */ - public static final char SIMPLE_TAGLET_OPT_SEPERATOR = ':'; + public static final char SIMPLE_TAGLET_OPT_SEPARATOR = ':'; /** - * The alternate seperator for simple tag options. Use this - * with you want the default seperator to be in the name of the + * The alternate separator for simple tag options. Use this + * when you want the default separator to be in the name of the * custom tag. */ - public static final String ALT_SIMPLE_TAGLET_OPT_SEPERATOR = "-"; + public static final String ALT_SIMPLE_TAGLET_OPT_SEPARATOR = "-"; /** * The map of custom tags. @@ -200,18 +203,24 @@ public class TagletManager { * @param classname the name of the class representing the custom tag. * @param tagletPath the path to the class representing the custom tag. */ - public void addCustomTag(String classname, String tagletPath) { + public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) { try { Class customTagClass = null; // construct class loader String cpString = null; // make sure env.class.path defaults to dot - // do prepends to get correct ordering - cpString = appendPath(System.getProperty("env.class.path"), cpString); - cpString = appendPath(System.getProperty("java.class.path"), cpString); - cpString = appendPath(tagletPath, cpString); - URLClassLoader appClassLoader = new URLClassLoader(pathToURLs(cpString)); - customTagClass = appClassLoader.loadClass(classname); + ClassLoader tagClassLoader; + if (fileManager != null && fileManager.hasLocation(DocumentationTool.Location.TAGLET_PATH)) { + tagClassLoader = fileManager.getClassLoader(DocumentationTool.Location.TAGLET_PATH); + } else { + // do prepends to get correct ordering + cpString = appendPath(System.getProperty("env.class.path"), cpString); + cpString = appendPath(System.getProperty("java.class.path"), cpString); + cpString = appendPath(tagletPath, cpString); + tagClassLoader = new URLClassLoader(pathToURLs(cpString)); + } + + customTagClass = tagClassLoader.loadClass(classname); Method meth = customTagClass.getMethod("register", new Class[] {java.util.Map.class}); Object[] list = customTags.values().toArray(); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java index 5f0c28dc603..f55d99a999d 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java @@ -25,10 +25,14 @@ package com.sun.tools.doclets.internal.toolkit.util; +import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; @@ -36,10 +40,6 @@ import javax.tools.JavaFileManager.Location; import javax.tools.StandardLocation; import com.sun.tools.doclets.internal.toolkit.Configuration; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; /** * Abstraction for handling files, which may be specified directly @@ -115,7 +115,8 @@ public abstract class DocFile { /** * Open an output stream for the file. * The file must have been created with a location of - * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} + * and a corresponding relative path. */ public abstract OutputStream openOutputStream() throws IOException, UnsupportedEncodingException; @@ -123,7 +124,7 @@ public abstract class DocFile { * Open an writer for the file, using the encoding (if any) given in the * doclet configuration. * The file must have been created with a location of - * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. */ public abstract Writer openWriter() throws IOException, UnsupportedEncodingException; @@ -251,7 +252,8 @@ public abstract class DocFile { /** * Resolve a relative file against the given output location. - * @param locn Currently, only SOURCE_OUTPUT is supported. + * @param locn Currently, only + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported. */ - public abstract DocFile resolveAgainst(StandardLocation locn); + public abstract DocFile resolveAgainst(Location locn); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java index 276c2d2646d..dc5349c87bc 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java @@ -69,6 +69,7 @@ abstract class DocFileFactory { throw new IllegalStateException(t); } } + factories.put(configuration, f); } return f; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java index 5aa768876d7..0306f7b38c0 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java @@ -30,7 +30,7 @@ import java.net.*; import java.util.HashMap; import java.util.Map; -import javax.tools.StandardLocation; +import javax.tools.DocumentationTool; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; @@ -253,7 +253,7 @@ public class Extern { throws Fault { DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST); if (! (file.isAbsolute() || linkoffline)){ - file = file.resolveAgainst(StandardLocation.CLASS_OUTPUT); + file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT); } try { if (file.exists() && file.canRead()) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java index 801a88aa227..d2ee2d639ed 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java @@ -42,6 +42,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import javax.tools.DocumentationTool; import javax.tools.FileObject; import javax.tools.JavaFileManager.Location; import javax.tools.JavaFileObject; @@ -70,17 +71,17 @@ class PathDocFileFactory extends DocFileFactory { fileManager = (PathFileManager) configuration.getFileManager(); if (!configuration.destDirName.isEmpty() - || !fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { + || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) { try { String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName; Path dir = fileManager.getDefaultFileSystem().getPath(dirName); - fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(dir)); + fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir)); } catch (IOException e) { throw new DocletAbortException(); } } - destDir = fileManager.getLocation(StandardLocation.CLASS_OUTPUT).iterator().next(); + destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next(); } public DocFile createFileForDirectory(String file) { @@ -92,7 +93,7 @@ class PathDocFileFactory extends DocFileFactory { } public DocFile createFileForOutput(DocPath path) { - return new StandardDocFile(StandardLocation.CLASS_OUTPUT, path); + return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path); } @Override @@ -137,10 +138,10 @@ class PathDocFileFactory extends DocFileFactory { /** * Open an output stream for the file. * The file must have been created with a location of - * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. */ public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { - if (location != StandardLocation.CLASS_OUTPUT) + if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalStateException(); OutputStream out = getFileObjectForOutput(path).openOutputStream(); @@ -151,10 +152,10 @@ class PathDocFileFactory extends DocFileFactory { * Open an writer for the file, using the encoding (if any) given in the * doclet configuration. * The file must have been created with a location of - * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. */ public Writer openWriter() throws IOException, UnsupportedEncodingException { - if (location != StandardLocation.CLASS_OUTPUT) + if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalStateException(); OutputStream out = getFileObjectForOutput(path).openOutputStream(); @@ -262,10 +263,11 @@ class PathDocFileFactory extends DocFileFactory { /** * Resolve a relative file against the given output location. - * @param locn Currently, only SOURCE_OUTPUT is supported. + * @param locn Currently, only + * {@link DocumentationTool.Location.DOCUMENTATION_OUTPUT} is supported. */ - public DocFile resolveAgainst(StandardLocation locn) { - if (locn != StandardLocation.CLASS_OUTPUT) + public DocFile resolveAgainst(Location locn) { + if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalArgumentException(); return new StandardDocFile(destDir.resolve(file)); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java index 0ffdd04df44..e9711f5c316 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java @@ -43,6 +43,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import javax.tools.DocumentationTool; import javax.tools.JavaFileManager.Location; import javax.tools.StandardLocation; @@ -74,7 +75,7 @@ class SimpleDocFileFactory extends DocFileFactory { } public DocFile createFileForOutput(DocPath path) { - return new SimpleDocFile(StandardLocation.CLASS_OUTPUT, path); + return new SimpleDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path); } @Override @@ -121,10 +122,10 @@ class SimpleDocFileFactory extends DocFileFactory { /** * Open an output stream for the file. * The file must have been created with a location of - * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. */ public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { - if (location != StandardLocation.CLASS_OUTPUT) + if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalStateException(); createDirectoryForFile(file); @@ -135,10 +136,10 @@ class SimpleDocFileFactory extends DocFileFactory { * Open an writer for the file, using the encoding (if any) given in the * doclet configuration. * The file must have been created with a location of - * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. */ public Writer openWriter() throws IOException, UnsupportedEncodingException { - if (location != StandardLocation.CLASS_OUTPUT) + if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalStateException(); createDirectoryForFile(file); @@ -243,10 +244,11 @@ class SimpleDocFileFactory extends DocFileFactory { /** * Resolve a relative file against the given output location. - * @param locn Currently, only SOURCE_OUTPUT is supported. + * @param locn Currently, only + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported. */ - public DocFile resolveAgainst(StandardLocation locn) { - if (locn != StandardLocation.CLASS_OUTPUT) + public DocFile resolveAgainst(Location locn) { + if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalArgumentException(); return new SimpleDocFile( new File(configuration.destDirName, file.getPath())); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java index 4b7fb570e3e..1f7d20c1126 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java @@ -41,6 +41,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import javax.tools.DocumentationTool; import javax.tools.FileObject; import javax.tools.JavaFileManager.Location; import javax.tools.JavaFileObject; @@ -62,24 +63,29 @@ import com.sun.tools.javac.util.Assert; */ class StandardDocFileFactory extends DocFileFactory { private final StandardJavaFileManager fileManager; - private final File destDir; + private File destDir; public StandardDocFileFactory(Configuration configuration) { super(configuration); fileManager = (StandardJavaFileManager) configuration.getFileManager(); + } - if (!configuration.destDirName.isEmpty() - || !fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { - try { - String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName; - File dir = new File(dirName); - fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(dir)); - } catch (IOException e) { - throw new DocletAbortException(); + private File getDestDir() { + if (destDir == null) { + if (!configuration.destDirName.isEmpty() + || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) { + try { + String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName; + File dir = new File(dirName); + fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir)); + } catch (IOException e) { + throw new DocletAbortException(); + } } - } - destDir = fileManager.getLocation(StandardLocation.CLASS_OUTPUT).iterator().next(); + destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next(); + } + return destDir; } public DocFile createFileForDirectory(String file) { @@ -91,7 +97,7 @@ class StandardDocFileFactory extends DocFileFactory { } public DocFile createFileForOutput(DocPath path) { - return new StandardDocFile(StandardLocation.CLASS_OUTPUT, path); + return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path); } @Override @@ -100,13 +106,13 @@ class StandardDocFileFactory extends DocFileFactory { throw new IllegalArgumentException(); Set files = new LinkedHashSet(); - if (fileManager.hasLocation(location)) { - for (File f: fileManager.getLocation(location)) { - if (f.isDirectory()) { - f = new File(f, path.getPath()); - if (f.exists()) - files.add(new StandardDocFile(f)); - } + Location l = fileManager.hasLocation(StandardLocation.SOURCE_PATH) + ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH; + for (File f: fileManager.getLocation(l)) { + if (f.isDirectory()) { + f = new File(f, path.getPath()); + if (f.exists()) + files.add(new StandardDocFile(f)); } } return files; @@ -129,8 +135,8 @@ class StandardDocFileFactory extends DocFileFactory { /** Create a StandardDocFile for a given location and relative path. */ private StandardDocFile(Location location, DocPath path) { super(configuration, location, path); - Assert.check(location == StandardLocation.CLASS_OUTPUT); - this.file = newFile(destDir, path.getPath()); + Assert.check(location == DocumentationTool.Location.DOCUMENTATION_OUTPUT); + this.file = newFile(getDestDir(), path.getPath()); } /** Open an input stream for the file. */ @@ -142,10 +148,10 @@ class StandardDocFileFactory extends DocFileFactory { /** * Open an output stream for the file. * The file must have been created with a location of - * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. */ public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { - if (location != StandardLocation.CLASS_OUTPUT) + if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalStateException(); OutputStream out = getFileObjectForOutput(path).openOutputStream(); @@ -156,10 +162,10 @@ class StandardDocFileFactory extends DocFileFactory { * Open an writer for the file, using the encoding (if any) given in the * doclet configuration. * The file must have been created with a location of - * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. */ public Writer openWriter() throws IOException, UnsupportedEncodingException { - if (location != StandardLocation.CLASS_OUTPUT) + if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalStateException(); OutputStream out = getFileObjectForOutput(path).openOutputStream(); @@ -263,12 +269,13 @@ class StandardDocFileFactory extends DocFileFactory { /** * Resolve a relative file against the given output location. - * @param locn Currently, only SOURCE_OUTPUT is supported. + * @param locn Currently, only + * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported. */ - public DocFile resolveAgainst(StandardLocation locn) { - if (locn != StandardLocation.CLASS_OUTPUT) + public DocFile resolveAgainst(Location locn) { + if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalArgumentException(); - return new StandardDocFile(newFile(destDir, file.getPath())); + return new StandardDocFile(newFile(getDestDir(), file.getPath())); } /** Return a string to identify the contents of this object, diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java b/langtools/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java index 8726ffe867e..a4dddf8f909 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java @@ -149,7 +149,7 @@ public class ClientCodeWrapper { return fo; } - DiagnosticListener wrap(DiagnosticListener dl) { + public DiagnosticListener wrap(DiagnosticListener dl) { if (isTrusted(dl)) return dl; return new WrappedDiagnosticListener(dl); diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java index a9661c77727..fbb22ff2d73 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java @@ -74,7 +74,7 @@ public class JavacTaskImpl extends BasicJavacTask { private List fileObjects; private Map notYetEntered; private ListBuffer> genList; - private AtomicBoolean used = new AtomicBoolean(); + private final AtomicBoolean used = new AtomicBoolean(); private Iterable processors; private Main.Result result = null; @@ -99,11 +99,11 @@ public class JavacTaskImpl extends BasicJavacTask { } JavacTaskImpl(Main compilerMain, - Iterable flags, + Iterable args, Context context, Iterable classes, Iterable fileObjects) { - this(compilerMain, toArray(flags), toArray(classes), context, toList(fileObjects)); + this(compilerMain, toArray(args), toArray(classes), context, toList(fileObjects)); } static private String[] toArray(Iterable iter) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java b/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java index 9c44b627211..e5701ceee55 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java +++ b/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. 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 @@ -253,7 +253,8 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan for (File f: files) pl.add(f.toPath()); } - pathsForLocation.put(locn, pl); + if (!pl.isEmpty()) + pathsForLocation.put(locn, pl); } private void lazyInitSearchPaths() { @@ -513,7 +514,8 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan } private static String getRelativePath(String packageName, String relativeName) { - return packageName.replace(".", "/") + relativeName; + return packageName.isEmpty() + ? relativeName : packageName.replace(".", "/") + "/" + relativeName; } private static String getBaseName(String relativePath) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java index 06e6e46d76c..a75d92cb59b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java @@ -31,6 +31,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Set; + import javax.tools.JavaFileObject; import com.sun.tools.javac.api.DiagnosticFormatter; @@ -43,9 +44,8 @@ import com.sun.tools.javac.code.Printer; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Type.CapturedType; -import com.sun.tools.javac.tree.JCTree.*; - import com.sun.tools.javac.file.BaseFileObject; +import com.sun.tools.javac.tree.JCTree.*; import com.sun.tools.javac.tree.Pretty; import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*; diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java b/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java index 9627f5a7f8d..3fedeeea512 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java @@ -32,7 +32,12 @@ import java.lang.reflect.Modifier; import java.net.URL; import java.net.URLClassLoader; +import javax.tools.DocumentationTool; +import javax.tools.JavaFileManager; + import com.sun.javadoc.*; +import com.sun.tools.javac.file.Locations; +import com.sun.tools.javac.util.ClientCodeException; import com.sun.tools.javac.util.List; import static com.sun.javadoc.LanguageVersion.*; @@ -57,6 +62,12 @@ public class DocletInvoker { private final Messager messager; + /** + * In API mode, exceptions thrown while calling the doclet are + * propagated using ClientCodeException. + */ + private final boolean apiMode; + private static class DocletInvokeException extends Exception { private static final long serialVersionUID = 0; } @@ -71,24 +82,38 @@ public class DocletInvoker { } } - public DocletInvoker(Messager messager, + public DocletInvoker(Messager messager, Class docletClass, boolean apiMode) { + this.messager = messager; + this.docletClass = docletClass; + docletClassName = docletClass.getName(); + appClassLoader = null; + this.apiMode = apiMode; + } + + public DocletInvoker(Messager messager, JavaFileManager fileManager, String docletClassName, String docletPath, - ClassLoader docletParentClassLoader) { + ClassLoader docletParentClassLoader, + boolean apiMode) { this.messager = messager; this.docletClassName = docletClassName; + this.apiMode = apiMode; - // construct class loader - String cpString = null; // make sure env.class.path defaults to dot + if (fileManager != null && fileManager.hasLocation(DocumentationTool.Location.DOCLET_PATH)) { + appClassLoader = fileManager.getClassLoader(DocumentationTool.Location.DOCLET_PATH); + } else { + // construct class loader + String cpString = null; // make sure env.class.path defaults to dot - // do prepends to get correct ordering - cpString = appendPath(System.getProperty("env.class.path"), cpString); - cpString = appendPath(System.getProperty("java.class.path"), cpString); - cpString = appendPath(docletPath, cpString); - URL[] urls = com.sun.tools.javac.file.Locations.pathToURLs(cpString); - if (docletParentClassLoader == null) - appClassLoader = new URLClassLoader(urls, getDelegationClassLoader(docletClassName)); - else - appClassLoader = new URLClassLoader(urls, docletParentClassLoader); + // do prepends to get correct ordering + cpString = appendPath(System.getProperty("env.class.path"), cpString); + cpString = appendPath(System.getProperty("java.class.path"), cpString); + cpString = appendPath(docletPath, cpString); + URL[] urls = Locations.pathToURLs(cpString); + if (docletParentClassLoader == null) + appClassLoader = new URLClassLoader(urls, getDelegationClassLoader(docletClassName)); + else + appClassLoader = new URLClassLoader(urls, docletParentClassLoader); + } // attempt to find doclet Class dc = null; @@ -280,7 +305,8 @@ public class DocletInvoker { ClassLoader savedCCL = Thread.currentThread().getContextClassLoader(); try { - Thread.currentThread().setContextClassLoader(appClassLoader); + if (appClassLoader != null) // will be null if doclet class provided via API + Thread.currentThread().setContextClassLoader(appClassLoader); return meth.invoke(null , params); } catch (IllegalArgumentException exc) { messager.error(Messager.NOPOS, "main.internal_error_exception_thrown", @@ -296,10 +322,12 @@ public class DocletInvoker { throw new DocletInvokeException(); } catch (InvocationTargetException exc) { Throwable err = exc.getTargetException(); + if (apiMode) + throw new ClientCodeException(err); if (err instanceof java.lang.OutOfMemoryError) { messager.error(Messager.NOPOS, "main.out.of.memory"); } else { - messager.error(Messager.NOPOS, "main.exception_thrown", + messager.error(Messager.NOPOS, "main.exception_thrown", docletClassName, methodName, exc.toString()); exc.getTargetException().printStackTrace(); } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java index df63f2c88ce..1cc3de3c8c3 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java @@ -119,6 +119,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { ModifierFilter filter, List javaNames, List options, + Iterable fileObjects, boolean breakiterator, List subPackages, List excludedPackages, @@ -140,10 +141,11 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { ListBuffer packTrees = new ListBuffer(); try { - StandardJavaFileManager fm = (StandardJavaFileManager) docenv.fileManager; + StandardJavaFileManager fm = docenv.fileManager instanceof StandardJavaFileManager + ? (StandardJavaFileManager) docenv.fileManager : null; for (List it = javaNames; it.nonEmpty(); it = it.tail) { String name = it.head; - if (!docClasses && name.endsWith(".java") && new File(name).exists()) { + if (!docClasses && fm != null && name.endsWith(".java") && new File(name).exists()) { JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next(); docenv.notice("main.Loading_source_file", name); JCCompilationUnit tree = parse(fo); @@ -151,11 +153,19 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { } else if (isValidPackageName(name)) { names = names.append(name); } else if (name.endsWith(".java")) { + if (fm == null) + throw new IllegalArgumentException(); + else docenv.error(null, "main.file_not_found", name); } else { docenv.error(null, "main.illegal_package_name", name); } } + for (JavaFileObject fo: fileObjects) { + docenv.notice("main.Loading_source_file", fo.getName()); + JCCompilationUnit tree = parse(fo); + classTrees.append(tree); + } if (!docClasses) { // Recursively search given subpackages. If any packages diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java b/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java index b397816c86b..c5b955fc58c 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java @@ -33,6 +33,7 @@ import java.util.ResourceBundle; import com.sun.javadoc.*; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.JCDiagnostic; +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType; import com.sun.tools.javac.util.JavacMessages; import com.sun.tools.javac.util.Log; @@ -174,6 +175,11 @@ public class Messager extends Log implements DocErrorReporter { * @param msg message to print */ public void printError(SourcePosition pos, String msg) { + if (diagListener != null) { + report(DiagnosticType.ERROR, pos, msg); + return; + } + if (nerrors < MaxErrors) { String prefix = (pos == null) ? programName : pos.toString(); errWriter.println(prefix + ": " + getText("javadoc.error") + " - " + msg); @@ -201,6 +207,11 @@ public class Messager extends Log implements DocErrorReporter { * @param msg message to print */ public void printWarning(SourcePosition pos, String msg) { + if (diagListener != null) { + report(DiagnosticType.WARNING, pos, msg); + return; + } + if (nwarnings < MaxWarnings) { String prefix = (pos == null) ? programName : pos.toString(); warnWriter.println(prefix + ": " + getText("javadoc.warning") +" - " + msg); @@ -227,6 +238,11 @@ public class Messager extends Log implements DocErrorReporter { * @param msg message to print */ public void printNotice(SourcePosition pos, String msg) { + if (diagListener != null) { + report(DiagnosticType.NOTE, pos, msg); + return; + } + if (pos == null) noticeWriter.println(msg); else @@ -295,4 +311,22 @@ public class Messager extends Log implements DocErrorReporter { public void exit() { throw new ExitJavadoc(); } + + private void report(DiagnosticType type, SourcePosition pos, String msg) { + switch (type) { + case ERROR: + case WARNING: + Object prefix = (pos == null) ? programName : pos; + report(javadocDiags.create(type, null, null, "msg", prefix, msg)); + break; + + case NOTE: + String key = (pos == null) ? "msg" : "pos.msg"; + report(javadocDiags.create(type, null, null, key, pos, msg)); + break; + + default: + throw new IllegalArgumentException(type.toString()); + } + } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/Start.java b/langtools/src/share/classes/com/sun/tools/javadoc/Start.java index 0dbab39b669..4efb9324e26 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/Start.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/Start.java @@ -29,9 +29,16 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; + +import javax.tools.JavaFileManager; +import javax.tools.JavaFileObject; import com.sun.javadoc.*; import com.sun.tools.javac.main.CommandLine; +import com.sun.tools.javac.util.ClientCodeException; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; @@ -70,6 +77,12 @@ public class Start extends ToolOption.Helper { private DocletInvoker docletInvoker; + /** + * In API mode, exceptions thrown while calling the doclet are + * propagated using ClientCodeException. + */ + private boolean apiMode; + Start(String programName, PrintWriter errWriter, PrintWriter warnWriter, @@ -121,6 +134,7 @@ public class Start extends ToolOption.Helper { public Start(Context context) { context.getClass(); // null check this.context = context; + apiMode = true; defaultDocletClassName = standardDocletClassName; docletParentClassLoader = null; @@ -184,15 +198,29 @@ public class Start extends ToolOption.Helper { * Main program - external wrapper */ int begin(String... argv) { + boolean ok = begin(null, argv, Collections. emptySet()); + return ok ? 0 : 1; + } + + public boolean begin(Class docletClass, Iterable options, Iterable fileObjects) { + Collection opts = new ArrayList(); + for (String opt: options) opts.add(opt); + return begin(docletClass, opts.toArray(new String[opts.size()]), fileObjects); + } + + private boolean begin(Class docletClass, String[] options, Iterable fileObjects) { boolean failed = false; try { - failed = !parseAndExecute(argv); + failed = !parseAndExecute(docletClass, options, fileObjects); } catch (Messager.ExitJavadoc exc) { // ignore, we just exit this way } catch (OutOfMemoryError ee) { messager.error(Messager.NOPOS, "main.out.of.memory"); failed = true; + } catch (ClientCodeException e) { + // simply rethrow these exceptions, to be caught and handled by JavadocTaskImpl + throw e; } catch (Error ee) { ee.printStackTrace(System.err); messager.error(Messager.NOPOS, "main.fatal.error"); @@ -207,13 +235,16 @@ public class Start extends ToolOption.Helper { } failed |= messager.nerrors() > 0; failed |= rejectWarnings && messager.nwarnings() > 0; - return failed ? 1 : 0; + return !failed; } /** * Main program - internal */ - private boolean parseAndExecute(String... argv) throws IOException { + private boolean parseAndExecute( + Class docletClass, + String[] argv, + Iterable fileObjects) throws IOException { long tm = System.currentTimeMillis(); ListBuffer javaNames = new ListBuffer(); @@ -229,7 +260,9 @@ public class Start extends ToolOption.Helper { exit(); } - setDocletInvoker(argv); + + JavaFileManager fileManager = context.get(JavaFileManager.class); + setDocletInvoker(docletClass, fileManager, argv); compOpts = Options.instance(context); @@ -287,7 +320,7 @@ public class Start extends ToolOption.Helper { } compOpts.notifyListeners(); - if (javaNames.isEmpty() && subPackages.isEmpty()) { + if (javaNames.isEmpty() && subPackages.isEmpty() && isEmpty(fileObjects)) { usageError("main.No_packages_or_classes_specified"); } @@ -310,6 +343,7 @@ public class Start extends ToolOption.Helper { showAccess, javaNames.toList(), options.toList(), + fileObjects, breakiterator, subPackages.toList(), excludedPackages.toList(), @@ -334,21 +368,43 @@ public class Start extends ToolOption.Helper { return ok; } - private void setDocletInvoker(String[] argv) { + private boolean isEmpty(Iterable iter) { + return !iter.iterator().hasNext(); + } + + /** + * Init the doclet invoker. + * The doclet class may be given explicitly, or via the -doclet option in + * argv. + * If the doclet class is not given explicitly, it will be loaded from + * the file manager's DOCLET_PATH location, if available, or via the + * -doclet path option in argv. + * @param docletClass The doclet class. May be null. + * @param fileManager The file manager used to get the class loader to load + * the doclet class if required. May be null. + * @param argv Args containing -doclet and -docletpath, in case they are required. + */ + private void setDocletInvoker(Class docletClass, JavaFileManager fileManager, String[] argv) { + if (docletClass != null) { + docletInvoker = new DocletInvoker(messager, docletClass, apiMode); + // TODO, check no -doclet, -docletpath + return; + } + String docletClassName = null; String docletPath = null; // Parse doclet specifying arguments for (int i = 0 ; i < argv.length ; i++) { String arg = argv[i]; - if (arg.equals("-doclet")) { + if (arg.equals(ToolOption.DOCLET.opt)) { oneArg(argv, i++); if (docletClassName != null) { usageError("main.more_than_one_doclet_specified_0_and_1", docletClassName, argv[i]); } docletClassName = argv[i]; - } else if (arg.equals("-docletpath")) { + } else if (arg.equals(ToolOption.DOCLETPATH.opt)) { oneArg(argv, i++); if (docletPath == null) { docletPath = argv[i]; @@ -363,9 +419,10 @@ public class Start extends ToolOption.Helper { } // attempt to find doclet - docletInvoker = new DocletInvoker(messager, - docletClassName, docletPath, - docletParentClassLoader); + docletInvoker = new DocletInvoker(messager, fileManager, + docletClassName, docletPath, + docletParentClassLoader, + apiMode); } /** diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java new file mode 100644 index 00000000000..ae1fc061e42 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.tools.javadoc.api; + +import com.sun.tools.javac.util.ClientCodeException; +import java.util.Locale; +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaFileObject; + +import com.sun.tools.javac.util.Context; +import com.sun.tools.javadoc.Start; +import java.util.Collections; + +/** + * Provides access to functionality specific to the JDK documentation tool, + * javadoc. + * + *

This is NOT part of any supported API. + * 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.

+ */ +public class JavadocTaskImpl implements DocumentationTask { + private final AtomicBoolean used = new AtomicBoolean(); + + private final Context context; + private Class docletClass; + private Iterable options; + private Iterable fileObjects; + private Locale locale; + + public JavadocTaskImpl(Context context, Class docletClass, + Iterable options, Iterable fileObjects) { + this.context = context; + this.docletClass = docletClass; + + this.options = (options == null) ? Collections.emptySet() + : nullCheck(options); + this.fileObjects = (fileObjects == null) ? Collections.emptySet() + : nullCheck(fileObjects); + setLocale(Locale.getDefault()); + } + + public void setLocale(Locale locale) { + if (used.get()) + throw new IllegalStateException(); + this.locale = locale; + } + + public Boolean call() { + if (!used.getAndSet(true)) { + initContext(); + Start jdoc = new Start(context); + try { + return jdoc.begin(docletClass, options, fileObjects); + } catch (ClientCodeException e) { + throw new RuntimeException(e.getCause()); + } + } else { + throw new IllegalStateException("multiple calls to method 'call'"); + } + } + + private void initContext() { + //initialize compiler's default locale + context.put(Locale.class, locale); + } + + private static Iterable nullCheck(Iterable items) { + for (T item: items) { + if (item == null) + throw new NullPointerException(); + } + return items; + } +} diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/api/JavadocTool.java b/langtools/src/share/classes/com/sun/tools/javadoc/api/JavadocTool.java new file mode 100644 index 00000000000..a8aa2786577 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javadoc/api/JavadocTool.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.javadoc.api; + +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.Writer; +import java.nio.charset.Charset; +import java.util.Collections; +import java.util.EnumSet; +import java.util.Locale; +import java.util.Set; + +import javax.lang.model.SourceVersion; +import javax.tools.DiagnosticListener; +import javax.tools.DocumentationTool; +import javax.tools.JavaFileManager; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; + +import com.sun.tools.javac.api.ClientCodeWrapper; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.util.ClientCodeException; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.Log; +import com.sun.tools.javadoc.ToolOption; + +/** + * Provides access to functionality specific to the JDK documentation tool, + * javadoc. + * + *

This is NOT part of any supported API. + * 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.

+ */ +public class JavadocTool implements DocumentationTool { + @Override + public DocumentationTask getTask( + Writer out, + JavaFileManager fileManager, + DiagnosticListener diagnosticListener, + Class docletClass, + Iterable options, + Iterable compilationUnits) { + Context context = new Context(); + return getTask(out, fileManager, diagnosticListener, + docletClass, options, compilationUnits, context); + } + + public DocumentationTask getTask( + Writer out, + JavaFileManager fileManager, + DiagnosticListener diagnosticListener, + Class docletClass, + Iterable options, + Iterable compilationUnits, + Context context) { + try { + ClientCodeWrapper ccw = ClientCodeWrapper.instance(context); + + if (options != null) { + for (String option : options) + option.getClass(); // null check + } + + if (compilationUnits != null) { + compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check + for (JavaFileObject cu : compilationUnits) { + if (cu.getKind() != JavaFileObject.Kind.SOURCE) { + final String kindMsg = "All compilation units must be of SOURCE kind"; + throw new IllegalArgumentException(kindMsg); + } + } + } + + if (diagnosticListener != null) + context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener)); + + if (out == null) + context.put(Log.outKey, new PrintWriter(System.err, true)); + else if (out instanceof PrintWriter) + context.put(Log.outKey, ((PrintWriter) out)); + else + context.put(Log.outKey, new PrintWriter(out, true)); + + if (fileManager == null) + fileManager = getStandardFileManager(diagnosticListener, null, null); + fileManager = ccw.wrap(fileManager); + context.put(JavaFileManager.class, fileManager); + + return new JavadocTaskImpl(context, docletClass, options, compilationUnits); + } catch (ClientCodeException ex) { + throw new RuntimeException(ex.getCause()); + } + } + + // TODO: used shared static method in JavacFileManager + @Override + public StandardJavaFileManager getStandardFileManager( + DiagnosticListener diagnosticListener, + Locale locale, + Charset charset) { + Context context = new Context(); + context.put(Locale.class, locale); + if (diagnosticListener != null) + context.put(DiagnosticListener.class, diagnosticListener); + PrintWriter pw = (charset == null) + ? new PrintWriter(System.err, true) + : new PrintWriter(new OutputStreamWriter(System.err, charset), true); + context.put(Log.outKey, pw); + return new JavacFileManager(context, true, charset); + } + + @Override + public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { + PrintWriter err_pw = new PrintWriter(err, true); + PrintWriter out_pw = new PrintWriter(out); + try { + String standardDocletName = "com.sun.tools.doclets.standard.Standard"; + return com.sun.tools.javadoc.Main.execute( + "javadoc", err_pw, err_pw, out_pw, standardDocletName, arguments); + } finally { + err_pw.flush(); + out_pw.flush(); + } + } + + @Override + public Set getSourceVersions() { + return Collections.unmodifiableSet( + EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest())); + } + + @Override + public int isSupportedOption(String option) { + if (option == null) + throw new NullPointerException(); + for (ToolOption o: ToolOption.values()) { + if (o.opt.equals(option)) + return o.hasArg ? 1 : 0; + } + return -1; + } + +} diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties b/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties index 861fea44a36..4189f6ba7e7 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties +++ b/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties @@ -108,3 +108,8 @@ javadoc.Multiple_package_comments=Multiple sources of package comments found for javadoc.class_not_found=Class {0} not found. javadoc.error=error javadoc.warning=warning + +javadoc.error.msg={0}: error - {1} +javadoc.warning.msg={0}: warning - {1} +javadoc.note.msg = {1} +javadoc.note.pos.msg= {0}: {1} diff --git a/langtools/src/share/classes/javax/tools/DocumentationTool.java b/langtools/src/share/classes/javax/tools/DocumentationTool.java new file mode 100644 index 00000000000..63158ed005e --- /dev/null +++ b/langtools/src/share/classes/javax/tools/DocumentationTool.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package javax.tools; + +import java.io.Writer; +import java.nio.charset.Charset; +import java.util.Locale; +import java.util.concurrent.Callable; + +/** + * Interface to invoke Java™ programming language documentation tools from + * programs. + */ +public interface DocumentationTool extends Tool, OptionChecker { + /** + * Creates a future for a documentation task with the given + * components and arguments. The task might not have + * completed as described in the DocumentationTask interface. + * + *

If a file manager is provided, it must be able to handle all + * locations defined in {@link DocumentationTool.Location}, + * as well as + * {@link StandardLocation#SOURCE_PATH}, + * {@link StandardLocation#CLASS_PATH}, and + * {@link StandardLocation#PLATFORM_CLASS_PATH}. + * + * @param out a Writer for additional output from the tool; + * use {@code System.err} if {@code null} + * + * @param fileManager a file manager; if {@code null} use the + * tool's standard filemanager + * + * @param diagnosticListener a diagnostic listener; if {@code null} + * use the tool's default method for reporting diagnostics + * + * @param docletClass a class providing the necessary methods required + * of a doclet + * + * @param options documentation tool options and doclet options, + * {@code null} means no options + * + * @param compilationUnits the compilation units to compile, {@code + * null} means no compilation units + * + * @return an object representing the compilation + * + * @throws RuntimeException if an unrecoverable error + * occurred in a user supplied component. The + * {@linkplain Throwable#getCause() cause} will be the error in + * user code. + * + * @throws IllegalArgumentException if any of the given + * compilation units are of other kind than + * {@linkplain JavaFileObject.Kind#SOURCE source} + */ + DocumentationTask getTask(Writer out, + JavaFileManager fileManager, + DiagnosticListener diagnosticListener, + Class docletClass, + Iterable options, + Iterable compilationUnits); + + /** + * Gets a new instance of the standard file manager implementation + * for this tool. The file manager will use the given diagnostic + * listener for producing any non-fatal diagnostics. Fatal errors + * will be signaled with the appropriate exceptions. + * + *

The standard file manager will be automatically reopened if + * it is accessed after calls to {@code flush} or {@code close}. + * The standard file manager must be usable with other tools. + * + * @param diagnosticListener a diagnostic listener for non-fatal + * diagnostics; if {@code null} use the compiler's default method + * for reporting diagnostics + * + * @param locale the locale to apply when formatting diagnostics; + * {@code null} means the {@linkplain Locale#getDefault() default locale}. + * + * @param charset the character set used for decoding bytes; if + * {@code null} use the platform default + * + * @return the standard file manager + */ + StandardJavaFileManager getStandardFileManager( + DiagnosticListener diagnosticListener, + Locale locale, + Charset charset); + + /** + * Interface representing a future for a documentation task. The + * task has not yet started. To start the task, call + * the {@linkplain #call call} method. + * + *

Before calling the call method, additional aspects of the + * task can be configured, for example, by calling the + * {@linkplain #setLocale setLocale} method. + */ + interface DocumentationTask extends Callable { + /** + * Set the locale to be applied when formatting diagnostics and + * other localized data. + * + * @param locale the locale to apply; {@code null} means apply no + * locale + * @throws IllegalStateException if the task has started + */ + void setLocale(Locale locale); + + /** + * Performs this documentation task. The task may only + * be performed once. Subsequent calls to this method throw + * IllegalStateException. + * + * @return true if and only all the files were processed without errors; + * false otherwise + * + * @throws RuntimeException if an unrecoverable error occurred + * in a user-supplied component. The + * {@linkplain Throwable#getCause() cause} will be the error + * in user code. + * + * @throws IllegalStateException if called more than once + */ + Boolean call(); + } + + /** + * Locations specific to {@link DocumentationTool}. + * + * @see StandardLocation + */ + enum Location implements JavaFileManager.Location { + /** + * Location of new documentation files. + */ + DOCUMENTATION_OUTPUT, + + /** + * Location to search for doclets. + */ + DOCLET_PATH, + + /** + * Location to search for taglets. + */ + TAGLET_PATH; + + public String getName() { return name(); } + + public boolean isOutputLocation() { + switch (this) { + case DOCUMENTATION_OUTPUT: + return true; + default: + return false; + } + } + } + +} diff --git a/langtools/src/share/classes/javax/tools/JavaCompiler.java b/langtools/src/share/classes/javax/tools/JavaCompiler.java index f5b572d107f..36d86cfe8f3 100644 --- a/langtools/src/share/classes/javax/tools/JavaCompiler.java +++ b/langtools/src/share/classes/javax/tools/JavaCompiler.java @@ -266,7 +266,7 @@ public interface JavaCompiler extends Tool, OptionChecker { * Gets a new instance of the standard file manager implementation * for this tool. The file manager will use the given diagnostic * listener for producing any non-fatal diagnostics. Fatal errors - * will be signalled with the appropriate exceptions. + * will be signaled with the appropriate exceptions. * *

The standard file manager will be automatically reopened if * it is accessed after calls to {@code flush} or {@code close}. diff --git a/langtools/src/share/classes/javax/tools/ToolProvider.java b/langtools/src/share/classes/javax/tools/ToolProvider.java index 7fc4a9cd280..b8af9da321a 100644 --- a/langtools/src/share/classes/javax/tools/ToolProvider.java +++ b/langtools/src/share/classes/javax/tools/ToolProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. 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 @@ -102,6 +102,19 @@ public class ToolProvider { return instance().getSystemTool(JavaCompiler.class, defaultJavaCompilerName); } + private static final String defaultDocumentationToolName + = "com.sun.tools.javadoc.api.JavadocTool"; + + /** + * Gets the Java™ programming language documentation tool provided + * with this platform. + * @return the documentation tool provided with this platform or + * {@code null} if no documentation tool is provided + */ + public static DocumentationTool getSystemDocumentationTool() { + return instance().getSystemTool(DocumentationTool.class, defaultDocumentationToolName); + } + /** * Returns the class loader for tools provided with this platform. * This does not include user-installed tools. Use the diff --git a/langtools/test/tools/javadoc/CheckResourceKeys.java b/langtools/test/tools/javadoc/CheckResourceKeys.java index 45f3b13fd0f..b3de88f7050 100644 --- a/langtools/test/tools/javadoc/CheckResourceKeys.java +++ b/langtools/test/tools/javadoc/CheckResourceKeys.java @@ -167,6 +167,13 @@ public class CheckResourceKeys { results.add("doclet." + s.toLowerCase()); } + // special handling for code strings synthesized in + // com.sun.tools.javadoc.Messager + results.add("javadoc.error.msg"); + results.add("javadoc.note.msg"); + results.add("javadoc.note.pos.msg"); + results.add("javadoc.warning.msg"); + return results; } diff --git a/langtools/test/tools/javadoc/api/basic/APITest.java b/langtools/test/tools/javadoc/api/basic/APITest.java new file mode 100644 index 00000000000..c9da54f0eb2 --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/APITest.java @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.TreeSet; + +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; + + +/* + * Superclass with utility methods for API tests. + */ +class APITest { + protected APITest() { } + + /** Marker annotation for test cases. */ + @Retention(RetentionPolicy.RUNTIME) + @interface Test { } + + /** Invoke all methods annotated with @Test. */ + protected void run() throws Exception { + for (Method m: getClass().getDeclaredMethods()) { + Annotation a = m.getAnnotation(Test.class); + if (a != null) { + testCount++; + testName = m.getName(); + System.err.println("test: " + testName); + try { + m.invoke(this, new Object[] { }); + } catch (InvocationTargetException e) { + Throwable cause = e.getCause(); + throw (cause instanceof Exception) ? ((Exception) cause) : e; + } + System.err.println(); + } + } + + if (testCount == 0) + error("no tests found"); + + StringBuilder summary = new StringBuilder(); + if (testCount != 1) + summary.append(testCount).append(" tests"); + if (errorCount > 0) { + if (summary.length() > 0) summary.append(", "); + summary.append(errorCount).append(" errors"); + } + System.err.println(summary); + if (errorCount > 0) + throw new Exception(errorCount + " errors found"); + } + + /** + * Create a directory in which to store generated doc files. + * Avoid using the default (current) directory, so that we can + * be sure that javadoc is writing in the intended location, + * not a default location. + */ + protected File getOutDir() { + File dir = new File(testName); + dir.mkdirs(); + return dir; + } + + /** + * Create a directory in which to store generated doc files. + * Avoid using the default (current) directory, so that we can + * be sure that javadoc is writing in the intended location, + * not a default location. + */ + protected File getOutDir(String path) { + File dir = new File(testName, path); + dir.mkdirs(); + return dir; + } + + protected JavaFileObject createSimpleJavaFileObject() { + return createSimpleJavaFileObject("pkg/C", "package pkg; public class C { }"); + } + + protected JavaFileObject createSimpleJavaFileObject(final String binaryName, final String content) { + return new SimpleJavaFileObject( + URI.create("myfo:///" + binaryName + ".java"), JavaFileObject.Kind.SOURCE) { + @Override + public CharSequence getCharContent(boolean ignoreEncoding) { + return content; + } + }; + } + + protected void checkFiles(File dir, Set expectFiles) { + Set files = new HashSet(); + listFiles(dir, files); + Set foundFiles = new HashSet(); + URI dirURI = dir.toURI(); + for (File f: files) + foundFiles.add(dirURI.relativize(f.toURI()).getPath()); + checkFiles(foundFiles, expectFiles, dir); + } + + protected void checkFiles(Path dir, Set expectFiles) throws IOException { + Set files = new HashSet(); + listFiles(dir, files); + Set foundFiles = new HashSet(); + for (Path f: files) { + foundFiles.add(dir.relativize(f).toString().replace(f.getFileSystem().getSeparator(), "/")); + } + checkFiles(foundFiles, expectFiles, dir); + } + + private void checkFiles(Set foundFiles, Set expectFiles, Object where) { + if (!foundFiles.equals(expectFiles)) { + Set missing = new TreeSet(expectFiles); + missing.removeAll(foundFiles); + if (!missing.isEmpty()) + error("the following files were not found in " + where + ": " + missing); + Set unexpected = new TreeSet(foundFiles); + unexpected.removeAll(expectFiles); + if (!unexpected.isEmpty()) + error("the following unexpected files were found in " + where + ": " + unexpected); + } + } + + protected void listFiles(File dir, Set files) { + for (File f: dir.listFiles()) { + if (f.isDirectory()) + listFiles(f, files); + else if (f.isFile()) + files.add(f); + } + } + + private void listFiles(Path dir, Set files) throws IOException { + for (Path f: Files.newDirectoryStream(dir)) { + if (Files.isDirectory(f)) + listFiles(f, files); + else if (Files.isRegularFile(f)) + files.add(f); + } + } + + protected void error(String msg) { + System.err.println("Error: " + msg); + errorCount++; + } + + protected int testCount; + protected int errorCount; + + protected String testName; + + /** + * Standard files generated by processing a documented class pkg.C. + */ + protected static Set standardExpectFiles = new HashSet(Arrays.asList( + "allclasses-frame.html", + "allclasses-noframe.html", + "constant-values.html", + "deprecated-list.html", + "help-doc.html", + "index-all.html", + "index.html", + "overview-tree.html", + "package-list", + "pkg/C.html", + "pkg/package-frame.html", + "pkg/package-summary.html", + "pkg/package-tree.html", + "resources/background.gif", + "resources/tab.gif", + "resources/titlebar_end.gif", + "resources/titlebar.gif", + "stylesheet.css" + )); +} + diff --git a/langtools/test/tools/javadoc/api/basic/DocletPathTest.java b/langtools/test/tools/javadoc/api/basic/DocletPathTest.java new file mode 100644 index 00000000000..daf40cc4037 --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/DocletPathTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main DocletPathTest + */ + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Arrays; +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +/** + * Tests for locating a doclet via the file manager's DOCLET_PATH. + */ +public class DocletPathTest extends APITest { + public static void main(String... args) throws Exception { + new DocletPathTest().run(); + } + + /** + * Verify that an alternate doclet can be specified, and located via + * the file manager's DOCLET_PATH. + */ + @Test + public void testDocletPath() throws Exception { + JavaFileObject docletSrc = + createSimpleJavaFileObject("DocletOnDocletPath", docletSrcText); + File docletDir = getOutDir("classes"); + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager cfm = compiler.getStandardFileManager(null, null, null); + cfm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(docletDir)); + Iterable cfiles = Arrays.asList(docletSrc); + if (!compiler.getTask(null, cfm, null, null, null, cfiles).call()) + throw new Exception("cannot compile doclet"); + + JavaFileObject srcFile = createSimpleJavaFileObject(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir("api"); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + fm.setLocation(DocumentationTool.Location.DOCLET_PATH, Arrays.asList(docletDir)); + Iterable files = Arrays.asList(srcFile); + Iterable options = Arrays.asList("-doclet", "DocletOnDocletPath"); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + DocumentationTask t = tool.getTask(pw, fm, null, null, options, files); + boolean ok = t.call(); + String out = sw.toString(); + System.err.println(">>" + out + "<<"); + if (ok) { + if (out.contains(TEST_STRING)) { + System.err.println("doclet executed as expected"); + } else { + error("test string not found in doclet output"); + } + } else { + error("task failed"); + } + } + + private static final String TEST_STRING = "DocletOnDocletPath found and running"; + + private static final String docletSrcText = + "import com.sun.javadoc.*;\n" + + "public class DocletOnDocletPath {\n" + + " public static boolean start(RootDoc doc) {\n" + + " doc.printNotice(\"" + TEST_STRING + "\");\n" + + " return true;\n" + + " }\n" + + " public static int optionLength(String option) { return 0; }\n" + + " public static boolean validOptions(String options[][],\n" + + " DocErrorReporter reporter) { return true; }\n" + + " public static LanguageVersion languageVersion() {\n" + + " return LanguageVersion.JAVA_1_1;\n" + + " }\n" + + "}\n"; +} + diff --git a/langtools/test/tools/javadoc/api/basic/GetSourceVersionsTest.java b/langtools/test/tools/javadoc/api/basic/GetSourceVersionsTest.java new file mode 100644 index 00000000000..1af73938f8a --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/GetSourceVersionsTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main GetSourceVersionsTest + */ + +import java.util.EnumSet; +import java.util.Set; +import javax.lang.model.SourceVersion; +import javax.tools.DocumentationTool; +import javax.tools.ToolProvider; + +/** + * Tests for DocumentationTool.getSourceVersions method. + */ +public class GetSourceVersionsTest extends APITest { + public static void main(String... args) throws Exception { + new GetSourceVersionsTest().run(); + } + + /** + * Verify getSourceVersions. + */ + @Test + public void testRun() throws Exception { + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + Set found = tool.getSourceVersions(); + Set expect = EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest()); + if (!expect.equals(found)) { + System.err.println("expect: " + expect); + System.err.println(" found: " + expect); + error("unexpected versions"); + } + } +} + diff --git a/langtools/test/tools/javadoc/api/basic/GetTask_DiagListenerTest.java b/langtools/test/tools/javadoc/api/basic/GetTask_DiagListenerTest.java new file mode 100644 index 00000000000..fafc02835a9 --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/GetTask_DiagListenerTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main GetTask_DiagListenerTest + */ + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticCollector; +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +/** + * Tests for DocumentationTool.getTask diagnosticListener parameter. + */ +public class GetTask_DiagListenerTest extends APITest { + public static void main(String... args) throws Exception { + new GetTask_DiagListenerTest().run(); + } + + /** + * Verify that a diagnostic listener can be specified. + * Note that messages from the tool and doclet are imperfectly modeled + * because the DocErrorReporter API works in terms of localized strings + * and file:line positions. Therefore, messages reported via DocErrorReporter + * and simply wrapped and passed through. + */ + @Test + public void testDiagListener() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject("pkg/C", "package pkg; public error { }"); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList(srcFile); + DiagnosticCollector dc = new DiagnosticCollector(); + DocumentationTask t = tool.getTask(null, fm, dc, null, null, files); + if (t.call()) { + throw new Exception("task succeeded unexpectedly"); + } else { + List diagCodes = new ArrayList(); + for (Diagnostic d: dc.getDiagnostics()) { + System.err.println(d); + diagCodes.add(d.getCode()); + } + List expect = Arrays.asList( + "javadoc.note.msg", // Loading source file + "compiler.err.expected3", // class, interface, or enum expected + "javadoc.note.msg"); // 1 error + if (!diagCodes.equals(expect)) + throw new Exception("unexpected diagnostics occurred"); + System.err.println("diagnostics received as expected"); + } + } + +} + diff --git a/langtools/test/tools/javadoc/api/basic/GetTask_DocletClassTest.java b/langtools/test/tools/javadoc/api/basic/GetTask_DocletClassTest.java new file mode 100644 index 00000000000..c5085043cff --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/GetTask_DocletClassTest.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main GetTask_DocletClassTest + */ + +import com.sun.javadoc.DocErrorReporter; +import com.sun.javadoc.LanguageVersion; +import com.sun.javadoc.RootDoc; +import java.io.File; +import java.util.Arrays; +import java.util.Collections; +import java.util.Random; +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +/** + * Tests for DocumentationTool.getTask docletClass parameter. + */ +public class GetTask_DocletClassTest extends APITest { + public static void main(String... args) throws Exception { + new GetTask_DocletClassTest().run(); + } + + /** + * Verify that an alternate doclet can be specified. + * + * There is no standard interface or superclass for a doclet; + * the only requirement is that it provides static methods that + * can be invoked via reflection. So, for now, the doclet is + * specified as a class. + * Because we cannot create and use a unique instance of the class, + * we verify that the doclet has been called by having it record + * (in a static field!) the comment from the last time it was invoked, + * which is randomly generated each time the test is run. + */ + @Test + public void testDoclet() throws Exception { + Random r = new Random(); + int key = r.nextInt(); + JavaFileObject srcFile = createSimpleJavaFileObject( + "pkg/C", + "package pkg; /** " + key + "*/ public class C { }"); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList(srcFile); + DocumentationTask t = tool.getTask(null, fm, null, TestDoclet.class, null, files); + if (t.call()) { + System.err.println("task succeeded"); + if (TestDoclet.lastCaller.equals(String.valueOf(key))) + System.err.println("found expected key: " + key); + else + error("Expected key not found"); + checkFiles(outDir, Collections.emptySet()); + } else { + throw new Exception("task failed"); + } + } + + public static class TestDoclet { + static String lastCaller; + public static boolean start(RootDoc root) { + lastCaller = root.classNamed("pkg.C").commentText().trim(); + return true; + } + + public static int optionLength(String option) { + return 0; // default is option unknown + } + + public static boolean validOptions(String options[][], + DocErrorReporter reporter) { + return true; // default is options are valid + } + + public static LanguageVersion languageVersion() { + return LanguageVersion.JAVA_1_1; + } + } + + /** + * Verify that exceptions from a doclet are thrown as expected. + */ + @Test + public void testBadDoclet() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList(srcFile); + DocumentationTask t = tool.getTask(null, fm, null, BadDoclet.class, null, files); + try { + t.call(); + error("call completed without exception"); + } catch (RuntimeException e) { + Throwable c = e.getCause(); + if (c.getClass() == UnexpectedError.class) + System.err.println("exception caught as expected: " + c); + else + throw e; + } + } + + public static class UnexpectedError extends Error { } + + public static class BadDoclet { + public static boolean start(RootDoc root) { + throw new UnexpectedError(); + } + + public static int optionLength(String option) { + return 0; // default is option unknown + } + + public static boolean validOptions(String options[][], + DocErrorReporter reporter) { + return true; // default is options are valid + } + + public static LanguageVersion languageVersion() { + return LanguageVersion.JAVA_1_1; + } + } + +} + diff --git a/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java b/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java new file mode 100644 index 00000000000..4532e619f9b --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main GetTask_FileManagerTest + */ + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Set; + +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaFileObject; +import javax.tools.JavaFileObject.Kind; +import javax.tools.ToolProvider; + +import com.sun.tools.javac.nio.JavacPathFileManager; +import com.sun.tools.javac.nio.PathFileManager; +import com.sun.tools.javac.util.Context; + +/** + * Tests for DocumentationTool.getTask fileManager parameter. + */ +public class GetTask_FileManagerTest extends APITest { + public static void main(String... args) throws Exception { + new GetTask_FileManagerTest().run(); + } + + /** + * Verify that an alternate file manager can be specified: + * in this case, a PathFileManager. + */ + @Test + public void testFileManager() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + PathFileManager fm = new JavacPathFileManager(new Context(), false, null); + Path outDir = getOutDir().toPath(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList(srcFile); + DocumentationTask t = tool.getTask(null, fm, null, null, null, files); + if (t.call()) { + System.err.println("task succeeded"); + checkFiles(outDir, standardExpectFiles); + } else { + throw new Exception("task failed"); + } + } + + /** + * Verify that exceptions from a bad file manager are thrown as expected. + */ + @Test + public void testBadFileManager() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + PathFileManager fm = new JavacPathFileManager(new Context(), false, null) { + @Override + public Iterable list(Location location, + String packageName, + Set kinds, + boolean recurse) + throws IOException { + throw new UnexpectedError(); + } + }; + Path outDir = getOutDir().toPath(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList(srcFile); + DocumentationTask t = tool.getTask(null, fm, null, null, null, files); + try { + t.call(); + error("call completed without exception"); + } catch (RuntimeException e) { + Throwable c = e.getCause(); + if (c.getClass() == UnexpectedError.class) + System.err.println("exception caught as expected: " + c); + else + throw e; + } + } + + public static class UnexpectedError extends Error { } + +} diff --git a/langtools/test/tools/javadoc/api/basic/GetTask_FileObjectsTest.java b/langtools/test/tools/javadoc/api/basic/GetTask_FileObjectsTest.java new file mode 100644 index 00000000000..fc3cd1419b5 --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/GetTask_FileObjectsTest.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main GetTask_FileObjectsTest + */ + +import java.io.File; +import java.util.Arrays; +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +/** + * Tests for DocumentationTool.getTask fileObjects parameter. + */ +public class GetTask_FileObjectsTest extends APITest { + public static void main(String... args) throws Exception { + new GetTask_FileObjectsTest().run(); + } + + /** + * Verify that expected output files are written via the file manager, + * for a source file read from the file system with StandardJavaFileManager. + */ + @Test + public void testStandardFileObject() throws Exception { + File testSrc = new File(System.getProperty("test.src")); + File srcFile = new File(testSrc, "pkg/C.java"); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = fm.getJavaFileObjects(srcFile); + DocumentationTask t = tool.getTask(null, fm, null, null, null, files); + if (t.call()) { + System.err.println("task succeeded"); + checkFiles(outDir, standardExpectFiles); + } else { + throw new Exception("task failed"); + } + } + + /** + * Verify that expected output files are written via the file manager, + * for an in-memory file object. + */ + @Test + public void testMemoryFileObject() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList(srcFile); + DocumentationTask t = tool.getTask(null, fm, null, null, null, files); + if (t.call()) { + System.err.println("task succeeded"); + checkFiles(outDir, standardExpectFiles); + } else { + throw new Exception("task failed"); + } + } + + /** + * Verify bad file object is handled correctly. + */ + @Test + public void testBadFileObject() throws Exception { + File testSrc = new File(System.getProperty("test.src")); + File srcFile = new File(testSrc, "pkg/C.class"); // unacceptable file kind + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = fm.getJavaFileObjects(srcFile); + try { + DocumentationTask t = tool.getTask(null, fm, null, null, null, files); + error("getTask succeeded, no exception thrown"); + } catch (IllegalArgumentException e) { + System.err.println("exception caught as expected: " + e); + } + } + + /** + * Verify null is handled correctly. + */ + @Test + public void testNull() throws Exception { + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList((JavaFileObject) null); + try { + DocumentationTask t = tool.getTask(null, fm, null, null, null, files); + error("getTask succeeded, no exception thrown"); + } catch (NullPointerException e) { + System.err.println("exception caught as expected: " + e); + } + } + +} + diff --git a/langtools/test/tools/javadoc/api/basic/GetTask_OptionsTest.java b/langtools/test/tools/javadoc/api/basic/GetTask_OptionsTest.java new file mode 100644 index 00000000000..c6da9c8927d --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/GetTask_OptionsTest.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main GetTask_OptionsTest + */ + +import java.io.File; +import java.util.Arrays; +import java.util.Set; +import java.util.TreeSet; +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +/** + * Tests for DocumentationTool.getTask options parameter. + */ +public class GetTask_OptionsTest extends APITest { + public static void main(String... args) throws Exception { + new GetTask_OptionsTest().run(); + } + + /** + * Verify that expected output files are written for given options. + */ + @Test + public void testNoIndex() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList(srcFile); + Iterable options = Arrays.asList("-noindex"); + DocumentationTask t = tool.getTask(null, fm, null, null, options, files); + if (t.call()) { + System.err.println("task succeeded"); + Set expectFiles = new TreeSet(standardExpectFiles); + expectFiles.remove("index-all.html"); + checkFiles(outDir, expectFiles); + } else { + error("task failed"); + } + } + + /** + * Verify null is handled correctly. + */ + @Test + public void testNull() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable options = Arrays.asList((String) null); + Iterable files = Arrays.asList(srcFile); + try { + DocumentationTask t = tool.getTask(null, fm, null, null, options, files); + error("getTask succeeded, no exception thrown"); + } catch (NullPointerException e) { + System.err.println("exception caught as expected: " + e); + } + } + +} + diff --git a/langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java b/langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java new file mode 100644 index 00000000000..1ba40228689 --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main GetTask_WriterTest + */ + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Arrays; +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +/** + * Tests for DocumentationTool.getTask writer parameter. + */ +public class GetTask_WriterTest extends APITest { + public static void main(String... args) throws Exception { + new GetTask_WriterTest().run(); + } + + /** + * Verify that a writer can be provided. + */ + @Test + public void testWriter() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList(srcFile); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + DocumentationTask t = tool.getTask(pw, fm, null, null, null, files); + if (t.call()) { + System.err.println("task succeeded"); + checkFiles(outDir, standardExpectFiles); + String out = sw.toString(); + System.err.println(">>" + out + "<<"); + for (String f: standardExpectFiles) { + if (f.endsWith(".html") && !out.contains(f)) + throw new Exception("expected string not found: " + f); + } + } else { + throw new Exception("task failed"); + } + } +} + diff --git a/langtools/test/tools/javadoc/api/basic/IsSupportedOptionTest.java b/langtools/test/tools/javadoc/api/basic/IsSupportedOptionTest.java new file mode 100644 index 00000000000..f10c957e393 --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/IsSupportedOptionTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main IsSupportedOptionTest + */ + +import javax.tools.DocumentationTool; +import javax.tools.ToolProvider; + +/** + * Tests for DocumentationTool.usSupportedOption method. + */ +public class IsSupportedOptionTest extends APITest { + public static void main(String... args) throws Exception { + new IsSupportedOptionTest().run(); + } + + /** + * Verify that isSupportedOption method can be invoked. + */ + @Test + public void test() throws Exception { + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + check(tool, "-sourcepath", 1); + check(tool, "-verbose", 0); + check(tool, "-ZZZ", -1); + + try { + check(tool, null, -1); + error("null was accepted without exception"); + } catch (NullPointerException e) { + } + } + + private void check(DocumentationTool tool, String option, int numArgs) { + System.err.println("check " + option); + int n = tool.isSupportedOption(option); + if (n != numArgs) + error("unexpected result for option: " + option + ": " + n); + } +} + diff --git a/langtools/test/tools/javadoc/api/basic/JavadocTaskImplTest.java b/langtools/test/tools/javadoc/api/basic/JavadocTaskImplTest.java new file mode 100644 index 00000000000..9a372cdea80 --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/JavadocTaskImplTest.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main JavadocTaskImplTest + */ + +import java.io.File; +import java.util.Arrays; +import java.util.concurrent.Callable; + +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javadoc.Messager; +import com.sun.tools.javadoc.api.JavadocTaskImpl; + +/** + * Misc tests for JavacTaskImpl. + */ +public class JavadocTaskImplTest extends APITest { + public static void main(String... args) throws Exception { + new JavadocTaskImplTest().run(); + } + + @Test + public void testRawCall() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList(srcFile); + + @SuppressWarnings("rawtypes") + Callable t = tool.getTask(null, fm, null, null, null, files); + + if (t.call() == Boolean.TRUE) { + System.err.println("task succeeded"); + } else { + throw new Exception("task failed"); + } + } + + @Test + public void testDirectAccess1() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject(); + Iterable files = Arrays.asList(srcFile); + Context c = new Context(); + Messager.preRegister(c, "javadoc"); + StandardJavaFileManager fm = new JavacFileManager(c, true, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + DocumentationTask t = new JavadocTaskImpl(c, null, null, files); + if (t.call()) { + System.err.println("task succeeded"); + } else { + throw new Exception("task failed"); + } + } + + @Test + public void testDirectAccess2() throws Exception { + JavaFileObject srcFile = null; // error, provokes NPE + Iterable files = Arrays.asList(srcFile); + Context c = new Context(); + Messager.preRegister(c, "javadoc"); + StandardJavaFileManager fm = new JavacFileManager(c, true, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + try { + DocumentationTask t = new JavadocTaskImpl(c, null, null, files);; + error("getTask succeeded, no exception thrown"); + } catch (NullPointerException e) { + System.err.println("exception caught as expected: " + e); + } + } +} + diff --git a/langtools/test/tools/javadoc/api/basic/RunTest.java b/langtools/test/tools/javadoc/api/basic/RunTest.java new file mode 100644 index 00000000000..aa006e0a7d7 --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/RunTest.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main RunTest + */ + +import java.io.ByteArrayOutputStream; +import java.io.File; +import javax.tools.DocumentationTool; +import javax.tools.ToolProvider; + +/** + * Tests for DocumentationTool.run method. + */ +public class RunTest extends APITest { + public static void main(String... args) throws Exception { + new RunTest().run(); + } + + /** + * Verify that run method can be invoked. + */ + @Test + public void testRun() throws Exception { + File testSrc = new File(System.getProperty("test.src")); + File srcFile = new File(testSrc, "pkg/C.java"); + File outDir = getOutDir(); + String[] args = { "-d", outDir.getPath(), srcFile.getPath() }; + + ByteArrayOutputStream stdout = new ByteArrayOutputStream(); + ByteArrayOutputStream stderr = new ByteArrayOutputStream(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + int rc = tool.run(null, stdout, stderr, args); + System.err.println("stdout >>" + stdout.toString() + "<<"); + System.err.println("stderr >>" + stderr.toString() + "<<"); + + if (rc == 0) { + System.err.println("call succeeded"); + checkFiles(outDir, standardExpectFiles); + String out = stdout.toString(); + for (String f: standardExpectFiles) { + if (f.endsWith(".html") && !out.contains(f)) + error("expected string not found: " + f); + } + } else { + error("call failed"); + } + } + + /** + * Verify that run method can be invoked. + */ + @Test + public void testRun2() throws Exception { + File outDir = getOutDir(); + String badfile = "badfile.java"; + String[] args = { "-d", outDir.getPath(), badfile }; + + ByteArrayOutputStream stdout = new ByteArrayOutputStream(); + ByteArrayOutputStream stderr = new ByteArrayOutputStream(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + int rc = tool.run(null, stdout, stderr, args); + System.err.println("stdout >>" + stdout.toString() + "<<"); + System.err.println("stderr >>" + stderr.toString() + "<<"); + + if (rc == 0) { + error("call succeeded unexpectedly"); + } else { + String err = stderr.toString(); + if (err.contains(badfile)) + System.err.println("call failed as expected"); + else + error("expected diagnostic not found"); + } + } + +} + diff --git a/langtools/test/tools/javadoc/api/basic/TagletPathTest.java b/langtools/test/tools/javadoc/api/basic/TagletPathTest.java new file mode 100644 index 00000000000..52dd5c81b7e --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/TagletPathTest.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main TagletPathTest + */ + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.List; +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +/** + * Tests for locating a doclet via the file manager's DOCLET_PATH. + */ +public class TagletPathTest extends APITest { + public static void main(String... args) throws Exception { + new TagletPathTest().run(); + } + + /** + * Verify that a taglet can be specified, and located via + * the file manager's TAGLET_PATH. + */ + @Test + public void testTagletPath() throws Exception { + File testSrc = new File(System.getProperty("test.src")); + File tagletSrcFile = new File(testSrc, "taglets/UnderlineTaglet.java"); + File tagletDir = getOutDir("classes"); + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager cfm = compiler.getStandardFileManager(null, null, null); + cfm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tagletDir)); + Iterable cfiles = cfm.getJavaFileObjects(tagletSrcFile); + if (!compiler.getTask(null, cfm, null, null, null, cfiles).call()) + throw new Exception("cannot compile taglet"); + + JavaFileObject srcFile = createSimpleJavaFileObject("pkg/C", testSrcText); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir("api"); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + fm.setLocation(DocumentationTool.Location.TAGLET_PATH, Arrays.asList(tagletDir)); + Iterable files = Arrays.asList(srcFile); + Iterable options = Arrays.asList("-taglet", "UnderlineTaglet"); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + DocumentationTask t = tool.getTask(pw, fm, null, null, options, files); + boolean ok = t.call(); + String out = sw.toString(); + System.err.println(">>" + out + "<<"); + if (ok) { + File f = new File(outDir, "pkg/C.html"); + List doc = Files.readAllLines(f.toPath(), Charset.defaultCharset()); + for (String line: doc) { + if (line.contains("" + TEST_STRING + "")) { + System.err.println("taglet executed as expected"); + return; + } + } + error("expected text not found in output " + f); + } else { + error("task failed"); + } + } + + static final String TEST_STRING = "xyzzy"; + static final String testSrcText = + "package pkg;\n" + + "/** {@underline " + TEST_STRING + "} */\n" + + "public class C { }"; +} + diff --git a/langtools/test/tools/javadoc/api/basic/Task_reuseTest.java b/langtools/test/tools/javadoc/api/basic/Task_reuseTest.java new file mode 100644 index 00000000000..5bda0d34d74 --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/Task_reuseTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6493690 + * @summary javadoc should have a javax.tools.Tool service provider + * @build APITest + * @run main Task_reuseTest + */ + +import java.io.File; +import java.util.Arrays; +import java.util.Locale; +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +/** + * Tests for reusing a documentation task. + */ +public class Task_reuseTest extends APITest { + public static void main(String... args) throws Exception { + new Task_reuseTest().run(); + } + + /** + * Verify that call can only be called once. + */ + @Test + public void testReuse() throws Exception { + DocumentationTask t = getAndRunTask(); + try { + t.call(); + error("task was reused without exception"); + } catch (IllegalStateException e) { + System.err.println("caught exception " + e); + } + } + + /** + * Verify that cannot update task after call + */ + @Test + public void testUpdateSetLocale() throws Exception { + DocumentationTask t = getAndRunTask(); + try { + t.setLocale(Locale.getDefault()); + error("task was reused without exception"); + } catch (IllegalStateException e) { + System.err.println("caught exception " + e); + } + } + + private DocumentationTask getAndRunTask() throws Exception { + JavaFileObject srcFile = createSimpleJavaFileObject(); + DocumentationTool tool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + File outDir = getOutDir(); + fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir)); + Iterable files = Arrays.asList(srcFile); + DocumentationTask t = tool.getTask(null, fm, null, null, null, files); + if (t.call()) { + System.err.println("task succeeded"); + return t; + } else { + throw new Exception("task failed"); + } + } +} + diff --git a/langtools/test/tools/javadoc/api/basic/pkg/C.java b/langtools/test/tools/javadoc/api/basic/pkg/C.java new file mode 100644 index 00000000000..74383c04f08 --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/pkg/C.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +public class C { } + diff --git a/langtools/test/tools/javadoc/api/basic/taglets/UnderlineTaglet.java b/langtools/test/tools/javadoc/api/basic/taglets/UnderlineTaglet.java new file mode 100644 index 00000000000..426b0db853e --- /dev/null +++ b/langtools/test/tools/javadoc/api/basic/taglets/UnderlineTaglet.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * -Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * -Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Oracle nor the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any + * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY + * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY + * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR + * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR + * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE + * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, + * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER + * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF + * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that Software is not designed, licensed or + * intended for use in the design, construction, operation or + * maintenance of any nuclear facility. + */ + +import com.sun.tools.doclets.Taglet; +import com.sun.javadoc.*; +import java.util.Map; + +/** + * A sample Inline Taglet representing {@underline ...}. This tag can + * be used in any kind of {@link com.sun.javadoc.Doc}. + * The text is underlined. For example, + * "@underline UNDERLINE ME" would be shown as: UNDERLINE ME. + * + * @author Jamie Ho + * @since 1.4 + */ + +public class UnderlineTaglet implements Taglet { + + private static final String NAME = "underline"; + + /** + * Return the name of this custom tag. + */ + public String getName() { + return NAME; + } + + /** + * @return true since this tag can be used in a field + * doc comment + */ + public boolean inField() { + return true; + } + + /** + * @return true since this tag can be used in a constructor + * doc comment + */ + public boolean inConstructor() { + return true; + } + + /** + * @return true since this tag can be used in a method + * doc comment + */ + public boolean inMethod() { + return true; + } + + /** + * @return true since this tag can be used in an overview + * doc comment + */ + public boolean inOverview() { + return true; + } + + /** + * @return true since this tag can be used in a package + * doc comment + */ + public boolean inPackage() { + return true; + } + + /** + * @return true since this + */ + public boolean inType() { + return true; + } + + /** + * Will return true since this is an inline tag. + * @return true since this is an inline tag. + */ + + public boolean isInlineTag() { + return true; + } + + /** + * Register this Taglet. + * @param tagletMap the map to register this tag to. + */ + public static void register(Map tagletMap) { + UnderlineTaglet tag = new UnderlineTaglet(); + Taglet t = (Taglet) tagletMap.get(tag.getName()); + if (t != null) { + tagletMap.remove(tag.getName()); + } + tagletMap.put(tag.getName(), tag); + } + + /** + * Given the Tag representation of this custom + * tag, return its string representation. + * @param tag he Tag representation of this custom tag. + */ + public String toString(Tag tag) { + return "" + tag.text() + ""; + } + + /** + * This method should not be called since arrays of inline tags do not + * exist. Method {@link #tostring(Tag)} should be used to convert this + * inline tag to a string. + * @param tags the array of Tags representing of this custom tag. + */ + public String toString(Tag[] tags) { + return null; + } +} + From 03311b147c6eecf8f4ed6c9f25d6e1ee373aeae1 Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Fri, 16 Nov 2012 09:36:41 -0800 Subject: [PATCH 36/94] Added tag hs25-b10 for changeset 6d791db85d73 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 60e39ef0b85..8e61891d92e 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -294,3 +294,4 @@ acabb5c282f59be7e3238920b2ea06b684ab68f7 jdk8-b63 5920f72e799c8133d1066c4a62fa1fafcb729966 jdk8-b64 b4ee7b773144a88af8b6b92e4384dea82cb948d8 hs25-b09 0f7290a03b24bd562583fa325d3566c21c51fb94 jdk8-b65 +cfc5309f03b7bd6c1567618b63cf1fc74c0f2a8f hs25-b10 From c39f1d99b4cf593ee466c5baedad0c626c65a11f Mon Sep 17 00:00:00 2001 From: Jim Holmlund Date: Fri, 16 Nov 2012 18:27:36 +0000 Subject: [PATCH 37/94] 8003357: Add support for jtreg -concurrency to langtools/test/Makefile Reviewed-by: jjg --- langtools/test/Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/langtools/test/Makefile b/langtools/test/Makefile index c77f5647090..9db478dc8da 100644 --- a/langtools/test/Makefile +++ b/langtools/test/Makefile @@ -146,10 +146,15 @@ ifdef TESTBOOTCLASSPATH endif # Concurrency is the number of tests that can execute at once. -# Supported for JCK, not supported for jtreg. # On an otherwise empty machine, suggest setting to (#cpus + 2) # If unset, the default is (#cpus) ### RFE: determine and use #cpus +ifdef CONCURRENCY + JTREG_OPTIONS += -agentvm -concurrency:$(CONCURRENCY) +else + JTREG_OPTIONS += -samevm +endif + ifdef JCK_CONCURRENCY JCK_OPTIONS += -concurrency:$(JCK_CONCURRENCY) endif @@ -266,7 +271,7 @@ jtreg-tests: check-jtreg FRC @mkdir -p $(JTREG_OUTPUT_DIR) JT_JAVA=$(JT_JAVA) $(JTREG) \ -J-Xmx512m \ - -a -samevm -ignore:quiet -v:fail,error,nopass \ + -a -ignore:quiet -v:fail,error,nopass \ -r:$(JTREG_OUTPUT_DIR)/JTreport \ -w:$(JTREG_OUTPUT_DIR)/JTwork \ -jdk:$(TESTJAVA) \ From a494f0ab863143876c7d0ca1bda116f57c5ef04c Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Sat, 17 Nov 2012 19:01:03 +0000 Subject: [PATCH 38/94] 8003280: Add lambda tests Turn on lambda expression, method reference and default method support Reviewed-by: jjg --- .../com/sun/tools/javac/code/Flags.java | 3 +- .../com/sun/tools/javac/code/Symbol.java | 8 +- .../com/sun/tools/javac/code/Types.java | 63 ++-- .../com/sun/tools/javac/comp/Attr.java | 192 ++++++---- .../com/sun/tools/javac/comp/Check.java | 130 ++----- .../sun/tools/javac/comp/DeferredAttr.java | 56 ++- .../com/sun/tools/javac/comp/Flow.java | 4 +- .../com/sun/tools/javac/comp/Infer.java | 6 +- .../com/sun/tools/javac/comp/Lower.java | 6 +- .../com/sun/tools/javac/comp/Resolve.java | 126 +++++-- .../com/sun/tools/javac/comp/TransTypes.java | 2 +- .../com/sun/tools/javac/jvm/ClassReader.java | 23 +- .../classes/com/sun/tools/javac/jvm/Pool.java | 47 ++- .../sun/tools/javac/parser/JavacParser.java | 9 +- .../tools/javac/resources/compiler.properties | 25 +- .../com/sun/tools/javac/tree/Pretty.java | 2 +- .../javac/util/RichDiagnosticFormatter.java | 3 +- .../com/sun/tools/javac/util/Warner.java | 1 - .../tools/javac/conditional/Conditional.java | 4 +- .../ClassReaderTest/ClassReaderTest.java | 2 +- .../tools/javac/defaultMethods/Neg01.java | 2 +- .../tools/javac/defaultMethods/Neg02.java | 2 +- .../tools/javac/defaultMethods/Neg03.java | 2 +- .../tools/javac/defaultMethods/Neg04.java | 2 +- .../tools/javac/defaultMethods/Neg05.java | 2 +- .../tools/javac/defaultMethods/Neg06.java | 2 +- .../tools/javac/defaultMethods/Neg07.java | 2 +- .../tools/javac/defaultMethods/Neg08.java | 2 +- .../tools/javac/defaultMethods/Neg09.java | 2 +- .../tools/javac/defaultMethods/Neg10.java | 2 +- .../tools/javac/defaultMethods/Neg11.java | 2 +- .../tools/javac/defaultMethods/Neg12.java | 2 +- .../test/tools/javac/defaultMethods/Neg12.out | 2 +- .../tools/javac/defaultMethods/Neg13.java | 2 +- .../tools/javac/defaultMethods/Neg14.java | 2 +- .../tools/javac/defaultMethods/Neg15.java | 2 +- .../tools/javac/defaultMethods/Neg16.java | 2 +- .../tools/javac/defaultMethods/Pos01.java | 4 +- .../tools/javac/defaultMethods/Pos02.java | 2 +- .../tools/javac/defaultMethods/Pos04.java | 2 +- .../tools/javac/defaultMethods/Pos05.java | 2 +- .../tools/javac/defaultMethods/Pos06.java | 2 +- .../tools/javac/defaultMethods/Pos07.java | 2 +- .../tools/javac/defaultMethods/Pos08.java | 2 +- .../tools/javac/defaultMethods/Pos10.java | 2 +- .../tools/javac/defaultMethods/Pos11.java | 2 +- .../tools/javac/defaultMethods/Pos12.java | 2 +- .../tools/javac/defaultMethods/Pos13.java | 2 +- .../tools/javac/defaultMethods/Pos14.java | 2 +- .../tools/javac/defaultMethods/Pos15.java | 2 +- .../tools/javac/defaultMethods/Pos16.java | 2 +- .../javac/defaultMethods/TestDefaultBody.java | 3 - .../TestNoBridgeOnDefaults.java | 2 - .../tools/javac/defaultMethods/fd/FDTest.java | 2 +- .../defaultMethods/separate/Separate.java | 4 +- .../super/TestDefaultSuperCall.java | 2 +- .../syntax/TestDefaultMethodsSyntax.java | 2 +- .../examples/CantAccessInnerClsConstr.java | 1 - .../examples/CantApplySymbolFragment.java | 1 - .../examples/CantApplySymbolsFragment.java | 1 - .../CantRefNonEffectivelyFinalVar.java | 1 - .../CantResolveLocationArgsFragment.java | 1 - ...CantResolveLocationArgsParamsFragment.java | 1 - .../examples/ConditionalTargetCantBeVoid.java | 37 ++ .../javac/diags/examples/CyclicInference.java | 1 - .../DefaultOverridesObjectMember.java | 1 - .../diags/examples/IncompatibleAbstracts.java | 1 - .../IncompatibleArgTypesInLambda.java | 1 - .../IncompatibleDescsInFunctionalIntf.java | 1 - .../examples/IncompatibleRetTypeInLambda.java | 1 - .../examples/IncompatibleRetTypeInMref.java | 1 - .../IncompatibleThrownTypesInLambda.java | 1 - .../IncompatibleThrownTypesInMref.java | 1 - .../IncompatibleTypesInConditional.java | 1 - ...validGenericDescInFunctionalInterface.java | 1 - .../diags/examples/LocalVarNeedsFinal.java | 1 + .../diags/examples/MissingReturnValue.java | 5 +- .../examples/MissingReturnValueFragment.java | 1 - .../javac/diags/examples/NoAbstracts.java | 1 - .../NoSuitableFunctionalIntfInst.java | 1 - .../examples/NonStaticCantBeRefFragment.java | 1 - .../diags/examples/NotAFunctionalIntf.java | 1 - ...tDefAccessClassIntfCantAccessFragment.java | 1 - .../diags/examples/OverriddenDefault.java | 3 +- .../diags/examples/PotentialLambdaFound.java | 2 +- .../diags/examples/RedundantSupertype.java | 1 - .../diags/examples/RefAmbiguousFragment.java | 1 - .../TypesIncompatibleAbstractDefault.java | 1 - .../TypesIncompatibleUnrelatedDefaults.java | 1 - .../diags/examples/UnexpectedLambda.java | 1 - .../javac/diags/examples/UnexpectedMref.java | 1 - ...orVoid.java => UnexpectedReturnValue.java} | 7 +- .../javac/generics/7022054/T7022054pos1.java | 2 +- .../javac/generics/7022054/T7022054pos1.out | 2 + .../javac/generics/7022054/T7022054pos2.java | 2 +- .../javac/generics/7022054/T7022054pos2.out | 2 + .../test/tools/javac/lambda/BadAccess.java | 30 ++ .../test/tools/javac/lambda/BadAccess.out | 2 + .../test/tools/javac/lambda/BadAccess02.java | 31 ++ .../test/tools/javac/lambda/BadAccess02.out | 3 + .../test/tools/javac/lambda/BadAccess03.java | 15 + .../test/tools/javac/lambda/BadAccess03.out | 2 + .../tools/javac/lambda/BadBreakContinue.java | 44 +++ .../tools/javac/lambda/BadBreakContinue.out | 13 + .../test/tools/javac/lambda/BadConv03.java | 20 ++ .../test/tools/javac/lambda/BadConv03.out | 2 + .../test/tools/javac/lambda/BadConv04.java | 22 ++ .../test/tools/javac/lambda/BadConv04.out | 3 + .../javac/lambda/BadExpressionLambda.java | 21 ++ .../javac/lambda/BadExpressionLambda.out | 2 + .../tools/javac/lambda/BadLambdaExpr.java | 191 ++++++++++ .../test/tools/javac/lambda/BadLambdaPos.java | 31 ++ .../test/tools/javac/lambda/BadLambdaPos.out | 9 + .../tools/javac/lambda/BadMethodCall.java | 16 + .../test/tools/javac/lambda/BadMethodCall.out | 2 + .../test/tools/javac/lambda/BadRecovery.java | 19 + .../test/tools/javac/lambda/BadRecovery.out | 3 + .../test/tools/javac/lambda/BadReturn.java | 38 ++ .../test/tools/javac/lambda/BadReturn.out | 3 + .../javac/lambda/BadStatementInLambda.java | 19 + .../javac/lambda/BadStatementInLambda.out | 4 + .../javac/lambda/BadStatementInLambda02.java | 19 + .../javac/lambda/BadStatementInLambda02.out | 2 + .../tools/javac/lambda/BadTargetType.java | 23 ++ .../test/tools/javac/lambda/BadTargetType.out | 5 + .../tools/javac/lambda/Conditional01.java | 45 +++ .../tools/javac/lambda/Conditional02.java | 42 +++ .../tools/javac/lambda/Conditional03.java | 43 +++ .../tools/javac/lambda/Conformance01.java | 36 ++ .../test/tools/javac/lambda/Defender01.java | 45 +++ .../javac/lambda/DisjunctiveTypeTest.java | 52 +++ .../javac/lambda/EffectivelyFinal01.java | 18 + .../tools/javac/lambda/EffectivelyFinal01.out | 2 + .../javac/lambda/EffectivelyFinalTest.java | 33 +- .../javac/lambda/EffectivelyFinalTest01.out | 10 +- .../javac/lambda/EffectivelyFinalTest02.out | 26 +- .../test/tools/javac/lambda/ErroneousArg.java | 36 ++ .../test/tools/javac/lambda/ErroneousArg.out | 7 + .../javac/lambda/ErroneousLambdaExpr.java | 65 ++++ .../tools/javac/lambda/InnerConstructor.java | 18 +- .../tools/javac/lambda/LambdaCapture01.java | 107 ++++++ .../tools/javac/lambda/LambdaCapture02.java | 107 ++++++ .../tools/javac/lambda/LambdaCapture03.java | 99 +++++ .../tools/javac/lambda/LambdaCapture04.java | 143 ++++++++ .../tools/javac/lambda/LambdaCapture05.java | 81 +++++ .../tools/javac/lambda/LambdaCapture06.java | 57 +++ .../test/tools/javac/lambda/LambdaConv01.java | 145 ++++++++ .../test/tools/javac/lambda/LambdaConv03.java | 121 +++++++ .../test/tools/javac/lambda/LambdaConv05.java | 62 ++++ .../test/tools/javac/lambda/LambdaConv06.java | 52 +++ .../test/tools/javac/lambda/LambdaConv08.java | 57 +++ .../test/tools/javac/lambda/LambdaConv09.java | 50 +++ .../test/tools/javac/lambda/LambdaConv09.out | 5 + .../test/tools/javac/lambda/LambdaConv10.java | 17 + .../test/tools/javac/lambda/LambdaConv10.out | 2 + .../test/tools/javac/lambda/LambdaConv11.java | 42 +++ .../test/tools/javac/lambda/LambdaConv12.java | 45 +++ .../test/tools/javac/lambda/LambdaConv13.java | 48 +++ .../test/tools/javac/lambda/LambdaConv16.java | 63 ++++ .../test/tools/javac/lambda/LambdaConv17.java | 38 ++ .../test/tools/javac/lambda/LambdaConv18.java | 24 ++ .../test/tools/javac/lambda/LambdaConv18.out | 4 + .../test/tools/javac/lambda/LambdaConv19.java | 39 ++ .../test/tools/javac/lambda/LambdaConv20.java | 56 +++ .../test/tools/javac/lambda/LambdaConv21.java | 38 ++ .../test/tools/javac/lambda/LambdaConv21.out | 6 + .../test/tools/javac/lambda/LambdaConv22.java | 42 +++ .../test/tools/javac/lambda/LambdaConv23.java | 62 ++++ .../test/tools/javac/lambda/LambdaConv24.java | 64 ++++ .../javac/lambda/LambdaConversionTest.java | 246 +++++++++++++ .../lambda/LambdaEffectivelyFinalTest.java | 60 ++++ .../lambda/LambdaEffectivelyFinalTest.out | 6 + .../test/tools/javac/lambda/LambdaExpr01.java | 133 +++++++ .../test/tools/javac/lambda/LambdaExpr02.java | 133 +++++++ .../test/tools/javac/lambda/LambdaExpr04.java | 46 +++ .../test/tools/javac/lambda/LambdaExpr05.java | 39 ++ .../test/tools/javac/lambda/LambdaExpr06.java | 51 +++ .../test/tools/javac/lambda/LambdaExpr07.java | 57 +++ .../test/tools/javac/lambda/LambdaExpr08.java | 43 +++ .../test/tools/javac/lambda/LambdaExpr09.java | 54 +++ .../test/tools/javac/lambda/LambdaExpr10.java | 37 ++ .../test/tools/javac/lambda/LambdaExpr10.out | 9 + .../test/tools/javac/lambda/LambdaExpr11.java | 89 +++++ .../test/tools/javac/lambda/LambdaExpr12.java | 66 ++++ .../test/tools/javac/lambda/LambdaExpr13.java | 47 +++ .../test/tools/javac/lambda/LambdaExpr14.java | 43 +++ .../test/tools/javac/lambda/LambdaExpr15.java | 67 ++++ .../test/tools/javac/lambda/LambdaExpr16.java | 76 ++++ .../test/tools/javac/lambda/LambdaExpr17.java | 63 ++++ .../test/tools/javac/lambda/LambdaExpr18.java | 62 ++++ .../test/tools/javac/lambda/LambdaExpr19.java | 53 +++ .../test/tools/javac/lambda/LambdaExpr19.out | 6 + .../test/tools/javac/lambda/LambdaExpr20.java | 45 +++ .../tools/javac/lambda/LambdaExprNotVoid.java | 16 + .../tools/javac/lambda/LambdaExprNotVoid.out | 3 + .../tools/javac/lambda/LambdaParserTest.java | 6 +- .../tools/javac/lambda/LambdaScope01.java | 79 ++++ .../tools/javac/lambda/LambdaScope02.java | 63 ++++ .../tools/javac/lambda/LambdaScope03.java | 64 ++++ .../tools/javac/lambda/LambdaScope04.java | 163 +++++++++ .../test/tools/javac/lambda/LambdaScope04.out | 37 ++ .../javac/lambda/LocalBreakAndContinue.java | 42 +++ .../tools/javac/lambda/MethodReference01.java | 92 +++++ .../tools/javac/lambda/MethodReference02.java | 42 +++ .../tools/javac/lambda/MethodReference03.java | 55 +++ .../tools/javac/lambda/MethodReference04.java | 14 + .../tools/javac/lambda/MethodReference04.out | 2 + .../tools/javac/lambda/MethodReference05.java | 54 +++ .../tools/javac/lambda/MethodReference06.java | 62 ++++ .../tools/javac/lambda/MethodReference07.java | 45 +++ .../tools/javac/lambda/MethodReference08.java | 24 ++ .../tools/javac/lambda/MethodReference08.out | 5 + .../tools/javac/lambda/MethodReference09.java | 25 ++ .../tools/javac/lambda/MethodReference09.out | 4 + .../tools/javac/lambda/MethodReference10.java | 53 +++ .../tools/javac/lambda/MethodReference11.java | 46 +++ .../tools/javac/lambda/MethodReference12.java | 77 ++++ .../tools/javac/lambda/MethodReference13.java | 51 +++ .../tools/javac/lambda/MethodReference14.java | 54 +++ .../tools/javac/lambda/MethodReference15.java | 44 +++ .../tools/javac/lambda/MethodReference16.java | 61 ++++ .../tools/javac/lambda/MethodReference17.java | 61 ++++ .../tools/javac/lambda/MethodReference18.java | 65 ++++ .../tools/javac/lambda/MethodReference19.java | 61 ++++ .../tools/javac/lambda/MethodReference20.java | 24 ++ .../tools/javac/lambda/MethodReference20.out | 3 + .../tools/javac/lambda/MethodReference21.java | 23 ++ .../tools/javac/lambda/MethodReference21.out | 3 + .../tools/javac/lambda/MethodReference22.java | 67 ++++ .../tools/javac/lambda/MethodReference22.out | 11 + .../tools/javac/lambda/MethodReference23.java | 74 ++++ .../tools/javac/lambda/MethodReference23.out | 6 + .../tools/javac/lambda/MethodReference24.java | 57 +++ .../tools/javac/lambda/MethodReference25.java | 59 +++ .../tools/javac/lambda/MethodReference26.java | 23 ++ .../tools/javac/lambda/MethodReference26.out | 2 + .../tools/javac/lambda/MethodReference27.java | 62 ++++ .../tools/javac/lambda/MethodReference28.java | 56 +++ .../tools/javac/lambda/MethodReference28.out | 14 + .../tools/javac/lambda/MethodReference29.java | 53 +++ .../tools/javac/lambda/MethodReference30.java | 55 +++ .../tools/javac/lambda/MethodReference31.java | 217 +++++++++++ .../tools/javac/lambda/MethodReference32.java | 22 ++ .../tools/javac/lambda/MethodReference32.out | 7 + .../tools/javac/lambda/MethodReference33.java | 66 ++++ .../tools/javac/lambda/MethodReference34.java | 65 ++++ .../tools/javac/lambda/MethodReference35.java | 64 ++++ .../tools/javac/lambda/MethodReference36.java | 91 +++++ .../tools/javac/lambda/MethodReference37.java | 40 +++ .../tools/javac/lambda/MethodReference37.out | 5 + .../tools/javac/lambda/MethodReference38.java | 29 ++ .../tools/javac/lambda/MethodReference38.out | 5 + .../tools/javac/lambda/MethodReference39.java | 25 ++ .../tools/javac/lambda/MethodReference39.out | 2 + .../tools/javac/lambda/MethodReference40.java | 24 ++ .../tools/javac/lambda/MethodReference40.out | 2 + .../tools/javac/lambda/MethodReference41.java | 66 ++++ .../tools/javac/lambda/MethodReference42.java | 65 ++++ .../tools/javac/lambda/MethodReference43.java | 71 ++++ .../tools/javac/lambda/MethodReference44.java | 67 ++++ .../tools/javac/lambda/MethodReference45.java | 40 +++ .../tools/javac/lambda/MethodReference45.out | 2 + .../tools/javac/lambda/MethodReference46.java | 67 ++++ .../tools/javac/lambda/MethodReference47.java | 40 +++ .../tools/javac/lambda/MethodReference47.out | 2 + .../tools/javac/lambda/MethodReference48.java | 65 ++++ .../tools/javac/lambda/MethodReference49.java | 50 +++ .../tools/javac/lambda/MethodReference50.java | 25 ++ .../tools/javac/lambda/MethodReference50.out | 2 + .../tools/javac/lambda/MethodReference51.java | 46 +++ .../tools/javac/lambda/MethodReference51.out | 7 + .../tools/javac/lambda/MethodReference52.java | 39 ++ .../tools/javac/lambda/MethodReference52.out | 3 + .../tools/javac/lambda/MethodReference53.java | 24 ++ .../tools/javac/lambda/MethodReference53.out | 2 + .../tools/javac/lambda/MethodReference54.java | 19 + .../tools/javac/lambda/MethodReference54.out | 2 + .../lambda/MethodReferenceParserTest.java | 6 +- .../tools/javac/lambda/MostSpecific01.java | 25 ++ .../tools/javac/lambda/MostSpecific01.out | 2 + .../tools/javac/lambda/MostSpecific02.java | 25 ++ .../tools/javac/lambda/MostSpecific02.out | 2 + .../tools/javac/lambda/MostSpecific03.java | 63 ++++ .../tools/javac/lambda/MostSpecific03.out | 13 + .../tools/javac/lambda/MostSpecific04.java | 58 +++ .../tools/javac/lambda/MostSpecific05.java | 58 +++ .../tools/javac/lambda/MostSpecific06.java | 30 ++ .../tools/javac/lambda/MostSpecific06.out | 4 + .../tools/javac/lambda/MostSpecific07.java | 31 ++ .../tools/javac/lambda/MostSpecific07.out | 4 + .../test/tools/javac/lambda/NakedThis.java | 42 +++ .../tools/javac/lambda/SourceLevelTest.java | 23 ++ .../tools/javac/lambda/SourceLevelTest.out | 6 + .../test/tools/javac/lambda/TargetType01.java | 49 +++ .../test/tools/javac/lambda/TargetType02.java | 62 ++++ .../test/tools/javac/lambda/TargetType03.java | 68 ++++ .../test/tools/javac/lambda/TargetType04.java | 18 + .../test/tools/javac/lambda/TargetType04.out | 3 + .../test/tools/javac/lambda/TargetType05.java | 53 +++ .../test/tools/javac/lambda/TargetType06.java | 27 ++ .../test/tools/javac/lambda/TargetType06.out | 2 + .../test/tools/javac/lambda/TargetType07.java | 45 +++ .../test/tools/javac/lambda/TargetType08.java | 45 +++ .../test/tools/javac/lambda/TargetType10.java | 19 + .../test/tools/javac/lambda/TargetType10.out | 2 + .../test/tools/javac/lambda/TargetType11.java | 22 ++ .../test/tools/javac/lambda/TargetType11.out | 4 + .../test/tools/javac/lambda/TargetType12.java | 45 +++ .../test/tools/javac/lambda/TargetType13.java | 21 ++ .../test/tools/javac/lambda/TargetType13.out | 2 + .../test/tools/javac/lambda/TargetType14.java | 25 ++ .../test/tools/javac/lambda/TargetType14.out | 2 + .../test/tools/javac/lambda/TargetType15.java | 52 +++ .../test/tools/javac/lambda/TargetType16.java | 25 ++ .../test/tools/javac/lambda/TargetType16.out | 2 + .../test/tools/javac/lambda/TargetType17.java | 22 ++ .../test/tools/javac/lambda/TargetType17.out | 9 + .../test/tools/javac/lambda/TargetType18.java | 42 +++ .../test/tools/javac/lambda/TargetType19.java | 43 +++ .../test/tools/javac/lambda/TargetType19.out | 2 + .../test/tools/javac/lambda/TargetType20.java | 21 ++ .../test/tools/javac/lambda/TargetType20.out | 2 + .../test/tools/javac/lambda/TargetType21.java | 33 ++ .../test/tools/javac/lambda/TargetType21.out | 3 + .../test/tools/javac/lambda/TargetType22.java | 44 +++ .../test/tools/javac/lambda/TargetType22.out | 4 + .../test/tools/javac/lambda/TargetType23.java | 37 ++ .../test/tools/javac/lambda/TargetType23.out | 2 + .../test/tools/javac/lambda/TargetType24.java | 39 ++ .../test/tools/javac/lambda/TargetType24.out | 5 + .../test/tools/javac/lambda/TargetType25.java | 65 ++++ .../test/tools/javac/lambda/TargetType26.java | 17 + .../test/tools/javac/lambda/TargetType26.out | 2 + .../test/tools/javac/lambda/TargetType27.java | 20 ++ .../test/tools/javac/lambda/TargetType27.out | 2 + .../test/tools/javac/lambda/TargetType28.java | 23 ++ .../test/tools/javac/lambda/TargetType28.out | 3 + .../test/tools/javac/lambda/TargetType29.java | 44 +++ .../test/tools/javac/lambda/TargetType30.java | 51 +++ .../test/tools/javac/lambda/TargetType31.java | 51 +++ .../test/tools/javac/lambda/TargetType32.java | 77 ++++ .../test/tools/javac/lambda/TargetType33.java | 25 ++ .../test/tools/javac/lambda/TargetType33.out | 5 + .../test/tools/javac/lambda/TargetType34.java | 41 +++ .../test/tools/javac/lambda/TargetType35.java | 75 ++++ .../test/tools/javac/lambda/TargetType36.java | 43 +++ .../TargetType37.java} | 20 +- .../test/tools/javac/lambda/TargetType38.java | 22 ++ .../test/tools/javac/lambda/TargetType38.out | 3 + .../test/tools/javac/lambda/TargetType39.java | 22 ++ .../test/tools/javac/lambda/TargetType39.out | 3 + .../test/tools/javac/lambda/TargetType40.java | 18 + .../test/tools/javac/lambda/TargetType40.out | 2 + .../test/tools/javac/lambda/TargetType41.java | 15 + .../test/tools/javac/lambda/TargetType41.out | 2 + .../test/tools/javac/lambda/TargetType42.java | 42 +++ .../test/tools/javac/lambda/TargetType43.java | 16 + .../test/tools/javac/lambda/TargetType43.out | 5 + .../test/tools/javac/lambda/TargetType44.java | 27 ++ .../test/tools/javac/lambda/TargetType44.out | 3 + .../test/tools/javac/lambda/TargetType45.java | 29 ++ .../test/tools/javac/lambda/TargetType45.out | 2 + .../test/tools/javac/lambda/TargetType46.java | 29 ++ .../test/tools/javac/lambda/TargetType46.out | 3 + .../test/tools/javac/lambda/TargetType47.java | 44 +++ .../test/tools/javac/lambda/TargetType48.java | 48 +++ .../test/tools/javac/lambda/TargetType49.java | 19 + .../test/tools/javac/lambda/TargetType49.out | 3 + .../test/tools/javac/lambda/TargetType50.java | 28 ++ .../test/tools/javac/lambda/TargetType50.out | 3 + .../tools/javac/lambda/TestInvokeDynamic.java | 4 +- .../test/tools/javac/lambda/TestSelfRef.java | 201 +++++++++++ .../tools/javac/lambda/VoidCompatibility.java | 26 ++ .../tools/javac/lambda/VoidCompatibility.out | 2 + .../test/tools/javac/lambda/abort/Abort.java | 119 ++++++ .../lambda/badMemberRefBytecode/Main.java | 9 + .../TestBadMemberRefBytecode.java | 32 ++ .../lambda/badMemberRefBytecode/Use.java | 3 + .../javac/lambda/funcInterfaces/Helper.java | 138 +++++++ .../lambda/funcInterfaces/LambdaTest1.java | 119 ++++++ .../funcInterfaces/LambdaTest1_neg1.java | 15 + .../funcInterfaces/LambdaTest1_neg1.out | 3 + .../funcInterfaces/LambdaTest1_neg2.java | 17 + .../funcInterfaces/LambdaTest1_neg2.out | 2 + .../funcInterfaces/LambdaTest1_neg3.java | 19 + .../funcInterfaces/LambdaTest1_neg3.out | 2 + .../funcInterfaces/LambdaTest2_SAM1.java | 99 +++++ .../funcInterfaces/LambdaTest2_SAM2.java | 225 ++++++++++++ .../funcInterfaces/LambdaTest2_SAM3.java | 86 +++++ .../funcInterfaces/LambdaTest2_neg1.java | 19 + .../funcInterfaces/LambdaTest2_neg1.out | 2 + .../javac/lambda/funcInterfaces/NonSAM1.java | 14 + .../javac/lambda/funcInterfaces/NonSAM1.out | 2 + .../javac/lambda/funcInterfaces/NonSAM2.java | 21 ++ .../javac/lambda/funcInterfaces/NonSAM2.out | 6 + .../javac/lambda/funcInterfaces/NonSAM3.java | 24 ++ .../javac/lambda/funcInterfaces/NonSAM3.out | 9 + .../lambdaExpression/AbstractClass_neg.java | 18 + .../lambdaExpression/AbstractClass_neg.out | 2 + .../lambdaExpression/AccessNonStatic_neg.java | 26 ++ .../lambdaExpression/AccessNonStatic_neg.out | 5 + .../EffectivelyFinal_neg.java | 25 ++ .../lambdaExpression/EffectivelyFinal_neg.out | 5 + .../lambdaExpression/InvalidExpression1.java | 17 + .../lambdaExpression/InvalidExpression1.out | 3 + .../lambdaExpression/InvalidExpression3.java | 16 + .../lambdaExpression/InvalidExpression3.out | 2 + .../lambdaExpression/InvalidExpression4.java | 18 + .../lambdaExpression/InvalidExpression4.out | 2 + .../lambdaExpression/InvalidExpression5.java | 14 + .../lambdaExpression/InvalidExpression5.out | 2 + .../lambdaExpression/InvalidExpression6.java | 19 + .../lambdaExpression/InvalidExpression6.out | 3 + .../lambda/lambdaExpression/LambdaTest1.java | 119 ++++++ .../lambda/lambdaExpression/LambdaTest2.java | 118 ++++++ .../lambda/lambdaExpression/LambdaTest3.java | 56 +++ .../lambda/lambdaExpression/LambdaTest4.java | 72 ++++ .../lambda/lambdaExpression/LambdaTest5.java | 79 ++++ .../lambda/lambdaExpression/LambdaTest6.java | 118 ++++++ .../lambdaExpression/SamConversion.java | 151 ++++++++ .../SamConversionComboTest.java | 277 ++++++++++++++ .../lambda/methodReference/BridgeMethod.java | 117 ++++++ .../lambda/methodReference/MethodRef1.java | 82 +++++ .../lambda/methodReference/MethodRef2.java | 69 ++++ .../lambda/methodReference/MethodRef3.java | 60 ++++ .../lambda/methodReference/MethodRef4.java | 79 ++++ .../lambda/methodReference/MethodRef5.java | 96 +++++ .../lambda/methodReference/MethodRef6.java | 66 ++++ .../lambda/methodReference/MethodRef7.java | 105 ++++++ .../lambda/methodReference/MethodRef_neg.java | 36 ++ .../lambda/methodReference/MethodRef_neg.out | 5 + .../lambda/methodReference/SamConversion.java | 337 +++++++++++++++++ .../SamConversionComboTest.java | 265 ++++++++++++++ .../StructuralMostSpecificTest.java | 303 ++++++++++++++++ .../speculative/A.java} | 12 +- .../speculative/DiamondFinder.java} | 20 +- .../tools/javac/lambda/speculative/Main.java | 15 + .../tools/javac/lambda/speculative/Main.out | 2 + .../lambda/typeInference/InferenceTest11.java | 67 ++++ .../lambda/typeInference/InferenceTest2.java | 115 ++++++ .../lambda/typeInference/InferenceTest2b.java | 76 ++++ .../lambda/typeInference/InferenceTest3.java | 79 ++++ .../lambda/typeInference/InferenceTest4.java | 73 ++++ .../lambda/typeInference/InferenceTest5.java | 122 +++++++ .../typeInference/InferenceTest789.java | 67 ++++ .../typeInference/InferenceTest_neg1_2.java | 58 +++ .../typeInference/InferenceTest_neg1_2.out | 4 + .../typeInference/InferenceTest_neg5.java | 26 ++ .../typeInference/InferenceTest_neg5.out | 2 + .../combo/TypeInferenceComboTest.java | 338 ++++++++++++++++++ .../newlocations/BasicTest.out | 3 +- 451 files changed, 15433 insertions(+), 488 deletions(-) create mode 100644 langtools/test/tools/javac/diags/examples/ConditionalTargetCantBeVoid.java rename langtools/test/tools/javac/diags/examples/{CantReturnValueForVoid.java => UnexpectedReturnValue.java} (85%) create mode 100644 langtools/test/tools/javac/generics/7022054/T7022054pos1.out create mode 100644 langtools/test/tools/javac/generics/7022054/T7022054pos2.out create mode 100644 langtools/test/tools/javac/lambda/BadAccess.java create mode 100644 langtools/test/tools/javac/lambda/BadAccess.out create mode 100644 langtools/test/tools/javac/lambda/BadAccess02.java create mode 100644 langtools/test/tools/javac/lambda/BadAccess02.out create mode 100644 langtools/test/tools/javac/lambda/BadAccess03.java create mode 100644 langtools/test/tools/javac/lambda/BadAccess03.out create mode 100644 langtools/test/tools/javac/lambda/BadBreakContinue.java create mode 100644 langtools/test/tools/javac/lambda/BadBreakContinue.out create mode 100644 langtools/test/tools/javac/lambda/BadConv03.java create mode 100644 langtools/test/tools/javac/lambda/BadConv03.out create mode 100644 langtools/test/tools/javac/lambda/BadConv04.java create mode 100644 langtools/test/tools/javac/lambda/BadConv04.out create mode 100644 langtools/test/tools/javac/lambda/BadExpressionLambda.java create mode 100644 langtools/test/tools/javac/lambda/BadExpressionLambda.out create mode 100644 langtools/test/tools/javac/lambda/BadLambdaExpr.java create mode 100644 langtools/test/tools/javac/lambda/BadLambdaPos.java create mode 100644 langtools/test/tools/javac/lambda/BadLambdaPos.out create mode 100644 langtools/test/tools/javac/lambda/BadMethodCall.java create mode 100644 langtools/test/tools/javac/lambda/BadMethodCall.out create mode 100644 langtools/test/tools/javac/lambda/BadRecovery.java create mode 100644 langtools/test/tools/javac/lambda/BadRecovery.out create mode 100644 langtools/test/tools/javac/lambda/BadReturn.java create mode 100644 langtools/test/tools/javac/lambda/BadReturn.out create mode 100644 langtools/test/tools/javac/lambda/BadStatementInLambda.java create mode 100644 langtools/test/tools/javac/lambda/BadStatementInLambda.out create mode 100644 langtools/test/tools/javac/lambda/BadStatementInLambda02.java create mode 100644 langtools/test/tools/javac/lambda/BadStatementInLambda02.out create mode 100644 langtools/test/tools/javac/lambda/BadTargetType.java create mode 100644 langtools/test/tools/javac/lambda/BadTargetType.out create mode 100644 langtools/test/tools/javac/lambda/Conditional01.java create mode 100644 langtools/test/tools/javac/lambda/Conditional02.java create mode 100644 langtools/test/tools/javac/lambda/Conditional03.java create mode 100644 langtools/test/tools/javac/lambda/Conformance01.java create mode 100644 langtools/test/tools/javac/lambda/Defender01.java create mode 100644 langtools/test/tools/javac/lambda/DisjunctiveTypeTest.java create mode 100644 langtools/test/tools/javac/lambda/EffectivelyFinal01.java create mode 100644 langtools/test/tools/javac/lambda/EffectivelyFinal01.out create mode 100644 langtools/test/tools/javac/lambda/ErroneousArg.java create mode 100644 langtools/test/tools/javac/lambda/ErroneousArg.out create mode 100644 langtools/test/tools/javac/lambda/ErroneousLambdaExpr.java create mode 100644 langtools/test/tools/javac/lambda/LambdaCapture01.java create mode 100644 langtools/test/tools/javac/lambda/LambdaCapture02.java create mode 100644 langtools/test/tools/javac/lambda/LambdaCapture03.java create mode 100644 langtools/test/tools/javac/lambda/LambdaCapture04.java create mode 100644 langtools/test/tools/javac/lambda/LambdaCapture05.java create mode 100644 langtools/test/tools/javac/lambda/LambdaCapture06.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv01.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv03.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv05.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv06.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv08.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv09.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv09.out create mode 100644 langtools/test/tools/javac/lambda/LambdaConv10.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv10.out create mode 100644 langtools/test/tools/javac/lambda/LambdaConv11.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv12.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv13.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv16.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv17.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv18.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv18.out create mode 100644 langtools/test/tools/javac/lambda/LambdaConv19.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv20.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv21.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv21.out create mode 100644 langtools/test/tools/javac/lambda/LambdaConv22.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv23.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConv24.java create mode 100644 langtools/test/tools/javac/lambda/LambdaConversionTest.java create mode 100644 langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java create mode 100644 langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr01.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr02.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr04.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr05.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr06.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr07.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr08.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr09.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr10.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr10.out create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr11.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr12.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr13.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr14.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr15.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr16.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr17.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr18.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr19.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr19.out create mode 100644 langtools/test/tools/javac/lambda/LambdaExpr20.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExprNotVoid.java create mode 100644 langtools/test/tools/javac/lambda/LambdaExprNotVoid.out create mode 100644 langtools/test/tools/javac/lambda/LambdaScope01.java create mode 100644 langtools/test/tools/javac/lambda/LambdaScope02.java create mode 100644 langtools/test/tools/javac/lambda/LambdaScope03.java create mode 100644 langtools/test/tools/javac/lambda/LambdaScope04.java create mode 100644 langtools/test/tools/javac/lambda/LambdaScope04.out create mode 100644 langtools/test/tools/javac/lambda/LocalBreakAndContinue.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference01.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference02.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference03.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference04.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference04.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference05.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference06.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference07.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference08.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference08.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference09.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference09.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference10.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference11.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference12.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference13.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference14.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference15.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference16.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference17.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference18.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference19.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference20.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference20.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference21.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference21.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference22.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference22.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference23.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference23.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference24.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference25.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference26.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference26.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference27.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference28.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference28.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference29.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference30.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference31.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference32.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference32.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference33.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference34.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference35.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference36.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference37.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference37.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference38.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference38.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference39.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference39.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference40.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference40.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference41.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference42.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference43.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference44.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference45.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference45.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference46.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference47.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference47.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference48.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference49.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference50.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference50.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference51.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference51.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference52.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference52.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference53.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference53.out create mode 100644 langtools/test/tools/javac/lambda/MethodReference54.java create mode 100644 langtools/test/tools/javac/lambda/MethodReference54.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific01.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific01.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific02.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific02.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific03.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific03.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific04.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific05.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific06.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific06.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific07.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific07.out create mode 100644 langtools/test/tools/javac/lambda/NakedThis.java create mode 100644 langtools/test/tools/javac/lambda/SourceLevelTest.java create mode 100644 langtools/test/tools/javac/lambda/SourceLevelTest.out create mode 100644 langtools/test/tools/javac/lambda/TargetType01.java create mode 100644 langtools/test/tools/javac/lambda/TargetType02.java create mode 100644 langtools/test/tools/javac/lambda/TargetType03.java create mode 100644 langtools/test/tools/javac/lambda/TargetType04.java create mode 100644 langtools/test/tools/javac/lambda/TargetType04.out create mode 100644 langtools/test/tools/javac/lambda/TargetType05.java create mode 100644 langtools/test/tools/javac/lambda/TargetType06.java create mode 100644 langtools/test/tools/javac/lambda/TargetType06.out create mode 100644 langtools/test/tools/javac/lambda/TargetType07.java create mode 100644 langtools/test/tools/javac/lambda/TargetType08.java create mode 100644 langtools/test/tools/javac/lambda/TargetType10.java create mode 100644 langtools/test/tools/javac/lambda/TargetType10.out create mode 100644 langtools/test/tools/javac/lambda/TargetType11.java create mode 100644 langtools/test/tools/javac/lambda/TargetType11.out create mode 100644 langtools/test/tools/javac/lambda/TargetType12.java create mode 100644 langtools/test/tools/javac/lambda/TargetType13.java create mode 100644 langtools/test/tools/javac/lambda/TargetType13.out create mode 100644 langtools/test/tools/javac/lambda/TargetType14.java create mode 100644 langtools/test/tools/javac/lambda/TargetType14.out create mode 100644 langtools/test/tools/javac/lambda/TargetType15.java create mode 100644 langtools/test/tools/javac/lambda/TargetType16.java create mode 100644 langtools/test/tools/javac/lambda/TargetType16.out create mode 100644 langtools/test/tools/javac/lambda/TargetType17.java create mode 100644 langtools/test/tools/javac/lambda/TargetType17.out create mode 100644 langtools/test/tools/javac/lambda/TargetType18.java create mode 100644 langtools/test/tools/javac/lambda/TargetType19.java create mode 100644 langtools/test/tools/javac/lambda/TargetType19.out create mode 100644 langtools/test/tools/javac/lambda/TargetType20.java create mode 100644 langtools/test/tools/javac/lambda/TargetType20.out create mode 100644 langtools/test/tools/javac/lambda/TargetType21.java create mode 100644 langtools/test/tools/javac/lambda/TargetType21.out create mode 100644 langtools/test/tools/javac/lambda/TargetType22.java create mode 100644 langtools/test/tools/javac/lambda/TargetType22.out create mode 100644 langtools/test/tools/javac/lambda/TargetType23.java create mode 100644 langtools/test/tools/javac/lambda/TargetType23.out create mode 100644 langtools/test/tools/javac/lambda/TargetType24.java create mode 100644 langtools/test/tools/javac/lambda/TargetType24.out create mode 100644 langtools/test/tools/javac/lambda/TargetType25.java create mode 100644 langtools/test/tools/javac/lambda/TargetType26.java create mode 100644 langtools/test/tools/javac/lambda/TargetType26.out create mode 100644 langtools/test/tools/javac/lambda/TargetType27.java create mode 100644 langtools/test/tools/javac/lambda/TargetType27.out create mode 100644 langtools/test/tools/javac/lambda/TargetType28.java create mode 100644 langtools/test/tools/javac/lambda/TargetType28.out create mode 100644 langtools/test/tools/javac/lambda/TargetType29.java create mode 100644 langtools/test/tools/javac/lambda/TargetType30.java create mode 100644 langtools/test/tools/javac/lambda/TargetType31.java create mode 100644 langtools/test/tools/javac/lambda/TargetType32.java create mode 100644 langtools/test/tools/javac/lambda/TargetType33.java create mode 100644 langtools/test/tools/javac/lambda/TargetType33.out create mode 100644 langtools/test/tools/javac/lambda/TargetType34.java create mode 100644 langtools/test/tools/javac/lambda/TargetType35.java create mode 100644 langtools/test/tools/javac/lambda/TargetType36.java rename langtools/test/tools/javac/{diags/examples/CantAccessThrownTypesInFunctionalDesc.java => lambda/TargetType37.java} (77%) create mode 100644 langtools/test/tools/javac/lambda/TargetType38.java create mode 100644 langtools/test/tools/javac/lambda/TargetType38.out create mode 100644 langtools/test/tools/javac/lambda/TargetType39.java create mode 100644 langtools/test/tools/javac/lambda/TargetType39.out create mode 100644 langtools/test/tools/javac/lambda/TargetType40.java create mode 100644 langtools/test/tools/javac/lambda/TargetType40.out create mode 100644 langtools/test/tools/javac/lambda/TargetType41.java create mode 100644 langtools/test/tools/javac/lambda/TargetType41.out create mode 100644 langtools/test/tools/javac/lambda/TargetType42.java create mode 100644 langtools/test/tools/javac/lambda/TargetType43.java create mode 100644 langtools/test/tools/javac/lambda/TargetType43.out create mode 100644 langtools/test/tools/javac/lambda/TargetType44.java create mode 100644 langtools/test/tools/javac/lambda/TargetType44.out create mode 100644 langtools/test/tools/javac/lambda/TargetType45.java create mode 100644 langtools/test/tools/javac/lambda/TargetType45.out create mode 100644 langtools/test/tools/javac/lambda/TargetType46.java create mode 100644 langtools/test/tools/javac/lambda/TargetType46.out create mode 100644 langtools/test/tools/javac/lambda/TargetType47.java create mode 100644 langtools/test/tools/javac/lambda/TargetType48.java create mode 100644 langtools/test/tools/javac/lambda/TargetType49.java create mode 100644 langtools/test/tools/javac/lambda/TargetType49.out create mode 100644 langtools/test/tools/javac/lambda/TargetType50.java create mode 100644 langtools/test/tools/javac/lambda/TargetType50.out create mode 100644 langtools/test/tools/javac/lambda/TestSelfRef.java create mode 100644 langtools/test/tools/javac/lambda/VoidCompatibility.java create mode 100644 langtools/test/tools/javac/lambda/VoidCompatibility.out create mode 100644 langtools/test/tools/javac/lambda/abort/Abort.java create mode 100644 langtools/test/tools/javac/lambda/badMemberRefBytecode/Main.java create mode 100644 langtools/test/tools/javac/lambda/badMemberRefBytecode/TestBadMemberRefBytecode.java create mode 100644 langtools/test/tools/javac/lambda/badMemberRefBytecode/Use.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/Helper.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.out create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.out create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.out create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM1.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM2.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM3.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.out create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.out create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.out create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.java create mode 100644 langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.out create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.out create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.out create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.out create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.out create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.out create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.out create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.out create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.out create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest2.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest3.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest4.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest5.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest6.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/SamConversion.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/BridgeMethod.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRef1.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRef2.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRef3.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRef4.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRef5.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRef6.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRef7.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.out create mode 100644 langtools/test/tools/javac/lambda/methodReference/SamConversion.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/SamConversionComboTest.java create mode 100644 langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java rename langtools/test/tools/javac/{diags/examples/CantAccessReturnTypeInFunctionalDesc.java => lambda/speculative/A.java} (79%) rename langtools/test/tools/javac/{diags/examples/CantAccessArgTypeInFunctionalDesc.java => lambda/speculative/DiamondFinder.java} (77%) create mode 100644 langtools/test/tools/javac/lambda/speculative/Main.java create mode 100644 langtools/test/tools/javac/lambda/speculative/Main.out create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest11.java create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest2.java create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest2b.java create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest3.java create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest4.java create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest5.java create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest789.java create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.java create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java create mode 100644 langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out create mode 100644 langtools/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java index 1a71cab46ee..36b669b6337 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java @@ -67,6 +67,7 @@ public class Flags { if ((mask&NATIVE) != 0) flags.add(Flag.NATIVE); if ((mask&INTERFACE) != 0) flags.add(Flag.INTERFACE); if ((mask&ABSTRACT) != 0) flags.add(Flag.ABSTRACT); + if ((mask&DEFAULT) != 0) flags.add(Flag.DEFAULT); if ((mask&STRICTFP) != 0) flags.add(Flag.STRICTFP); if ((mask&BRIDGE) != 0) flags.add(Flag.BRIDGE); if ((mask&SYNTHETIC) != 0) flags.add(Flag.SYNTHETIC); @@ -261,7 +262,7 @@ public class Flags { * Flag that marks class as auxiliary, ie a non-public class following * the public class in a source file, that could block implicit compilation. */ - public static final long AUXILIARY = 1L<<43; + public static final long AUXILIARY = 1L<<44; /** Modifier masks. */ diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java index 09b38d68587..2248f47e0e0 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java @@ -438,7 +438,8 @@ public abstract class Symbol implements Element { } public Set getModifiers() { - return Flags.asModifierSet(flags()); + long flags = flags(); + return Flags.asModifierSet((flags & DEFAULT) != 0 ? flags & ~ABSTRACT : flags); } public Name getSimpleName() { @@ -475,6 +476,7 @@ public abstract class Symbol implements Element { public String toString() { return other.toString(); } public Symbol location() { return other.location(); } public Symbol location(Type site, Types types) { return other.location(site, types); } + public Symbol baseSymbol() { return other; } public Type erasure(Types types) { return other.erasure(types); } public Type externalType(Types types) { return other.externalType(types); } public boolean isLocal() { return other.isLocal(); } @@ -1192,7 +1194,7 @@ public abstract class Symbol implements Element { // check for an inherited implementation if ((flags() & ABSTRACT) != 0 || - (other.flags() & ABSTRACT) == 0 || + ((other.flags() & ABSTRACT) == 0 && (other.flags() & DEFAULT) == 0) || !other.isOverridableIn(origin) || !this.isMemberOf(origin, types)) return false; @@ -1202,7 +1204,7 @@ public abstract class Symbol implements Element { Type ot = types.memberType(origin.type, other); return types.isSubSignature(mt, ot) && - (!checkResult || types.resultSubtype(mt, ot, Warner.noWarnings)); + (!checkResult || types.resultSubtype(mt, ot, types.noWarnings)); } private boolean isOverridableIn(TypeSymbol origin) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index c8b6b258462..22063dcbf16 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -83,6 +83,8 @@ public class Types { final Name capturedName; private final FunctionDescriptorLookupError functionDescriptorLookupError; + public final Warner noWarnings; + // public static Types instance(Context context) { Types instance = context.get(typesKey); @@ -106,6 +108,7 @@ public class Types { messages = JavacMessages.instance(context); diags = JCDiagnostic.Factory.instance(context); functionDescriptorLookupError = new FunctionDescriptorLookupError(); + noWarnings = new Warner(null); } // @@ -296,7 +299,7 @@ public class Types { * convertions to s? */ public boolean isConvertible(Type t, Type s) { - return isConvertible(t, s, Warner.noWarnings); + return isConvertible(t, s, noWarnings); } // @@ -394,15 +397,10 @@ public class Types { @Override public boolean accepts(Symbol sym) { - return sym.kind == Kinds.MTH && - (sym.flags() & ABSTRACT) != 0 && - !overridesObjectMethod(origin, sym) && - notOverridden(sym); - } - - private boolean notOverridden(Symbol msym) { - Symbol impl = ((MethodSymbol)msym).implementation(origin, Types.this, false); - return impl == null || (impl.flags() & ABSTRACT) != 0; + return sym.kind == Kinds.MTH && + (sym.flags() & (ABSTRACT | DEFAULT)) == ABSTRACT && + !overridesObjectMethod(origin, sym) && + (interfaceCandidates(origin.type, (MethodSymbol)sym).head.flags() & DEFAULT) == 0; } }; @@ -593,7 +591,7 @@ public class Types { * Is t an unchecked subtype of s? */ public boolean isSubtypeUnchecked(Type t, Type s) { - return isSubtypeUnchecked(t, s, Warner.noWarnings); + return isSubtypeUnchecked(t, s, noWarnings); } /** * Is t an unchecked subtype of s? @@ -1196,7 +1194,7 @@ public class Types { // public boolean isCastable(Type t, Type s) { - return isCastable(t, s, Warner.noWarnings); + return isCastable(t, s, noWarnings); } /** @@ -1259,7 +1257,7 @@ public class Types { return true; if (s.tag == TYPEVAR) { - if (isCastable(t, s.getUpperBound(), Warner.noWarnings)) { + if (isCastable(t, s.getUpperBound(), noWarnings)) { warnStack.head.warn(LintCategory.UNCHECKED); return true; } else { @@ -1269,7 +1267,7 @@ public class Types { if (t.isCompound()) { Warner oldWarner = warnStack.head; - warnStack.head = Warner.noWarnings; + warnStack.head = noWarnings; if (!visit(supertype(t), s)) return false; for (Type intf : interfaces(t)) { @@ -1368,7 +1366,7 @@ public class Types { case BOT: return true; case TYPEVAR: - if (isCastable(s, t, Warner.noWarnings)) { + if (isCastable(s, t, noWarnings)) { warnStack.head.warn(LintCategory.UNCHECKED); return true; } else { @@ -1396,7 +1394,7 @@ public class Types { case TYPEVAR: if (isSubtype(t, s)) { return true; - } else if (isCastable(t.bound, s, Warner.noWarnings)) { + } else if (isCastable(t.bound, s, noWarnings)) { warnStack.head.warn(LintCategory.UNCHECKED); return true; } else { @@ -1535,7 +1533,7 @@ public class Types { TypeVar tv = (TypeVar) t; return !isCastable(tv.bound, relaxBound(s), - Warner.noWarnings); + noWarnings); } if (s.tag != WILDCARD) s = upperBound(s); @@ -1838,7 +1836,7 @@ public class Types { // public boolean isAssignable(Type t, Type s) { - return isAssignable(t, s, Warner.noWarnings); + return isAssignable(t, s, noWarnings); } /** @@ -2149,9 +2147,9 @@ public class Types { } }; - public boolean isDirectSuperInterface(Type t, TypeSymbol tsym) { - for (Type t2 : interfaces(tsym.type)) { - if (isSameType(t, t2)) return true; + public boolean isDirectSuperInterface(TypeSymbol isym, TypeSymbol origin) { + for (Type i2 : interfaces(origin.type)) { + if (isym == i2.tsym) return true; } return false; } @@ -2224,7 +2222,9 @@ public class Types { * Return list of bounds of the given type variable. */ public List getBounds(TypeVar t) { - if (t.bound.isErroneous() || !t.bound.isCompound()) + if (t.bound.hasTag(NONE)) + return List.nil(); + else if (t.bound.isErroneous() || !t.bound.isCompound()) return List.of(t.bound); else if ((erasure(t).tsym.flags() & INTERFACE) == 0) return interfaces(t).prepend(supertype(t)); @@ -2319,10 +2319,6 @@ public class Types { return false; } - public boolean overridesObjectMethod(Symbol msym) { - return ((MethodSymbol)msym).implementation(syms.objectType.tsym, this, true) != null; - } - // class ImplementationCache { @@ -2471,11 +2467,7 @@ public class Types { //where public List interfaceCandidates(Type site, MethodSymbol ms) { - return interfaceCandidates(site, ms, false); - } - - public List interfaceCandidates(Type site, MethodSymbol ms, boolean intfOnly) { - Filter filter = new MethodFilter(ms, site, intfOnly); + Filter filter = new MethodFilter(ms, site); List candidates = List.nil(); for (Symbol s : membersClosure(site, false).getElements(filter)) { if (!site.tsym.isInterface() && !s.owner.isInterface()) { @@ -2514,17 +2506,14 @@ public class Types { Symbol msym; Type site; - boolean intfOnly; - MethodFilter(Symbol msym, Type site, boolean intfOnly) { + MethodFilter(Symbol msym, Type site) { this.msym = msym; this.site = site; - this.intfOnly = intfOnly; } public boolean accepts(Symbol s) { return s.kind == Kinds.MTH && - (!intfOnly || s.owner.isInterface()) && s.name == msym.name && s.isInheritedIn(site.tsym, Types.this) && overrideEquivalent(memberType(site, s), memberType(site, msym)); @@ -3462,11 +3451,11 @@ public class Types { */ public boolean returnTypeSubstitutable(Type r1, Type r2) { if (hasSameArgs(r1, r2)) - return resultSubtype(r1, r2, Warner.noWarnings); + return resultSubtype(r1, r2, noWarnings); else return covariantReturnType(r1.getReturnType(), erasure(r2.getReturnType()), - Warner.noWarnings); + noWarnings); } public boolean returnTypeSubstitutable(Type r1, diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index c3cc1f01806..0d743da7be4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -133,7 +133,7 @@ public class Attr extends JCTree.Visitor { allowCovariantReturns = source.allowCovariantReturns(); allowAnonOuterThis = source.allowAnonOuterThis(); allowStringsInSwitch = source.allowStringsInSwitch(); - allowPoly = source.allowPoly() && options.isSet("allowPoly"); + allowPoly = source.allowPoly(); allowLambda = source.allowLambda(); allowDefaultMethods = source.allowDefaultMethods(); sourceName = source.name; @@ -179,14 +179,14 @@ public class Attr extends JCTree.Visitor { */ boolean allowCovariantReturns; - /** Switch: support default methods ? - */ - boolean allowDefaultMethods; - /** Switch: support lambda expressions ? */ boolean allowLambda; + /** Switch: support default methods ? + */ + boolean allowDefaultMethods; + /** Switch: allow references to surrounding object from anonymous * objects during constructor call? */ @@ -524,6 +524,10 @@ public class Attr extends JCTree.Visitor { protected ResultInfo dup(Type newPt) { return new ResultInfo(pkind, newPt, checkContext); } + + protected ResultInfo dup(CheckContext newContext) { + return new ResultInfo(pkind, pt, newContext); + } } class RecoveryInfo extends ResultInfo { @@ -540,7 +544,7 @@ public class Attr extends JCTree.Visitor { } @Override public void report(DiagnosticPosition pos, JCDiagnostic details) { - //do nothing + chk.basicHandler.report(pos, details); } }); } @@ -595,8 +599,10 @@ public class Attr extends JCTree.Visitor { this.env = env; this.resultInfo = resultInfo; tree.accept(this); - if (tree == breakTree) + if (tree == breakTree && + resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) { throw new BreakAttr(env); + } return result; } catch (CompletionFailure ex) { tree.type = syms.errType; @@ -903,7 +909,7 @@ public class Attr extends JCTree.Visitor { localEnv.info.lint = lint; - if (isDefaultMethod && types.overridesObjectMethod(m)) { + if (isDefaultMethod && types.overridesObjectMethod(m.enclClass(), m)) { log.error(tree, "default.overrides.object.member", m.name, Kinds.kindName(m.location()), m.location()); } @@ -1390,13 +1396,14 @@ public class Attr extends JCTree.Visitor { if (!standaloneConditional && resultInfo.pt.hasTag(VOID)) { //cannot get here (i.e. it means we are returning from void method - which is already an error) + resultInfo.checkContext.report(tree, diags.fragment("conditional.target.cant.be.void")); result = tree.type = types.createErrorType(resultInfo.pt); return; } ResultInfo condInfo = standaloneConditional ? unknownExprInfo : - new ResultInfo(VAL, pt(), new Check.NestedCheckContext(resultInfo.checkContext) { + resultInfo.dup(new Check.NestedCheckContext(resultInfo.checkContext) { //this will use enclosing check context to check compatibility of //subexpression against target type; if we are in a method check context, //depending on whether boxing is allowed, we could have incompatibilities @@ -1419,11 +1426,11 @@ public class Attr extends JCTree.Visitor { result = check(tree, owntype, VAL, resultInfo); } //where - @SuppressWarnings("fallthrough") private boolean isBooleanOrNumeric(Env env, JCExpression tree) { switch (tree.getTag()) { case LITERAL: return ((JCLiteral)tree).typetag.isSubRangeOf(DOUBLE) || - ((JCLiteral)tree).typetag == BOOLEAN; + ((JCLiteral)tree).typetag == BOOLEAN || + ((JCLiteral)tree).typetag == BOT; case LAMBDA: case REFERENCE: return false; case PARENS: return isBooleanOrNumeric(env, ((JCParens)tree).expr); case CONDEXPR: @@ -1612,19 +1619,23 @@ public class Attr extends JCTree.Visitor { // it conforms to result type of enclosing method. if (tree.expr != null) { if (env.info.returnResult.pt.hasTag(VOID)) { - log.error(tree.expr.pos(), - "cant.ret.val.from.meth.decl.void"); + env.info.returnResult.checkContext.report(tree.expr.pos(), + diags.fragment("unexpected.ret.val")); } attribTree(tree.expr, env, env.info.returnResult); } else if (!env.info.returnResult.pt.hasTag(VOID)) { - log.error(tree.pos(), "missing.ret.val"); + env.info.returnResult.checkContext.report(tree.pos(), + diags.fragment("missing.ret.val")); } } result = null; } public void visitThrow(JCThrow tree) { - attribExpr(tree.expr, env, syms.throwableType); + Type owntype = attribExpr(tree.expr, env, allowPoly ? Type.noType : syms.throwableType); + if (allowPoly) { + chk.checkType(tree, owntype, syms.throwableType); + } result = null; } @@ -2068,7 +2079,7 @@ public class Attr extends JCTree.Visitor { resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt()); Type inferred = deferredAttr.attribSpeculative(tree, env, findDiamondResult).type; if (!inferred.isErroneous() && - types.isAssignable(inferred, pt().hasTag(NONE) ? syms.objectType : pt(), Warner.noWarnings)) { + types.isAssignable(inferred, pt().hasTag(NONE) ? syms.objectType : pt(), types.noWarnings)) { String key = types.isSameType(clazztype, inferred) ? "diamond.redundant.args" : "diamond.redundant.args.1"; @@ -2172,7 +2183,7 @@ public class Attr extends JCTree.Visitor { } //create an environment for attribution of the lambda expression final Env localEnv = lambdaEnv(that, env); - boolean needsRecovery = resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext || + boolean needsRecovery = resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK; try { List explicitParamTypes = null; @@ -2182,10 +2193,16 @@ public class Attr extends JCTree.Visitor { explicitParamTypes = TreeInfo.types(that.params); } - Type target = infer.instantiateFunctionalInterface(that, pt(), explicitParamTypes, resultInfo.checkContext); - Type lambdaType = (target == Type.recoveryType) ? - fallbackDescriptorType(that) : - types.findDescriptorType(target); + Type target; + Type lambdaType; + if (pt() != Type.recoveryType) { + target = infer.instantiateFunctionalInterface(that, pt(), explicitParamTypes, resultInfo.checkContext); + lambdaType = types.findDescriptorType(target); + chk.checkFunctionalInterface(that, target); + } else { + target = Type.recoveryType; + lambdaType = fallbackDescriptorType(that); + } if (!TreeInfo.isExplicitLambda(that)) { //add param type info in the AST @@ -2250,7 +2267,7 @@ public class Attr extends JCTree.Visitor { checkLambdaCompatible(that, lambdaType, resultInfo.checkContext, isSpeculativeRound); if (!isSpeculativeRound) { - checkAccessibleFunctionalDescriptor(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType); + checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType, target); } result = check(that, target, VAL, resultInfo); } catch (Types.FunctionDescriptorLookupError ex) { @@ -2285,17 +2302,22 @@ public class Attr extends JCTree.Visitor { return null; } - private void checkAccessibleFunctionalDescriptor(final DiagnosticPosition pos, - final Env env, final InferenceContext inferenceContext, final Type desc) { - if (inferenceContext.free(desc)) { - inferenceContext.addFreeTypeListener(List.of(desc), new FreeTypeListener() { + private void checkAccessibleTypes(final DiagnosticPosition pos, final Env env, final InferenceContext inferenceContext, final Type... ts) { + checkAccessibleTypes(pos, env, inferenceContext, List.from(ts)); + } + + private void checkAccessibleTypes(final DiagnosticPosition pos, final Env env, final InferenceContext inferenceContext, final List ts) { + if (inferenceContext.free(ts)) { + inferenceContext.addFreeTypeListener(ts, new FreeTypeListener() { @Override public void typesInferred(InferenceContext inferenceContext) { - checkAccessibleFunctionalDescriptor(pos, env, inferenceContext, inferenceContext.asInstType(desc, types)); + checkAccessibleTypes(pos, env, inferenceContext, inferenceContext.asInstTypes(ts, types)); } }); } else { - chk.checkAccessibleFunctionalDescriptor(pos, env, desc); + for (Type t : ts) { + rs.checkAccessibleType(env, t); + } } } @@ -2411,15 +2433,20 @@ public class Attr extends JCTree.Visitor { typeargtypes = attribTypes(that.typeargs, localEnv); } - Type target = infer.instantiateFunctionalInterface(that, pt(), null, resultInfo.checkContext); - Type desc = (target == Type.recoveryType) ? - fallbackDescriptorType(that) : - types.findDescriptorType(target); + Type target; + Type desc; + if (pt() != Type.recoveryType) { + target = infer.instantiateFunctionalInterface(that, pt(), null, resultInfo.checkContext); + desc = types.findDescriptorType(target); + chk.checkFunctionalInterface(that, target); + } else { + target = Type.recoveryType; + desc = fallbackDescriptorType(that); + } List argtypes = desc.getParameterTypes(); boolean allowBoxing = - resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext || resultInfo.checkContext.deferredAttrContext().phase.isBoxingRequired(); Pair refResult = rs.resolveMemberReference(that.pos(), localEnv, that, that.expr.type, that.name, argtypes, typeargtypes, allowBoxing); @@ -2455,18 +2482,25 @@ public class Attr extends JCTree.Visitor { JCDiagnostic diag = diags.create(diagKind, log.currentSource(), that, "invalid.mref", Kinds.kindName(that.getMode()), detailsDiag); - if (targetError) { - resultInfo.checkContext.report(that, diag); + if (targetError && target == Type.recoveryType) { + //a target error doesn't make sense during recovery stage + //as we don't know what actual parameter types are + result = that.type = target; + return; } else { - log.report(diag); + if (targetError) { + resultInfo.checkContext.report(that, diag); + } else { + log.report(diag); + } + result = that.type = types.createErrorType(target); + return; } - result = that.type = types.createErrorType(target); - return; } if (desc.getReturnType() == Type.recoveryType) { // stop here - result = that.type = types.createErrorType(target); + result = that.type = target; return; } @@ -2492,7 +2526,7 @@ public class Attr extends JCTree.Visitor { resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE; checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound); if (!isSpeculativeRound) { - checkAccessibleFunctionalDescriptor(that, localEnv, resultInfo.checkContext.inferenceContext(), desc); + checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, target); } result = check(that, target, VAL, resultInfo); } catch (Types.FunctionDescriptorLookupError ex) { @@ -2526,7 +2560,7 @@ public class Attr extends JCTree.Visitor { if (!returnType.hasTag(VOID) && !resType.hasTag(VOID)) { if (resType.isErroneous() || - new LambdaReturnContext(checkContext).compatible(resType, returnType, Warner.noWarnings)) { + new LambdaReturnContext(checkContext).compatible(resType, returnType, types.noWarnings)) { incompatibleReturnType = null; } } @@ -3039,15 +3073,52 @@ public class Attr extends JCTree.Visitor { Symbol sym, Env env, ResultInfo resultInfo) { - Type pt = resultInfo.pt.hasTag(FORALL) || resultInfo.pt.hasTag(METHOD) ? - resultInfo.pt.map(deferredAttr.new DeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase)) : - resultInfo.pt; + return (resultInfo.pt.hasTag(FORALL) || resultInfo.pt.hasTag(METHOD)) ? + checkMethodId(tree, site, sym, env, resultInfo) : + checkIdInternal(tree, site, sym, resultInfo.pt, env, resultInfo); + } - DeferredAttr.DeferredTypeMap recoveryMap = - deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase); + Type checkMethodId(JCTree tree, + Type site, + Symbol sym, + Env env, + ResultInfo resultInfo) { + boolean isPolymorhicSignature = + sym.kind == MTH && ((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types); + return isPolymorhicSignature ? + checkSigPolyMethodId(tree, site, sym, env, resultInfo) : + checkMethodIdInternal(tree, site, sym, env, resultInfo); + } + Type checkSigPolyMethodId(JCTree tree, + Type site, + Symbol sym, + Env env, + ResultInfo resultInfo) { + //recover original symbol for signature polymorphic methods + checkMethodIdInternal(tree, site, sym.baseSymbol(), env, resultInfo); + env.info.pendingResolutionPhase = Resolve.MethodResolutionPhase.BASIC; + return sym.type; + } + + Type checkMethodIdInternal(JCTree tree, + Type site, + Symbol sym, + Env env, + ResultInfo resultInfo) { + Type pt = resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase)); + Type owntype = checkIdInternal(tree, site, sym, pt, env, resultInfo); + resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase)); + return owntype; + } + + Type checkIdInternal(JCTree tree, + Type site, + Symbol sym, + Type pt, + Env env, + ResultInfo resultInfo) { if (pt.isErroneous()) { - Type.map(resultInfo.pt.getParameterTypes(), recoveryMap); return types.createErrorType(site); } Type owntype; // The computed type of this identifier occurrence. @@ -3132,7 +3203,6 @@ public class Attr extends JCTree.Visitor { break; } case PCK: case ERR: - Type.map(resultInfo.pt.getParameterTypes(), recoveryMap); owntype = sym.type; break; default: @@ -3288,21 +3358,21 @@ public class Attr extends JCTree.Visitor { } } - if (env.info.defaultSuperCallSite != null && - !types.interfaceCandidates(env.enclClass.type, (MethodSymbol)sym, true).contains(sym)) { - Symbol ovSym = null; - for (MethodSymbol msym : types.interfaceCandidates(env.enclClass.type, (MethodSymbol)sym, true)) { - if (msym.overrides(sym, msym.enclClass(), types, true)) { - for (Type i : types.interfaces(env.enclClass.type)) { - if (i.tsym.isSubClass(msym.owner, types)) { - ovSym = i.tsym; - break; - } - } + if (env.info.defaultSuperCallSite != null) { + for (Type sup : types.interfaces(env.enclClass.type).prepend(types.supertype((env.enclClass.type)))) { + if (!sup.tsym.isSubClass(sym.enclClass(), types) || + types.isSameType(sup, env.info.defaultSuperCallSite)) continue; + List icand_sup = + types.interfaceCandidates(sup, (MethodSymbol)sym); + if (icand_sup.nonEmpty() && + icand_sup.head != sym && + icand_sup.head.overrides(sym, icand_sup.head.enclClass(), types, true)) { + log.error(env.tree.pos(), "illegal.default.super.call", env.info.defaultSuperCallSite, + diags.fragment("overridden.default", sym, sup)); + break; } } - log.error(env.tree.pos(), "illegal.default.super.call", env.info.defaultSuperCallSite, - diags.fragment("overridden.default", sym, ovSym)); + env.info.defaultSuperCallSite = null; } // Compute the identifier's instantiated type. diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 52dccced8a6..78ba105984f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -120,8 +120,7 @@ public class Check { allowCovariantReturns = source.allowCovariantReturns(); allowSimplifiedVarargs = source.allowSimplifiedVarargs(); allowDefaultMethods = source.allowDefaultMethods(); - allowStrictMethodClashCheck = source.allowStrictMethodClashCheck() && - options.isSet("strictMethodClashCheck"); //pre-lambda guard + allowStrictMethodClashCheck = source.allowStrictMethodClashCheck(); complexInference = options.isSet("complexinference"); warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); @@ -451,8 +450,6 @@ public class Check { public Infer.InferenceContext inferenceContext(); public DeferredAttr.DeferredAttrContext deferredAttrContext(); - - public boolean allowBoxing(); } /** @@ -487,10 +484,6 @@ public class Check { public DeferredAttrContext deferredAttrContext() { return enclosingContext.deferredAttrContext(); } - - public boolean allowBoxing() { - return enclosingContext.allowBoxing(); - } } /** @@ -515,10 +508,6 @@ public class Check { public DeferredAttrContext deferredAttrContext() { return deferredAttr.emptyDeferredAttrContext; } - - public boolean allowBoxing() { - return true; - } }; /** Check that a given type is assignable to a given proto-type. @@ -625,7 +614,7 @@ public class Check { a = types.upperBound(a); return types.isSubtype(a, bound); } else if (a.isExtendsBound()) { - return types.isCastable(bound, types.upperBound(a), Warner.noWarnings); + return types.isCastable(bound, types.upperBound(a), types.noWarnings); } else if (a.isSuperBound()) { return !types.notSoftSubtype(types.lowerBound(a), bound); } @@ -909,19 +898,21 @@ public class Check { "unchecked.generic.array.creation", argtype); } - Type elemtype = types.elemtype(argtype); - switch (tree.getTag()) { - case APPLY: - ((JCMethodInvocation) tree).varargsElement = elemtype; - break; - case NEWCLASS: - ((JCNewClass) tree).varargsElement = elemtype; - break; - case REFERENCE: - ((JCMemberReference) tree).varargsElement = elemtype; - break; - default: - throw new AssertionError(""+tree); + if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) { + Type elemtype = types.elemtype(argtype); + switch (tree.getTag()) { + case APPLY: + ((JCMethodInvocation) tree).varargsElement = elemtype; + break; + case NEWCLASS: + ((JCNewClass) tree).varargsElement = elemtype; + break; + case REFERENCE: + ((JCMemberReference) tree).varargsElement = elemtype; + break; + default: + throw new AssertionError(""+tree); + } } } return owntype; @@ -937,65 +928,6 @@ public class Check { return; } - void checkAccessibleFunctionalDescriptor(DiagnosticPosition pos, Env env, Type desc) { - AccessChecker accessChecker = new AccessChecker(env); - //check args accessibility (only if implicit parameter types) - for (Type arg : desc.getParameterTypes()) { - if (!accessChecker.visit(arg)) { - log.error(pos, "cant.access.arg.type.in.functional.desc", arg); - return; - } - } - //check return type accessibility - if (!accessChecker.visit(desc.getReturnType())) { - log.error(pos, "cant.access.return.in.functional.desc", desc.getReturnType()); - return; - } - //check thrown types accessibility - for (Type thrown : desc.getThrownTypes()) { - if (!accessChecker.visit(thrown)) { - log.error(pos, "cant.access.thrown.in.functional.desc", thrown); - return; - } - } - } - - class AccessChecker extends Types.UnaryVisitor { - - Env env; - - AccessChecker(Env env) { - this.env = env; - } - - Boolean visit(List ts) { - for (Type t : ts) { - if (!visit(t)) - return false; - } - return true; - } - - public Boolean visitType(Type t, Void s) { - return true; - } - - @Override - public Boolean visitArrayType(ArrayType t, Void s) { - return visit(t.elemtype); - } - - @Override - public Boolean visitClassType(ClassType t, Void s) { - return rs.isAccessible(env, t, true) && - visit(t.getTypeArguments()); - } - - @Override - public Boolean visitWildcardType(WildcardType t, Void s) { - return visit(t.type); - } - }; /** * Check that type 't' is a valid instantiation of a generic class * (see JLS 4.5) @@ -1919,8 +1851,8 @@ public class Check { types.isSameType(rt1, rt2) || !rt1.isPrimitiveOrVoid() && !rt2.isPrimitiveOrVoid() && - (types.covariantReturnType(rt1, rt2, Warner.noWarnings) || - types.covariantReturnType(rt2, rt1, Warner.noWarnings)) || + (types.covariantReturnType(rt1, rt2, types.noWarnings) || + types.covariantReturnType(rt2, rt1, types.noWarnings)) || checkCommonOverriderIn(s1,s2,site); if (!compat) { log.error(pos, "types.incompatible.diff.ret", @@ -1965,8 +1897,8 @@ public class Check { boolean compat = !rt13.isPrimitiveOrVoid() && !rt23.isPrimitiveOrVoid() && - (types.covariantReturnType(rt13, rt1, Warner.noWarnings) && - types.covariantReturnType(rt23, rt2, Warner.noWarnings)); + (types.covariantReturnType(rt13, rt1, types.noWarnings) && + types.covariantReturnType(rt23, rt2, types.noWarnings)); if (compat) return true; } @@ -2280,19 +2212,33 @@ public class Check { c.flags_field |= ACYCLIC; } + /** + * Check that functional interface methods would make sense when seen + * from the perspective of the implementing class + */ + void checkFunctionalInterface(JCTree tree, Type funcInterface) { + ClassType c = new ClassType(Type.noType, List.nil(), null); + ClassSymbol csym = new ClassSymbol(0, names.empty, c, syms.noSymbol); + c.interfaces_field = List.of(funcInterface); + c.supertype_field = syms.objectType; + c.tsym = csym; + csym.members_field = new Scope(csym); + csym.completer = null; + checkImplementations(tree, csym, csym); + } + /** Check that all methods which implement some * method conform to the method they implement. * @param tree The class definition whose members are checked. */ void checkImplementations(JCClassDecl tree) { - checkImplementations(tree, tree.sym); + checkImplementations(tree, tree.sym, tree.sym); } //where /** Check that all methods which implement some * method in `ic' conform to the method they implement. */ - void checkImplementations(JCClassDecl tree, ClassSymbol ic) { - ClassSymbol origin = tree.sym; + void checkImplementations(JCTree tree, ClassSymbol origin, ClassSymbol ic) { for (List l = types.closure(ic.type); l.nonEmpty(); l = l.tail) { ClassSymbol lc = (ClassSymbol)l.head.tsym; if ((allowGenerics || origin != lc) && (lc.flags() & ABSTRACT) != 0) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index 772afbe86ea..cf81fc6f5dd 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -38,14 +38,13 @@ import com.sun.tools.javac.tree.JCTree.*; import javax.tools.JavaFileObject; import java.util.ArrayList; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Map; import java.util.Queue; import java.util.Set; import java.util.WeakHashMap; -import static com.sun.tools.javac.code.TypeTag.DEFERRED; -import static com.sun.tools.javac.code.TypeTag.NONE; +import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.tree.JCTree.Tag.*; /** @@ -136,19 +135,6 @@ public class DeferredAttr extends JCTree.Visitor { } } - /** - * Clone a speculative cache entry as a fresh entry associated - * with a new method (this maybe required to fixup speculative cache - * misses after Resolve.access()) - */ - void dupAllTo(Symbol from, Symbol to) { - Assert.check(cache.get(to) == null); - List entries = cache.get(from); - if (entries != null) { - cache.put(to, entries); - } - } - /** * Retrieve a speculative cache entry corresponding to given symbol * and resolution phase @@ -194,7 +180,7 @@ public class DeferredAttr extends JCTree.Visitor { DeferredAttrContext deferredAttrContext = resultInfo.checkContext.deferredAttrContext(); Assert.check(deferredAttrContext != emptyDeferredAttrContext); - List stuckVars = stuckVars(tree, resultInfo); + List stuckVars = stuckVars(tree, env, resultInfo); if (stuckVars.nonEmpty()) { deferredAttrContext.addDeferredAttrNode(this, resultInfo, stuckVars); return Type.noType; @@ -275,6 +261,10 @@ public class DeferredAttr extends JCTree.Visitor { @Override public void visitClassDef(JCClassDecl tree) { ClassSymbol csym = tree.sym; + //if something went wrong during method applicability check + //it is possible that nested expressions inside argument expression + //are left unchecked - in such cases there's nothing to clean up. + if (csym == null) return; enter.typeEnvs.remove(csym); chk.compiled.remove(csym.flatname); syms.classes.remove(csym.flatname); @@ -333,7 +323,7 @@ public class DeferredAttr extends JCTree.Visitor { */ void complete() { while (!deferredAttrNodes.isEmpty()) { - Set stuckVars = new HashSet(); + Set stuckVars = new LinkedHashSet(); boolean progress = false; //scan a defensive copy of the node list - this is because a deferred //attribution round can add new nodes to the list @@ -407,7 +397,7 @@ public class DeferredAttr extends JCTree.Visitor { /** an empty deferred attribution context - all methods throw exceptions */ final DeferredAttrContext emptyDeferredAttrContext = - new DeferredAttrContext(null, null, null, null) { + new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, null) { @Override void addDeferredAttrNode(DeferredType dt, ResultInfo ri, List stuckVars) { Assert.error("Empty deferred context!"); @@ -471,13 +461,13 @@ public class DeferredAttr extends JCTree.Visitor { public class RecoveryDeferredTypeMap extends DeferredTypeMap { public RecoveryDeferredTypeMap(AttrMode mode, Symbol msym, MethodResolutionPhase phase) { - super(mode, msym, phase); + super(mode, msym, phase != null ? phase : MethodResolutionPhase.BOX); } @Override protected Type typeOf(DeferredType dt) { Type owntype = super.typeOf(dt); - return owntype.hasTag(NONE) ? + return owntype == Type.noType ? recover(dt) : owntype; } @@ -495,16 +485,7 @@ public class DeferredAttr extends JCTree.Visitor { */ private Type recover(DeferredType dt) { dt.check(attr.new RecoveryInfo(deferredAttrContext)); - switch (TreeInfo.skipParens(dt.tree).getTag()) { - case LAMBDA: - case REFERENCE: - case CONDEXPR: - //propagate those deferred types to the - //diagnostic formatter - return dt; - default: - return super.apply(dt); - } + return super.apply(dt); } } @@ -513,11 +494,11 @@ public class DeferredAttr extends JCTree.Visitor { * an AST node can be type-checked */ @SuppressWarnings("fallthrough") - List stuckVars(JCTree tree, ResultInfo resultInfo) { - if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) { + List stuckVars(JCTree tree, Env env, ResultInfo resultInfo) { + if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) { return List.nil(); } else { - StuckChecker sc = new StuckChecker(resultInfo); + StuckChecker sc = new StuckChecker(resultInfo, env); sc.scan(tree); return List.from(sc.stuckVars); } @@ -534,7 +515,8 @@ public class DeferredAttr extends JCTree.Visitor { Type pt; Filter treeFilter; Infer.InferenceContext inferenceContext; - Set stuckVars = new HashSet(); + Set stuckVars = new LinkedHashSet(); + Env env; final Filter argsFilter = new Filter() { public boolean accepts(JCTree t) { @@ -563,10 +545,11 @@ public class DeferredAttr extends JCTree.Visitor { } }; - StuckChecker(ResultInfo resultInfo) { + StuckChecker(ResultInfo resultInfo, Env env) { this.pt = resultInfo.pt; this.inferenceContext = resultInfo.checkContext.inferenceContext(); this.treeFilter = argsFilter; + this.env = env; } @Override @@ -616,6 +599,7 @@ public class DeferredAttr extends JCTree.Visitor { if (!types.isFunctionalInterface(pt.tsym)) { return; } + Type descType = types.findDescriptorType(pt); List freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes()); stuckVars.addAll(freeArgVars); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index f5cdb99b06b..d0afb484158 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -272,9 +272,7 @@ public class Flow { Source source = Source.instance(context); allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis(); allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis(); - Options options = Options.instance(context); - allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses() && - options.isSet("allowEffectivelyFinalInInnerClasses"); //pre-lambda guard + allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses(); } /** diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java index 31e7ade9185..678e6216b4d 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java @@ -501,10 +501,10 @@ public class Infer { } for (Type t : funcInterfaceContext.undetvars) { UndetVar uv = (UndetVar)t; - minimizeInst(uv, Warner.noWarnings); + minimizeInst(uv, types.noWarnings); if (uv.inst == null && Type.filter(uv.getBounds(InferenceBound.UPPER), boundFilter).nonEmpty()) { - maximizeInst(uv, Warner.noWarnings); + maximizeInst(uv, types.noWarnings); } } @@ -801,7 +801,7 @@ public class Infer { for (Type t : varsToSolve) { UndetVar uv = (UndetVar)asFree(t, types); if (uv.inst == null) { - infer.minimizeInst(uv, Warner.noWarnings); + infer.minimizeInst(uv, types.noWarnings); if (uv.inst != null) { progress = true; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 4273e857535..828e7fbbe1f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -682,7 +682,7 @@ public class Lower extends TreeTranslator { /** Look up a method in a given scope. */ private MethodSymbol lookupMethod(DiagnosticPosition pos, Name name, Type qual, List args) { - return rs.resolveInternalMethod(pos, attrEnv, qual, name, args, null); + return rs.resolveInternalMethod(pos, attrEnv, qual, name, args, List.nil()); } /** Look up a constructor. @@ -3636,13 +3636,13 @@ public class Lower extends TreeTranslator { boolean qualifiedSuperAccess = tree.selected.hasTag(SELECT) && TreeInfo.name(tree.selected) == names._super && - !types.isDirectSuperInterface(((JCFieldAccess)tree.selected).selected.type, currentClass); + !types.isDirectSuperInterface(((JCFieldAccess)tree.selected).selected.type.tsym, currentClass); tree.selected = translate(tree.selected); if (tree.name == names._class) { result = classOf(tree.selected); } else if (tree.name == names._super && - types.isDirectSuperInterface(tree.selected.type, currentClass)) { + types.isDirectSuperInterface(tree.selected.type.tsym, currentClass)) { //default super call!! Not a classic qualified super call TypeSymbol supSym = tree.selected.type.tsym; Assert.checkNonNull(types.asSuper(currentClass.type, supSym)); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index e2242c3f2e9..5ca35ca7e69 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -427,6 +427,60 @@ public class Resolve { return c != null; } + /** + * Performs a recursive scan of a type looking for accessibility problems + * from current attribution environment + */ + void checkAccessibleType(Env env, Type t) { + accessibilityChecker.visit(t, env); + } + + /** + * Accessibility type-visitor + */ + Types.SimpleVisitor> accessibilityChecker = + new Types.SimpleVisitor>() { + + void visit(List ts, Env env) { + for (Type t : ts) { + visit(t, env); + } + } + + public Void visitType(Type t, Env env) { + return null; + } + + @Override + public Void visitArrayType(ArrayType t, Env env) { + visit(t.elemtype, env); + return null; + } + + @Override + public Void visitClassType(ClassType t, Env env) { + visit(t.getTypeArguments(), env); + if (!isAccessible(env, t, true)) { + accessBase(new AccessError(t.tsym), env.tree.pos(), env.enclClass.sym, t, t.tsym.name, true); + } + return null; + } + + @Override + public Void visitWildcardType(WildcardType t, Env env) { + visit(t.type, env); + return null; + } + + @Override + public Void visitMethodType(MethodType t, Env env) { + visit(t.getParameterTypes(), env); + visit(t.getReturnType(), env); + visit(t.getThrownTypes(), env); + return null; + } + }; + /** Try to instantiate the type of a method so that it fits * given type arguments and argument types. If succesful, return * the method's instantiated type, else return null. @@ -750,10 +804,6 @@ public class Resolve { public boolean compatible(Type found, Type req, Warner warn) { return types.isSubtypeUnchecked(found, inferenceContext.asFree(req, types), warn); } - - public boolean allowBoxing() { - return false; - } } /** @@ -770,10 +820,6 @@ public class Resolve { public boolean compatible(Type found, Type req, Warner warn) { return types.isConvertible(found, inferenceContext.asFree(req, types), warn); } - - public boolean allowBoxing() { - return true; - } } /** @@ -792,7 +838,7 @@ public class Resolve { DeferredAttr.DeferredAttrContext deferredAttrContext; - public MethodResultInfo(Type pt, MethodCheckContext checkContext, DeferredAttr.DeferredAttrContext deferredAttrContext) { + public MethodResultInfo(Type pt, CheckContext checkContext, DeferredAttr.DeferredAttrContext deferredAttrContext) { attr.super(VAL, pt, checkContext); this.deferredAttrContext = deferredAttrContext; } @@ -809,7 +855,12 @@ public class Resolve { @Override protected MethodResultInfo dup(Type newPt) { - return new MethodResultInfo(newPt, (MethodCheckContext)checkContext, deferredAttrContext); + return new MethodResultInfo(newPt, checkContext, deferredAttrContext); + } + + @Override + protected ResultInfo dup(CheckContext newContext) { + return new MethodResultInfo(pt, newContext, deferredAttrContext); } } @@ -1020,7 +1071,7 @@ public class Resolve { Assert.check(sym.kind < AMBIGUOUS); try { Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes, - allowBoxing, useVarargs, Warner.noWarnings); + allowBoxing, useVarargs, types.noWarnings); if (!operator) currentResolutionContext.addApplicableCandidate(sym, mt); } catch (InapplicableMethodException ex) { @@ -1921,28 +1972,31 @@ public class Resolve { (typeargtypes == null || !Type.isErroneous(typeargtypes)); } public List getArgumentTypes(ResolveError errSym, Symbol accessedSym, Name name, List argtypes) { - if (syms.operatorNames.contains(name)) { - return argtypes; - } else { - Symbol msym = errSym.kind == WRONG_MTH ? - ((InapplicableSymbolError)errSym).errCandidate().sym : accessedSym; + return (syms.operatorNames.contains(name)) ? + argtypes : + Type.map(argtypes, new ResolveDeferredRecoveryMap(accessedSym)); + } - List argtypes2 = Type.map(argtypes, - deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, msym, currentResolutionContext.step)); + class ResolveDeferredRecoveryMap extends DeferredAttr.RecoveryDeferredTypeMap { - if (msym != accessedSym) { - //fixup deferred type caches - this 'hack' is required because the symbol - //returned by InapplicableSymbolError.access() will hide the candidate - //method symbol that can be used for lookups in the speculative cache, - //causing problems in Attr.checkId() - for (Type t : argtypes) { - if (t.hasTag(DEFERRED)) { - DeferredType dt = (DeferredType)t; - dt.speculativeCache.dupAllTo(msym, accessedSym); - } + public ResolveDeferredRecoveryMap(Symbol msym) { + deferredAttr.super(AttrMode.SPECULATIVE, msym, currentResolutionContext.step); + } + + @Override + protected Type typeOf(DeferredType dt) { + Type res = super.typeOf(dt); + if (!res.isErroneous()) { + switch (TreeInfo.skipParens(dt.tree).getTag()) { + case LAMBDA: + case REFERENCE: + return dt; + case CONDEXPR: + return res == Type.recoveryType ? + dt : res; } } - return argtypes2; + return res; } } }; @@ -2069,7 +2123,6 @@ public class Resolve { } else if (allowMethodHandles) { MethodSymbol msym = (MethodSymbol)sym; if (msym.isSignaturePolymorphic(types)) { - env.info.pendingResolutionPhase = BASIC; return findPolymorphicSignatureInstance(env, sym, argtypes); } } @@ -2086,7 +2139,7 @@ public class Resolve { * @param argtypes The required argument types */ Symbol findPolymorphicSignatureInstance(Env env, - Symbol spMethod, + final Symbol spMethod, List argtypes) { Type mtype = infer.instantiatePolymorphicSignatureInstance(env, (MethodSymbol)spMethod, currentResolutionContext, argtypes); @@ -2098,7 +2151,12 @@ public class Resolve { // create the desired method long flags = ABSTRACT | HYPOTHETICAL | spMethod.flags() & Flags.AccessFlags; - Symbol msym = new MethodSymbol(flags, spMethod.name, mtype, spMethod.owner); + Symbol msym = new MethodSymbol(flags, spMethod.name, mtype, spMethod.owner) { + @Override + public Symbol baseSymbol() { + return spMethod; + } + }; polymorphicSignatureScope.enter(msym); return msym; } @@ -2707,7 +2765,7 @@ public class Resolve { } if (allowDefaultMethods && c.isInterface() && name == names._super && !isStatic(env) && - types.isDirectSuperInterface(c.type, env.enclClass.sym)) { + types.isDirectSuperInterface(c, env.enclClass.sym)) { //this might be a default super call if one of the superinterfaces is 'c' for (Type t : pruneInterfaces(env.enclClass.type)) { if (t.tsym == c) { @@ -3150,7 +3208,7 @@ public class Resolve { "cant.apply.symbols", name == names.init ? KindName.CONSTRUCTOR : absentKind(kind), name == names.init ? site.tsym.name : name, - argtypes); + methodArguments(argtypes)); return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site)); } else { return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos, diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java index e06da066d14..8b1b7f54c9a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -133,7 +133,7 @@ public class TransTypes extends TreeTranslator { JCExpression coerce(JCExpression tree, Type target) { Type btarget = target.baseType(); if (tree.type.isPrimitive() == target.isPrimitive()) { - return types.isAssignable(tree.type, btarget, Warner.noWarnings) + return types.isAssignable(tree.type, btarget, types.noWarnings) ? tree : cast(tree, btarget); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java index 1f86b01f1ea..43c65db98b2 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -941,18 +941,6 @@ public class ClassReader implements Completer { new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) { protected void read(Symbol sym, int attrLen) { - if (currentOwner.isInterface() && - (sym.flags_field & ABSTRACT) == 0 && !name.equals(names.clinit)) { - if (majorVersion > Target.JDK1_8.majorVersion || - //todo replace with Target.Version when available - (majorVersion == Target.JDK1_8.majorVersion && minorVersion >= Target.JDK1_8.minorVersion)) { - currentOwner.flags_field |= DEFAULT; - sym.flags_field |= DEFAULT | ABSTRACT; - } else { - //protect against ill-formed classfiles - throw new CompletionFailure(currentOwner, "default method found in pre JDK 8 classfile"); - } - } if (readAllOfClassFile || saveParameterNames) ((MethodSymbol)sym).code = readCode(sym); else @@ -1753,6 +1741,17 @@ public class ClassReader implements Completer { long flags = adjustMethodFlags(nextChar()); Name name = readName(nextChar()); Type type = readType(nextChar()); + if (currentOwner.isInterface() && + (flags & ABSTRACT) == 0 && !name.equals(names.clinit)) { + if (majorVersion > Target.JDK1_8.majorVersion || + (majorVersion == Target.JDK1_8.majorVersion && minorVersion >= Target.JDK1_8.minorVersion)) { + currentOwner.flags_field |= DEFAULT; + flags |= DEFAULT | ABSTRACT; + } else { + //protect against ill-formed classfiles + throw new CompletionFailure(currentOwner, "default method found in pre JDK 8 classfile"); + } + } if (name == names.init && currentOwner.hasOuterInstance()) { // Sometimes anonymous classes don't have an outer // instance, however, there is no reliable way to tell so diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java index dbcee2841a4..8ac53f948f4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java @@ -95,10 +95,7 @@ public class Pool { * package. Return the object's index in the pool. */ public int put(Object value) { - if (value instanceof MethodSymbol) - value = new Method((MethodSymbol)value); - else if (value instanceof VarSymbol) - value = new Variable((VarSymbol)value); + value = makePoolValue(value); // assert !(value instanceof Type.TypeVar); Integer index = indices.get(value); if (index == null) { @@ -115,6 +112,18 @@ public class Pool { return index.intValue(); } + Object makePoolValue(Object o) { + if (o instanceof DynamicMethodSymbol) { + return new DynamicMethod((DynamicMethodSymbol)o); + } else if (o instanceof MethodSymbol) { + return new Method((MethodSymbol)o); + } else if (o instanceof VarSymbol) { + return new Variable((VarSymbol)o); + } else { + return o; + } + } + /** Return the given object's index in the pool, * or -1 if object is not in there. */ @@ -145,6 +154,36 @@ public class Pool { } } + static class DynamicMethod extends Method { + + DynamicMethod(DynamicMethodSymbol m) { + super(m); + } + + @Override + public boolean equals(Object other) { + if (!super.equals(other)) return false; + if (!(other instanceof DynamicMethod)) return false; + DynamicMethodSymbol dm1 = (DynamicMethodSymbol)m; + DynamicMethodSymbol dm2 = (DynamicMethodSymbol)((DynamicMethod)other).m; + return dm1.bsm == dm2.bsm && + dm1.bsmKind == dm2.bsmKind && + Arrays.equals(dm1.staticArgs, dm2.staticArgs); + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + DynamicMethodSymbol dm = (DynamicMethodSymbol)m; + hash += dm.bsmKind * 7 + + dm.bsm.hashCode() * 11; + for (int i = 0; i < dm.staticArgs.length; i++) { + hash += (dm.staticArgs[i].hashCode() * 23); + } + return hash; + } + } + static class Variable extends DelegatedSymbol { VarSymbol v; Variable(VarSymbol v) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index bfa1433304b..35fa62915bb 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -121,12 +121,9 @@ public class JavacParser implements Parser { this.allowDiamond = source.allowDiamond(); this.allowMulticatch = source.allowMulticatch(); this.allowStringFolding = fac.options.getBoolean("allowStringFolding", true); - this.allowLambda = source.allowLambda() && - fac.options.isSet("allowLambda"); //pre-lambda guard - this.allowMethodReferences = source.allowMethodReferences() && - fac.options.isSet("allowMethodReferences"); //pre-lambda guard - this.allowDefaultMethods = source.allowDefaultMethods() && - fac.options.isSet("allowDefaultMethods"); //pre-lambda guard + this.allowLambda = source.allowLambda(); + this.allowMethodReferences = source.allowMethodReferences(); + this.allowDefaultMethods = source.allowDefaultMethods(); this.keepDocComments = keepDocComments; docComments = newDocCommentTable(keepDocComments, fac); this.keepLineMap = keepLineMap; diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index e742ce983ec..2ac10a97658 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -170,19 +170,6 @@ compiler.misc.cant.apply.symbol=\ compiler.misc.cant.apply.symbols=\ no suitable {0} found for {1}({2}) - -# 0: type -compiler.err.cant.access.arg.type.in.functional.desc=\ - cannot access parameter type {0} in target functional descriptor - -# 0: type -compiler.err.cant.access.return.in.functional.desc=\ - cannot access return type {0} in target functional descriptor - -# 0: type -compiler.err.cant.access.thrown.in.functional.desc=\ - cannot access thrown type {0} in target functional descriptor - # 0: symbol kind, 1: symbol compiler.misc.no.abstracts=\ no abstract method found in {0} {1} @@ -257,9 +244,6 @@ compiler.err.cant.inherit.from.final=\ compiler.err.cant.ref.before.ctor.called=\ cannot reference {0} before supertype constructor has been called -compiler.err.cant.ret.val.from.meth.decl.void=\ - cannot return a value from method whose result type is void - compiler.err.cant.select.static.class.from.param.type=\ cannot select a static class from a parameterized type @@ -661,8 +645,8 @@ compiler.err.missing.ret.stmt=\ compiler.misc.missing.ret.val=\ missing return value -compiler.err.missing.ret.val=\ - missing return value +compiler.misc.unexpected.ret.val=\ + unexpected return value # 0: set of modifier compiler.err.mod.not.allowed.here=\ @@ -708,6 +692,9 @@ compiler.err.neither.conditional.subtype=\ compiler.misc.incompatible.type.in.conditional=\ bad type in conditional expression; {0} +compiler.misc.conditional.target.cant.be.void=\ + target-type for conditional expression cannot be void + # 0: type compiler.misc.incompatible.ret.type.in.lambda=\ bad return type in lambda expression\n\ @@ -960,7 +947,7 @@ compiler.err.illegal.default.super.call=\ # 0: symbol, 1: type compiler.misc.overridden.default=\ - method {0} is overridden in {2} + method {0} is overridden in {1} # 0: symbol, 1: symbol compiler.misc.redundant.supertype=\ diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java index 5fc31dc733f..e2f7b89399b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java @@ -1110,7 +1110,7 @@ public class Pretty extends JCTree.Visitor { public void visitReference(JCMemberReference tree) { try { printExpr(tree.expr); - print("#"); + print("::"); if (tree.typeargs != null) { print("<"); printExprs(tree.typeargs); diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java index 6cdbb2447db..ae637f56c3b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java @@ -525,7 +525,8 @@ public class RichDiagnosticFormatter extends bound = ((ErrorType)bound).getOriginalType(); //retrieve the bound list - if the type variable //has not been attributed the bound is not set - List bounds = bound != null ? + List bounds = (bound != null) && + (bound.hasTag(CLASS) || bound.hasTag(TYPEVAR)) ? types.getBounds(t) : List.nil(); diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/Warner.java b/langtools/src/share/classes/com/sun/tools/javac/util/Warner.java index 8b7643900dc..7b993c1bf16 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/Warner.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/Warner.java @@ -39,7 +39,6 @@ import java.util.EnumSet; * deletion without notice. */ public class Warner { - public static final Warner noWarnings = new Warner(); private DiagnosticPosition pos = null; protected boolean warned = false; diff --git a/langtools/test/tools/javac/conditional/Conditional.java b/langtools/test/tools/javac/conditional/Conditional.java index 84417385560..c637103984f 100644 --- a/langtools/test/tools/javac/conditional/Conditional.java +++ b/langtools/test/tools/javac/conditional/Conditional.java @@ -27,8 +27,8 @@ * @summary Conditional operator applies assignment conversion * @author Tim Hanson, BEA * - * @compile -XDallowPoly Conditional.java - * @compile/fail Conditional.java + * @compile Conditional.java + * @compile/fail -source 7 Conditional.java */ import java.util.*; diff --git a/langtools/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java b/langtools/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java index 746b296edfc..0e533acbe6f 100644 --- a/langtools/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java +++ b/langtools/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java @@ -25,7 +25,7 @@ * @test * @summary check that default methods don't cause ClassReader to complete classes recursively * @author Maurizio Cimadamore - * @compile -XDallowDefaultMethods pkg/Foo.java + * @compile pkg/Foo.java * @compile ClassReaderTest.java */ diff --git a/langtools/test/tools/javac/defaultMethods/Neg01.java b/langtools/test/tools/javac/defaultMethods/Neg01.java index 6a3c19fdfef..bbf1aba7eaa 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg01.java +++ b/langtools/test/tools/javac/defaultMethods/Neg01.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary negative test for ambiguous defaults - * @compile/fail/ref=Neg01.out -XDallowDefaultMethods -XDrawDiagnostics Neg01.java + * @compile/fail/ref=Neg01.out -XDrawDiagnostics Neg01.java */ class Neg01 { diff --git a/langtools/test/tools/javac/defaultMethods/Neg02.java b/langtools/test/tools/javac/defaultMethods/Neg02.java index 0fa686557de..deb35a19d78 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg02.java +++ b/langtools/test/tools/javac/defaultMethods/Neg02.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that ill-formed MI hierarchies do not compile - * @compile/fail/ref=Neg02.out -XDallowDefaultMethods -XDrawDiagnostics Neg02.java + * @compile/fail/ref=Neg02.out -XDrawDiagnostics Neg02.java */ class Neg02 { diff --git a/langtools/test/tools/javac/defaultMethods/Neg03.java b/langtools/test/tools/javac/defaultMethods/Neg03.java index 94ea0016b43..ba6262c853b 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg03.java +++ b/langtools/test/tools/javac/defaultMethods/Neg03.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that re-abstraction works properly - * @compile/fail/ref=Neg03.out -XDallowDefaultMethods -XDrawDiagnostics Neg03.java + * @compile/fail/ref=Neg03.out -XDrawDiagnostics Neg03.java */ class Neg03 { diff --git a/langtools/test/tools/javac/defaultMethods/Neg04.java b/langtools/test/tools/javac/defaultMethods/Neg04.java index 21aac883702..a057f35d620 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg04.java +++ b/langtools/test/tools/javac/defaultMethods/Neg04.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that default method must have most specific return type - * @compile/fail/ref=Neg04.out -XDallowDefaultMethods -XDrawDiagnostics Neg04.java + * @compile/fail/ref=Neg04.out -XDrawDiagnostics Neg04.java */ class Neg04 { diff --git a/langtools/test/tools/javac/defaultMethods/Neg05.java b/langtools/test/tools/javac/defaultMethods/Neg05.java index c34ff3ebde6..3550c497241 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg05.java +++ b/langtools/test/tools/javac/defaultMethods/Neg05.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that abstract methods are compatible with inherited defaults - * @compile/fail/ref=Neg05.out -XDallowDefaultMethods -XDrawDiagnostics Neg05.java + * @compile/fail/ref=Neg05.out -XDrawDiagnostics Neg05.java */ class Neg05 { diff --git a/langtools/test/tools/javac/defaultMethods/Neg06.java b/langtools/test/tools/javac/defaultMethods/Neg06.java index 52c88b97551..602ece8166f 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg06.java +++ b/langtools/test/tools/javac/defaultMethods/Neg06.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary flow analysis is not run on inlined default bodies - * @compile/fail/ref=Neg06.out -XDallowDefaultMethods -XDrawDiagnostics Neg06.java + * @compile/fail/ref=Neg06.out -XDrawDiagnostics Neg06.java */ class Neg06 { diff --git a/langtools/test/tools/javac/defaultMethods/Neg07.java b/langtools/test/tools/javac/defaultMethods/Neg07.java index a5d0ab70fbe..c11f3157b22 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg07.java +++ b/langtools/test/tools/javac/defaultMethods/Neg07.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that default overrides are properly type-checked - * @compile/fail/ref=Neg07.out -XDallowDefaultMethods -XDrawDiagnostics Neg07.java + * @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java */ class Neg07 { diff --git a/langtools/test/tools/javac/defaultMethods/Neg08.java b/langtools/test/tools/javac/defaultMethods/Neg08.java index 918dc2df172..5e3ef07e719 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg08.java +++ b/langtools/test/tools/javac/defaultMethods/Neg08.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that default overrides are properly type-checked - * @compile/fail/ref=Neg08.out -XDallowDefaultMethods -XDrawDiagnostics Neg08.java + * @compile/fail/ref=Neg08.out -XDrawDiagnostics Neg08.java */ class Neg08 { interface I { diff --git a/langtools/test/tools/javac/defaultMethods/Neg09.java b/langtools/test/tools/javac/defaultMethods/Neg09.java index 9f662e5e42e..cabda07c321 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg09.java +++ b/langtools/test/tools/javac/defaultMethods/Neg09.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that default overrides are properly type-checked - * @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDallowDefaultMethods -XDrawDiagnostics Neg09.java + * @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg09.java */ import java.util.List; diff --git a/langtools/test/tools/javac/defaultMethods/Neg10.java b/langtools/test/tools/javac/defaultMethods/Neg10.java index ce904dd599b..3ecb1af86e1 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg10.java +++ b/langtools/test/tools/javac/defaultMethods/Neg10.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that default overrides are properly type-checked - * @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDallowDefaultMethods -XDrawDiagnostics Neg10.java + * @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg10.java */ class Neg10 { interface I { diff --git a/langtools/test/tools/javac/defaultMethods/Neg11.java b/langtools/test/tools/javac/defaultMethods/Neg11.java index dde9f090296..acf88f65ef2 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg11.java +++ b/langtools/test/tools/javac/defaultMethods/Neg11.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that default overrides are properly type-checked - * @compile/fail/ref=Neg11.out -XDallowDefaultMethods -XDrawDiagnostics Neg11.java + * @compile/fail/ref=Neg11.out -XDrawDiagnostics Neg11.java */ class Neg11 { interface I { diff --git a/langtools/test/tools/javac/defaultMethods/Neg12.java b/langtools/test/tools/javac/defaultMethods/Neg12.java index 33282121f83..e61245bf7e3 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg12.java +++ b/langtools/test/tools/javac/defaultMethods/Neg12.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that abstract methods are discarded in overload resolution diags - * @compile/fail/ref=Neg12.out -XDallowDefaultMethods -XDrawDiagnostics Neg12.java + * @compile/fail/ref=Neg12.out -XDrawDiagnostics Neg12.java */ class Neg12 { diff --git a/langtools/test/tools/javac/defaultMethods/Neg12.out b/langtools/test/tools/javac/defaultMethods/Neg12.out index 70efbf7344f..8083d03a32b 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg12.out +++ b/langtools/test/tools/javac/defaultMethods/Neg12.out @@ -1,4 +1,4 @@ Neg12.java:21:12: compiler.err.does.not.override.abstract: Neg12.D, m(java.lang.String), Neg12.I2 -Neg12.java:24:10: compiler.err.cant.apply.symbols: kindname.method, m, ,{(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch))} +Neg12.java:24:10: compiler.err.cant.apply.symbols: kindname.method, m, compiler.misc.no.args,{(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch))} Neg12.java:25:10: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Integer, compiler.misc.no.args, kindname.class, Neg12.B, (compiler.misc.arg.length.mismatch) 3 errors diff --git a/langtools/test/tools/javac/defaultMethods/Neg13.java b/langtools/test/tools/javac/defaultMethods/Neg13.java index d4df32677d2..e512cc3a65b 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg13.java +++ b/langtools/test/tools/javac/defaultMethods/Neg13.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that default method overriding object members are flagged as error - * @compile/fail/ref=Neg13.out -XDallowDefaultMethods -XDrawDiagnostics Neg13.java + * @compile/fail/ref=Neg13.out -XDrawDiagnostics Neg13.java */ interface Neg13 { default protected Object clone() { return null; } //protected not allowed here diff --git a/langtools/test/tools/javac/defaultMethods/Neg14.java b/langtools/test/tools/javac/defaultMethods/Neg14.java index 74b54e092a8..9c3c6a69e3c 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg14.java +++ b/langtools/test/tools/javac/defaultMethods/Neg14.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that a class cannot have two sibling interfaces with a default and abstract method - * @compile/fail/ref=Neg14.out -XDallowDefaultMethods -XDrawDiagnostics Neg14.java + * @compile/fail/ref=Neg14.out -XDrawDiagnostics Neg14.java */ class Neg14 { interface IA { int m(); } diff --git a/langtools/test/tools/javac/defaultMethods/Neg15.java b/langtools/test/tools/javac/defaultMethods/Neg15.java index 0c6968c0502..7c42167d75f 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg15.java +++ b/langtools/test/tools/javac/defaultMethods/Neg15.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that level skipping in default super calls is correctly rejected - * @compile/fail/ref=Neg15.out -XDallowDefaultMethods -XDrawDiagnostics Neg15.java + * @compile/fail/ref=Neg15.out -XDrawDiagnostics Neg15.java */ class Neg15 { interface I { default void m() { } } diff --git a/langtools/test/tools/javac/defaultMethods/Neg16.java b/langtools/test/tools/javac/defaultMethods/Neg16.java index 14abadeb9e6..1022fda22c8 100644 --- a/langtools/test/tools/javac/defaultMethods/Neg16.java +++ b/langtools/test/tools/javac/defaultMethods/Neg16.java @@ -1,7 +1,7 @@ /* * @test /nodynamiccopyright/ * @summary check that level skipping in default super calls is correctly rejected - * @compile/fail/ref=Neg16.out -XDallowDefaultMethods -XDrawDiagnostics Neg16.java + * @compile/fail/ref=Neg16.out -XDrawDiagnostics Neg16.java */ class Neg16 { interface I { default void m() { } } diff --git a/langtools/test/tools/javac/defaultMethods/Pos01.java b/langtools/test/tools/javac/defaultMethods/Pos01.java index 314619ce797..13fa6b47e83 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos01.java +++ b/langtools/test/tools/javac/defaultMethods/Pos01.java @@ -24,14 +24,12 @@ /* * @test * @summary basic test for default methods - * @ignore awaits lambda support * @author Maurizio Cimadamore - * @compile -XDallowLambda -XDallowPoly -XDallowDefaultMethods Pos01.java */ import java.util.*; -class Pos01 { +public class Pos01 { interface Mapper { T map(T in); diff --git a/langtools/test/tools/javac/defaultMethods/Pos02.java b/langtools/test/tools/javac/defaultMethods/Pos02.java index 5ddeaad4378..597e7f50c79 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos02.java +++ b/langtools/test/tools/javac/defaultMethods/Pos02.java @@ -25,7 +25,7 @@ * @test * @summary test for explicit resolution of ambiguous default methods * @author Maurizio Cimadamore - * @compile -XDallowDefaultMethods Pos02.java + * @compile Pos02.java */ class Pos02 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos04.java b/langtools/test/tools/javac/defaultMethods/Pos04.java index fce305878db..3cc0cd4c4c5 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos04.java +++ b/langtools/test/tools/javac/defaultMethods/Pos04.java @@ -25,7 +25,7 @@ * @test * @summary test for overriding with default method * @author Maurizio Cimadamore - * @compile -XDallowDefaultMethods Pos04.java + * @compile Pos04.java */ class Pos04 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos05.java b/langtools/test/tools/javac/defaultMethods/Pos05.java index 380e907501f..92a7eaccc9c 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos05.java +++ b/langtools/test/tools/javac/defaultMethods/Pos05.java @@ -25,7 +25,7 @@ * @test * @summary check that indirectly inherited default methods are discovered during resolution * @author Maurizio Cimadamore - * @compile -XDallowDefaultMethods Pos05.java + * @compile Pos05.java */ class Pos05 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos06.java b/langtools/test/tools/javac/defaultMethods/Pos06.java index 62855653948..3263e9276e2 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos06.java +++ b/langtools/test/tools/javac/defaultMethods/Pos06.java @@ -25,7 +25,7 @@ * @test * @summary check that well-formed MI hierarchies behaves well w.r.t. method resolution (i.e. no ambiguities) * @author Maurizio Cimadamore - * @compile -XDallowDefaultMethods Pos06.java + * @compile Pos06.java */ class Pos06 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos07.java b/langtools/test/tools/javac/defaultMethods/Pos07.java index fe9a3455f49..6e1c2308bb5 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos07.java +++ b/langtools/test/tools/javac/defaultMethods/Pos07.java @@ -25,7 +25,7 @@ * @test * @summary check that compilation order does not matter * @author Maurizio Cimadamore - * @compile -XDallowDefaultMethods Pos07.java + * @compile Pos07.java */ class Pos07 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos08.java b/langtools/test/tools/javac/defaultMethods/Pos08.java index 9f0a0099547..b12486a7f8b 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos08.java +++ b/langtools/test/tools/javac/defaultMethods/Pos08.java @@ -25,7 +25,7 @@ * @test * @summary check that common overrider solves default method conflicts * @author Maurizio Cimadamore - * @compile -XDallowDefaultMethods Pos08.java + * @compile Pos08.java */ class Pos08 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos10.java b/langtools/test/tools/javac/defaultMethods/Pos10.java index 764ef4d1b27..7f0039a685b 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos10.java +++ b/langtools/test/tools/javac/defaultMethods/Pos10.java @@ -25,7 +25,7 @@ * @test * @summary check that type-variables in generic extension decl can be accessed from default impl * @author Maurizio Cimadamore - * @compile -XDallowDefaultMethods Pos10.java + * @compile Pos10.java */ class Pos10 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos11.java b/langtools/test/tools/javac/defaultMethods/Pos11.java index a55c8dd7c37..91b83ccbb1c 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos11.java +++ b/langtools/test/tools/javac/defaultMethods/Pos11.java @@ -25,7 +25,7 @@ * @test * @summary complex test with conflict resolution via overriding * @author Brian Goetz - * @compile -XDallowDefaultMethods Pos11.java + * @compile Pos11.java */ class Pos11 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos12.java b/langtools/test/tools/javac/defaultMethods/Pos12.java index fdebd993686..4db7f3ca182 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos12.java +++ b/langtools/test/tools/javac/defaultMethods/Pos12.java @@ -24,7 +24,7 @@ /* * @test * @summary check that 'this' can be used from within an extension method - * @compile -XDallowDefaultMethods Pos12.java + * @compile Pos12.java */ interface Pos12 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos13.java b/langtools/test/tools/javac/defaultMethods/Pos13.java index b6aeb52ca5b..b9acba34b44 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos13.java +++ b/langtools/test/tools/javac/defaultMethods/Pos13.java @@ -24,7 +24,7 @@ /* * @test * @summary qualified 'this' inside default method causes StackOverflowException - * @compile -XDallowDefaultMethods Pos13.java + * @compile Pos13.java */ public class Pos13 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos14.java b/langtools/test/tools/javac/defaultMethods/Pos14.java index 1eb713361af..d8ac04af981 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos14.java +++ b/langtools/test/tools/javac/defaultMethods/Pos14.java @@ -24,7 +24,7 @@ /* * @test * @summary check that overload resolution selects most specific signature - * @compile -XDallowDefaultMethods Pos14.java + * @compile Pos14.java */ class Pos14 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos15.java b/langtools/test/tools/javac/defaultMethods/Pos15.java index 01cc1bf9c73..a2dad21b237 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos15.java +++ b/langtools/test/tools/javac/defaultMethods/Pos15.java @@ -24,7 +24,7 @@ /* * @test * @summary check that overload resolution selects most specific signature - * @compile -XDallowDefaultMethods Pos15.java + * @compile Pos15.java */ class Pos15 { diff --git a/langtools/test/tools/javac/defaultMethods/Pos16.java b/langtools/test/tools/javac/defaultMethods/Pos16.java index 6a4f157740f..eca63b94faf 100644 --- a/langtools/test/tools/javac/defaultMethods/Pos16.java +++ b/langtools/test/tools/javac/defaultMethods/Pos16.java @@ -24,7 +24,7 @@ /* * @test * @summary 'class wins' should not short-circuit overload resolution - * @compile -XDallowDefaultMethods Pos16.java + * @compile Pos16.java */ class Pos16 { diff --git a/langtools/test/tools/javac/defaultMethods/TestDefaultBody.java b/langtools/test/tools/javac/defaultMethods/TestDefaultBody.java index d182dfd1a88..be3f6bfbf94 100644 --- a/langtools/test/tools/javac/defaultMethods/TestDefaultBody.java +++ b/langtools/test/tools/javac/defaultMethods/TestDefaultBody.java @@ -23,10 +23,7 @@ /* * @test - * @ignore awaits for VM support * @summary check that code attributed for default methods is correctly generated - * @compile -XDallowDefaultMethods TestDefaultBody.java - * @run main TestDefaultBody */ import com.sun.tools.classfile.AccessFlags; diff --git a/langtools/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java b/langtools/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java index edfd01b2771..a52cfb7240e 100644 --- a/langtools/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java +++ b/langtools/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java @@ -25,8 +25,6 @@ * @test * @ignore awaits for VM support * @summary check that javac does not generate bridge methods for defaults - * @compile -XDallowDefaultMethods TestNoBridgeOnDefaults.java - * @run main TestNoBridgeOnDefaults */ import com.sun.tools.classfile.ClassFile; diff --git a/langtools/test/tools/javac/defaultMethods/fd/FDTest.java b/langtools/test/tools/javac/defaultMethods/fd/FDTest.java index 85f85fa7abb..04a295209e1 100644 --- a/langtools/test/tools/javac/defaultMethods/fd/FDTest.java +++ b/langtools/test/tools/javac/defaultMethods/fd/FDTest.java @@ -82,7 +82,7 @@ public class FDTest { void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, - Arrays.asList("-XDallowDefaultMethods"), null, Arrays.asList(source)); + null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { diff --git a/langtools/test/tools/javac/defaultMethods/separate/Separate.java b/langtools/test/tools/javac/defaultMethods/separate/Separate.java index f01d672da33..7dcf4e3ac2b 100644 --- a/langtools/test/tools/javac/defaultMethods/separate/Separate.java +++ b/langtools/test/tools/javac/defaultMethods/separate/Separate.java @@ -25,8 +25,8 @@ * @test * @summary smoke test for separate compilation of default methods * @author Maurizio Cimadamore - * @compile -XDallowDefaultMethods pkg1/A.java - * @compile -XDallowDefaultMethods Separate.java + * @compile pkg1/A.java + * @compile Separate.java */ import pkg1.A; diff --git a/langtools/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java b/langtools/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java index 21bb467345b..7c4ced6d293 100644 --- a/langtools/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java +++ b/langtools/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java @@ -323,7 +323,7 @@ public class TestDefaultSuperCall { void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, - Arrays.asList("-XDallowDefaultMethods"), null, Arrays.asList(source)); + null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { diff --git a/langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java b/langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java index 973e4c6f7f5..c67146474fa 100644 --- a/langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java +++ b/langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java @@ -54,7 +54,7 @@ public class TestDefaultMethodsSyntax { } List getOptions() { - return Arrays.asList("-XDallowDefaultMethods", "-source", versionString); + return Arrays.asList("-source", versionString); } } diff --git a/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java b/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java index 169de29d42f..ce4f3238abd 100644 --- a/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java +++ b/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java @@ -24,7 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.cant.access.inner.cls.constr // key: compiler.misc.invalid.mref -// options: -XDallowMethodReferences class CantAccessInnerClsConstructor { diff --git a/langtools/test/tools/javac/diags/examples/CantApplySymbolFragment.java b/langtools/test/tools/javac/diags/examples/CantApplySymbolFragment.java index 5ce08eb163b..0ed248c829f 100644 --- a/langtools/test/tools/javac/diags/examples/CantApplySymbolFragment.java +++ b/langtools/test/tools/javac/diags/examples/CantApplySymbolFragment.java @@ -26,7 +26,6 @@ // key: compiler.misc.no.conforming.assignment.exists // key: compiler.misc.cant.apply.symbol // key: compiler.misc.invalid.mref -// options: -XDallowMethodReferences class CantApplySymbolFragment { diff --git a/langtools/test/tools/javac/diags/examples/CantApplySymbolsFragment.java b/langtools/test/tools/javac/diags/examples/CantApplySymbolsFragment.java index 77a740b3473..d49b7f8a979 100644 --- a/langtools/test/tools/javac/diags/examples/CantApplySymbolsFragment.java +++ b/langtools/test/tools/javac/diags/examples/CantApplySymbolsFragment.java @@ -28,7 +28,6 @@ // key: compiler.misc.inapplicable.method // key: compiler.misc.cant.apply.symbols // key: compiler.misc.invalid.mref -// options: -XDallowMethodReferences class CantApplySymbolsFragment { diff --git a/langtools/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java b/langtools/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java index fabb43ed80b..421d1f0a768 100644 --- a/langtools/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java +++ b/langtools/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java @@ -24,7 +24,6 @@ // key: compiler.err.cant.ref.non.effectively.final.var // key: compiler.misc.inner.cls // key: compiler.misc.lambda -// options: -XDallowLambda -XDallowEffectivelyFinalInInnerClasses class CantRefNonEffectivelyFinalVar { void test() { diff --git a/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java b/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java index 215dffbd148..d8e11601058 100644 --- a/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java +++ b/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java @@ -24,7 +24,6 @@ // key: compiler.misc.cant.resolve.location.args // key: compiler.misc.location // key: compiler.err.invalid.mref -// options: -XDallowMethodReferences class CantResolveLocationArgsFragment { diff --git a/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java b/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java index daf2310ae08..b522e7fc6ce 100644 --- a/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java +++ b/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java @@ -24,7 +24,6 @@ // key: compiler.misc.cant.resolve.location.args.params // key: compiler.misc.location // key: compiler.err.invalid.mref -// options: -XDallowMethodReferences class CantResolveLocationArgsParamsFragment { diff --git a/langtools/test/tools/javac/diags/examples/ConditionalTargetCantBeVoid.java b/langtools/test/tools/javac/diags/examples/ConditionalTargetCantBeVoid.java new file mode 100644 index 00000000000..7ba09912a89 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/ConditionalTargetCantBeVoid.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.prob.found.req +// key: compiler.misc.incompatible.ret.type.in.lambda +// key: compiler.misc.conditional.target.cant.be.void + +class ConditionalTargetCantBeVoid { + + interface SAM { + void m(); + } + + void test(boolean cond, Object o1, Object o2) { + SAM s = ()-> cond ? o1 : o2; + } +} diff --git a/langtools/test/tools/javac/diags/examples/CyclicInference.java b/langtools/test/tools/javac/diags/examples/CyclicInference.java index 4f51c9c2df7..cc929332404 100644 --- a/langtools/test/tools/javac/diags/examples/CyclicInference.java +++ b/langtools/test/tools/javac/diags/examples/CyclicInference.java @@ -23,7 +23,6 @@ // key: compiler.err.cant.apply.symbol // key: compiler.misc.cyclic.inference -// options: -XDallowLambda -XDallowPoly class CyclicInference { interface SAM { diff --git a/langtools/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java b/langtools/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java index d5fd7d515f4..395a3c2a8e5 100644 --- a/langtools/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java +++ b/langtools/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java @@ -22,7 +22,6 @@ */ // key: compiler.err.default.overrides.object.member -// options: -XDallowDefaultMethods interface DefaultOverridesObjectMember { default String toString() { return ""; } diff --git a/langtools/test/tools/javac/diags/examples/IncompatibleAbstracts.java b/langtools/test/tools/javac/diags/examples/IncompatibleAbstracts.java index 13b33b0d793..351ce64d9dd 100644 --- a/langtools/test/tools/javac/diags/examples/IncompatibleAbstracts.java +++ b/langtools/test/tools/javac/diags/examples/IncompatibleAbstracts.java @@ -24,7 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.not.a.functional.intf.1 // key: compiler.misc.incompatible.abstracts -// options: -XDallowLambda class IncompatibleAbstracts { diff --git a/langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java b/langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java index aeb73b84d02..be53ae275cb 100644 --- a/langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java +++ b/langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java @@ -23,7 +23,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.incompatible.arg.types.in.lambda -// options: -XDallowLambda -XDallowPoly class IncompatibleArgTypesInLambda { interface SAM { diff --git a/langtools/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java b/langtools/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java index cbb0912b5b6..4873516465d 100644 --- a/langtools/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java +++ b/langtools/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java @@ -26,7 +26,6 @@ // key: compiler.misc.incompatible.descs.in.functional.intf // key: compiler.misc.descriptor // key: compiler.misc.descriptor.throws -// options: -XDallowLambda class IncompatibleDescsInFunctionalIntf { interface A { diff --git a/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java b/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java index fd087553ea8..0270a08d7b2 100644 --- a/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java +++ b/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java @@ -24,7 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.inconvertible.types // key: compiler.misc.incompatible.ret.type.in.lambda -// options: -XDallowLambda -XDallowPoly class IncompatibleRetTypeInLambda { interface SAM { diff --git a/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java b/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java index 6ffadd08b99..aeca94812e2 100644 --- a/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java +++ b/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java @@ -24,7 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.inconvertible.types // key: compiler.misc.incompatible.ret.type.in.mref -// options: -XDallowMethodReferences -XDallowPoly class IncompatibleRetTypeInMref { interface SAM { diff --git a/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java b/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java index 14543406180..53845226a4b 100644 --- a/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java +++ b/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java @@ -22,7 +22,6 @@ */ // key: compiler.err.incompatible.thrown.types.in.lambda -// options: -XDallowLambda class IncompatibleThrownTypesInLambda { interface SAM { diff --git a/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java b/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java index 4403cb707f2..952314a294c 100644 --- a/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java +++ b/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java @@ -22,7 +22,6 @@ */ // key: compiler.err.incompatible.thrown.types.in.mref -// options: -XDallowMethodReferences class IncompatibleThrownTypesInMref { interface SAM { diff --git a/langtools/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java b/langtools/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java index 8a188e6fe4d..25e8e3d5658 100644 --- a/langtools/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java +++ b/langtools/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java @@ -24,7 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.incompatible.type.in.conditional // key: compiler.misc.inconvertible.types -// options: -XDallowPoly class IncompatibleTypesInConditional { diff --git a/langtools/test/tools/javac/diags/examples/InvalidGenericDescInFunctionalInterface.java b/langtools/test/tools/javac/diags/examples/InvalidGenericDescInFunctionalInterface.java index 4f76dae18e5..a43795ea1dc 100644 --- a/langtools/test/tools/javac/diags/examples/InvalidGenericDescInFunctionalInterface.java +++ b/langtools/test/tools/javac/diags/examples/InvalidGenericDescInFunctionalInterface.java @@ -23,7 +23,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.invalid.generic.desc.in.functional.intf -// options: -XDallowLambda class InvalidGenericDescInFunctionalIntf { diff --git a/langtools/test/tools/javac/diags/examples/LocalVarNeedsFinal.java b/langtools/test/tools/javac/diags/examples/LocalVarNeedsFinal.java index fea47efecec..fc7c5538534 100644 --- a/langtools/test/tools/javac/diags/examples/LocalVarNeedsFinal.java +++ b/langtools/test/tools/javac/diags/examples/LocalVarNeedsFinal.java @@ -22,6 +22,7 @@ */ // key: compiler.err.local.var.accessed.from.icls.needs.final +// options: -Xlint:-options -source 7 class LocalVarNeedsFinal { Runnable m() { diff --git a/langtools/test/tools/javac/diags/examples/MissingReturnValue.java b/langtools/test/tools/javac/diags/examples/MissingReturnValue.java index 3341c3b6973..55e96a4608b 100644 --- a/langtools/test/tools/javac/diags/examples/MissingReturnValue.java +++ b/langtools/test/tools/javac/diags/examples/MissingReturnValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Oracle and/or its affiliates. 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 @@ -21,7 +21,8 @@ * questions. */ -// key: compiler.err.missing.ret.val +// key: compiler.err.prob.found.req +// key: compiler.misc.missing.ret.val class MissingReturnValue { int m() { diff --git a/langtools/test/tools/javac/diags/examples/MissingReturnValueFragment.java b/langtools/test/tools/javac/diags/examples/MissingReturnValueFragment.java index ad9358b1a83..8edeb62c1bb 100644 --- a/langtools/test/tools/javac/diags/examples/MissingReturnValueFragment.java +++ b/langtools/test/tools/javac/diags/examples/MissingReturnValueFragment.java @@ -24,7 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.incompatible.ret.type.in.lambda // key: compiler.misc.missing.ret.val -// options: -XDallowLambda class MissingReturnValueFragment { interface SAM { diff --git a/langtools/test/tools/javac/diags/examples/NoAbstracts.java b/langtools/test/tools/javac/diags/examples/NoAbstracts.java index ab7af7f6e4c..011115e2f4f 100644 --- a/langtools/test/tools/javac/diags/examples/NoAbstracts.java +++ b/langtools/test/tools/javac/diags/examples/NoAbstracts.java @@ -24,7 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.not.a.functional.intf.1 // key: compiler.misc.no.abstracts -// options: -XDallowLambda class NoAbstracts { diff --git a/langtools/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java b/langtools/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java index fdc2f017d57..ef21673a86b 100644 --- a/langtools/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java +++ b/langtools/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java @@ -23,7 +23,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.no.suitable.functional.intf.inst -// options: -XDallowLambda class NoSuitableFunctionalIntfInst { diff --git a/langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java b/langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java index d18f6c18300..78d7344cc56 100644 --- a/langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java +++ b/langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java @@ -24,7 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.non-static.cant.be.ref // key: compiler.misc.invalid.mref -// options: -XDallowMethodReferences class NonStaticCantBeRefFragment { diff --git a/langtools/test/tools/javac/diags/examples/NotAFunctionalIntf.java b/langtools/test/tools/javac/diags/examples/NotAFunctionalIntf.java index 1135abff9c8..e151aa444ae 100644 --- a/langtools/test/tools/javac/diags/examples/NotAFunctionalIntf.java +++ b/langtools/test/tools/javac/diags/examples/NotAFunctionalIntf.java @@ -23,7 +23,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.not.a.functional.intf -// options: -XDallowLambda class NotAFunctionalIntf { diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java index a138a48c1b7..cbcdf668945 100644 --- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java @@ -24,7 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.not.def.access.class.intf.cant.access // key: compiler.misc.invalid.mref -// options: -XDallowMethodReferences class NotDefAccessClassIntfCantAccessFragment { diff --git a/langtools/test/tools/javac/diags/examples/OverriddenDefault.java b/langtools/test/tools/javac/diags/examples/OverriddenDefault.java index 1d70bcb4f86..6fe9bcc5483 100644 --- a/langtools/test/tools/javac/diags/examples/OverriddenDefault.java +++ b/langtools/test/tools/javac/diags/examples/OverriddenDefault.java @@ -23,7 +23,6 @@ // key: compiler.err.illegal.default.super.call // key: compiler.misc.overridden.default -// options: -XDallowDefaultMethods class OverriddenDefault { interface I { default void m() { } } @@ -33,4 +32,4 @@ class OverriddenDefault { static class C implements J, K { void foo() { K.super.m(); } } -} \ No newline at end of file +} diff --git a/langtools/test/tools/javac/diags/examples/PotentialLambdaFound.java b/langtools/test/tools/javac/diags/examples/PotentialLambdaFound.java index 1512ee87ae6..050f26c4eae 100644 --- a/langtools/test/tools/javac/diags/examples/PotentialLambdaFound.java +++ b/langtools/test/tools/javac/diags/examples/PotentialLambdaFound.java @@ -22,7 +22,7 @@ */ // key: compiler.note.potential.lambda.found -// options: -XDallowLambda -XDidentifyLambdaCandidate=true +// options: -XDidentifyLambdaCandidate=true class PotentialLambdaFound { diff --git a/langtools/test/tools/javac/diags/examples/RedundantSupertype.java b/langtools/test/tools/javac/diags/examples/RedundantSupertype.java index 86aea78778e..3129025bc26 100644 --- a/langtools/test/tools/javac/diags/examples/RedundantSupertype.java +++ b/langtools/test/tools/javac/diags/examples/RedundantSupertype.java @@ -23,7 +23,6 @@ // key: compiler.err.illegal.default.super.call // key: compiler.misc.redundant.supertype -// options: -XDallowDefaultMethods class RedundantSupertype { interface I { default void m() { } } diff --git a/langtools/test/tools/javac/diags/examples/RefAmbiguousFragment.java b/langtools/test/tools/javac/diags/examples/RefAmbiguousFragment.java index be43f1d3f7d..7909002f9e0 100644 --- a/langtools/test/tools/javac/diags/examples/RefAmbiguousFragment.java +++ b/langtools/test/tools/javac/diags/examples/RefAmbiguousFragment.java @@ -24,7 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.ref.ambiguous // key: compiler.misc.invalid.mref -// options: -XDallowMethodReferences class RefAmbiguousFragment { diff --git a/langtools/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java b/langtools/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java index ea249c8dd24..d94a88ef7bb 100644 --- a/langtools/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java +++ b/langtools/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java @@ -22,7 +22,6 @@ */ // key: compiler.err.types.incompatible.abstract.default -// options: -XDallowDefaultMethods class TypesIncompatibleAbstractDefault { interface A { diff --git a/langtools/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java b/langtools/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java index 8ec697b8b70..28c75bc644b 100644 --- a/langtools/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java +++ b/langtools/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java @@ -22,7 +22,6 @@ */ // key: compiler.err.types.incompatible.unrelated.defaults -// options: -XDallowDefaultMethods class TypesIncompatibleUnrelatedDefaults { interface A { diff --git a/langtools/test/tools/javac/diags/examples/UnexpectedLambda.java b/langtools/test/tools/javac/diags/examples/UnexpectedLambda.java index 66eb5908d71..e1c27836a2a 100644 --- a/langtools/test/tools/javac/diags/examples/UnexpectedLambda.java +++ b/langtools/test/tools/javac/diags/examples/UnexpectedLambda.java @@ -22,7 +22,6 @@ */ // key: compiler.err.unexpected.lambda -// options: -XDallowLambda class UnexpectedLambda { { (()-> { })++; } diff --git a/langtools/test/tools/javac/diags/examples/UnexpectedMref.java b/langtools/test/tools/javac/diags/examples/UnexpectedMref.java index 5f3cc2c6031..9cc21d90a7f 100644 --- a/langtools/test/tools/javac/diags/examples/UnexpectedMref.java +++ b/langtools/test/tools/javac/diags/examples/UnexpectedMref.java @@ -22,7 +22,6 @@ */ // key: compiler.err.unexpected.mref -// options: -XDallowMethodReferences class UnexpectedLambda { { (Foo::bar)++; } diff --git a/langtools/test/tools/javac/diags/examples/CantReturnValueForVoid.java b/langtools/test/tools/javac/diags/examples/UnexpectedReturnValue.java similarity index 85% rename from langtools/test/tools/javac/diags/examples/CantReturnValueForVoid.java rename to langtools/test/tools/javac/diags/examples/UnexpectedReturnValue.java index fbd42ddcd65..6327d32df3d 100644 --- a/langtools/test/tools/javac/diags/examples/CantReturnValueForVoid.java +++ b/langtools/test/tools/javac/diags/examples/UnexpectedReturnValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Oracle and/or its affiliates. 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 @@ -21,9 +21,10 @@ * questions. */ -// key: compiler.err.cant.ret.val.from.meth.decl.void +// key: compiler.err.prob.found.req +// key: compiler.misc.unexpected.ret.val -class CantReturnValueForVoid { +class UnexpectedReturnValue { void m() { return 3; } diff --git a/langtools/test/tools/javac/generics/7022054/T7022054pos1.java b/langtools/test/tools/javac/generics/7022054/T7022054pos1.java index 8a9c6a0c301..25003a8a8be 100644 --- a/langtools/test/tools/javac/generics/7022054/T7022054pos1.java +++ b/langtools/test/tools/javac/generics/7022054/T7022054pos1.java @@ -27,7 +27,7 @@ * * @summary Invalid compiler error on covariant overriding methods with the same erasure * @compile -source 7 T7022054pos1.java - * @compile/fail -XDstrictMethodClashCheck T7022054pos1.java + * @compile/fail/ref=T7022054pos1.out -XDrawDiagnostics T7022054pos1.java * */ diff --git a/langtools/test/tools/javac/generics/7022054/T7022054pos1.out b/langtools/test/tools/javac/generics/7022054/T7022054pos1.out new file mode 100644 index 00000000000..b7f41063ee6 --- /dev/null +++ b/langtools/test/tools/javac/generics/7022054/T7022054pos1.out @@ -0,0 +1,2 @@ +T7022054pos1.java:39:25: compiler.err.name.clash.same.erasure.no.override: m(java.lang.String), T7022054pos1.B, m(java.lang.String), T7022054pos1.A, m(java.lang.String), T7022054pos1.B +1 error diff --git a/langtools/test/tools/javac/generics/7022054/T7022054pos2.java b/langtools/test/tools/javac/generics/7022054/T7022054pos2.java index 637ee7e40d7..613b4542f90 100644 --- a/langtools/test/tools/javac/generics/7022054/T7022054pos2.java +++ b/langtools/test/tools/javac/generics/7022054/T7022054pos2.java @@ -27,7 +27,7 @@ * * @summary Invalid compiler error on covariant overriding methods with the same erasure * @compile -source 7 T7022054pos2.java - * @compile/fail -XDstrictMethodClashCheck T7022054pos2.java + * @compile/fail/ref=T7022054pos2.out -XDrawDiagnostics T7022054pos2.java */ class T7022054pos2 { diff --git a/langtools/test/tools/javac/generics/7022054/T7022054pos2.out b/langtools/test/tools/javac/generics/7022054/T7022054pos2.out new file mode 100644 index 00000000000..406bef8f32d --- /dev/null +++ b/langtools/test/tools/javac/generics/7022054/T7022054pos2.out @@ -0,0 +1,2 @@ +T7022054pos2.java:38:32: compiler.err.name.clash.same.erasure.no.hide: m(java.lang.String), T7022054pos2.B, m(java.lang.String), T7022054pos2.A +1 error diff --git a/langtools/test/tools/javac/lambda/BadAccess.java b/langtools/test/tools/javac/lambda/BadAccess.java new file mode 100644 index 00000000000..39eed691ad4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadAccess.java @@ -0,0 +1,30 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that non-static variables are not accessible from static lambdas + * @author Maurizio Cimadamore + * @compile/fail/ref=BadAccess.out -XDrawDiagnostics BadAccess.java + */ + +public class BadAccess { + + int i; + static int I; + + interface SAM { + int m(); + } + + static void test1() { + int l = 0; //effectively final + final int L = 0; + SAM s = ()-> i + I + l + L; + } + + void test2() { + int l = 0; //effectively final + final int L = 0; + SAM s = ()-> i + I + l + L; + } +} diff --git a/langtools/test/tools/javac/lambda/BadAccess.out b/langtools/test/tools/javac/lambda/BadAccess.out new file mode 100644 index 00000000000..26484a7e87b --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadAccess.out @@ -0,0 +1,2 @@ +BadAccess.java:22:22: compiler.err.non-static.cant.be.ref: kindname.variable, i +1 error diff --git a/langtools/test/tools/javac/lambda/BadAccess02.java b/langtools/test/tools/javac/lambda/BadAccess02.java new file mode 100644 index 00000000000..d8a9e6e2fdf --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadAccess02.java @@ -0,0 +1,31 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check lambda can access only effectively-final locals + * @author Maurizio Cimadamore + * @compile/fail/ref=BadAccess02.out -XDrawDiagnostics BadAccess02.java + */ + +public class BadAccess02 { + + interface SAM { + int m(int h); + } + + static void test1() { + int l = 0; //effectively final + int j = 0; //non-effectively final + j = 2; + final int L = 0; + SAM s = (int h) -> { int k = 0; return h + j + l + L; }; + } + + void test2() { + int l = 0; //effectively final + int j = 0; //non-effectively final + j = 2; + final int L = 0; + SAM s = (int h) -> { int k = 0; return h + k + j + l + L; }; + } +} diff --git a/langtools/test/tools/javac/lambda/BadAccess02.out b/langtools/test/tools/javac/lambda/BadAccess02.out new file mode 100644 index 00000000000..a28d06551c0 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadAccess02.out @@ -0,0 +1,3 @@ +BadAccess02.java:21:52: compiler.err.cant.ref.non.effectively.final.var: j, (compiler.misc.lambda) +BadAccess02.java:29:56: compiler.err.cant.ref.non.effectively.final.var: j, (compiler.misc.lambda) +2 errors diff --git a/langtools/test/tools/javac/lambda/BadAccess03.java b/langtools/test/tools/javac/lambda/BadAccess03.java new file mode 100644 index 00000000000..22af1771fe0 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadAccess03.java @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check lambda cannot assign non-effectively final locals + * @compile/fail/ref=BadAccess03.out -XDrawDiagnostics BadAccess03.java + */ + +class BadAccess03 { + void test() { + int k = 0; + int n = 2; //effectively final variable + Runnable r = ()-> { k = n; }; //error + } +} diff --git a/langtools/test/tools/javac/lambda/BadAccess03.out b/langtools/test/tools/javac/lambda/BadAccess03.out new file mode 100644 index 00000000000..5520b307b4b --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadAccess03.out @@ -0,0 +1,2 @@ +BadAccess03.java:13:29: compiler.err.cant.ref.non.effectively.final.var: k, (compiler.misc.lambda) +1 error diff --git a/langtools/test/tools/javac/lambda/BadBreakContinue.java b/langtools/test/tools/javac/lambda/BadBreakContinue.java new file mode 100644 index 00000000000..861c8794b07 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadBreakContinue.java @@ -0,0 +1,44 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that break/continue is disallowed in lambda expressions + * @author Maurizio Cimadamore + * @compile/fail/ref=BadBreakContinue.out -XDrawDiagnostics BadBreakContinue.java + */ + +class BadBreakContinue { + + static interface SAM { + void m(); + } + + SAM s1 = ()-> { break; }; + SAM s2 = ()-> { continue; }; + SAM s3 = ()-> { + SAM s3_1 = ()-> { break; }; + SAM s3_2 = ()-> { continue; }; + }; + + void testLabelled() { + loop: while (true) { + SAM s1 = ()-> { break loop; }; + SAM s2 = ()-> { continue loop; }; + SAM s3 = ()-> { + SAM s3_1 = ()-> { break loop; }; + SAM s3_2 = ()-> { continue loop; }; + }; + } + } + + void testNonLabelled() { + while (true) { + SAM s1 = ()-> { break; }; + SAM s2 = ()-> { continue; }; + SAM s3 = ()-> { + SAM s3_1 = ()-> { break; }; + SAM s3_2 = ()-> { continue; }; + }; + } + } +} diff --git a/langtools/test/tools/javac/lambda/BadBreakContinue.out b/langtools/test/tools/javac/lambda/BadBreakContinue.out new file mode 100644 index 00000000000..76acc71f958 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadBreakContinue.out @@ -0,0 +1,13 @@ +BadBreakContinue.java:16:21: compiler.err.break.outside.switch.loop +BadBreakContinue.java:17:21: compiler.err.cont.outside.loop +BadBreakContinue.java:19:27: compiler.err.break.outside.switch.loop +BadBreakContinue.java:20:27: compiler.err.cont.outside.loop +BadBreakContinue.java:25:29: compiler.err.undef.label: loop +BadBreakContinue.java:26:29: compiler.err.undef.label: loop +BadBreakContinue.java:28:35: compiler.err.undef.label: loop +BadBreakContinue.java:29:35: compiler.err.undef.label: loop +BadBreakContinue.java:36:29: compiler.err.break.outside.switch.loop +BadBreakContinue.java:37:29: compiler.err.cont.outside.loop +BadBreakContinue.java:39:35: compiler.err.break.outside.switch.loop +BadBreakContinue.java:40:35: compiler.err.cont.outside.loop +12 errors diff --git a/langtools/test/tools/javac/lambda/BadConv03.java b/langtools/test/tools/javac/lambda/BadConv03.java new file mode 100644 index 00000000000..c2f440dc602 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadConv03.java @@ -0,0 +1,20 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * NPE while checking if subinterface is a SAM type + * @compile/fail/ref=BadConv03.out -XDrawDiagnostics BadConv03.java + */ + +class BadConv03 { + + interface A { + void a(); + } + + interface B extends A { //not a SAM (2 non-override equivalent abstracts!) + void a(int i); + } + + B b = ()-> { }; +} diff --git a/langtools/test/tools/javac/lambda/BadConv03.out b/langtools/test/tools/javac/lambda/BadConv03.out new file mode 100644 index 00000000000..078f304f413 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadConv03.out @@ -0,0 +1,2 @@ +BadConv03.java:19:11: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, BadConv03.B)) +1 error diff --git a/langtools/test/tools/javac/lambda/BadConv04.java b/langtools/test/tools/javac/lambda/BadConv04.java new file mode 100644 index 00000000000..910d3ecc742 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadConv04.java @@ -0,0 +1,22 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that ill-formed SAM type generates right diagnostic when SAM converted + * @compile/fail/ref=BadConv04.out -XDrawDiagnostics BadConv04.java + */ + +class BadConv04 { + + interface I1 { + int m(); + } + + interface I2 { + long m(); + } + + interface SAM extends I1, I2 {} + + SAM s = ()-> { }; +} diff --git a/langtools/test/tools/javac/lambda/BadConv04.out b/langtools/test/tools/javac/lambda/BadConv04.out new file mode 100644 index 00000000000..4eae22a993a --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadConv04.out @@ -0,0 +1,3 @@ +BadConv04.java:19:5: compiler.err.types.incompatible.diff.ret: BadConv04.I2, BadConv04.I1, m() +BadConv04.java:21:13: compiler.err.prob.found.req: (compiler.misc.incompatible.descs.in.functional.intf: kindname.interface, BadConv04.SAM,{(compiler.misc.descriptor: m, , long, ),(compiler.misc.descriptor: m, , int, )}) +2 errors diff --git a/langtools/test/tools/javac/lambda/BadExpressionLambda.java b/langtools/test/tools/javac/lambda/BadExpressionLambda.java new file mode 100644 index 00000000000..567ab8a967f --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadExpressionLambda.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that a conditonal can't be void + * @compile/fail/ref=BadExpressionLambda.out -XDrawDiagnostics BadExpressionLambda.java + */ + +class BadExpressionLambda { + + interface SAM { + void invoke(); + } + + public static void m() {} + + void test() { + SAM sam1 = () -> m(); //ok + SAM sam2 = () -> true ? m() : m(); //not ok + } +} diff --git a/langtools/test/tools/javac/lambda/BadExpressionLambda.out b/langtools/test/tools/javac/lambda/BadExpressionLambda.out new file mode 100644 index 00000000000..f466df0a73f --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadExpressionLambda.out @@ -0,0 +1,2 @@ +BadExpressionLambda.java:19:31: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.conditional.target.cant.be.void)) +1 error diff --git a/langtools/test/tools/javac/lambda/BadLambdaExpr.java b/langtools/test/tools/javac/lambda/BadLambdaExpr.java new file mode 100644 index 00000000000..80b342288e2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadLambdaExpr.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * compile crashes on partial lambda expressions + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + + +public class BadLambdaExpr { + + static int checkCount = 0; + + enum ParameterListKind { + ZERO_ARY("()"), + UNARY("(#P)"), + TWO_ARY("(#P, #P)"), + THREE_ARY("(#P, #P, #P)"); + + String parametersTemplateStr; + + ParameterListKind(String parametersTemplateStr) { + this.parametersTemplateStr = parametersTemplateStr; + } + + String getParameterString(ParameterKind pk) { + return parametersTemplateStr.replaceAll("#P", pk.parameterStr); + } + } + + enum ParameterKind { + IMPLICIT("a"), + EXPLIICT("A a"); + + String parameterStr; + + ParameterKind(String parameterStr) { + this.parameterStr = parameterStr; + } + } + + enum ArrowKind { + NONE(""), + SEMI("-"), + FULL("->"); + + String arrowStr; + + ArrowKind(String arrowStr) { + this.arrowStr = arrowStr; + } + } + + enum ExprKind { + NONE("#P#A"), + METHOD_CALL("m(#P#A)"), + CONSTR_CALL("new Foo(#P#A)"); + + String expressionTemplate; + + ExprKind(String expressionTemplate) { + this.expressionTemplate = expressionTemplate; + } + + String expressionString(ParameterListKind plk, ParameterKind pk, + ArrowKind ak) { + return expressionTemplate.replaceAll("#P", plk.getParameterString(pk)) + .replaceAll("#A", ak.arrowStr); + } + } + + public static void main(String... args) throws Exception { + + //create default shared JavaCompiler - reused across multiple compilations + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + for (ParameterListKind plk : ParameterListKind.values()) { + for (ParameterKind pk : ParameterKind.values()) { + for (ArrowKind ak : ArrowKind.values()) { + for (ExprKind ek : ExprKind.values()) { + new BadLambdaExpr(plk, pk, ak, ek).run(comp, fm); + } + } + } + } + System.out.println("Total check executed: " + checkCount); + } + + ParameterListKind plk; + ParameterKind pk; + ArrowKind ak; + ExprKind ek; + JavaSource source; + DiagnosticChecker diagChecker; + + BadLambdaExpr(ParameterListKind plk, ParameterKind pk, ArrowKind ak, ExprKind ek) { + this.plk = plk; + this.pk = pk; + this.ak = ak; + this.ek = ek; + this.source = new JavaSource(); + this.diagChecker = new DiagnosticChecker(); + } + + class JavaSource extends SimpleJavaFileObject { + + String template = "class Test {\n" + + " SAM s = #E;\n" + + "}"; + + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = template.replaceAll("#E", ek.expressionString(plk, pk, ak)); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, + null, null, Arrays.asList(source)); + try { + ct.parse(); + } catch (Throwable ex) { + throw new AssertionError("Error thron when parsing the following source:\n" + source.getCharContent(true)); + } + check(); + } + + void check() { + boolean errorExpected = + ak != ArrowKind.NONE || + plk != ParameterListKind.UNARY || + pk != ParameterKind.IMPLICIT; + if (errorExpected != diagChecker.errorFound) { + throw new Error("bad diag for source:\n" + + source.getCharContent(true)); + } + checkCount++; + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound; + + @Override + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } +} diff --git a/langtools/test/tools/javac/lambda/BadLambdaPos.java b/langtools/test/tools/javac/lambda/BadLambdaPos.java new file mode 100644 index 00000000000..52c517f066a --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadLambdaPos.java @@ -0,0 +1,31 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that lambda is only allowed in argument/cast/assignment context + * @author Maurizio Cimadamore + * @compile/fail/ref=BadLambdaPos.out -XDrawDiagnostics BadLambdaPos.java + */ + +interface SAM { + void m(Integer x); +} + +class Test { + void test(Object x) {} + + void test1() { + test((int x)-> { } + (int x)-> { } ); + test((int x)-> { } instanceof Object ); + } + + void test2() { + int i2 = (int x)-> { } + (int x)-> { }; + boolean b = (int x)-> { } instanceof Object; + } + + void test3() { + test((Object)(int x)-> { }); + Object o = (Object)(int x)-> { }; + } +} diff --git a/langtools/test/tools/javac/lambda/BadLambdaPos.out b/langtools/test/tools/javac/lambda/BadLambdaPos.out new file mode 100644 index 00000000000..b2436d9ca1a --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadLambdaPos.out @@ -0,0 +1,9 @@ +BadLambdaPos.java:18:14: compiler.err.unexpected.lambda +BadLambdaPos.java:18:30: compiler.err.unexpected.lambda +BadLambdaPos.java:19:14: compiler.err.unexpected.lambda +BadLambdaPos.java:23:18: compiler.err.unexpected.lambda +BadLambdaPos.java:23:34: compiler.err.unexpected.lambda +BadLambdaPos.java:24:21: compiler.err.unexpected.lambda +BadLambdaPos.java:28:22: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +BadLambdaPos.java:29:28: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +8 errors diff --git a/langtools/test/tools/javac/lambda/BadMethodCall.java b/langtools/test/tools/javac/lambda/BadMethodCall.java new file mode 100644 index 00000000000..f129f150787 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadMethodCall.java @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that diagnostics on nested erroneous deferred types are flushed + * @compile/fail/ref=BadMethodCall.out -XDrawDiagnostics BadMethodCall.java + */ +import java.util.*; + +class BadMethodCall { + List id(List z) { return null; }; + + List cons(String s, List ls) { return null; } + + void test(List lo) { Object t = cons(id(""),lo); } +} diff --git a/langtools/test/tools/javac/lambda/BadMethodCall.out b/langtools/test/tools/javac/lambda/BadMethodCall.out new file mode 100644 index 00000000000..deb85f517fa --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadMethodCall.out @@ -0,0 +1,2 @@ +BadMethodCall.java:15:50: compiler.err.cant.apply.symbol: kindname.method, id, java.util.List, java.lang.String, kindname.class, BadMethodCall, (compiler.misc.infer.no.conforming.assignment.exists: I, (compiler.misc.inconvertible.types: java.lang.String, java.util.List)) +1 error diff --git a/langtools/test/tools/javac/lambda/BadRecovery.java b/langtools/test/tools/javac/lambda/BadRecovery.java new file mode 100644 index 00000000000..271a7ff0fe7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadRecovery.java @@ -0,0 +1,19 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that recovery of speculative types is not attempted if receiver is erroneous + * @compile/fail/ref=BadRecovery.out -XDrawDiagnostics BadRecovery.java + */ +class BadRecovery { + + interface SAM1 { + void m(Object o); + } + + void m(SAM1 m) { }; + + void test() { + m((receiver, t) -> { receiver.someMemberOfReceiver(()->{ Object x = f; }); }); + } +} diff --git a/langtools/test/tools/javac/lambda/BadRecovery.out b/langtools/test/tools/javac/lambda/BadRecovery.out new file mode 100644 index 00000000000..427d97f0f81 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadRecovery.out @@ -0,0 +1,3 @@ +BadRecovery.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, BadRecovery.SAM1, @369, kindname.class, BadRecovery, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)) +BadRecovery.java:17:77: compiler.err.cant.resolve.location: kindname.variable, f, , , (compiler.misc.location: kindname.class, BadRecovery, null) +2 errors diff --git a/langtools/test/tools/javac/lambda/BadReturn.java b/langtools/test/tools/javac/lambda/BadReturn.java new file mode 100644 index 00000000000..01667ec7b20 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadReturn.java @@ -0,0 +1,38 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that incompatible return types in lambdas are flagged with error + * @author Maurizio Cimadamore + * @compile/fail/ref=BadReturn.out -XDrawDiagnostics BadReturn.java + */ + +class BadReturn { + + interface SAM { + Comparable m(); + } + + static void testNeg1() { + SAM s = ()-> { + if (true) { + return ""; + } else { + return System.out.println(""); + }}; + } + + static void testNeg2() { + SAM s = ()-> { return System.out.println(""); }; + } + + static void testPos() { + SAM s = ()-> { + if (false) { + return 10; + } + else { + return true; + }}; + } +} diff --git a/langtools/test/tools/javac/lambda/BadReturn.out b/langtools/test/tools/javac/lambda/BadReturn.out new file mode 100644 index 00000000000..2f32c6cd3aa --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadReturn.out @@ -0,0 +1,3 @@ +BadReturn.java:21:42: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable)) +BadReturn.java:26:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable)) +2 errors diff --git a/langtools/test/tools/javac/lambda/BadStatementInLambda.java b/langtools/test/tools/javac/lambda/BadStatementInLambda.java new file mode 100644 index 00000000000..ae17d26be61 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadStatementInLambda.java @@ -0,0 +1,19 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that the compiler emits meaningful diagnostics when the lambda body contains bad statements + * @author Maurizio Cimadamore + * @compile/fail/ref=BadStatementInLambda.out -XDrawDiagnostics BadStatementInLambda.java + */ + +class BadStatementInLambda { + + interface SAM{ + Object m(); + } + + SAM t1 = ()-> { null; }; + SAM t2 = ()-> { 1; }; + SAM t3 = ()-> { 1 + 5; }; +} diff --git a/langtools/test/tools/javac/lambda/BadStatementInLambda.out b/langtools/test/tools/javac/lambda/BadStatementInLambda.out new file mode 100644 index 00000000000..597876873a5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadStatementInLambda.out @@ -0,0 +1,4 @@ +BadStatementInLambda.java:16:21: compiler.err.not.stmt +BadStatementInLambda.java:17:21: compiler.err.not.stmt +BadStatementInLambda.java:18:23: compiler.err.not.stmt +3 errors diff --git a/langtools/test/tools/javac/lambda/BadStatementInLambda02.java b/langtools/test/tools/javac/lambda/BadStatementInLambda02.java new file mode 100644 index 00000000000..0b554046007 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadStatementInLambda02.java @@ -0,0 +1,19 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that the compiler emits meaningful diagnostics when the lambda body contains bad statements + * @author Maurizio Cimadamore + * @compile/fail/ref=BadStatementInLambda02.out -XDrawDiagnostics BadStatementInLambda02.java + */ + +class BadStatementInLambda02 { + + interface SAM { + void m(); + } + + { call(()-> { System.out.println(new NonExistentClass() + ""); }); } + + void call(SAM s) { } +} diff --git a/langtools/test/tools/javac/lambda/BadStatementInLambda02.out b/langtools/test/tools/javac/lambda/BadStatementInLambda02.out new file mode 100644 index 00000000000..99a4c065311 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadStatementInLambda02.out @@ -0,0 +1,2 @@ +BadStatementInLambda02.java:16:42: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, BadStatementInLambda02, null) +1 error diff --git a/langtools/test/tools/javac/lambda/BadTargetType.java b/langtools/test/tools/javac/lambda/BadTargetType.java new file mode 100644 index 00000000000..f7eabd8b930 --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadTargetType.java @@ -0,0 +1,23 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that only SAM are allowed as target types for lambda expressions + * @author Jan Lahoda + * @author Maurizio Cimadamore + * @compile/fail/ref=BadTargetType.out -XDrawDiagnostics BadTargetType.java + */ + +class BadTargetType { + + static void m1(Object o) {} + void m2(Object o) {} + + static Object l1 = (int pos)-> { }; + Object l2 = (int pos)-> { }; + + { + m1((int pos)-> { }); + m2((int pos)-> { }); + } +} diff --git a/langtools/test/tools/javac/lambda/BadTargetType.out b/langtools/test/tools/javac/lambda/BadTargetType.out new file mode 100644 index 00000000000..8979631251b --- /dev/null +++ b/langtools/test/tools/javac/lambda/BadTargetType.out @@ -0,0 +1,5 @@ +BadTargetType.java:16:24: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +BadTargetType.java:17:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +BadTargetType.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, java.lang.Object, @460, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf)) +BadTargetType.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, java.lang.Object, @489, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf)) +4 errors diff --git a/langtools/test/tools/javac/lambda/Conditional01.java b/langtools/test/tools/javac/lambda/Conditional01.java new file mode 100644 index 00000000000..61b0f26e870 --- /dev/null +++ b/langtools/test/tools/javac/lambda/Conditional01.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * conditional and varargs + * @compile -XDcomplexinference Conditional01.java + */ + +import java.util.*; + +class Conditional01 { + void varargs(Object ... args) { } + + void test(boolean flag, List ls) { + varargs(flag ? "" : ls); + varargs(null, flag ? "" : ls); + varargs(flag ? "" : ls()); + varargs(null, flag ? "" : ls()); + } + + List ls() { return null; } +} diff --git a/langtools/test/tools/javac/lambda/Conditional02.java b/langtools/test/tools/javac/lambda/Conditional02.java new file mode 100644 index 00000000000..5a5e72ce3f9 --- /dev/null +++ b/langtools/test/tools/javac/lambda/Conditional02.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * inference and conditionals + * @compile -XDcomplexinference Conditional02.java + */ + +class Conditional02 { + + void m1(Z z) { } + void m2(Z... z) { } + + void test(boolean flag) { + m1(flag ? "" : ""); + m2(flag ? "" : ""); + m2("", flag ? "" : ""); + } +} diff --git a/langtools/test/tools/javac/lambda/Conditional03.java b/langtools/test/tools/javac/lambda/Conditional03.java new file mode 100644 index 00000000000..2b8d6273c0b --- /dev/null +++ b/langtools/test/tools/javac/lambda/Conditional03.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * conditionals and boxing + * @compile -XDcomplexinference Conditional03.java + */ + +class Conditional03 { + + void m1(Object o) { } + void m2(int i) { } + + void test(boolean cond) { + m1((cond ? 1 : 1)); + m1((cond ? box(1) : box(1))); + } + + Integer box(int i) { return i; } +} diff --git a/langtools/test/tools/javac/lambda/Conformance01.java b/langtools/test/tools/javac/lambda/Conformance01.java new file mode 100644 index 00000000000..54c593d7177 --- /dev/null +++ b/langtools/test/tools/javac/lambda/Conformance01.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * lambda compiler regression with uninferred type-variables in generic constructor call + * @compile Conformance01.java + */ + +class Conformance01 { + Conformance01(T1 t) { } + + Conformance01 c01 = new Conformance01(null); +} diff --git a/langtools/test/tools/javac/lambda/Defender01.java b/langtools/test/tools/javac/lambda/Defender01.java new file mode 100644 index 00000000000..b8c3f2cf793 --- /dev/null +++ b/langtools/test/tools/javac/lambda/Defender01.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * routine that checks for SAM types should skip defender methods in extended interfaces + * @author Maurizio Cimadamore + * @compile Defender01.java + */ + +class Defender01 { + + interface A{ + Object m(); + default void n() { E.n(this); } + } + + static class E{ + static void n(A a){}; + } + + A t = ()-> null; +} diff --git a/langtools/test/tools/javac/lambda/DisjunctiveTypeTest.java b/langtools/test/tools/javac/lambda/DisjunctiveTypeTest.java new file mode 100644 index 00000000000..137e9808711 --- /dev/null +++ b/langtools/test/tools/javac/lambda/DisjunctiveTypeTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that subtyping between disjunctive and non disjunctive type works + * @author Maurizio Cimadamore + * @compile DisjunctiveTypeTest.java + */ + +class DisjunctiveTypeTest { + + static class A extends IllegalArgumentException { + A(String a) { super(a); } + } + + class B extends IllegalArgumentException { + B(String b) { super(b); } + } + + void m() throws A,B {} + + void test() { + try { + m(); + } catch (A|B e) { + throw new IllegalArgumentException(e); + } + } +} diff --git a/langtools/test/tools/javac/lambda/EffectivelyFinal01.java b/langtools/test/tools/javac/lambda/EffectivelyFinal01.java new file mode 100644 index 00000000000..c12062cb696 --- /dev/null +++ b/langtools/test/tools/javac/lambda/EffectivelyFinal01.java @@ -0,0 +1,18 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * effectively final check fails on method parameter + * @compile/fail/ref=EffectivelyFinal01.out -XDrawDiagnostics EffectivelyFinal01.java + */ +class EffectivelyFinal01 { + + interface SAM { + Integer m(Integer i); + } + + void test(Integer nefPar) { + SAM s = (Integer h) -> { Integer k = 0; return k + h + nefPar; }; + nefPar++; //non-effectively final + } +} diff --git a/langtools/test/tools/javac/lambda/EffectivelyFinal01.out b/langtools/test/tools/javac/lambda/EffectivelyFinal01.out new file mode 100644 index 00000000000..dadc311fdb8 --- /dev/null +++ b/langtools/test/tools/javac/lambda/EffectivelyFinal01.out @@ -0,0 +1,2 @@ +EffectivelyFinal01.java:15:65: compiler.err.cant.ref.non.effectively.final.var: nefPar, (compiler.misc.lambda) +1 error diff --git a/langtools/test/tools/javac/lambda/EffectivelyFinalTest.java b/langtools/test/tools/javac/lambda/EffectivelyFinalTest.java index 4dce2a67f61..9d1dff9b6e4 100644 --- a/langtools/test/tools/javac/lambda/EffectivelyFinalTest.java +++ b/langtools/test/tools/javac/lambda/EffectivelyFinalTest.java @@ -1,30 +1,9 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Integrate efectively final check with DA/DU analysis - * @compile/fail/ref=EffectivelyFinalTest01.out -XDallowEffectivelyFinalInInnerClasses -XDrawDiagnostics EffectivelyFinalTest.java + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Integrate effectively final check with DA/DU analysis + * @compile/fail/ref=EffectivelyFinalTest01.out -XDrawDiagnostics EffectivelyFinalTest.java * @compile/fail/ref=EffectivelyFinalTest02.out -source 7 -Xlint:-options -XDrawDiagnostics EffectivelyFinalTest.java */ class EffectivelyFinalTest { @@ -62,7 +41,7 @@ class EffectivelyFinalTest { void m6(int x) { new Object() { { System.out.println(x+1); } }; //error - x not EF - x++; + x++; // Illegal: x is not effectively final. } void m7(int x) { diff --git a/langtools/test/tools/javac/lambda/EffectivelyFinalTest01.out b/langtools/test/tools/javac/lambda/EffectivelyFinalTest01.out index 5cb36edba4a..27961635b1b 100644 --- a/langtools/test/tools/javac/lambda/EffectivelyFinalTest01.out +++ b/langtools/test/tools/javac/lambda/EffectivelyFinalTest01.out @@ -1,6 +1,6 @@ -EffectivelyFinalTest.java:46:47: compiler.err.var.might.not.have.been.initialized: y -EffectivelyFinalTest.java:60:47: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls) -EffectivelyFinalTest.java:64:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls) -EffectivelyFinalTest.java:69:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls) -EffectivelyFinalTest.java:74:45: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls) +EffectivelyFinalTest.java:25:47: compiler.err.var.might.not.have.been.initialized: y +EffectivelyFinalTest.java:39:47: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls) +EffectivelyFinalTest.java:43:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls) +EffectivelyFinalTest.java:48:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls) +EffectivelyFinalTest.java:53:45: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls) 5 errors diff --git a/langtools/test/tools/javac/lambda/EffectivelyFinalTest02.out b/langtools/test/tools/javac/lambda/EffectivelyFinalTest02.out index 02442db60da..c1510394935 100644 --- a/langtools/test/tools/javac/lambda/EffectivelyFinalTest02.out +++ b/langtools/test/tools/javac/lambda/EffectivelyFinalTest02.out @@ -1,14 +1,14 @@ -EffectivelyFinalTest.java:46:47: compiler.err.var.might.not.have.been.initialized: y -EffectivelyFinalTest.java:34:45: compiler.err.local.var.accessed.from.icls.needs.final: x -EffectivelyFinalTest.java:34:47: compiler.err.local.var.accessed.from.icls.needs.final: y -EffectivelyFinalTest.java:40:45: compiler.err.local.var.accessed.from.icls.needs.final: x -EffectivelyFinalTest.java:40:47: compiler.err.local.var.accessed.from.icls.needs.final: y -EffectivelyFinalTest.java:46:45: compiler.err.local.var.accessed.from.icls.needs.final: x -EffectivelyFinalTest.java:53:45: compiler.err.local.var.accessed.from.icls.needs.final: x -EffectivelyFinalTest.java:53:47: compiler.err.local.var.accessed.from.icls.needs.final: y -EffectivelyFinalTest.java:60:45: compiler.err.local.var.accessed.from.icls.needs.final: x -EffectivelyFinalTest.java:60:47: compiler.err.local.var.accessed.from.icls.needs.final: y -EffectivelyFinalTest.java:64:45: compiler.err.local.var.accessed.from.icls.needs.final: x -EffectivelyFinalTest.java:69:45: compiler.err.local.var.accessed.from.icls.needs.final: x -EffectivelyFinalTest.java:74:45: compiler.err.local.var.accessed.from.icls.needs.final: y +EffectivelyFinalTest.java:25:47: compiler.err.var.might.not.have.been.initialized: y +EffectivelyFinalTest.java:13:45: compiler.err.local.var.accessed.from.icls.needs.final: x +EffectivelyFinalTest.java:13:47: compiler.err.local.var.accessed.from.icls.needs.final: y +EffectivelyFinalTest.java:19:45: compiler.err.local.var.accessed.from.icls.needs.final: x +EffectivelyFinalTest.java:19:47: compiler.err.local.var.accessed.from.icls.needs.final: y +EffectivelyFinalTest.java:25:45: compiler.err.local.var.accessed.from.icls.needs.final: x +EffectivelyFinalTest.java:32:45: compiler.err.local.var.accessed.from.icls.needs.final: x +EffectivelyFinalTest.java:32:47: compiler.err.local.var.accessed.from.icls.needs.final: y +EffectivelyFinalTest.java:39:45: compiler.err.local.var.accessed.from.icls.needs.final: x +EffectivelyFinalTest.java:39:47: compiler.err.local.var.accessed.from.icls.needs.final: y +EffectivelyFinalTest.java:43:45: compiler.err.local.var.accessed.from.icls.needs.final: x +EffectivelyFinalTest.java:48:45: compiler.err.local.var.accessed.from.icls.needs.final: x +EffectivelyFinalTest.java:53:45: compiler.err.local.var.accessed.from.icls.needs.final: y 13 errors diff --git a/langtools/test/tools/javac/lambda/ErroneousArg.java b/langtools/test/tools/javac/lambda/ErroneousArg.java new file mode 100644 index 00000000000..9e3a2593a01 --- /dev/null +++ b/langtools/test/tools/javac/lambda/ErroneousArg.java @@ -0,0 +1,36 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * speculative cache mismatches between Resolve.access and Attr.checkId leads to compiler crashes + * @compile/fail/ref=ErroneousArg.out -XDrawDiagnostics ErroneousArg.java + */ +class ErroneousArg { + + private static class Foo { + static int j() { return 1; } + } + + static Foo foo = new Foo(); + + static void m(String s) { } + static void m(Integer i) { } + + static int f(String s) { return 1; } + + static int g(String s) { return 1; } + static int g(Double s) { return 1; } + + int h() { return 1; } +} + +class TestErroneousArg extends ErroneousArg { + static void test() { + m(unknown()); //method not found + m(f(1)); //inapplicable method + m(g(1)); //inapplicable methods + m(g(null)); //ambiguous + m(h()); //static error + m(foo.j()); //inaccessible method + } +} diff --git a/langtools/test/tools/javac/lambda/ErroneousArg.out b/langtools/test/tools/javac/lambda/ErroneousArg.out new file mode 100644 index 00000000000..bd596868568 --- /dev/null +++ b/langtools/test/tools/javac/lambda/ErroneousArg.out @@ -0,0 +1,7 @@ +ErroneousArg.java:29:11: compiler.err.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, TestErroneousArg, null) +ErroneousArg.java:30:11: compiler.err.cant.apply.symbol: kindname.method, f, java.lang.String, int, kindname.class, ErroneousArg, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String)) +ErroneousArg.java:31:11: compiler.err.cant.apply.symbols: kindname.method, g, int,{(compiler.misc.inapplicable.method: kindname.method, ErroneousArg, g(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))),(compiler.misc.inapplicable.method: kindname.method, ErroneousArg, g(java.lang.Double), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.Double)))} +ErroneousArg.java:32:11: compiler.err.ref.ambiguous: g, kindname.method, g(java.lang.String), ErroneousArg, kindname.method, g(java.lang.Double), ErroneousArg +ErroneousArg.java:33:11: compiler.err.non-static.cant.be.ref: kindname.method, h() +ErroneousArg.java:34:14: compiler.err.not.def.access.class.intf.cant.access: j(), ErroneousArg.Foo +6 errors diff --git a/langtools/test/tools/javac/lambda/ErroneousLambdaExpr.java b/langtools/test/tools/javac/lambda/ErroneousLambdaExpr.java new file mode 100644 index 00000000000..be21473b241 --- /dev/null +++ b/langtools/test/tools/javac/lambda/ErroneousLambdaExpr.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * stale state after speculative attribution round leads to missing classfiles + */ +public class ErroneousLambdaExpr { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM1 { + X m(X t, String s); + } + + interface SAM2 { + void m(String s, int i); + } + + interface SAM3 { + X m(X t, String s, int i); + } + + void call(SAM1 s1) { assertTrue(true); } + + void call(SAM2 s2) { assertTrue(false); } + + void call(SAM3 s3) { assertTrue(false); } + + public static void main(String[] args) { + ErroneousLambdaExpr test = + new ErroneousLambdaExpr<>(); + + test.call((builder, string) -> { builder.append(string); return builder; }); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/InnerConstructor.java b/langtools/test/tools/javac/lambda/InnerConstructor.java index 6a5bf98498e..3675020c9d8 100644 --- a/langtools/test/tools/javac/lambda/InnerConstructor.java +++ b/langtools/test/tools/javac/lambda/InnerConstructor.java @@ -23,15 +23,20 @@ /* * @test - * @summary Regression test JDK-8003306 inner class constructor in lambda + * @bug 8003280 + * @summary Add lambda tests + * Regression test JDK-8003306 inner class constructor in lambda * @author Robert Field - * @compile -XDallowLambda InnerConstructor.java */ -class InnerConstructor { +public class InnerConstructor { - public void testLambdaWithInnerConstructor() { - System.out.printf("%s should be %s\n", seq1().m().toString(), "Cbl:nada"); + public static void main(String... args) { + InnerConstructor ic = new InnerConstructor(); + String res = ic.seq1().m().toString(); + if (!res.equals("Cbl.toString")) { + throw new AssertionError(String.format("Unexpected result: %s", res)); + } } Ib1 seq1() { @@ -40,6 +45,9 @@ class InnerConstructor { class Cbl { Cbl() { } + public String toString() { + return "Cbl.toString"; + } } interface Ib1 { diff --git a/langtools/test/tools/javac/lambda/LambdaCapture01.java b/langtools/test/tools/javac/lambda/LambdaCapture01.java new file mode 100644 index 00000000000..4ee36d6ee05 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaCapture01.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * basic test for capture of non-mutable locals + * @author Brian Goetz + * @author Maurizio Cimadamore + * @run main LambdaCapture01 + */ + +public class LambdaCapture01 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface Tester { + void test(); + } + + interface TU { + public T foo(U u); + } + + public static T exec(TU lambda, U x) { + return lambda.foo(x); + } + + public int n = 5; + + //Simple local capture + void test1() { + final int N = 1; + int res = LambdaCapture01.exec((Integer x) -> x + N, 3); + assertTrue(4 == res); + } + + //Local capture with multiple scopes (anon class) + void test2() { + final int N = 1; + new Tester() { + public void test() { + final int M = 2; + int res = LambdaCapture01.exec((Integer x) -> x + N + M, 3); + assertTrue(6 == res); + } + }.test(); + } + + //Local capture with multiple scopes (local class) + void test3() { + final int N = 1; + class MyTester implements Tester { + public void test() { + final int M = 2; + int res = LambdaCapture01.exec((Integer x) -> x + N + M, 3); + assertTrue(6 == res); + } + } + new MyTester().test(); + } + + //access to field from enclosing scope + void test4() { + final int N = 4; + int res1 = LambdaCapture01.exec((Integer x) -> x + n + N, 3); + assertTrue(12 == res1); + int res2 = LambdaCapture01.exec((Integer x) -> x + LambdaCapture01.this.n + N, 3); + assertTrue(12 == res2); + } + + public static void main(String[] args) { + LambdaCapture01 t = new LambdaCapture01(); + t.test1(); + t.test2(); + t.test3(); + t.test4(); + assertTrue(assertionCount == 5); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaCapture02.java b/langtools/test/tools/javac/lambda/LambdaCapture02.java new file mode 100644 index 00000000000..3faf6a0f857 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaCapture02.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * basic test for capture of non-mutable locals + * @author Brian Goetz + * @author Maurizio Cimadamore + * @run main LambdaCapture02 + */ + +public class LambdaCapture02 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface Tester { + void test(); + } + + interface TU { + public T foo(U u); + } + + public static T exec(TU lambda, U x) { + return lambda.foo(x); + } + + public Integer n = 5; + + //Simple local capture + void test1() { + final Integer N = 1; + int res = LambdaCapture02.exec((Integer x) -> x + N, 3); + assertTrue(4 == res); + } + + //Local capture with multiple scopes (anon class) + void test2() { + final Integer N = 1; + new Tester() { + public void test() { + final Integer M = 2; + int res = LambdaCapture02.exec((Integer x) -> x + N + M, 3); + assertTrue(6 == res); + } + }.test(); + } + + //Local capture with multiple scopes (local class) + void test3() { + final Integer N = 1; + class MyTester implements Tester { + public void test() { + final Integer M = 2; + int res = LambdaCapture02.exec((Integer x) -> x + N + M, 3); + assertTrue(6 == res); + } + } + new MyTester().test(); + } + + //access to field from enclosing scope + void test4() { + final Integer N = 4; + int res1 = LambdaCapture02.exec((Integer x) -> x + n + N, 3); + assertTrue(12 == res1); + int res2 = LambdaCapture02.exec((Integer x) -> x + LambdaCapture02.this.n + N, 3); + assertTrue(12 == res2); + } + + public static void main(String[] args) { + LambdaCapture02 t = new LambdaCapture02(); + t.test1(); + t.test2(); + t.test3(); + t.test4(); + assertTrue(assertionCount == 5); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaCapture03.java b/langtools/test/tools/javac/lambda/LambdaCapture03.java new file mode 100644 index 00000000000..5399754e6ee --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaCapture03.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * test for capture of non-mutable locals/outer fields in multiple scopes + * @author Maurizio Cimadamore + * @run main LambdaCapture03 + */ + +public class LambdaCapture03 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface Tester { + void test(); + } + + interface TU { + public T foo(U u); + } + + public static T exec(TU lambda, U x) { + return lambda.foo(x); + } + + Integer n1 = 10; + + void test1() { + final Integer N1 = 1; + class A { + Integer n2 = 20; + void test() { + final Integer N2 = 2; + class B { + void test() { + final Integer N3 = 3; + int res = LambdaCapture03.exec((Integer x) -> x + n1 + n2 + N1 + N2 + N3, 30); + assertTrue(res == 66); + } + } + new B().test(); + } + } + new A().test(); + } + + void test2() { + final Integer N1 = 1; + new Tester() { + Integer n2 = 20; + public void test() { + final Integer N2 = 2; + new Tester() { + public void test() { + final Integer N3 = 3; + int res = LambdaCapture03.exec((Integer x) -> x + n1 + n2 + N1 + N2 + N3, 30); + assertTrue(res == 66); + } + }.test(); + } + }.test(); + } + + public static void main(String[] args) { + LambdaCapture03 t = new LambdaCapture03(); + t.test1(); + t.test2(); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaCapture04.java b/langtools/test/tools/javac/lambda/LambdaCapture04.java new file mode 100644 index 00000000000..8f4c193954a --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaCapture04.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * test for capture of non-mutable locals/outer fields in multiple scopes + * @author Maurizio Cimadamore + * @run main LambdaCapture04 + */ + +public class LambdaCapture04 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface Tester { + void test(); + } + + interface TU { + public void foo(U u); + } + + public static void exec(TU lambda, U x) { + lambda.foo(x); + } + + Integer n1 = 10; + + void test1() { + final Integer N1 = 1; + class A { + Integer n2 = 20; + void test() { + final Integer N2 = 2; + class B { + void test() { + final Integer N3 = 3; + exec((final Integer x) -> new Tester() { public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); } }.test(),30); + } + } + new B().test(); + } + } + new A().test(); + } + + void test2() { + final Integer N1 = 1; + class A { + Integer n2 = 20; + void test() { + final Integer N2 = 2; + class B { + void test() { + final Integer N3 = 3; + exec((final Integer x) -> { + class LocTester implements Tester { + public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); } + }; + new LocTester().test(); + },30); + } + } + new B().test(); + } + } + new A().test(); + } + + void test3() { + final Integer N1 = 1; + new Tester() { + Integer n2 = 20; + public void test() { + final Integer N2 = 2; + new Tester() { + public void test() { + final Integer N3 = 3; + exec((final Integer x) -> new Tester() { public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); } }.test(),30); + } + }.test(); + } + }.test(); + } + + void test4() { + final Integer N1 = 1; + new Tester() { + Integer n2 = 20; + public void test() { + final Integer N2 = 2; + new Tester() { + public void test() { + final Integer N3 = 3; + exec((final Integer x) -> { + class LocTester implements Tester { + public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); } + }; + new LocTester().test(); + },30); + } + }.test(); + } + }.test(); + } + + public static void main(String[] args) { + LambdaCapture04 t = new LambdaCapture04(); + t.test1(); + t.test2(); + t.test3(); + t.test4(); + assertTrue(assertionCount == 4); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaCapture05.java b/langtools/test/tools/javac/lambda/LambdaCapture05.java new file mode 100644 index 00000000000..3752dd79a13 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaCapture05.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * test for capture in nested lambda expressions + * @author Maurizio Cimadamore + * @run main LambdaCapture05 + */ + +public class LambdaCapture05 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface TU { + public T foo(U u); + } + + public static T exec(TU lambda, U x) { + return lambda.foo(x); + } + + int i = 40; + + void test1(final int a0) { + exec((final Integer a1) -> { + final Integer x2 = 10; exec((final Integer a2) -> { + final Integer x3 = 20; + exec((final Integer a3) -> { assertTrue(106 == (a0 + a1 + a2 + a3 + x2 + x3 + i)); return null; }, 3); + return null; + },2); + return null; + },1); + } + + static void test2(final int a0) { + exec((final Integer a1) -> { + final Integer x2 = 10; exec((final Integer a2) -> { + final Integer x3 = 20; + exec((final Integer a3) -> { assertTrue(66 == (a0 + a1 + a2 + a3 + x2 + x3)); return null; }, 3); + return null; + }, 2); + return null; + }, 1); + } + + public static void main(String[] args) { + LambdaCapture05 t = new LambdaCapture05(); + t.test1(30); + test2(30); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaCapture06.java b/langtools/test/tools/javac/lambda/LambdaCapture06.java new file mode 100644 index 00000000000..85a6feb0e23 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaCapture06.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @ignore investigate as to whether code generation fails + * @bug 8003280 + * @summary Add lambda tests + * Compiler crash when local inner class nested inside lambda captures local variables from enclosing scope + */ +public class LambdaCapture06 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + void m(int n); + } + + public static void main(String[] args) { + int n = 5; + SAM s = k -> { + new Object() { + void test() { int j = n; assertTrue(j == 5); } + }.test(); + }; + s.m(42); + assertTrue(assertionCount == 1); + } +} + + diff --git a/langtools/test/tools/javac/lambda/LambdaConv01.java b/langtools/test/tools/javac/lambda/LambdaConv01.java new file mode 100644 index 00000000000..73436c2f509 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv01.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * basic test for lambda conversion + * @author Brian Goetz + * @author Maurizio Cimadamore + * @run main LambdaConv01 + */ + +public class LambdaConv01 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface IntToInt { + public int foo(int x); + } + + interface IntToVoid { + public void foo(int x); + } + + interface VoidToInt { + public int foo(); + } + + interface TU { + public T foo(U u); + } + + public static T exec(TU lambda, U x) { + return lambda.foo(x); + } + + static { + //Assignment conversion: + VoidToInt f1 = ()-> 3; + assertTrue(3 == f1.foo()); + //Covariant returns: + TU f2 = (Integer x) -> x; + assertTrue(3 == f2.foo(3)); + //Method resolution with boxing: + int res = LambdaConv01.exec((Integer x) -> x, 3); + assertTrue(3 == res); + //Runtime exception transparency: + try { + LambdaConv01.exec((Object x) -> x.hashCode(), null); + } + catch (RuntimeException e) { + assertTrue(true); + } + } + + { + //Assignment conversion: + VoidToInt f1 = ()-> 3; + assertTrue(3 == f1.foo()); + //Covariant returns: + TU f2 = (Integer x) -> x; + assertTrue(3 == f2.foo(3)); + //Method resolution with boxing: + int res = LambdaConv01.exec((Integer x) -> x, 3); + assertTrue(3 == res); + //Runtime exception transparency: + try { + LambdaConv01.exec((Object x) -> x.hashCode(), null); + } + catch (RuntimeException e) { + assertTrue(true); + } + } + + public static void test1() { + //Assignment conversion: + VoidToInt f1 = ()-> 3; + assertTrue(3 == f1.foo()); + //Covariant returns: + TU f2 = (Integer x) -> x; + assertTrue(3 == f2.foo(3)); + //Method resolution with boxing: + int res = LambdaConv01.exec((Integer x) -> x, 3); + assertTrue(3 == res); + //Runtime exception transparency: + try { + LambdaConv01.exec((Object x) -> x.hashCode(), null); + } + catch (RuntimeException e) { + assertTrue(true); + } + } + + public void test2() { + //Assignment conversion: + VoidToInt f1 = ()-> 3; + assertTrue(3 == f1.foo()); + //Covariant returns: + TU f2 = (Integer x) -> x; + assertTrue(3 == f2.foo(3)); + //Method resolution with boxing: + int res = LambdaConv01.exec((Integer x) -> x, 3); + assertTrue(3 == res); + //Runtime exception transparency: + try { + LambdaConv01.exec((Object x) -> x.hashCode(), null); + } + catch (RuntimeException e) { + assertTrue(true); + } + } + + public static void main(String[] args) { + test1(); + new LambdaConv01().test2(); + assertTrue(assertionCount == 16); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv03.java b/langtools/test/tools/javac/lambda/LambdaConv03.java new file mode 100644 index 00000000000..1c0480bc769 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv03.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * SAM types and method type inference + * @author Brian Goetz + * @author Maurizio Cimadamore + * @run main LambdaConv03 + */ + +public class LambdaConv03 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface TU { + public T foo(U u); + } + + public static T exec(TU lambda, U x) { + return lambda.foo(x); + } + + static { + //Covariant returns: + int i1 = exec((Integer x) -> { return x; }, 3); + assertTrue(3 == i1); + //Method resolution with boxing: + int i2 = exec((Integer x) -> { return x; }, 3); + assertTrue(3 == i2); + //Runtime exception transparency: + try { + exec((Object x) -> { return x.hashCode(); }, null); + } + catch (RuntimeException e) { + assertTrue(true); + } + } + + { + //Covariant returns: + int i1 = exec((Integer x) -> { return x; }, 3); + assertTrue(3 == i1); + //Method resolution with boxing: + int i2 = exec((Integer x) -> { return x; }, 3); + assertTrue(3 == i2); + //Runtime exception transparency: + try { + exec((Object x) -> { return x.hashCode(); }, null); + } + catch (RuntimeException e) { + assertTrue(true); + } + } + + public static void test1() { + //Covariant returns: + int i1 = exec((Integer x) -> { return x; }, 3); + assertTrue(3 == i1); + //Method resolution with boxing: + int i2 = exec((Integer x) -> { return x; }, 3); + assertTrue(3 == i2); + //Runtime exception transparency: + try { + exec((Object x) -> { return x.hashCode(); }, null); + } + catch (RuntimeException e) { + assertTrue(true); + } + } + + public void test2() { + //Covariant returns: + int i1 = exec((Integer x) -> { return x; }, 3); + assertTrue(3 == i1); + //Method resolution with boxing: + int i2 = exec((Integer x) -> { return x; }, 3); + assertTrue(3 == i2); + //Runtime exception transparency: + try { + exec((Object x) -> { return x.hashCode(); }, null); + } + catch (RuntimeException e) { + assertTrue(true); + } + } + + public static void main(String[] args) { + test1(); + new LambdaConv03().test2(); + assertTrue(assertionCount == 12); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv05.java b/langtools/test/tools/javac/lambda/LambdaConv05.java new file mode 100644 index 00000000000..7cce28aef71 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv05.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * function type and method type inference + * @author Alex Buckley + * @author Maurizio Cimadamore + * @run main LambdaConv05 + */ + +import java.util.*; + +public class LambdaConv05 { + + static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + int count = 0; + + void sort(List data) { + Collections.sort(data, + (String a, String b) -> { LambdaConv05.this.count++; return a.length()-b.length(); }); + } + + public static void main(String[] args) { + ArrayList arr = new ArrayList<>(); + arr.add("Three"); + arr.add("Four"); + arr.add("One"); + LambdaConv05 sorter = new LambdaConv05(); + sorter.sort(arr); + assertTrue(arr.get(0).equals("One")); + assertTrue(arr.get(1).equals("Four")); + assertTrue(arr.get(2).equals("Three")); + assertTrue(sorter.count == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv06.java b/langtools/test/tools/javac/lambda/LambdaConv06.java new file mode 100644 index 00000000000..404ca52dfcd --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv06.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * ensure that definite assignment analysis doesn't mess up with lambda attribution + * @author Jan Lahoda + * @author Maurizio Cimadamore + * @compile LambdaConv06.java + */ + +class LambdaConv06 { + + private int t() { + return a((final Object indexed) -> { + return b(new R() { + public String build(final Object index) { + return ""; + } + }); + }); + } + + private int a(R r) {return 0;} + private String b(R r) {return null;} + + public static interface R { + public String build(Object o); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv08.java b/langtools/test/tools/javac/lambda/LambdaConv08.java new file mode 100644 index 00000000000..83638662505 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv08.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that SAM conversion handles covarinat return types correctly + * @author Peter Levart + * @author Maurizio Cimadamore + * @run main LambdaConv08 + */ + +public class LambdaConv08 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + public interface ObjectF { Object invoke(); } + public interface StringF extends ObjectF { String invoke(); } + + public static void call(StringF stringFunc) { + assertTrue(true); + } + + public static void call(ObjectF objectFunc) { } + + public static void main(String[] args) { + call(()-> "Hello"); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv09.java b/langtools/test/tools/javac/lambda/LambdaConv09.java new file mode 100644 index 00000000000..7ae19930940 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv09.java @@ -0,0 +1,50 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that SAM conversion handles Object members correctly + * @author Alex Buckley + * @author Maurizio Cimadamore + * @compile/fail/ref=LambdaConv09.out -XDrawDiagnostics LambdaConv09.java + */ + +class LambdaConv09 { + + // Not a SAM type; not enough abstract methods + interface Foo1 {} + + // SAM type; Foo has no abstract methods + interface Foo2 { boolean equals(Object object); } + + + // Not a SAM type; Foo still has no abstract methods + interface Foo3 extends Foo2 { public abstract String toString(); } + + // SAM type; Bar has one abstract non-Object method + interface Foo4 extends Foo2 { int compare(T o1, T o2); } + + // Not a SAM type; still no valid abstract methods + interface Foo5 { + boolean equals(Object object); + String toString(); + } + + // SAM type; Foo6 has one abstract non-Object method + interface Foo6 { + boolean equals(Object obj); + int compare(T o1, T o2); + } + + // SAM type; Foo6 has one abstract non-Object method + interface Foo7 extends Foo2, Foo6 { } + + void test() { + Foo1 f1 = ()-> { }; + Foo2 f2 = ()-> { }; + Foo3 f3 = x -> true; + Foo4 f4 = (x, y) -> 1; + Foo5 f5 = x -> true; + Foo6 f6 = (x, y) -> 1; + Foo7 f7 = (x, y) -> 1; + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv09.out b/langtools/test/tools/javac/lambda/LambdaConv09.out new file mode 100644 index 00000000000..1f99986794c --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv09.out @@ -0,0 +1,5 @@ +LambdaConv09.java:42:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo1)) +LambdaConv09.java:43:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo2)) +LambdaConv09.java:44:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo3)) +LambdaConv09.java:46:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo5)) +4 errors diff --git a/langtools/test/tools/javac/lambda/LambdaConv10.java b/langtools/test/tools/javac/lambda/LambdaConv10.java new file mode 100644 index 00000000000..cc11f967f19 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv10.java @@ -0,0 +1,17 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that lambda conversion does not allow boxing of lambda parameters + * @author Maurizio Cimadamore + * @compile/fail/ref=LambdaConv10.out -XDrawDiagnostics LambdaConv10.java + */ + +class LambdaConv10 { + + interface Method1 { public R call( A1 a1 ); } + + public static void main( final String... notUsed ) { + Method1 m1 = (int i) -> 2 * i; + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv10.out b/langtools/test/tools/javac/lambda/LambdaConv10.out new file mode 100644 index 00000000000..0f58e5e4054 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv10.out @@ -0,0 +1,2 @@ +LambdaConv10.java:15:39: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda) +1 error diff --git a/langtools/test/tools/javac/lambda/LambdaConv11.java b/langtools/test/tools/javac/lambda/LambdaConv11.java new file mode 100644 index 00000000000..f69601477b3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv11.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * issues with lambda conversion involving generic class hierarchies + * @author Maurizio Cimadamore + * @compile LambdaConv11.java + */ + +import java.util.Comparator; + +class LambdaConv11 { + + interface SAM extends Comparator { + public int compare(X left, X right); + } + + SAM y = (l, r) -> 0; +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv12.java b/langtools/test/tools/javac/lambda/LambdaConv12.java new file mode 100644 index 00000000000..59ef7cacd74 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv12.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * instance creation expression should allow lambda expressions as constrcutor arguments + * @author Maurizio Cimadamore + * @compile LambdaConv12.java + */ + +class LambdaConv12 { + + LambdaConv12(SAM s) {} + + interface SAM { + public abstract void m(); + } + + void test() { + new LambdaConv12(()-> { }); + new LambdaConv12(()-> { }) {}; + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv13.java b/langtools/test/tools/javac/lambda/LambdaConv13.java new file mode 100644 index 00000000000..326609aa60b --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv13.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * interface methods in diamond shaped inheritance trees shouldn't be counted twice + * @author Maurizio Cimadamore + * @compile LambdaConv13.java + */ + +class LambdaConv13 { + + interface I { + void m(); + } + + interface A extends I {} + interface B extends I {} + interface C extends A, B {} + interface D extends A, I {} + interface E extends B, I {} + + C c = ()-> { }; + D d = ()-> { }; + D e = ()-> { }; +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv16.java b/langtools/test/tools/javac/lambda/LambdaConv16.java new file mode 100644 index 00000000000..04c30596e4b --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv16.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * SAM conversion and raw types in argument/return types + * @author Maurizio Cimadamore + * @run main LambdaConv16 + */ + +import java.util.*; + +public class LambdaConv16 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface A { + Iterable m(List ls); + } + + interface B { + Iterable m(List l); + } + + interface AB extends A, B {} //SAM type ([List], Iterable, {}) + + static void test(AB ab, List l) { ab.m(l); } + + public static void main(String[] args) { + AB ab = (List list) -> { assertTrue(true); return new ArrayList(); }; + ab.m(null); + test((List list) -> { assertTrue(true); return new ArrayList(); }, null); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv17.java b/langtools/test/tools/javac/lambda/LambdaConv17.java new file mode 100644 index 00000000000..7cf937140f3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv17.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * lambda compiler crashes if lambda has try-with-resources + * @compile LambdaConv17.java + */ + +class LambdaConv17 { + interface SAM { + void m() throws Exception; + } + + SAM s = ()-> { try (AutoCloseable ac = null){ } }; +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv18.java b/langtools/test/tools/javac/lambda/LambdaConv18.java new file mode 100644 index 00000000000..279d99ff17c --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv18.java @@ -0,0 +1,24 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * simple test for lambda candidate check + * @compile/fail/ref=LambdaConv18.out -XDrawDiagnostics -XDidentifyLambdaCandidate=true LambdaConv18.java + */ + +class LambdaConv18 { + + interface SAM { + void m(); + } + + interface NonSAM { + void m1(); + void m2(); + } + + SAM s1 = new SAM() { public void m() {} }; + NonSAM s2 = new NonSAM() { public void m1() {} + public void m2() {} }; + NonExistent s3 = new NonExistent() { public void m() {} }; +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv18.out b/langtools/test/tools/javac/lambda/LambdaConv18.out new file mode 100644 index 00000000000..fa84e6b43f3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv18.out @@ -0,0 +1,4 @@ +LambdaConv18.java:23:5: compiler.err.cant.resolve.location: kindname.class, NonExistent, , , (compiler.misc.location: kindname.class, LambdaConv18, null) +LambdaConv18.java:20:24: compiler.note.potential.lambda.found +LambdaConv18.java:23:26: compiler.err.cant.resolve.location: kindname.class, NonExistent, , , (compiler.misc.location: kindname.class, LambdaConv18, null) +2 errors diff --git a/langtools/test/tools/javac/lambda/LambdaConv19.java b/langtools/test/tools/javac/lambda/LambdaConv19.java new file mode 100644 index 00000000000..4ba76e65819 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv19.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that redundant cast warnings are not generated for SAM conversions + * @compile -Xlint:cast -Werror LambdaConv19.java + */ + +class LambdaConv19 { + + interface SAM { + void m(); + } + + SAM s = (SAM)()-> { }; +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv20.java b/langtools/test/tools/javac/lambda/LambdaConv20.java new file mode 100644 index 00000000000..4a9e9c38778 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv20.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that synthetic casts are added when erased type of lambda body + * ends up being too general + * @run main LambdaConv20 + */ + +import java.util.*; + +public class LambdaConv20 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + X m(List l); + } + + public static void main(String[] args) { + SAM si1 = l -> l.get(0); + assertTrue(si1.m(Arrays.asList(1)) == 1); + SAM si2 = l -> { return l.get(0); }; + assertTrue(si2.m(Arrays.asList(1)) == 1); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv21.java b/langtools/test/tools/javac/lambda/LambdaConv21.java new file mode 100644 index 00000000000..ecc45931588 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv21.java @@ -0,0 +1,38 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that code generation handles void-compatibility correctly + * @compile/fail/ref=LambdaConv21.out -XDrawDiagnostics LambdaConv21.java + */ + +class LambdaConv21 { + + interface SAM_void { + void m(); + } + + interface SAM_java_lang_Void { + Void m(); + } + + static void m_void() { } + + static Void m_java_lang_Void() { return null; } + + static void testExpressionLambda() { + SAM_void s1 = ()->m_void(); //ok + SAM_java_lang_Void s2 = ()->m_void(); //no - incompatible target + SAM_void s3 = ()->m_java_lang_Void(); //no - incompatible target + SAM_java_lang_Void s4 = ()->m_java_lang_Void(); //ok + } + + static void testStatementLambda() { + SAM_void s1 = ()-> { m_void(); }; //ok + SAM_java_lang_Void s2 = ()-> { m_void(); }; //no - missing return value + SAM_void s3 = ()-> { return m_java_lang_Void(); }; //no - unexpected return value + SAM_java_lang_Void s4 = ()-> { return m_java_lang_Void(); }; //ok + SAM_void s5 = ()-> { m_java_lang_Void(); }; //ok + SAM_java_lang_Void s6 = ()-> { m_java_lang_Void(); }; //no - missing return value + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv21.out b/langtools/test/tools/javac/lambda/LambdaConv21.out new file mode 100644 index 00000000000..1ddf803701b --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv21.out @@ -0,0 +1,6 @@ +LambdaConv21.java:25:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Void)) +LambdaConv21.java:26:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Void, void)) +LambdaConv21.java:32:33: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void)) +LambdaConv21.java:33:53: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val)) +LambdaConv21.java:36:33: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void)) +5 errors diff --git a/langtools/test/tools/javac/lambda/LambdaConv22.java b/langtools/test/tools/javac/lambda/LambdaConv22.java new file mode 100644 index 00000000000..0ef1a9f8e55 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv22.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * inner class translator fails with spurious method clash errors + * @compile LambdaConv22.java + */ + +class LambdaConv22 { + + interface Factory { T make(); } + + U make() { return null; } + + void test(U u) { + Factory fu1 = () -> u; + Factory fu2 = this::make; + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv23.java b/langtools/test/tools/javac/lambda/LambdaConv23.java new file mode 100644 index 00000000000..a4197cc8ec7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv23.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check super varargs reference is handled correctly + * @run main LambdaConv23 + */ +public class LambdaConv23 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { void m(Integer a, Integer b); } + + static class Super { + void m(Object... vi) { assertTrue(true); } + } + + + static class Sub extends Super { + + void m(Object... vi) { assertTrue(false); } + + public void test() { + SAM q = super::m; + q.m(1, 2); + } + } + + public static void main(String[] args) { + new Sub().test(); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConv24.java b/langtools/test/tools/javac/lambda/LambdaConv24.java new file mode 100644 index 00000000000..4ddb0493174 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConv24.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that lambda inside 'this' call is handled properly + * @run main LambdaConv24 + */ +public class LambdaConv24 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + boolean m(X x); + } + + LambdaConv24(SAM p) { + assertTrue(p.m("42")); + } + + LambdaConv24(int i) { + this(s->true); + } + + LambdaConv24(int i1, int i2) { + this(LambdaConv24::m); + } + + static boolean m(String s) { return true; } + + public static void main(String[] args) { + new LambdaConv24(1); + new LambdaConv24(1,2); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaConversionTest.java b/langtools/test/tools/javac/lambda/LambdaConversionTest.java new file mode 100644 index 00000000000..0db2904e665 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaConversionTest.java @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * perform several automated checks in lambda conversion, esp. around accessibility + * @author Maurizio Cimadamore + * @run main LambdaConversionTest + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class LambdaConversionTest { + + enum PackageKind { + NO_PKG(""), + PKG_A("a"); + + String pkg; + + PackageKind(String pkg) { + this.pkg = pkg; + } + + String getPkgDecl() { + return this == NO_PKG ? + "" : + "package " + pkg + ";"; + } + + String getImportStat() { + return this == NO_PKG ? + "" : + "import " + pkg + ".*;"; + } + } + + enum SamKind { + CLASS("public class Sam { }"), + ABSTACT_CLASS("public abstract class Sam { }"), + ANNOTATION("public @interface Sam { }"), + ENUM("public enum Sam { }"), + INTERFACE("public interface Sam { \n #METH; \n }"); + + String sam_str; + + SamKind(String sam_str) { + this.sam_str = sam_str; + } + + String getSam(String methStr) { + return sam_str.replaceAll("#METH", methStr); + } + } + + enum ModifierKind { + PUBLIC("public"), + PACKAGE(""); + + String modifier_str; + + ModifierKind(String modifier_str) { + this.modifier_str = modifier_str; + } + + boolean stricterThan(ModifierKind that) { + return this.ordinal() > that.ordinal(); + } + } + + enum TypeKind { + EXCEPTION("Exception"), + PKG_CLASS("PackageClass"); + + String typeStr; + + private TypeKind(String typeStr) { + this.typeStr = typeStr; + } + } + + enum MethodKind { + NONE(""), + NON_GENERIC("public #R m(#ARG s) throws #T;"), + GENERIC("public #R m(#ARG s) throws #T;"); + + String methodTemplate; + + private MethodKind(String methodTemplate) { + this.methodTemplate = methodTemplate; + } + + String getMethod(TypeKind retType, TypeKind argType, TypeKind thrownType) { + return methodTemplate.replaceAll("#R", retType.typeStr). + replaceAll("#ARG", argType.typeStr). + replaceAll("#T", thrownType.typeStr); + } + } + + public static void main(String[] args) throws Exception { + for (PackageKind samPkg : PackageKind.values()) { + for (ModifierKind modKind : ModifierKind.values()) { + for (SamKind samKind : SamKind.values()) { + for (MethodKind meth : MethodKind.values()) { + for (TypeKind retType : TypeKind.values()) { + for (TypeKind argType : TypeKind.values()) { + for (TypeKind thrownType : TypeKind.values()) { + new LambdaConversionTest(samPkg, modKind, samKind, + meth, retType, argType, thrownType).test(); + } + } + } + } + } + } + } + } + + PackageKind samPkg; + ModifierKind modKind; + SamKind samKind; + MethodKind meth; + TypeKind retType; + TypeKind argType; + TypeKind thrownType; + + SourceFile samSourceFile = new SourceFile("Sam.java", "#P \n #C") { + public String toString() { + return template.replaceAll("#P", samPkg.getPkgDecl()). + replaceAll("#C", samKind.getSam(meth.getMethod(retType, argType, thrownType))); + } + }; + + SourceFile pkgClassSourceFile = new SourceFile("PackageClass.java", + "#P\n #M class PackageClass extends Exception { }") { + public String toString() { + return template.replaceAll("#P", samPkg.getPkgDecl()). + replaceAll("#M", modKind.modifier_str); + } + }; + + SourceFile clientSourceFile = new SourceFile("Client.java", + "#I\n class Client { Sam s = x -> null; }") { + public String toString() { + return template.replaceAll("#I", samPkg.getImportStat()); + } + }; + + LambdaConversionTest(PackageKind samPkg, ModifierKind modKind, SamKind samKind, + MethodKind meth, TypeKind retType, TypeKind argType, TypeKind thrownType) { + this.samPkg = samPkg; + this.modKind = modKind; + this.samKind = samKind; + this.meth = meth; + this.retType = retType; + this.argType = argType; + this.thrownType = thrownType; + } + + void test() throws Exception { + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + DiagnosticChecker dc = new DiagnosticChecker(); + JavacTask ct = (JavacTask)tool.getTask(null, null, dc, + null, null, Arrays.asList(samSourceFile, pkgClassSourceFile, clientSourceFile)); + ct.analyze(); + if (dc.errorFound == checkSamConversion()) { + throw new AssertionError(samSourceFile + "\n\n" + pkgClassSourceFile + "\n\n" + clientSourceFile); + } + } + + boolean checkSamConversion() { + if (samKind != SamKind.INTERFACE) { + //sam type must be an interface + return false; + } else if (meth != MethodKind.NON_GENERIC) { + //target method must be non-generic + return false; + } else if (samPkg != PackageKind.NO_PKG && + modKind != ModifierKind.PUBLIC && + (retType == TypeKind.PKG_CLASS || + argType == TypeKind.PKG_CLASS || + thrownType == TypeKind.PKG_CLASS)) { + //target must not contain inaccessible types + return false; + } else { + return true; + } + } + + abstract class SourceFile extends SimpleJavaFileObject { + + protected String template; + + public SourceFile(String filename, String template) { + super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE); + this.template = template; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return toString(); + } + + public abstract String toString(); + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound = false; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java b/langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java new file mode 100644 index 00000000000..944d554840d --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java @@ -0,0 +1,60 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Integrate efectively final check with DA/DU analysis + * @compile/fail/ref=LambdaEffectivelyFinalTest.out -XDrawDiagnostics LambdaEffectivelyFinalTest.java + */ +class LambdaEffectivelyFinalTest { + + interface SAM { + int m(); + } + + void foo(LambdaEffectivelyFinalTest.SAM s) { } + + void m1(int x) { + int y = 1; + foo(() -> x+y); // Legal: x and y are both effectively final. + } + + void m2(int x) { + int y; + y = 1; + foo(() -> x+y); // Legal: x and y are both effectively final. + } + + void m3(int x, boolean cond) { + int y; + if (cond) y = 1; + foo(() -> x+y); // Illegal: y is effectively final, but not definitely assigned. + } + + void m4(int x, boolean cond) { + int y; + if (cond) y = 1; + else y = 2; + foo(() -> x+y); // Legal: x and y are both effectively final. + } + + void m5(int x, boolean cond) { + int y; + if (cond) y = 1; + y = 2; + foo(() -> x+y); // Illegal: y is not effectively final.t EF + } + + void m6(int x) { + foo(() -> x+1); + x++; // Illegal: x is not effectively final. + } + + void m7(int x) { + foo(() -> x=1); // Illegal: x in the assignment does not denote a variable (see 6.5.6.1) + } + + void m8() { + int y; + foo(() -> y=1); // Illegal: y in the assignment does not denote a variable (see 6.5.6.1) + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out b/langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out new file mode 100644 index 00000000000..8291f3b7307 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out @@ -0,0 +1,6 @@ +LambdaEffectivelyFinalTest.java:30:21: compiler.err.var.might.not.have.been.initialized: y +LambdaEffectivelyFinalTest.java:44:21: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda) +LambdaEffectivelyFinalTest.java:48:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda) +LambdaEffectivelyFinalTest.java:53:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda) +LambdaEffectivelyFinalTest.java:58:19: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda) +5 errors diff --git a/langtools/test/tools/javac/lambda/LambdaExpr01.java b/langtools/test/tools/javac/lambda/LambdaExpr01.java new file mode 100644 index 00000000000..d0960c9b2a8 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr01.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * basic test for simple lambda expressions in multiple scopes + * @author Brian Goetz + * @author Maurizio Cimadamore + * @run main LambdaExpr01 + */ + +public class LambdaExpr01 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface S_int { + int m(); + } + + interface S_Integer { + Integer m(); + } + + interface S_int_int { + int m(int i); + } + + interface S_Integer_int { + int m(Integer i); + } + + interface S_int_Integer { + Integer m(int i); + } + + interface S_Integer_Integer { + Integer m(Integer i); + } + + static { + S_int s_i = ()-> 3; + assertTrue(3 == s_i.m()); + S_Integer s_I = ()-> 3; + assertTrue(3 == s_I.m()); + S_int_int s_i_i = (int x)-> x+1; + assertTrue(4 == s_i_i.m(3)); + S_int_Integer s_i_I = (int x)-> x+1; + assertTrue(4 == s_i_I.m(3)); + S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1; + assertTrue(4 == s_I_i.m(3)); + S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1; + assertTrue(4 == s_I_I.m(3)); + } + + { + S_int s_i = ()-> 3; + assertTrue(3 == s_i.m()); + S_Integer s_I = ()-> 3; + assertTrue(3 == s_I.m()); + S_int_int s_i_i = (int x)-> x+1; + assertTrue(4 == s_i_i.m(3)); + S_int_Integer s_i_I = (int x)-> x+1; + assertTrue(4 == s_i_I.m(3)); + S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1; + assertTrue(4 == s_I_i.m(3)); + S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1; + assertTrue(4 == s_I_I.m(3)); + } + + static void test1() { + S_int s_i = ()-> 3; + assertTrue(3 == s_i.m()); + S_Integer s_I = ()-> 3; + assertTrue(3 == s_I.m()); + S_int_int s_i_i = (int x)-> x+1; + assertTrue(4 == s_i_i.m(3)); + S_int_Integer s_i_I = (int x)-> x+1; + assertTrue(4 == s_i_I.m(3)); + S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1; + assertTrue(4 == s_I_i.m(3)); + S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1; + assertTrue(4 == s_I_I.m(3)); + } + + void test2() { + S_int s_i = ()-> 3; + assertTrue(3 == s_i.m()); + S_Integer s_I = ()-> 3; + assertTrue(3 == s_I.m()); + S_int_int s_i_i = (int x)-> x+1; + assertTrue(4 == s_i_i.m(3)); + S_int_Integer s_i_I = (int x)-> x+1; + assertTrue(4 == s_i_I.m(3)); + S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1; + assertTrue(4 == s_I_i.m(3)); + S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1; + assertTrue(4 == s_I_I.m(3)); + } + + public static void main(String[] args) { + test1(); + new LambdaExpr01().test2(); + assertTrue(assertionCount == 24); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr02.java b/langtools/test/tools/javac/lambda/LambdaExpr02.java new file mode 100644 index 00000000000..d2fb358dbe3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr02.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * basic test for simple lambda expressions in multiple scopes + * @author Brian Goetz + * @author Maurizio Cimadamore + * @run main LambdaExpr01 + */ + +public class LambdaExpr02 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface S_int { + int m(); + } + + interface S_Integer { + Integer m(); + } + + interface S_int_int { + int m(int i); + } + + interface S_Integer_int { + int m(Integer i); + } + + interface S_int_Integer { + Integer m(int i); + } + + interface S_Integer_Integer { + Integer m(Integer i); + } + + static { + S_int s_i = ()-> { return 3; }; + assertTrue(3 == s_i.m()); + S_Integer s_I = ()-> { return 3; }; + assertTrue(3 == s_I.m()); + S_int_int s_i_i = (int x) -> { return x + 1; }; + assertTrue(4 == s_i_i.m(3)); + S_int_Integer s_i_I = (int x) -> { return x + 1; }; + assertTrue(4 == s_i_I.m(3)); + S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; }; + assertTrue(4 == s_I_i.m(3)); + S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; }; + assertTrue(4 == s_I_I.m(3)); + } + + { + S_int s_i = ()-> { return 3; }; + assertTrue(3 == s_i.m()); + S_Integer s_I = ()-> { return 3; }; + assertTrue(3 == s_I.m()); + S_int_int s_i_i = (int x) -> { return x + 1; }; + assertTrue(4 == s_i_i.m(3)); + S_int_Integer s_i_I = (int x) -> { return x + 1; }; + assertTrue(4 == s_i_I.m(3)); + S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; }; + assertTrue(4 == s_I_i.m(3)); + S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; }; + assertTrue(4 == s_I_I.m(3)); + } + + static void test1() { + S_int s_i = ()-> { return 3; }; + assertTrue(3 == s_i.m()); + S_Integer s_I = ()-> { return 3; }; + assertTrue(3 == s_I.m()); + S_int_int s_i_i = (int x) -> { return x + 1; }; + assertTrue(4 == s_i_i.m(3)); + S_int_Integer s_i_I = (int x) -> { return x + 1; }; + assertTrue(4 == s_i_I.m(3)); + S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; }; + assertTrue(4 == s_I_i.m(3)); + S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; }; + assertTrue(4 == s_I_I.m(3)); + } + + void test2() { + S_int s_i = ()-> { return 3; }; + assertTrue(3 == s_i.m()); + S_Integer s_I = ()-> { return 3; }; + assertTrue(3 == s_I.m()); + S_int_int s_i_i = (int x) -> { return x + 1; }; + assertTrue(4 == s_i_i.m(3)); + S_int_Integer s_i_I = (int x) -> { return x + 1; }; + assertTrue(4 == s_i_I.m(3)); + S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; }; + assertTrue(4 == s_I_i.m(3)); + S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; }; + assertTrue(4 == s_I_I.m(3)); + } + + public static void main(String[] args) { + test1(); + new LambdaExpr02().test2(); + assertTrue(assertionCount == 24); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr04.java b/langtools/test/tools/javac/lambda/LambdaExpr04.java new file mode 100644 index 00000000000..eadf8266e36 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr04.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that lambda initializers compile w/o problems + * @author Jan Lahoda + * @author Maurizio Cimadamore + * @compile LambdaExpr04.java + */ + +class LambdaExpr04 { + + interface SAM { + void m(int i); + } + static SAM lambda_01 = (int pos) -> { }; + + static final SAM lambda_02 = (int pos) -> { }; + + SAM lambda_03 = (int pos) -> { }; + + final SAM lambda_04 = (int pos) -> { }; +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr05.java b/langtools/test/tools/javac/lambda/LambdaExpr05.java new file mode 100644 index 00000000000..db0348f0641 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr05.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that binary expression in lambda expression is parsed correctly + * @author Maurizio Cimadamore + * @compile LambdaExpr05.java + */ + +class LambdaExpr05 { + + interface SAM { int foo(int i); } + + SAM s1 = i -> i * 2; + SAM s2 = i -> 2 * i; +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr06.java b/langtools/test/tools/javac/lambda/LambdaExpr06.java new file mode 100644 index 00000000000..71d47caa346 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr06.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * parser test for nested parenthesized lambda expression + * @run main LambdaExpr06 + */ + +public class LambdaExpr06 { + + static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + interface A { + int m(); + } + + interface B { + int dup(int i); + } + + public static void main(String[] args) { + A a = ()-> ((B)i -> i * 2).dup(3); + assertTrue(a.m() == 6); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr07.java b/langtools/test/tools/javac/lambda/LambdaExpr07.java new file mode 100644 index 00000000000..2ea0f754f0a --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr07.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check access to effectively final local variable from doubly nested lambda + * @run main LambdaExpr07 + */ + +public class LambdaExpr07 { + + interface Block { + R apply(A x); + } + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + String S = "A"; + + void test() { + Block> o = s1 -> s2 -> S + s1 + s2; + assertTrue(o.apply("B").apply("C").equals("ABC")); + } + + public static void main(String[] args) { + new LambdaExpr07().test(); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr08.java b/langtools/test/tools/javac/lambda/LambdaExpr08.java new file mode 100644 index 00000000000..bb48c3eb71b --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr08.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that reference to local final variable w/o initializer is accepted + * @compile LambdaExpr08.java + */ + +class LambdaExpr08 { + + interface SAM { + String m(); + } + + void test() { + final String s; + s = ""; + SAM sam = () -> s; + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr09.java b/langtools/test/tools/javac/lambda/LambdaExpr09.java new file mode 100644 index 00000000000..e42e29865c1 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr09.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that lambda in array initializers is correctly accepted + * @compile LambdaExpr09.java + */ + +class LambdaExpr09 { + + interface Block { + void m(T t); + } + + void apply(Object[] obj_arr) { } + + void test1() { + Block[] arr1 = { t -> { }, t -> { } }; + Block[][] arr2 = { { t -> { }, t -> { } }, { t -> { }, t -> { } } }; + } + + void test2() { + Block[] arr1 = new Block[]{ t -> { }, t -> { } }; + Block[][] arr2 = new Block[][]{ { t -> { }, t -> { } }, { t -> { }, t -> { } } }; + } + + void test3() { + apply(new Block[]{ t -> { }, t -> { } }); + apply(new Block[][]{ { t -> { }, t -> { } }, { t -> { }, t -> { } } }); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr10.java b/langtools/test/tools/javac/lambda/LambdaExpr10.java new file mode 100644 index 00000000000..299582a5339 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr10.java @@ -0,0 +1,37 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that lambda in array initializers (with wrong type) are correctly rejected + * @compile/fail/ref=LambdaExpr10.out -XDrawDiagnostics LambdaExpr10.java + */ + +class LambdaExpr10 { + + interface Block { + void m(T t); + } + + void apply(Object[] obj_arr) { } + + void test1() { + Object[] arr1 = { t -> { } }; + Object[][] arr2 = { { t -> { } } }; + } + + void test2() { + Object[] arr1 = new Object[]{ t -> { } }; + Object[][] arr2 = new Object[][]{ { t -> { } } }; + } + + void test3() { + apply(new Object[]{ t -> { } }); + apply(new Object[][]{ { t -> { } } }); + } + + void test4() { + Block[] arr1 = { t -> t }; + Block[] arr2 = new Block[]{ t -> t }; + apply(new Block[]{ t -> { }, t -> { } }); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr10.out b/langtools/test/tools/javac/lambda/LambdaExpr10.out new file mode 100644 index 00000000000..adcba0ad43e --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr10.out @@ -0,0 +1,9 @@ +LambdaExpr10.java:18:28: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +LambdaExpr10.java:19:32: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +LambdaExpr10.java:23:40: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +LambdaExpr10.java:24:46: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +LambdaExpr10.java:28:29: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +LambdaExpr10.java:29:33: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +LambdaExpr10.java:33:35: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void)) +LambdaExpr10.java:34:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void)) +8 errors diff --git a/langtools/test/tools/javac/lambda/LambdaExpr11.java b/langtools/test/tools/javac/lambda/LambdaExpr11.java new file mode 100644 index 00000000000..81e69b38e86 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr11.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that creating an inner class from a lambda does add a captured this + * @run main LambdaExpr11 + */ +public class LambdaExpr11 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + class Inner { + Inner() { assertTrue(true); } + } + + void test() { + Runnable r1 = ()-> { new Inner(); }; + r1.run(); + Runnable r2 = ()-> { new Inner() {}; }; + r2.run(); + Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); }; + r3.run(); + Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; }; + r4.run(); + new Inner2().test(); + } + + class Inner2 { + void test() { + Runnable r1 = ()-> { new Inner(); }; + r1.run(); + Runnable r2 = ()-> { new Inner() {}; }; + r2.run(); + Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); }; + r3.run(); + Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; }; + r4.run(); + new Inner3().test(); + } + + class Inner3 { + void test() { + Runnable r1 = ()-> { new Inner(); }; + r1.run(); + Runnable r2 = ()-> { new Inner() {}; }; + r2.run(); + Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); }; + r3.run(); + Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; }; + r4.run(); + } + } + } + + public static void main(String[] args) { + new LambdaExpr11().test(); + assertTrue(assertionCount == 12); + } +} + diff --git a/langtools/test/tools/javac/lambda/LambdaExpr12.java b/langtools/test/tools/javac/lambda/LambdaExpr12.java new file mode 100644 index 00000000000..5fe27135fd6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr12.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that creating an inner class from a lambda does add a captured this + * @run main LambdaExpr12 + */ + +public class LambdaExpr12 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface Getter { + X get(); + } + + + interface Mapper { + Y map(X x); + } + + void test() { + Mapper> mapper = + (final String s) -> new Getter() { + @Override + public Character get() { + return s.charAt(0); + } + }; + assertTrue(mapper.map("First").get() == 'F'); + } + + public static void main(String[] args) { + new LambdaExpr12().test(); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr13.java b/langtools/test/tools/javac/lambda/LambdaExpr13.java new file mode 100644 index 00000000000..7a5181e54fe --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr13.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that recursive lambda (through field ref) is accepted in all contexts + * @compile LambdaExpr13.java + */ + +class LambdaExpr13 { + + Runnable ir = () -> { ir.run(); };; + static Runnable sr = () -> { sr.run(); }; + + { ir = () -> { ir.run(); }; } + static { sr = () -> { sr.run(); }; } + + static void m1() { + sr = () -> { sr.run(); }; + } + + void m2() { + ir = () -> { ir.run(); }; + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr14.java b/langtools/test/tools/javac/lambda/LambdaExpr14.java new file mode 100644 index 00000000000..e7290935ee7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr14.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that recursion from doubly nested lambda is handled correctly + */ + +public class LambdaExpr14 { + + interface SAM { + SAM invoke(); + } + + static SAM local; + + public static void main(String[] args) { + local = () -> () -> local.invoke(); + local.invoke().invoke(); // Not a recursive lambda - exec should terminate + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr15.java b/langtools/test/tools/javac/lambda/LambdaExpr15.java new file mode 100644 index 00000000000..3b38e8039b6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr15.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @ignore investigate as to whether code generation fails + * @bug 8003280 + * @summary Add lambda tests + * check that nested inner class in statement lambdas don't get corrupted return statements + * @run main LambdaExpr15 + */ +public class LambdaExpr15 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface Block { + void apply(T t); + } + + public static void main(String[] args) { + //anon class + Block ba1 = t -> { + new Object() { + String get() { return ""; } + }; + assertTrue(t == 1); + }; + ba1.apply(1); + + //local class + Block ba2 = t -> { + class A { + String get() { return ""; } + }; + new A(); + assertTrue(t == 2); + }; + ba2.apply(2); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr16.java b/langtools/test/tools/javac/lambda/LambdaExpr16.java new file mode 100644 index 00000000000..7d2200c4b24 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr16.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that super inside lambda is handled correctly + * @run main LambdaExpr16 + */ +public class LambdaExpr16 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface A { void m(); } + + static class Sup { + void m() { + assertTrue(true); + } + } + + static class Sub extends Sup { + void testLambda1() { + A a = ()->{ super.m(); }; + a.m(); + } + void testLambda2() { + A a = () -> { A a1 = () -> { super.m(); }; a1.m(); }; + a.m(); + } + void testRef1() { + A a = () -> { A a1 = super::m; a1.m(); }; + a.m(); + } + void testRef2() { + A a = () -> { A a1 = () -> { A a2 = super::m; a2.m(); }; a1.m(); }; + a.m(); + } + } + + public static void main(String[] args) { + Sub s = new Sub(); + s.testLambda1(); + s.testLambda2(); + s.testRef1(); + s.testRef2(); + assertTrue(assertionCount == 4); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr17.java b/langtools/test/tools/javac/lambda/LambdaExpr17.java new file mode 100644 index 00000000000..3be3a64b5d8 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr17.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that super in argument position inside lambda is handled correctly + * @run main LambdaExpr17 + */ +public class LambdaExpr17 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + void m(); + } + + static class Sup { + protected String m() { + assertTrue(true); + return "Hello!"; + } + } + + static class Sub extends Sup { + void test() { + SAM s = () -> { System.out.println(super.m()); }; + s.m(); + } + } + + public static void main(String[] args) { + new Sub().test(); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr18.java b/langtools/test/tools/javac/lambda/LambdaExpr18.java new file mode 100644 index 00000000000..fee12b637e6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr18.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that synthetic casts from outer environment are not inserted twice + * @run main LambdaExpr18 + */ +public class LambdaExpr18 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + R eval(); + } + + static void test(){ + SAM sam1 = () -> { + assertTrue(true); + SAM sam2 = () -> { + assertTrue(true); + return ""; + }; + sam2.eval(); + return 1; + }; + sam1.eval(); + } + + public static void main(String[] args) { + test(); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr19.java b/langtools/test/tools/javac/lambda/LambdaExpr19.java new file mode 100644 index 00000000000..1a1ba3da493 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr19.java @@ -0,0 +1,53 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that inner scopes are left after a lambda check exception has been thrown + * @compile/fail/ref=LambdaExpr19.out -XDrawDiagnostics LambdaExpr19.java + */ +class LambdaExpr19 { + + interface SAM { + String m(); + } + + void m(SAM s) { } + + void testTry() { + m(() -> { + try { return 1; } + catch (Exception e) { } + }); + } + + void testTryWithResources() { + m(() -> { + try (AutoCloseable c = null) { return 1; } + catch (Exception e) { } + }); + } + + void testSwitch() { + m(() -> { + switch (1) { + default: return 1; + } + }); + } + + void testFor() { + m(() -> { + for (;;) { + return 1; + } + }); + } + + void testForeach() { + m(() -> { + for (Object o : new Object[] { null , null }) { + return 1; + } + }); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExpr19.out b/langtools/test/tools/javac/lambda/LambdaExpr19.out new file mode 100644 index 00000000000..7b5a94f45f6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr19.out @@ -0,0 +1,6 @@ +LambdaExpr19.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @363, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String))) +LambdaExpr19.java:24:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @512, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String))) +LambdaExpr19.java:31:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @676, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String))) +LambdaExpr19.java:39:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @824, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String))) +LambdaExpr19.java:47:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @965, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String))) +5 errors diff --git a/langtools/test/tools/javac/lambda/LambdaExpr20.java b/langtools/test/tools/javac/lambda/LambdaExpr20.java new file mode 100644 index 00000000000..21a464b3a6a --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExpr20.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that default super call from lambda expression is compiled successfully + * @compile LambdaExpr20.java + */ + +class LambdaExpr20 { + + interface K { + default void m() { } + } + + static class Test implements K { + @Override + public void m() { + Runnable r = () -> { K.super.m(); }; + r.run(); + } + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaExprNotVoid.java b/langtools/test/tools/javac/lambda/LambdaExprNotVoid.java new file mode 100644 index 00000000000..0d041197c80 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExprNotVoid.java @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that lambda expression body (when not a block) cannot be void + * @author Maurizio Cimadamore + * @compile/fail/ref=LambdaExprNotVoid.out -XDlambdaInferenceDiags=false -XDrawDiagnostics LambdaExprNotVoid.java + */ + +class LambdaExpr05 { + + interface SAM { void foo(int i); } + + SAM s1 = i -> i * 2; + SAM s2 = i -> 2 * i; +} diff --git a/langtools/test/tools/javac/lambda/LambdaExprNotVoid.out b/langtools/test/tools/javac/lambda/LambdaExprNotVoid.out new file mode 100644 index 00000000000..97b66c8a5ea --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaExprNotVoid.out @@ -0,0 +1,3 @@ +LambdaExprNotVoid.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void)) +LambdaExprNotVoid.java:15:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void)) +2 errors diff --git a/langtools/test/tools/javac/lambda/LambdaParserTest.java b/langtools/test/tools/javac/lambda/LambdaParserTest.java index c728f849b5e..e208e792f8e 100644 --- a/langtools/test/tools/javac/lambda/LambdaParserTest.java +++ b/langtools/test/tools/javac/lambda/LambdaParserTest.java @@ -24,7 +24,9 @@ /* * @test * @bug 7115050 - * @summary Add parser support for lambda expressions + * @bug 8003280 + * @summary Add lambda tests + * Add parser support for lambda expressions */ import com.sun.source.util.JavacTask; @@ -234,7 +236,7 @@ public class LambdaParserTest { void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, - Arrays.asList("-XDallowLambda"), null, Arrays.asList(source)); + null, null, Arrays.asList(source)); try { ct.parse(); } catch (Throwable ex) { diff --git a/langtools/test/tools/javac/lambda/LambdaScope01.java b/langtools/test/tools/javac/lambda/LambdaScope01.java new file mode 100644 index 00000000000..ab8afe36757 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaScope01.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * basic test for capture of non-mutable locals + * @author Brian Goetz + * @author Maurizio Cimadamore + * @run main LambdaScope01 + */ + +public class LambdaScope01 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface TU { + public T foo(U u); + } + + public static T exec(TU lambda, U x) { + return lambda.foo(x); + } + + public int n = 5; + + public int hashCode() { + throw new RuntimeException(); + } + + public void test1() { + try { + int res = LambdaScope01.exec((Integer x) -> x * hashCode(), 3); + } + catch (RuntimeException e) { + assertTrue(true); //should throw + } + } + + public void test2() { + final int n = 10; + int res = LambdaScope01.exec((Integer x) -> x + n, 3); + assertTrue(13 == res); + } + + public static void main(String[] args) { + LambdaScope01 t = new LambdaScope01(); + t.test1(); + t.test2(); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaScope02.java b/langtools/test/tools/javac/lambda/LambdaScope02.java new file mode 100644 index 00000000000..0ab28a39c31 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaScope02.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that Object members are accessible as expected + * @author Maurizio Cimadamore + * @run main LambdaScope02 + */ + +public class LambdaScope02 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + @Override + public String toString() { + return "Callable1"; + } + + interface Callable { + void call(); + } + + static void call(Callable c) { c.call(); } + + void test() { + call(()-> { assertTrue(LambdaScope02.this.toString().equals("Callable1")); }); + call(()-> { assertTrue(toString().equals("Callable1")); }); + } + + public static void main(String[] args) { + new LambdaScope02().test(); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaScope03.java b/langtools/test/tools/javac/lambda/LambdaScope03.java new file mode 100644 index 00000000000..16b9db050fb --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaScope03.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that unqualified Object members are accessed as expected + * @author Maurizio Cimadamore + * @run main LambdaScope03 + */ + +public class LambdaScope03 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + void m(); + } + + static void call(SAM s) { s.m(); } + + void test() { + call(()-> { assertTrue(LambdaScope03.this.getClass().equals(getClass())); }); + call(()-> { assertTrue(LambdaScope03.this.getClass().equals(this.getClass())); }); + call(()-> { assertTrue(LambdaScope03.this.hashCode() == hashCode()); }); + call(()-> { assertTrue(LambdaScope03.this.hashCode() == this.hashCode()); }); + call(()-> { assertTrue(LambdaScope03.this.toString().equals(toString())); }); + call(()-> { assertTrue(LambdaScope03.this.toString().equals(this.toString())); }); + call(()-> { assertTrue(LambdaScope03.this.equals(this)); }); + call(()-> { assertTrue(equals(LambdaScope03.this)); }); + } + + public static void main(String[] args) { + new LambdaScope03().test(); + assertTrue(assertionCount == 8); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaScope04.java b/langtools/test/tools/javac/lambda/LambdaScope04.java new file mode 100644 index 00000000000..a2ebc6f28d5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaScope04.java @@ -0,0 +1,163 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that lambda cannot shadow variables from enclosing scope + * @compile/fail/ref=LambdaScope04.out -XDrawDiagnostics LambdaScope04.java + */ + +class LambdaScope04 { + + interface SAM { + void m(Object o); + } + + static SAM field1 = field1->{}; //ok + static SAM field2 = param->{ Object field2 = null; }; //ok + + SAM field3 = field3->{}; //ok + SAM field4 = param->{ Object field4 = null; }; //ok + + { + Object local = null; + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + } + + static { + Object local = null; + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + + void testLocalInstance() { + Object local = null; + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + + static void testLocalStatic() { + Object local = null; + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + + void testParamInstance(Object local) { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + + static void testParamStatic(Object local) { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + + void testForInstance() { + for (int local = 0; local != 0 ; local++) { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + } + + static void testForStatic(Iterable elems) { + for (int local = 0; local != 0 ; local++) { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + } + + void testForEachInstance(Iterable elems) { + for (Object local : elems) { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + } + + static void testForEachStatic(Iterable elems) { + for (Object local : elems) { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + } + + void testCatchInstance() { + try { } catch (Throwable local) { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + } + + static void testCatchStatic(Iterable elems) { + try { } catch (Throwable local) { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + } + + void testTWRInstance(AutoCloseable res) { + try (AutoCloseable local = res) { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } finally { } + } + + static void testTWRStatic(AutoCloseable res) { + try (AutoCloseable local = res) { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } finally { } + } + + void testBlockLocalInstance() { + Object local = null; + { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + } + + static void testBlockLocalStatic() { + Object local = null; + { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + } + + void testSwitchLocalInstance(int i) { + switch (i) { + case 0: Object local = null; + default: { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + } + } + + static void testSwitchLocalStatic(int i) { + switch (i) { + case 0: Object local = null; + default: { + SAM s1 = local->{}; //error + SAM s2 = param->{ Object local = null; }; //error + SAM s3 = field1->{ Object field_2 = null; }; //ok + } + } + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaScope04.out b/langtools/test/tools/javac/lambda/LambdaScope04.out new file mode 100644 index 00000000000..8cb2e2ab242 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaScope04.out @@ -0,0 +1,37 @@ +LambdaScope04.java:23:18: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.instance.init, kindname.class, LambdaScope04 +LambdaScope04.java:24:34: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.instance.init, kindname.class, LambdaScope04 +LambdaScope04.java:29:18: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.static.init, kindname.class, LambdaScope04 +LambdaScope04.java:30:34: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.static.init, kindname.class, LambdaScope04 +LambdaScope04.java:36:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalInstance() +LambdaScope04.java:37:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalInstance() +LambdaScope04.java:43:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalStatic() +LambdaScope04.java:44:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalStatic() +LambdaScope04.java:49:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamInstance(java.lang.Object) +LambdaScope04.java:50:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamInstance(java.lang.Object) +LambdaScope04.java:55:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamStatic(java.lang.Object) +LambdaScope04.java:56:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamStatic(java.lang.Object) +LambdaScope04.java:62:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForInstance() +LambdaScope04.java:63:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForInstance() +LambdaScope04.java:70:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForStatic(java.lang.Iterable) +LambdaScope04.java:71:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForStatic(java.lang.Iterable) +LambdaScope04.java:78:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachInstance(java.lang.Iterable) +LambdaScope04.java:79:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachInstance(java.lang.Iterable) +LambdaScope04.java:86:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachStatic(java.lang.Iterable) +LambdaScope04.java:87:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachStatic(java.lang.Iterable) +LambdaScope04.java:94:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchInstance() +LambdaScope04.java:95:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchInstance() +LambdaScope04.java:102:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchStatic(java.lang.Iterable) +LambdaScope04.java:103:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchStatic(java.lang.Iterable) +LambdaScope04.java:110:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRInstance(java.lang.AutoCloseable) +LambdaScope04.java:111:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRInstance(java.lang.AutoCloseable) +LambdaScope04.java:118:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRStatic(java.lang.AutoCloseable) +LambdaScope04.java:119:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRStatic(java.lang.AutoCloseable) +LambdaScope04.java:127:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalInstance() +LambdaScope04.java:128:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalInstance() +LambdaScope04.java:136:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalStatic() +LambdaScope04.java:137:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalStatic() +LambdaScope04.java:146:26: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalInstance(int) +LambdaScope04.java:147:42: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalInstance(int) +LambdaScope04.java:157:26: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalStatic(int) +LambdaScope04.java:158:42: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalStatic(int) +36 errors diff --git a/langtools/test/tools/javac/lambda/LocalBreakAndContinue.java b/langtools/test/tools/javac/lambda/LocalBreakAndContinue.java new file mode 100644 index 00000000000..16505b4fcd6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LocalBreakAndContinue.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that local break/continue is allowed in lambda expressions + * @author Maurizio Cimadamore + * @compile LocalBreakAndContinue.java + */ + +class LocalBreakAndContinue { + + static interface SAM { + void m(); + } + + SAM s1 = ()-> { while (true) break; }; + SAM s2 = ()-> { while (true) continue; }; +} diff --git a/langtools/test/tools/javac/lambda/MethodReference01.java b/langtools/test/tools/javac/lambda/MethodReference01.java new file mode 100644 index 00000000000..dcde9ce5b25 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference01.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * use method reference to sort list elements by field + * @author Brian Goetz + * @author Maurizio Cimadamore + * @run main MethodReference01 + */ + +import java.util.*; + +public class MethodReference01 { + + interface Getter { + public U get(T t); + } + + static class Foo { + private Integer a; + private String b; + + Foo(Integer a, String b) { + this.a = a; + this.b = b; + } + + static Integer getA(Foo f) { return f.a; } + static String getB(Foo f) { return f.b; } + } + + public static > + void sortBy(List s, final Getter getter) { + Collections.sort(s, new Comparator() { + public int compare(T t1, T t2) { + return getter.get(t1).compareTo(getter.get(t2)); + } + }); + }; + + public static void main(String[] args) { + List c = new ArrayList(); + c.add(new Foo(2, "Hello3!")); + c.add(new Foo(3, "Hello1!")); + c.add(new Foo(1, "Hello2!")); + checkSortByA(c); + checkSortByB(c); + } + + static void checkSortByA(List l) { + sortBy(l, Foo::getA); + int oldA = -1; + for (Foo foo : l) { + if (foo.a.compareTo(oldA) < 1) { + throw new AssertionError(); + } + } + } + + static void checkSortByB(List l) { + sortBy(l, Foo::getB); + String oldB = ""; + for (Foo foo : l) { + if (foo.b.compareTo(oldB) < 1) { + throw new AssertionError(); + } + } + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference02.java b/langtools/test/tools/javac/lambda/MethodReference02.java new file mode 100644 index 00000000000..86090eebe86 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference02.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that seemingly ambiguous method references are resolved properly + * @author Maurizio Cimadamore + * @compile MethodReference02.java + */ + +class MethodReference02 { + static interface SAM { + void m(Integer i); + } + + void m(Integer i) {} + void m(Double d) {} + + SAM s = this::m; //use target type to disambiguate +} diff --git a/langtools/test/tools/javac/lambda/MethodReference03.java b/langtools/test/tools/javac/lambda/MethodReference03.java new file mode 100644 index 00000000000..d61312a8a40 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference03.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that most specific method is selected as expected + * @author Maurizio Cimadamore + * @run main MethodReference03 + */ + +public class MethodReference03 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + void m(Integer i); + } + + static void m(Number i) {} + static void m(Integer d) { assertTrue(true); } + + public static void main(String[] args) { + SAM s = MethodReference03::m; + s.m(1); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference04.java b/langtools/test/tools/javac/lambda/MethodReference04.java new file mode 100644 index 00000000000..8ff90186220 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference04.java @@ -0,0 +1,14 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that target type of a method ref is a SAM type + * @author Maurizio Cimadamore + * @compile/fail/ref=MethodReference04.out -XDrawDiagnostics MethodReference04.java + */ + +class MethodReference04 { + void m(Integer i) {} + + Object o = this::m; //fail - not a valid target type +} diff --git a/langtools/test/tools/javac/lambda/MethodReference04.out b/langtools/test/tools/javac/lambda/MethodReference04.out new file mode 100644 index 00000000000..789804b78d5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference04.out @@ -0,0 +1,2 @@ +MethodReference04.java:13:16: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +1 error diff --git a/langtools/test/tools/javac/lambda/MethodReference05.java b/langtools/test/tools/javac/lambda/MethodReference05.java new file mode 100644 index 00000000000..434c2651ccd --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference05.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that non-static method refernces from static context are handled correctly + * @author Maurizio Cimadamore + * @run main MethodReference05 + */ + +public class MethodReference05 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + void m(MethodReference05 receiver, Integer i); + } + + void m(Integer i) { assertTrue(this != null); } + + public static void main(String[] args) { + SAM s = MethodReference05::m; + s.m(new MethodReference05(), 1); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference06.java b/langtools/test/tools/javac/lambda/MethodReference06.java new file mode 100644 index 00000000000..66b7f7e7466 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference06.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * method references and super + * @author Maurizio Cimadamore + * @run main MethodReference06 + */ + +public class MethodReference06 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { //works if SAM is an abstract class + abstract void meth(int i); + } + + static class A { + void m(int i) { assertTrue(true); } + } + + static class B extends A { + void m(int i) { + SAM mh = super::m; + mh.meth(i); + } + } + + public static void main(String[] args) { + new B().m(10); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference07.java b/langtools/test/tools/javac/lambda/MethodReference07.java new file mode 100644 index 00000000000..2a363935101 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference07.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that syntax for selecting generic receiver works + * @author Maurizio Cimadamore + * @compile MethodReference07.java + */ + +class MethodReference07 { + interface SAM { + String m(Foo f); + } + + static class Foo { + String getX() { return null; } + + static void test() { + SAM s = Foo::getX; + } + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference08.java b/langtools/test/tools/javac/lambda/MethodReference08.java new file mode 100644 index 00000000000..9792c4acd60 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference08.java @@ -0,0 +1,24 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that syntax for selecting generic receiver works + * @author Maurizio Cimadamore + * + * @compile MethodReference08.java + * @compile/fail/ref=MethodReference08.out -Werror -Xlint:rawtypes -XDrawDiagnostics MethodReference08.java + */ + +class MethodReference08 { + interface SAM { + String m(Foo f); + } + + static class Foo { + String getX() { return null; } + + static void test() { + SAM s = Foo::getX; + } + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference08.out b/langtools/test/tools/javac/lambda/MethodReference08.out new file mode 100644 index 00000000000..30b74363ade --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference08.out @@ -0,0 +1,5 @@ +MethodReference08.java:14:17: compiler.warn.raw.class.use: MethodReference08.Foo, MethodReference08.Foo +MethodReference08.java:21:19: compiler.warn.raw.class.use: MethodReference08.Foo, MethodReference08.Foo +- compiler.err.warnings.and.werror +1 error +2 warnings diff --git a/langtools/test/tools/javac/lambda/MethodReference09.java b/langtools/test/tools/javac/lambda/MethodReference09.java new file mode 100644 index 00000000000..a1d485324e6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference09.java @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that non static members cannot be referenced from a method reference qualifier + * @author Maurizio Cimadamore + * @compile/fail/ref=MethodReference09.out -XDrawDiagnostics MethodReference09.java + */ + +class MethodReference09 { + interface SAM { + String m(Foo f); + } + + static class Foo { + String getX() { return null; } + + Foo getThis() { return this; } + + static void test() { + SAM s1 = Foo.getThis()::getX; + SAM s2 = this::getX; + } + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference09.out b/langtools/test/tools/javac/lambda/MethodReference09.out new file mode 100644 index 00000000000..84984bbaa75 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference09.out @@ -0,0 +1,4 @@ +MethodReference09.java:21:23: compiler.err.non-static.cant.be.ref: kindname.method, getThis() +MethodReference09.java:21:20: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, getX, compiler.misc.no.args, MethodReference09.Foo, kindname.class, MethodReference09.Foo, (compiler.misc.arg.length.mismatch))) +MethodReference09.java:22:20: compiler.err.non-static.cant.be.ref: kindname.variable, this +3 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference10.java b/langtools/test/tools/javac/lambda/MethodReference10.java new file mode 100644 index 00000000000..a94383260ac --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference10.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that non static selectors in method refs are handled correctly + * @author Maurizio Cimadamore + * @compile MethodReference10.java + */ + +import java.util.*; + +class MethodReference10 { + + interface Getter { + public U get(T t); + } + + public static > + void sortBy(Collection s, Getter getter) {}; + + static class Foo { + private String a; + String getA(Foo f) { return f.a; } + } + + public static void main(String[] args) { + Collection c = new ArrayList(); + sortBy(c, new Foo()::getA); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference11.java b/langtools/test/tools/javac/lambda/MethodReference11.java new file mode 100644 index 00000000000..1eb43bc0b23 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference11.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that static vs. non-static selection logic in method references works + * @author Maurizio Cimadamore + * @run main MethodReference11 + */ + +import java.util.*; + +public class MethodReference11 { + public static void main(String[] args) { + String[] strings = new String[] { "D", "C", "B", "A" }; + Arrays.sort( strings, String.CASE_INSENSITIVE_ORDER::compare ); + String last = "1"; + for (String s : strings) { + if (String.CASE_INSENSITIVE_ORDER.compare(last, s) > 0) { + throw new AssertionError(); + } + } + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference12.java b/langtools/test/tools/javac/lambda/MethodReference12.java new file mode 100644 index 00000000000..0d16adfa216 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference12.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that Object methods are dispatched accordingly + * @author Maurizio Cimadamore + * @run main MethodReference12 + */ + +public class MethodReference12 { + + interface SAM { void foo(int i); } + + static void print(int i) { + System.out.println(i); + } + + public static void main(String[] args) { + try { + test(MethodReference12::print); + test(i -> { System.out.println(i); } ); + } + catch (Throwable t) { + t.printStackTrace(); + throw new AssertionError("An error occurred"); + } + } + + static void test(SAM s) throws Throwable { + s.hashCode(); + s.equals(null); + s.toString(); + try { + s.notify(); //will throw IllegalMonitorStateException + } + catch (final IllegalMonitorStateException e) { } + try { + s.notifyAll(); //will throw IllegalMonitorStateException + } + catch (final IllegalMonitorStateException e) { } + try { + s.wait(1); //will throw IllegalMonitorStateException + } + catch (final IllegalMonitorStateException | InterruptedException e) { } + try { + s.wait(1,1); //will throw IllegalMonitorStateException + } + catch (final IllegalMonitorStateException | InterruptedException e) { } + try { + s.wait(); //will throw IllegalMonitorStateException + } + catch (final IllegalMonitorStateException | InterruptedException e) { } + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference13.java b/langtools/test/tools/javac/lambda/MethodReference13.java new file mode 100644 index 00000000000..ac454f89aac --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference13.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that equals() on Proxied objects is handled accordingly + * @author Maurizio Cimadamore + * @compile -XDuseProxy MethodReference13.java + * @run main MethodReference13 + */ + +public class MethodReference13 { + + static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + interface SAM { + void m(); + } + + static void m() { } + + public static void main(String[] args) { + SAM s = MethodReference13::m; + assertTrue(s.equals(s)); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference14.java b/langtools/test/tools/javac/lambda/MethodReference14.java new file mode 100644 index 00000000000..8f9cce1762d --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference14.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check casting a method reference to a SAM type does not result in a CCE + * @author Maurizio Cimadamore + * @run main MethodReference14 + */ + +public class MethodReference14 { + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static int assertionCount = 0; + + interface SAM { + void m(); + } + + static void m() { assertTrue(true); } + + public static void main(String[] args) { + SAM s = (SAM)MethodReference14::m; + s.m(); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference15.java b/langtools/test/tools/javac/lambda/MethodReference15.java new file mode 100644 index 00000000000..66fcf19b050 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference15.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that assignments involving method references do not trigger transitional 292 warnings + * @author Maurizio Cimadamore + * @compile -Werror MethodReference15.java + */ + +public class MethodReference15 { + + interface SAM { + void m(); + } + + static void m() { } + + static void test() { + SAM s = MethodReference15::m; + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference16.java b/langtools/test/tools/javac/lambda/MethodReference16.java new file mode 100644 index 00000000000..e8fd0145cc6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference16.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * semantics of statically qualified method reference should not depend on the context + * @author Maurizio Cimadamore + * @run main MethodReference16 + */ + +public class MethodReference16 { + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static int assertionCount = 0; + + interface SAM { + void m(MethodReference16 receiver); + } + + void m() { assertTrue(true); } + + void test() { + SAM s = (SAM)MethodReference16::m; + s.m(this); + } + + public static void main(String[] args) { + MethodReference16 rec = new MethodReference16(); + SAM s = (SAM)MethodReference16::m; + s.m(rec); + rec.test(); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference17.java b/langtools/test/tools/javac/lambda/MethodReference17.java new file mode 100644 index 00000000000..590b2ecde16 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference17.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * basic test for constructor references + * @author Maurizio Cimadamore + * @run main MethodReference17 + */ + +public class MethodReference17 { + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static int assertionCount = 0; + + MethodReference17() { + assertTrue(true); + } + + interface SAM { + MethodReference17 m(); + } + + static void test(SAM s) { + s.m(); + } + + public static void main(String[] args) { + SAM s = MethodReference17::new; + s.m(); + test(MethodReference17::new); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference18.java b/langtools/test/tools/javac/lambda/MethodReference18.java new file mode 100644 index 00000000000..d9d9248c629 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference18.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * basic test for constructor references + * @author Maurizio Cimadamore + * @run main MethodReference18 + */ + +public class MethodReference18 { + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static int assertionCount = 0; + + MethodReference18(Object o) { + assertTrue(true); + } + + MethodReference18(Number n) { + assertTrue(false); + } + + interface SAM { + MethodReference18 m(Object o); + } + + static void test(SAM s, Object arg) { + s.m(arg); + } + + public static void main(String[] args) { + SAM s = MethodReference18::new; + s.m(""); + test(MethodReference18::new, ""); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference19.java b/langtools/test/tools/javac/lambda/MethodReference19.java new file mode 100644 index 00000000000..c155616c852 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference19.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * basic test for constructor references and generic classes + * @author Maurizio Cimadamore + * @run main MethodReference19 + */ + +public class MethodReference19 { + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static int assertionCount = 0; + + MethodReference19(X x) { + assertTrue(true); + } + + interface SAM { + MethodReference19 m(Z z); + } + + static void test(SAM s, Y arg) { + s.m(arg); + } + + public static void main(String[] args) { + SAM s = MethodReference19::new; + s.m(""); + test(MethodReference19::new, ""); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference20.java b/langtools/test/tools/javac/lambda/MethodReference20.java new file mode 100644 index 00000000000..e37ac797242 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference20.java @@ -0,0 +1,24 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * basic test for constructor references and generic classes + * @author Maurizio Cimadamore + * @compile/fail/ref=MethodReference20.out -XDrawDiagnostics MethodReference20.java + */ + +class MethodReference20 { + + MethodReference20(X x) { } + + interface SAM { + MethodReference20 m(Z z); + } + + static void test(SAM s) { } + + public static void main(String[] args) { + SAM s = MethodReference20::new; + test(MethodReference20::new); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference20.out b/langtools/test/tools/javac/lambda/MethodReference20.out new file mode 100644 index 00000000000..8af6bdb781d --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference20.out @@ -0,0 +1,3 @@ +MethodReference20.java:21:26: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, MethodReference20, java.lang.String, java.lang.Integer, kindname.class, MethodReference20, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String)))) +MethodReference20.java:22:9: compiler.err.cant.apply.symbol: kindname.method, test, MethodReference20.SAM, @549, kindname.class, MethodReference20, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, MethodReference20, java.lang.String, java.lang.Integer, kindname.class, MethodReference20, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String))))) +2 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference21.java b/langtools/test/tools/javac/lambda/MethodReference21.java new file mode 100644 index 00000000000..4daec95505d --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference21.java @@ -0,0 +1,23 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that erroneous method references are flagged with errors as expected + * @author Maurizio Cimadamore + * @compile/fail/ref=MethodReference21.out -XDrawDiagnostics MethodReference21.java + */ + +class MethodReference21 { + + interface SAM { + void m(); + } + + void call(SAM s) {} + + SAM s = NonExistentType::m; + + { + call(NonExistentType::m); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference21.out b/langtools/test/tools/javac/lambda/MethodReference21.out new file mode 100644 index 00000000000..6133c2a4ca4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference21.out @@ -0,0 +1,3 @@ +MethodReference21.java:18:13: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference21, null) +MethodReference21.java:21:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference21, null) +2 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference22.java b/langtools/test/tools/javac/lambda/MethodReference22.java new file mode 100644 index 00000000000..094ef8936e5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference22.java @@ -0,0 +1,67 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that pair of bound/non-bound method references checked correctly + * @author Maurizio Cimadamore + * @compile/fail/ref=MethodReference22.out -XDrawDiagnostics MethodReference22.java + */ + +class MethodReference22 { + + void m1(String x) { } + void m1(MethodReference22 rec, String x) { } + + static void m2(String x) { } + static void m2(MethodReference22 rec, String x) { } + + static void m3(String x) { } + void m3(MethodReference22 rec, String x) { } + + void m4(String x) { } + static void m4(MethodReference22 rec, String x) { } + + interface SAM1 { + void m(String x); + } + + interface SAM2 { + void m(MethodReference22 rec, String x); + } + + static void call1(SAM1 s) { } + + static void call2(SAM2 s) { } + + static void call3(SAM1 s) { } + static void call3(SAM2 s) { } + + static void test1() { + SAM1 s1 = MethodReference22::m1; //fail + call1(MethodReference22::m1); //fail + SAM1 s2 = MethodReference22::m2; //ok + call1(MethodReference22::m2); //ok + SAM1 s3 = MethodReference22::m3; //ok + call1(MethodReference22::m3); //ok + SAM1 s4 = MethodReference22::m4; //fail + call1(MethodReference22::m4); //fail + } + + static void test2() { + SAM2 s1 = MethodReference22::m1; //ok + call2(MethodReference22::m1); //ok + SAM2 s2 = MethodReference22::m2; //ok + call2(MethodReference22::m2); //ok + SAM2 s3 = MethodReference22::m3; //fail + call2(MethodReference22::m3); //fail + SAM2 s4 = MethodReference22::m4; //fail + call2(MethodReference22::m4); //fail + } + + static void test3() { + call3(MethodReference22::m1); //ok + call3(MethodReference22::m2); //ambiguous + call3(MethodReference22::m3); //ok + call3(MethodReference22::m4); //fail + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference22.out b/langtools/test/tools/javac/lambda/MethodReference22.out new file mode 100644 index 00000000000..406cd781476 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference22.out @@ -0,0 +1,11 @@ +MethodReference22.java:40:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))) +MethodReference22.java:41:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @999, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String)))) +MethodReference22.java:46:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))) +MethodReference22.java:47:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @1270, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)))) +MethodReference22.java:55:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String))) +MethodReference22.java:56:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1574, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String)))) +MethodReference22.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22)) +MethodReference22.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1667, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))) +MethodReference22.java:63:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22 +MethodReference22.java:65:9: compiler.err.cant.apply.symbols: kindname.method, call3, @1881,{(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))))),(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))))} +10 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference23.java b/langtools/test/tools/javac/lambda/MethodReference23.java new file mode 100644 index 00000000000..b7610389a02 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference23.java @@ -0,0 +1,74 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that pair of bound/non-bound constructor references is flagged as ambiguous + * @author Maurizio Cimadamore + * @compile/fail/ref=MethodReference23.out -XDrawDiagnostics MethodReference23.java + */ + +class MethodReference23 { + + class Inner1 { + Inner1(MethodReference23 outer) {}; + Inner1() {}; + } + + static class Inner2 { + Inner2(MethodReference23 outer) {}; + Inner2() {}; + } + + interface SAM11 { + Inner1 m(MethodReference23 rec); + } + + interface SAM12 { + Inner1 m(); + } + + interface SAM21 { + Inner2 m(MethodReference23 rec); + } + + interface SAM22 { + Inner2 m(); + } + + static void call11(SAM11 s) { } + + static void call12(SAM12 s) { } + + static void call21(SAM21 s) { } + + static void call22(SAM22 s) { } + + static void call3(SAM11 s) { } + static void call3(SAM12 s) { } + static void call3(SAM21 s) { } + static void call3(SAM22 s) { } + + static void test11() { + SAM11 s = MethodReference23.Inner1::new; //ok + call11(MethodReference23.Inner1::new); //ok + } + + static void test12() { + SAM12 s = MethodReference23.Inner1::new; //fail + call12(MethodReference23.Inner1::new); //fail + } + + static void test21() { + SAM21 s = MethodReference23.Inner2::new; //ok + call21(MethodReference23.Inner2::new); //ok + } + + static void test22() { + SAM22 s = MethodReference23.Inner2::new; //ok + call22(MethodReference23.Inner2::new); //ok + } + + static void test3() { + call3(MethodReference23.Inner2::new); //ambiguous + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference23.out b/langtools/test/tools/javac/lambda/MethodReference23.out new file mode 100644 index 00000000000..3849d8631c6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference23.out @@ -0,0 +1,6 @@ +MethodReference23.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)) +MethodReference23.java:53:9: compiler.err.cant.apply.symbol: kindname.method, call11, MethodReference23.SAM11, @1140, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23))) +MethodReference23.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)) +MethodReference23.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call12, MethodReference23.SAM12, @1282, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))) +MethodReference23.java:72:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference23.SAM21), MethodReference23, kindname.method, call3(MethodReference23.SAM22), MethodReference23 +5 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference24.java b/langtools/test/tools/javac/lambda/MethodReference24.java new file mode 100644 index 00000000000..f7fa8f1b536 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference24.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that non-boxing method references conversion has the precedence + * @run main MethodReference24 + */ + +public class MethodReference24 { + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static int assertionCount = 0; + + static void m(int i) { assertTrue(true); } + static void m(Integer i) { assertTrue(false); } + + interface SAM { + void m(int x); + } + + static void call(SAM s) { s.m(42); } + + public static void main(String[] args) { + SAM s = MethodReference24::m; //resolves to m(int) + s.m(42); + call(MethodReference24::m); //resolves to m(int) + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference25.java b/langtools/test/tools/javac/lambda/MethodReference25.java new file mode 100644 index 00000000000..cf180fcbac3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference25.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that non-boxing method references conversion has the precedence + * @run main MethodReference25 + */ + +public class MethodReference25 { + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static int assertionCount = 0; + + static void m(Integer i) { assertTrue(true); } + + interface SAM1 { + void m(int x); + } + + interface SAM2 { + void m(Integer x); + } + + static void call(int i, SAM1 s) { s.m(i); assertTrue(false); } + static void call(int i, SAM2 s) { s.m(i); } + + public static void main(String[] args) { + call(1, MethodReference25::m); //resolves to call(int, SAM2) + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference26.java b/langtools/test/tools/javac/lambda/MethodReference26.java new file mode 100644 index 00000000000..98b2540ff2e --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference26.java @@ -0,0 +1,23 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check strict method conversion does not allow loose method reference conversion + * @compile/fail/ref=MethodReference26.out -XDrawDiagnostics MethodReference26.java + */ + +class MethodReference26 { + + static void m(Integer i) { } + + interface SAM { + void m(int x); + } + + static void call(int i, SAM s) { } + static void call(Integer i, SAM s) { } + + static void test() { + call(1, MethodReference26::m); //ambiguous + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference26.out b/langtools/test/tools/javac/lambda/MethodReference26.out new file mode 100644 index 00000000000..62b8bcfb09d --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference26.out @@ -0,0 +1,2 @@ +MethodReference26.java:21:9: compiler.err.ref.ambiguous: call, kindname.method, call(int,MethodReference26.SAM), MethodReference26, kindname.method, call(java.lang.Integer,MethodReference26.SAM), MethodReference26 +1 error diff --git a/langtools/test/tools/javac/lambda/MethodReference27.java b/langtools/test/tools/javac/lambda/MethodReference27.java new file mode 100644 index 00000000000..ae1a4ec14e5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference27.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that non-boxing method references conversion has the precedence + * @run main MethodReference27 + */ + +public class MethodReference27 { + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static int assertionCount = 0; + + interface SAM { + void m(int i1, int i2); + } + + static void m1(int i1, int i2) { assertTrue(true); } + static void m1(Integer i1, int i2) { assertTrue(false); } + static void m1(int i1, Integer i2) { assertTrue(false); } + static void m1(Integer i1, Integer i2) { assertTrue(false); } + static void m1(Integer... is) { assertTrue(false); } + + static void m2(int... is) { assertTrue(true); } + static void m2(double... ds) { assertTrue(false); } + + public static void main(String[] args) { + SAM s1 = MethodReference27::m1; + s1.m(42,42); + SAM s2 = MethodReference27::m2; + s2.m(42,42); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference28.java b/langtools/test/tools/javac/lambda/MethodReference28.java new file mode 100644 index 00000000000..61da15420e5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference28.java @@ -0,0 +1,56 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that non-compatible method references are rejected + * @compile/fail/ref=MethodReference28.out -XDrawDiagnostics MethodReference28.java + */ + +class MethodReference28 { + + interface SAM1 { + void m(int i); + } + + interface SAM2 { + void m(MethodReference28 rec, int i); + } + + static void static_m1(Integer i) { } //ok - boxing + static void static_m2(Integer i1, Integer i2) { } //wrong arity + static void static_m3(String s) { } //type mismatch + static void static_m4(String... ss) { } //type mismatch - varargs + + void m1(Integer i) { } //ok - boxing + void m2(Integer i1, Integer i2) { } //wrong arity + void m3(String s) { } //type mismatch + void m4(String... ss) { } //type mismatch - varargs + + static void testStatic() { + SAM1 s1 = MethodReference28::static_m1; + SAM1 s2 = MethodReference28::static_m2; + SAM1 s3 = MethodReference28::static_m3; + SAM1 s4 = MethodReference28::static_m4; + } + + void testBadMember() { + SAM1 s1 = MethodReference28::m1; + SAM1 s2 = MethodReference28::m2; + SAM1 s3 = MethodReference28::m3; + SAM1 s4 = MethodReference28::m4; + } + + void testMember() { + SAM1 s1 = this::m1; + SAM1 s2 = this::m2; + SAM1 s3 = this::m3; + SAM1 s4 = this::m4; + } + + static void testUnbound() { + SAM2 s1 = MethodReference28::m1; + SAM2 s2 = MethodReference28::m2; + SAM2 s3 = MethodReference28::m3; + SAM2 s4 = MethodReference28::m4; + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference28.out b/langtools/test/tools/javac/lambda/MethodReference28.out new file mode 100644 index 00000000000..a0900d825f6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference28.out @@ -0,0 +1,14 @@ +MethodReference28.java:31:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch))) +MethodReference28.java:32:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String)))) +MethodReference28.java:33:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String)))) +MethodReference28.java:37:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.Integer))) +MethodReference28.java:38:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch))) +MethodReference28.java:39:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String)))) +MethodReference28.java:40:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String)))) +MethodReference28.java:45:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch))) +MethodReference28.java:46:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String)))) +MethodReference28.java:47:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String)))) +MethodReference28.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: MethodReference28, java.lang.Integer)))) +MethodReference28.java:53:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch))) +MethodReference28.java:54:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: MethodReference28, java.lang.String)))) +13 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference29.java b/langtools/test/tools/javac/lambda/MethodReference29.java new file mode 100644 index 00000000000..51b0e7bb768 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference29.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * reference to super leads to compiler crash when 292 translation scheme is enabled + */ + +public class MethodReference29 { + + interface SAM { + void m(Integer i); + } + + static class A { + void m(int i) { } + } + + static class B extends A { + void test() { + SAM s = super::m; + s.m(42); + } + + void m(int i) { throw new AssertionError(); } + } + + public static void main(String[] args) { + new B().test(); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference30.java b/langtools/test/tools/javac/lambda/MethodReference30.java new file mode 100644 index 00000000000..dec31d00e98 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference30.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that non-static qualifier of static method reference is eagerly evaluated + */ + +public class MethodReference30 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + void m(); + } + + MethodReference30() { + assertTrue(true); + } + + static void m() { } + + public static void main(String[] args) { + SAM s = new MethodReference30()::m; + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference31.java b/langtools/test/tools/javac/lambda/MethodReference31.java new file mode 100644 index 00000000000..aa3085bb472 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference31.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that boxing of return-type works as expected + */ + +public class MethodReference31 { + + static class Success extends RuntimeException { } + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + X m(); + } + + interface SAM_byte { + byte m(); + } + + interface SAM_short { + short m(); + } + + interface SAM_int { + int m(); + } + + interface SAM_long { + long m(); + } + + interface SAM_float { + float m(); + } + + interface SAM_double { + double m(); + } + + static Z test() { + assertTrue(true); + throw new Success(); + } + + static byte test_byte() { + assertTrue(true); + return 0; + } + + static short test_short() { + assertTrue(true); + return 0; + } + + static int test_int() { + assertTrue(true); + return 0; + } + + static long test_long() { + assertTrue(true); + return 0; + } + + static float test_float() { + assertTrue(true); + return 0; + } + + static double test_double() { + assertTrue(true); + return 0; + } + + static void testByte() { + SAM s1 = MethodReference31::test_byte; + s1.m(); + SAM_byte s2 = MethodReference31::test_byte; + s2.m(); + SAM s3 = MethodReference31::test; + try { + s3.m(); + } + catch (RuntimeException ex) { } + SAM_byte s4 = MethodReference31::test; + try { + s4.m(); + } + catch (RuntimeException ex) { } + } + + static void testShort() { + SAM s1 = MethodReference31::test_short; + s1.m(); + SAM_short s2 = MethodReference31::test_short; + s2.m(); + SAM s3 = MethodReference31::test; + try { + s3.m(); + } + catch (RuntimeException ex) { } + SAM_short s4 = MethodReference31::test; + try { + s4.m(); + } + catch (RuntimeException ex) { } + } + + static void testInteger() { + SAM s1 = MethodReference31::test_int; + s1.m(); + SAM_int s2 = MethodReference31::test_int; + s2.m(); + SAM s3 = MethodReference31::test; + try { + s3.m(); + } + catch (RuntimeException ex) { } + SAM_int s4 = MethodReference31::test; + try { + s4.m(); + } + catch (RuntimeException ex) { } + } + + static void testLong() { + SAM s1 = MethodReference31::test_long; + s1.m(); + SAM_long s2 = MethodReference31::test_long; + s2.m(); + SAM s3 = MethodReference31::test; + try { + s3.m(); + } + catch (RuntimeException ex) { } + SAM_long s4 = MethodReference31::test; + try { + s4.m(); + } + catch (RuntimeException ex) { } + } + + static void testFloat() { + SAM s1 = MethodReference31::test_float; + s1.m(); + SAM_float s2 = MethodReference31::test_float; + s2.m(); + SAM s3 = MethodReference31::test; + try { + s3.m(); + } + catch (RuntimeException ex) { } + SAM_float s4 = MethodReference31::test; + try { + s4.m(); + } + catch (RuntimeException ex) { } + } + + static void testDouble() { + SAM s1 = MethodReference31::test_double; + s1.m(); + SAM_double s2 = MethodReference31::test_double; + s2.m(); + SAM s3 = MethodReference31::test; + try { + s3.m(); + } + catch (RuntimeException ex) { } + SAM_double s4 = MethodReference31::test; + try { + s4.m(); + } + catch (RuntimeException ex) { } + } + + public static void main(String[] args) { + testByte(); + testShort(); + testInteger(); + testLong(); + testFloat(); + testDouble(); + assertTrue(assertionCount == 24); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference32.java b/langtools/test/tools/javac/lambda/MethodReference32.java new file mode 100644 index 00000000000..754dd366e0f --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference32.java @@ -0,0 +1,22 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that varargs warnings are generated during SAM conversion + * @compile/fail/ref=MethodReference32.out -Xlint:unchecked -Werror -XDrawDiagnostics MethodReference32.java + */ + +import java.util.*; + +class MethodReference32 { + + interface SAM { + MethodReference32 m(List l1, List l2); + } + + MethodReference32 meth(List... lli) { return null; } + MethodReference32(List... lli) { } + + SAM s1 = this::meth; + SAM s2 = MethodReference32::new; +} diff --git a/langtools/test/tools/javac/lambda/MethodReference32.out b/langtools/test/tools/javac/lambda/MethodReference32.out new file mode 100644 index 00000000000..1ea868ca5f7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference32.out @@ -0,0 +1,7 @@ +MethodReference32.java:17:45: compiler.warn.unchecked.varargs.non.reifiable.type: java.util.List +MethodReference32.java:18:40: compiler.warn.unchecked.varargs.non.reifiable.type: java.util.List +MethodReference32.java:20:14: compiler.warn.unchecked.generic.array.creation: java.util.List[] +MethodReference32.java:21:14: compiler.warn.unchecked.generic.array.creation: java.util.List[] +- compiler.err.warnings.and.werror +1 error +4 warnings diff --git a/langtools/test/tools/javac/lambda/MethodReference33.java b/langtools/test/tools/javac/lambda/MethodReference33.java new file mode 100644 index 00000000000..5edde6610c4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference33.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * test bridged constructor references + */ + +public class MethodReference33 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + class Foo { + Foo(Integer i) { assertTrue(true); } + Foo() { assertTrue(true); } + } + + interface BridgeSAMBound { + X m(int i); + } + + interface NonBridgeSAMBound { + X m(); + } + + void test() { + BridgeSAMBound b1 = Foo::new; + b1.m(1); + NonBridgeSAMBound b2 = Foo::new; + b2.m(); + } + + public static void main(String[] args) { + MethodReference33 test = new MethodReference33(); + test.test(); + assertTrue(assertionCount == 2); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference34.java b/langtools/test/tools/javac/lambda/MethodReference34.java new file mode 100644 index 00000000000..7591d366b8a --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference34.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that code generation handles void-compatibility correctly + * @run main MethodReference34 + */ + +public class MethodReference34 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM_void { + void m(); + } + + interface SAM_java_lang_Void { + void m(); + } + + static void m_void() { assertTrue(true); } + + static Void m_java_lang_Void() { assertTrue(true); return null; } + + public static void main(String[] args) { + SAM_void s1 = MethodReference34::m_void; + s1.m(); + SAM_java_lang_Void s2 = MethodReference34::m_void; + s2.m(); + SAM_void s3 = MethodReference34::m_java_lang_Void; + s3.m(); + SAM_java_lang_Void s4 = MethodReference34::m_java_lang_Void; + s4.m(); + assertTrue(assertionCount == 4); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference35.java b/langtools/test/tools/javac/lambda/MethodReference35.java new file mode 100644 index 00000000000..bb326c94a4e --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference35.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that lambda/method references are valid method reference qualifiers + * @run main MethodReference35 + */ + +public class MethodReference35 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM { + MethodReference35 invoke(); + } + + MethodReference35() { + assertTrue(true); + } + + static MethodReference35 m() { + assertTrue(true); + return null; + } + + public static void main(String[] args) { + SAM sam1 = ((SAM)() -> { assertTrue(true); return null; })::invoke; + sam1.invoke(); + SAM sam2 = ((SAM)MethodReference35::new)::invoke; + sam1.invoke(); + SAM sam3 = ((SAM)MethodReference35::m)::invoke; + sam1.invoke(); + assertTrue(assertionCount == 3); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference36.java b/langtools/test/tools/javac/lambda/MethodReference36.java new file mode 100644 index 00000000000..83828572f19 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference36.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that method reference handles varargs conversion properly + * @run main MethodReference36 + */ + +public class MethodReference36 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SamC { void m(char[] a); } + interface SamZ { void m(boolean[] a); } + interface SamB { void m(byte[] a); } + interface SamS { void m(short[] a); } + interface SamI { void m(int[] a); } + interface SamL { void m(long[] a); } + interface SamF { void m(float[] a); } + interface SamD { void m(double[] a); } + interface SamO { void m(Object[] a); } + + + static void m(Object... vi) { + assertTrue(true); + } + + public void test() { + + SamC sc = MethodReference36::m; + sc.m(new char[] { 'a', 'b' } ); + + SamZ sz = MethodReference36::m; + sz.m(new boolean[] { true, false } ); + + SamB sb = MethodReference36::m; + sb.m(new byte[] { 0, 1 } ); + + SamS ss = MethodReference36::m; + ss.m(new short[] { 0, 1 } ); + + SamI si = MethodReference36::m; + si.m(new int[] { 0, 1 } ); + + SamL sl = MethodReference36::m; + sl.m(new long[] { 0, 1 } ); + + SamF sf = MethodReference36::m; + sf.m(new float[] { 0, 1 } ); + + SamD sd = MethodReference36::m; + sd.m(new double[] { 0, 1 } ); + + SamO so = MethodReference36::m; + so.m(new Object[] { null, null } ); + } + + public static void main(String[] args) { + new MethodReference36().test(); + assertTrue(assertionCount == 9); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference37.java b/langtools/test/tools/javac/lambda/MethodReference37.java new file mode 100644 index 00000000000..c991a957a7e --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference37.java @@ -0,0 +1,40 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * spurious exceptions when checking references to inner constructors where + * the enclosing class is not defined in any outer context + * @compile/fail/ref=MethodReference37.out -XDrawDiagnostics MethodReference37.java + */ + +class MethodReference37 { + + interface SAM1 { + R invoke(); + } + + interface SAM2 { + R invoke(A a); + } + + static class Outer { + class Inner { } + + static void test1() { + SAM2 sam = Inner::new; + } + + void test2() { + SAM1 sam0 = Inner::new; + SAM2 sam1 = Inner::new; + } + } + + static void test1() { + SAM2 sam = Outer.Inner::new; + } + + void test2() { + SAM2 sam1 = Outer.Inner::new; + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference37.out b/langtools/test/tools/javac/lambda/MethodReference37.out new file mode 100644 index 00000000000..09dc966bd4a --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference37.out @@ -0,0 +1,5 @@ +MethodReference37.java:24:38: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch))) +MethodReference37.java:29:39: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch))) +MethodReference37.java:34:40: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch))) +MethodReference37.java:38:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch))) +4 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference38.java b/langtools/test/tools/javac/lambda/MethodReference38.java new file mode 100644 index 00000000000..e1e926e64b6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference38.java @@ -0,0 +1,29 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * The qualifier type of a constructor reference must be a concrete class + * @compile/fail/ref=MethodReference38.out -XDrawDiagnostics MethodReference38.java + */ + +class MethodReference38 { + + interface SAM { + R invoke(); + } + + @interface A { } + + interface I { } + + static abstract class AC { } + + enum E { } + + void test() { + SAM s1 = A::new; + SAM s2 = I::new; + SAM s3 = AC::new; + SAM s4 = E::new; + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference38.out b/langtools/test/tools/javac/lambda/MethodReference38.out new file mode 100644 index 00000000000..5a36237e1de --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference38.out @@ -0,0 +1,5 @@ +MethodReference38.java:24:18: compiler.err.abstract.cant.be.instantiated +MethodReference38.java:25:18: compiler.err.abstract.cant.be.instantiated +MethodReference38.java:26:18: compiler.err.abstract.cant.be.instantiated +MethodReference38.java:27:18: compiler.err.enum.cant.be.instantiated +4 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference39.java b/langtools/test/tools/javac/lambda/MethodReference39.java new file mode 100644 index 00000000000..f3b6f5d07b8 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference39.java @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that bad enclosing class parameter type is discarded accordingly + * @compile/fail/ref=MethodReference39.out -XDrawDiagnostics MethodReference39.java + */ +class MethodReference39 { + + static class Sup {} + + + static class Sub extends Sup { + + interface SAM { Sup m(Sup x, String str); } + + class Inner extends Sup { + Inner(String val) { } + } + + void test() { + SAM var = Sub.Inner::new;; + } + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference39.out b/langtools/test/tools/javac/lambda/MethodReference39.out new file mode 100644 index 00000000000..0cfcd406862 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference39.out @@ -0,0 +1,2 @@ +MethodReference39.java:22:23: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, java.lang.String, MethodReference39.Sup,java.lang.String, kindname.class, MethodReference39.Sub.Inner, (compiler.misc.arg.length.mismatch))) +1 error diff --git a/langtools/test/tools/javac/lambda/MethodReference40.java b/langtools/test/tools/javac/lambda/MethodReference40.java new file mode 100644 index 00000000000..a725044efb6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference40.java @@ -0,0 +1,24 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that unbound constructor reference are not accepted + * @compile/fail/ref=MethodReference40.out -XDrawDiagnostics MethodReference40.java + */ +class MethodReference40 { + + static class Sup { + class Inner { + Inner(String val) { } + } + } + + static class Sub extends Sup { + + interface SAM { Sup.Inner m(Sub x, String str); } + + void test() { + SAM var = Sub.Inner::new; + } + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference40.out b/langtools/test/tools/javac/lambda/MethodReference40.out new file mode 100644 index 00000000000..9afa437af70 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference40.out @@ -0,0 +1,2 @@ +MethodReference40.java:21:23: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, java.lang.String, MethodReference40.Sub,java.lang.String, kindname.class, MethodReference40.Sup.Inner, (compiler.misc.arg.length.mismatch))) +1 error diff --git a/langtools/test/tools/javac/lambda/MethodReference41.java b/langtools/test/tools/javac/lambda/MethodReference41.java new file mode 100644 index 00000000000..a2593320021 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference41.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that diamond inference is applied when using raw constructor reference qualifier + * @run main MethodReference41 + */ +public class MethodReference41 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM1 { + void m(String s); + } + + interface SAM2 { + void m(Integer s); + } + + interface SAM3 { + void m(Object o); + } + + static class Foo { + Foo(X x) { } + } + + + static void m(SAM1 s) { assertTrue(false); } + static void m(SAM2 s) { assertTrue(true); } + static void m(SAM3 s) { assertTrue(false); } + + public static void main(String[] args) { + m(Foo::new); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference42.java b/langtools/test/tools/javac/lambda/MethodReference42.java new file mode 100644 index 00000000000..1c8aaefab75 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference42.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that diamond inference is applied when using raw constructor reference qualifier + * @run main MethodReference42 + */ +public class MethodReference42 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static class SuperFoo { } + + static class Foo extends SuperFoo { } + + interface SAM1 { + SuperFoo m(); + } + + interface SAM2 { + SuperFoo m(); + } + + interface SAM3 { + SuperFoo m(); + } + + static void m(SAM1 s) { assertTrue(false); } + static void m(SAM2 s) { assertTrue(true); } + static void m(SAM3 s) { assertTrue(false); } + + public static void main(String[] args) { + m(Foo::new); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference43.java b/langtools/test/tools/javac/lambda/MethodReference43.java new file mode 100644 index 00000000000..17a50b91021 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference43.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that diamond inference is applied when using raw constructor reference qualifier + * @run main MethodReference43 + */ +public class MethodReference43 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM1 { + Foo m(String s); + } + + interface SAM2 { + Foo m(Integer s); + } + + interface SAM3 { + Foo m(Object o); + } + + interface SAM4 { + Foo m(Integer o); + } + + static class Foo { + Foo(X x) { } + } + + + static void m(SAM1 s) { assertTrue(false); } + static void m(SAM2 s) { assertTrue(true); } + static void m(SAM3 s) { assertTrue(false); } + static void m(SAM4 s) { assertTrue(false); } + + public static void main(String[] args) { + m(Foo::new); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference44.java b/langtools/test/tools/javac/lambda/MethodReference44.java new file mode 100644 index 00000000000..8c92593b43a --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference44.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that generic method reference is inferred when type parameters are omitted + * @run main MethodReference44 + */ +public class MethodReference44 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static class SuperFoo { } + + static class Foo extends SuperFoo { } + + interface SAM1 { + SuperFoo m(); + } + + interface SAM2 { + SuperFoo m(); + } + + interface SAM3 { + SuperFoo m(); + } + + static Foo m() { return null; } + + static void g(SAM1 s) { assertTrue(false); } + static void g(SAM2 s) { assertTrue(true); } + static void g(SAM3 s) { assertTrue(false); } + + public static void main(String[] args) { + g(MethodReference44::m); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference45.java b/langtools/test/tools/javac/lambda/MethodReference45.java new file mode 100644 index 00000000000..3c132df1857 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference45.java @@ -0,0 +1,40 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that generic method reference is inferred when type parameters are omitted + * @compile/fail/ref=MethodReference45.out -XDrawDiagnostics MethodReference45.java + */ +public class MethodReference45 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static class SuperFoo { } + + static class Foo extends SuperFoo { } + + interface SAM1 { + void m(); + } + + interface SAM2 { + void m(); + } + + static Foo m() { return null; } + + static void g1(SAM1 s) { } + static void g2(SAM1 s) { } + static void g2(SAM2 s) { } + + void test() { + g1(MethodReference45::m); + g2(MethodReference45::m); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference45.out b/langtools/test/tools/javac/lambda/MethodReference45.out new file mode 100644 index 00000000000..7a6b55802e0 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference45.out @@ -0,0 +1,2 @@ +MethodReference45.java:38:9: compiler.err.ref.ambiguous: g2, kindname.method, g2(MethodReference45.SAM1), MethodReference45, kindname.method, g2(MethodReference45.SAM2), MethodReference45 +1 error diff --git a/langtools/test/tools/javac/lambda/MethodReference46.java b/langtools/test/tools/javac/lambda/MethodReference46.java new file mode 100644 index 00000000000..8f0c327faff --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference46.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that generic method reference is inferred when type parameters are omitted + * @run main MethodReference46 + */ +public class MethodReference46 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM1 { + void m(String s); + } + + interface SAM2 { + void m(Integer s); + } + + interface SAM3 { + void m(Object o); + } + + static class Foo { + Foo(X x) { } + } + + static void m(X fx) { } + + static void g(SAM1 s) { assertTrue(false); } + static void g(SAM2 s) { assertTrue(true); } + static void g(SAM3 s) { assertTrue(false); } + + public static void main(String[] args) { + g(MethodReference46::m); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference47.java b/langtools/test/tools/javac/lambda/MethodReference47.java new file mode 100644 index 00000000000..5bc949dd03b --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference47.java @@ -0,0 +1,40 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that generic method reference is inferred when type parameters are omitted + * @compile/fail/ref=MethodReference47.out -XDrawDiagnostics MethodReference47.java + */ +public class MethodReference47 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface SAM1 { + void m(Integer s); + } + + interface SAM2 { + void m(Integer s); + } + + static class Foo { + Foo(X x) { } + } + + static void m(X fx) { } + + static void g1(SAM1 s) { } + static void g2(SAM1 s) { } + static void g2(SAM2 s) { } + + public static void main(String[] args) { + g1(MethodReference46::m); + g2(MethodReference46::m); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference47.out b/langtools/test/tools/javac/lambda/MethodReference47.out new file mode 100644 index 00000000000..39d3c31ba12 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference47.out @@ -0,0 +1,2 @@ +MethodReference47.java:38:9: compiler.err.ref.ambiguous: g2, kindname.method, g2(MethodReference47.SAM1), MethodReference47, kindname.method, g2(MethodReference47.SAM2), MethodReference47 +1 error diff --git a/langtools/test/tools/javac/lambda/MethodReference48.java b/langtools/test/tools/javac/lambda/MethodReference48.java new file mode 100644 index 00000000000..8c3a704dd02 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference48.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that raw qualifier in unbound method reference is inferred from descriptor + * @run main MethodReference48 + */ +public class MethodReference48 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + static class Foo { + X m() { return null; }; + } + + interface SAM1 { + Foo m(Foo fs); + } + + interface SAM2 { + Integer m(Foo fi); + } + + interface SAM3 { + Object m(Foo fi); + } + + static void g(SAM1 s) { assertTrue(false); } //return type not compatible + static void g(SAM2 s) { assertTrue(true); } //ok + static void g(SAM3 s) { assertTrue(false); } //ok but less specific + + public static void main(String[] args) { + g(Foo::m); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference49.java b/langtools/test/tools/javac/lambda/MethodReference49.java new file mode 100644 index 00000000000..15153923642 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference49.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that an array type can be used as a qualifier of an unbound method reference + * @run main MethodReference49 + */ +public class MethodReference49 { + + interface SAM { + Object m(int[] i); + } + + public static void main(String[] args) { + SAM s = int[]::clone; + int[] iarr = { 1, 2, 3 }; + int[] iarr2 = (int[])s.m(iarr); + if (iarr == iarr2) { + throw new AssertionError(); + } + for (int i = 0 ; i < iarr.length ; i ++) { + if (iarr[i] != iarr2[i]) { + throw new AssertionError(); + } + } + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference50.java b/langtools/test/tools/javac/lambda/MethodReference50.java new file mode 100644 index 00000000000..7da095088c8 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference50.java @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that erroneous method references are flagged with errors as expected + * @compile/fail/ref=MethodReference50.out -XDrawDiagnostics MethodReference50.java + */ + +class MethodReference50 { + + interface SAM1 { + void m(); + } + + interface SAM2 { + void m(); + } + + void call(SAM1 s) {} + void call(SAM2 s) {} + + { + call(NonExistentType::m); + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference50.out b/langtools/test/tools/javac/lambda/MethodReference50.out new file mode 100644 index 00000000000..3303de7c126 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference50.out @@ -0,0 +1,2 @@ +MethodReference50.java:23:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference50, null) +1 error diff --git a/langtools/test/tools/javac/lambda/MethodReference51.java b/langtools/test/tools/javac/lambda/MethodReference51.java new file mode 100644 index 00000000000..1ce3d74f332 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference51.java @@ -0,0 +1,46 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * certain cases of erroneous member reference lookup are not handled by Attr.visitReference + * @compile/fail/ref=MethodReference51.out -XDrawDiagnostics MethodReference51.java + */ +class MethodReference51 { + + private static class Foo { + static int j(int i) { return i; } + } + + static Foo foo = new Foo(); + + static void m(String s) { } + static void m(Integer i) { } + + static int f(String s) { return 1; } + + static int g(Integer i, Number n) { return 1; } + static int g(Number n, Integer i) { return 1; } + + int h(int i) { return i; } +} + +class TestMethodReference51 { + + interface IntSam { + int m(int i); + } + + interface IntegerIntegerSam { + int m(Integer i1, Integer i2); + } + + + static void test() { + IntSam s1 = MethodReference51::unknown; //method not found + IntSam s2 = MethodReference51::f; //inapplicable method + IntSam s3 = MethodReference51::g; //inapplicable methods + IntegerIntegerSam s4 = MethodReference51::g; //ambiguous + IntSam s5 = MethodReference51::h; //static error + IntSam s6 = MethodReference51.foo::j; //inaccessible method + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference51.out b/langtools/test/tools/javac/lambda/MethodReference51.out new file mode 100644 index 00000000000..dfcd73f058a --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference51.out @@ -0,0 +1,7 @@ +MethodReference51.java:39:21: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, unknown, , int, (compiler.misc.location: kindname.class, MethodReference51, null)) +MethodReference51.java:40:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, f, java.lang.String, int, kindname.class, MethodReference51, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String)))) +MethodReference51.java:41:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbols: kindname.method, g, int,{(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Integer,java.lang.Number), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Number,java.lang.Integer), (compiler.misc.arg.length.mismatch))})) +MethodReference51.java:42:32: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: g, kindname.method, g(java.lang.Integer,java.lang.Number), MethodReference51, kindname.method, g(java.lang.Number,java.lang.Integer), MethodReference51)) +MethodReference51.java:43:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, h(int))) +MethodReference51.java:44:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.not.def.access.class.intf.cant.access: j(int), MethodReference51.Foo)) +6 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference52.java b/langtools/test/tools/javac/lambda/MethodReference52.java new file mode 100644 index 00000000000..49170d53bbc --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference52.java @@ -0,0 +1,39 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * special cases of method references (getClass()/Array.clone()) not handled properly + * @compile/fail/ref=MethodReference52.out -XDrawDiagnostics MethodReference52.java + */ +import java.util.*; + +class MethodReference52 { + + interface Clone1 { + int[] m(); + } + + interface Clone2 { + Object m(); + } + + interface WrongClone { + long[] m(); + } + + interface GetClass { + Class m(); + } + + interface WrongGetClass { + Class> m(); + } + + void test(int[] iarr, List ls) { + Clone1 c1 = iarr::clone; //ok + Clone2 c2 = iarr::clone; //ok - type more generic + WrongClone c3 = iarr::clone; //bad return type + GetClass c4 = ls::getClass; //ok + WrongGetClass c5 = ls::getClass; //bad return type + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference52.out b/langtools/test/tools/javac/lambda/MethodReference52.out new file mode 100644 index 00000000000..1802ab51f1d --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference52.out @@ -0,0 +1,3 @@ +MethodReference52.java:35:25: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int[], long[])) +MethodReference52.java:37:28: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class>)) +2 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference53.java b/langtools/test/tools/javac/lambda/MethodReference53.java new file mode 100644 index 00000000000..df597d47785 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference53.java @@ -0,0 +1,24 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * the case in which no member reference is found is now treated as a normal error (not dependent on target-type) + * @compile/fail/ref=MethodReference53.out -XDrawDiagnostics MethodReference53.java + */ +class MethodReference53 { + + interface SAM1 { + void m(int i); + } + + interface SAM2 { + void m(long i); + } + + void m(SAM1 s1) { } + void m(SAM2 s1) { } + + void test() { + m(this::unknown); //should not generate outer resolution diagnostic + } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference53.out b/langtools/test/tools/javac/lambda/MethodReference53.out new file mode 100644 index 00000000000..f6f063f4354 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference53.out @@ -0,0 +1,2 @@ +MethodReference53.java:22:11: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, MethodReference53, null)) +1 error diff --git a/langtools/test/tools/javac/lambda/MethodReference54.java b/langtools/test/tools/javac/lambda/MethodReference54.java new file mode 100644 index 00000000000..f442735ac91 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference54.java @@ -0,0 +1,19 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * method call with bad qualifier generates NPE if argument is a method reference + * @compile/fail/ref=MethodReference54.out -XDrawDiagnostics MethodReference54.java + */ +class MethodReference54 { + + interface SAM { + void m(); + } + + void test() { + nonExistent.m(MethodReference54::get); + } + + static String get() { return ""; } +} diff --git a/langtools/test/tools/javac/lambda/MethodReference54.out b/langtools/test/tools/javac/lambda/MethodReference54.out new file mode 100644 index 00000000000..02dba67a467 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReference54.out @@ -0,0 +1,2 @@ +MethodReference54.java:15:9: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, MethodReference54, null) +1 error diff --git a/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java b/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java index 1c9980d44c9..2f0611f99fa 100644 --- a/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java +++ b/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java @@ -24,7 +24,9 @@ /* * @test * @bug 7115052 - * @summary Add parser support for method references + * @bug 8003280 + * @summary Add lambda tests + * Add parser support for method references */ import com.sun.source.util.JavacTask; @@ -227,7 +229,7 @@ public class MethodReferenceParserTest { void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, - Arrays.asList("-XDallowMethodReferences"), null, Arrays.asList(source)); + null, null, Arrays.asList(source)); try { ct.parse(); } catch (Throwable ex) { diff --git a/langtools/test/tools/javac/lambda/MostSpecific01.java b/langtools/test/tools/javac/lambda/MostSpecific01.java new file mode 100644 index 00000000000..f915c53b1b0 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific01.java @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check correctness of structural most specific test routine + * @compile/fail/ref=MostSpecific01.out -XDrawDiagnostics MostSpecific01.java + */ + +class Test { + + interface IntMapper { + int map(); + } + + interface LongMapper { + long map(); + } + + void m(IntMapper im, String s) { } + void m(LongMapper lm, Integer s) { } + + void test() { + m(()->1, null); + } +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific01.out b/langtools/test/tools/javac/lambda/MostSpecific01.out new file mode 100644 index 00000000000..da2f5c0bcc2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific01.out @@ -0,0 +1,2 @@ +MostSpecific01.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper,java.lang.String), Test, kindname.method, m(Test.LongMapper,java.lang.Integer), Test +1 error diff --git a/langtools/test/tools/javac/lambda/MostSpecific02.java b/langtools/test/tools/javac/lambda/MostSpecific02.java new file mode 100644 index 00000000000..af5349a08b7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific02.java @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check correctness of structural most specific test routine + * @compile/fail/ref=MostSpecific02.out -XDrawDiagnostics MostSpecific02.java + */ + +class Test { + + interface IntMapper { + int map(); + } + + interface LongMapper { + long map(); + } + + void m(IntMapper im, LongMapper s) { } + void m(LongMapper lm, IntMapper s) { } + + void test() { + m(()->1, ()->1); + } +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific02.out b/langtools/test/tools/javac/lambda/MostSpecific02.out new file mode 100644 index 00000000000..814fefbbaf4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific02.out @@ -0,0 +1,2 @@ +MostSpecific02.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper,Test.LongMapper), Test, kindname.method, m(Test.LongMapper,Test.IntMapper), Test +1 error diff --git a/langtools/test/tools/javac/lambda/MostSpecific03.java b/langtools/test/tools/javac/lambda/MostSpecific03.java new file mode 100644 index 00000000000..8fb8e78f45a --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific03.java @@ -0,0 +1,63 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check correctness of structural most specific test routine + * @compile/fail/ref=MostSpecific03.out -XDrawDiagnostics MostSpecific03.java + */ + +class Test { + + interface IntMapper { + int map(); + } + + interface LongMapper { + long map(); + } + + void m(IntMapper... im) { } + void m(LongMapper... lm) { } + + void m2(IntMapper im1, IntMapper... im) { } + void m2(LongMapper... lm) { } + + void test1() { + m(); //ambiguous + m(()->1); //ok + m(()->1, ()->1); //ok + m(()->1, ()->1, ()->1); //ok + } + + void test2() { + m(null, null); //ambiguous + m(()->1, null); //ambiguous + m(null, ()->1); //ambiguous + m(()->1L, null); //ok + m(null, ()->1L); //ok + } + + void test3() { + m2(); //ok + m2(()->1); //ambiguous + m2(()->1, ()->1); //ok + m2(()->1, ()->1, ()->1); //ok + } + + void test4() { + m2(null, null, null); //ambiguous + m2(()->1, null, null); //ambiguous + m2(null, ()->1, null); //ambiguous + m2(null, null, ()->1); //ambiguous + m2(()->1, ()->1, null); //ambiguous + m2(null, ()->1, ()->1); //ambiguous + m2(()->1, null, ()->1); //ambiguous + + m2(()->1L, null, null); //ok + m2(null, ()->1L, null); //ok + m2(null, null, ()->1L); //ok + m2(()->1L, ()->1L, null); //ok + m2(null, ()->1L, ()->1L); //ok + m2(()->1L, null, ()->1L); //ok + } +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific03.out b/langtools/test/tools/javac/lambda/MostSpecific03.out new file mode 100644 index 00000000000..6bb4fed9d21 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific03.out @@ -0,0 +1,13 @@ +MostSpecific03.java:26:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test +MostSpecific03.java:33:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test +MostSpecific03.java:34:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test +MostSpecific03.java:35:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test +MostSpecific03.java:42:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test +MostSpecific03.java:48:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test +MostSpecific03.java:49:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test +MostSpecific03.java:50:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test +MostSpecific03.java:51:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test +MostSpecific03.java:52:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test +MostSpecific03.java:53:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test +MostSpecific03.java:54:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test +12 errors diff --git a/langtools/test/tools/javac/lambda/MostSpecific04.java b/langtools/test/tools/javac/lambda/MostSpecific04.java new file mode 100644 index 00000000000..c5fbc3d35a5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific04.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * Structural most specific doesn't handle cases with wildcards in functional interfaces + */ +public class MostSpecific04 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface DoubleMapper { + double map(T t); + } + + interface LongMapper { + long map(T t); + } + + static class MyList { + void map(DoubleMapper m) { assertTrue(false); } + void map(LongMapper m) { assertTrue(true); } + } + + public static void main(String[] args) { + MyList ls = new MyList(); + ls.map(e->e.length()); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific05.java b/langtools/test/tools/javac/lambda/MostSpecific05.java new file mode 100644 index 00000000000..177a43e7637 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific05.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * Structural most specific doesn't handle cases with wildcards in functional interfaces + */ +public class MostSpecific05 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface ObjectConverter { + T map(Object o); + } + + interface NumberConverter { + T map(Object o); + } + + static class MyMapper { + void map(ObjectConverter m) { assertTrue(false); } + void map(NumberConverter m) { assertTrue(true); } + } + + public static void main(String[] args) { + MyMapper mm = new MyMapper(); + mm.map(e->1.0); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific06.java b/langtools/test/tools/javac/lambda/MostSpecific06.java new file mode 100644 index 00000000000..d8f48e98a28 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific06.java @@ -0,0 +1,30 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * most specific resolution crashes on stuck lambdas + * @compile/fail/ref=MostSpecific06.out -XDrawDiagnostics MostSpecific06.java + */ +import java.util.*; + +class MostSpecific06 { + + interface Predicate { + boolean accept(X x); + } + + interface ExtPredicate extends Predicate { } + + + + void test(boolean cond, ArrayList als) { + m(u -> true, als, als); + m((u -> true), als, als); + m(cond ? u -> true : u -> false, als, als); + } + + U m(Predicate p, List lu, ArrayList au) { return null; } + + + U m(ExtPredicate ep, ArrayList au, List lu) { return null; } +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific06.out b/langtools/test/tools/javac/lambda/MostSpecific06.out new file mode 100644 index 00000000000..83e47c5613e --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific06.out @@ -0,0 +1,4 @@ +MostSpecific06.java:21:9: compiler.err.ref.ambiguous: m, kindname.method, m(MostSpecific06.Predicate,java.util.List,java.util.ArrayList), MostSpecific06, kindname.method, m(MostSpecific06.ExtPredicate,java.util.ArrayList,java.util.List), MostSpecific06 +MostSpecific06.java:22:9: compiler.err.ref.ambiguous: m, kindname.method, m(MostSpecific06.Predicate,java.util.List,java.util.ArrayList), MostSpecific06, kindname.method, m(MostSpecific06.ExtPredicate,java.util.ArrayList,java.util.List), MostSpecific06 +MostSpecific06.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(MostSpecific06.Predicate,java.util.List,java.util.ArrayList), MostSpecific06, kindname.method, m(MostSpecific06.ExtPredicate,java.util.ArrayList,java.util.List), MostSpecific06 +3 errors diff --git a/langtools/test/tools/javac/lambda/MostSpecific07.java b/langtools/test/tools/javac/lambda/MostSpecific07.java new file mode 100644 index 00000000000..a128cd4416c --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific07.java @@ -0,0 +1,31 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * speculative cache contents are overwritten by deferred type-checking of nested stuck expressions + * @compile/fail/ref=MostSpecific07.out -XDrawDiagnostics MostSpecific07.java + */ +import java.util.*; + +class MostSpecific07 { + + interface Predicate { + Y accept(X x); + } + + interface VoidMapper { + void accept(); + } + + interface ExtPredicate extends Predicate { } + + void test(boolean cond, ArrayList als, VoidMapper vm) { + m(u -> ()->{}, als, als, vm); + m((u -> ()->{}), als, als, vm); + m(cond ? u -> ()->{} : u -> ()->{}, als, als, vm); + } + + U m(Predicate p, List lu, ArrayList au, V v) { return null; } + + U m(ExtPredicate ep, ArrayList au, List lu, V v) { return null; } +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific07.out b/langtools/test/tools/javac/lambda/MostSpecific07.out new file mode 100644 index 00000000000..76fc516ba9a --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific07.out @@ -0,0 +1,4 @@ +MostSpecific07.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(MostSpecific07.Predicate,java.util.List,java.util.ArrayList,V), MostSpecific07, kindname.method, m(MostSpecific07.ExtPredicate,java.util.ArrayList,java.util.List,V), MostSpecific07 +MostSpecific07.java:24:9: compiler.err.ref.ambiguous: m, kindname.method, m(MostSpecific07.Predicate,java.util.List,java.util.ArrayList,V), MostSpecific07, kindname.method, m(MostSpecific07.ExtPredicate,java.util.ArrayList,java.util.List,V), MostSpecific07 +MostSpecific07.java:25:9: compiler.err.ref.ambiguous: m, kindname.method, m(MostSpecific07.Predicate,java.util.List,java.util.ArrayList,V), MostSpecific07, kindname.method, m(MostSpecific07.ExtPredicate,java.util.ArrayList,java.util.List,V), MostSpecific07 +3 errors diff --git a/langtools/test/tools/javac/lambda/NakedThis.java b/langtools/test/tools/javac/lambda/NakedThis.java new file mode 100644 index 00000000000..0cb6cab2b75 --- /dev/null +++ b/langtools/test/tools/javac/lambda/NakedThis.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * basic test for capture of non-mutable locals + * @author Brian Goetz + * @author Maurizio Cimadamore + * @compile NakedThis.java + */ + +class NakedThis { + + interface SAM { + NakedThis m(int x); + } + + SAM s1 = (int x) -> this; + SAM s2 = (int x) -> NakedThis.this; +} diff --git a/langtools/test/tools/javac/lambda/SourceLevelTest.java b/langtools/test/tools/javac/lambda/SourceLevelTest.java new file mode 100644 index 00000000000..11ef228549b --- /dev/null +++ b/langtools/test/tools/javac/lambda/SourceLevelTest.java @@ -0,0 +1,23 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that lambda features are not enabled with source < 8 + * @compile/fail/ref=SourceLevelTest.out -XDrawDiagnostics -source 7 SourceLevelTest.java + */ + +class SourceLevelTest { + interface I { + default void m() { SourceLevelTest.impl(this); } + } + + interface SAM { + void m(); + } + + SAM s1 = () -> { }; + SAM s2 = this::m; + + static void impl(I i) {} + void m() {} +} diff --git a/langtools/test/tools/javac/lambda/SourceLevelTest.out b/langtools/test/tools/javac/lambda/SourceLevelTest.out new file mode 100644 index 00000000000..a9ed3bb7389 --- /dev/null +++ b/langtools/test/tools/javac/lambda/SourceLevelTest.out @@ -0,0 +1,6 @@ +- compiler.warn.source.no.bootclasspath: 1.7 +SourceLevelTest.java:11:9: compiler.err.default.methods.not.supported.in.source: 1.7 +SourceLevelTest.java:18:17: compiler.err.lambda.not.supported.in.source: 1.7 +SourceLevelTest.java:19:20: compiler.err.method.references.not.supported.in.source: 1.7 +3 errors +1 warning diff --git a/langtools/test/tools/javac/lambda/TargetType01.java b/langtools/test/tools/javac/lambda/TargetType01.java new file mode 100644 index 00000000000..2b3f5434b16 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType01.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check nested case of overload resolution and lambda parameter inference + * @author Maurizio Cimadamore + * @compile TargetType01.java + */ + +class TargetType01 { + + interface Func { + B call(A a); + } + + interface F_I_I extends Func {} + interface F_S_S extends Func {} + + static Integer M(F_I_I f){ return null; } + static String M(F_S_S f){ return null; } + + static { + //ambiguity here - the compiler does not try all the combinations! + M(x1 -> { return M( x2 -> { return x1 + x2; });}); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType02.java b/langtools/test/tools/javac/lambda/TargetType02.java new file mode 100644 index 00000000000..f5141ed18eb --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType02.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check overload resolution and target type inference w.r.t. generic methods + * @author Maurizio Cimadamore + * @run main TargetType02 + */ + +public class TargetType02 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface S1 { + X m(Integer x); + } + + interface S2 { + abstract X m(Integer x); + } + + static void call(S1 s) { s.m(1); assertTrue(true); } + static void call(S2 s) { s.m(2); assertTrue(false); } + + void test() { + call(i -> { toString(); return i; }); + } + + public static void main(String[] args) { + new TargetType02().test(); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType03.java b/langtools/test/tools/javac/lambda/TargetType03.java new file mode 100644 index 00000000000..b413c09731b --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType03.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check overload resolution and target type inference w.r.t. generic methods + * @author Maurizio Cimadamore + * @run main TargetType03 + */ +import java.util.*; + +public class TargetType03 { + + interface Mapper { + Y myMap(X a); + } + + static class MapperList extends ArrayList { + public List myMap(Mapper mapper) { + ArrayList mappedList = new ArrayList<>(); + for (A elem : this) { + mappedList.add(mapper.myMap(elem)); + } + return mappedList; + }; + } + + public static void main(String[] args) { + MapperList numbers = new MapperList<>(); + numbers.add(1); + numbers.add(2); + numbers.add(3); + numbers.add(4); + numbers.add(5); + List sqNumbers = numbers.myMap(a -> a * a); + //check invariants + if (numbers.size() != sqNumbers.size()) { + throw new AssertionError(); + } + for (int i = 0; i < numbers.size() ; i ++) { + if (sqNumbers.get(i) != Math.pow(numbers.get(i), 2)) { + throw new AssertionError(); + } + } + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType04.java b/langtools/test/tools/javac/lambda/TargetType04.java new file mode 100644 index 00000000000..103b8ff41c7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType04.java @@ -0,0 +1,18 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * target typing in assignment context + * @author Maurizio Cimadamore + * @compile/fail/ref=TargetType04.out -XDrawDiagnostics TargetType04.java + */ +class TargetType04 { + + interface S { + Y m(X x); + } + + S s1 = i -> { return i; }; //ok + S s2 = i -> { return i; }; //no + S s3 = i -> { return i; }; //no +} diff --git a/langtools/test/tools/javac/lambda/TargetType04.out b/langtools/test/tools/javac/lambda/TargetType04.out new file mode 100644 index 00000000000..e31efd48073 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType04.out @@ -0,0 +1,3 @@ +TargetType04.java:16:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Double, java.lang.Integer)) +TargetType04.java:17:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.Double)) +2 errors diff --git a/langtools/test/tools/javac/lambda/TargetType05.java b/langtools/test/tools/javac/lambda/TargetType05.java new file mode 100644 index 00000000000..936b1336317 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType05.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * test recursion through SAM type + * @author Maurizio Cimadamore + * @run main TargetType05 + */ +public class TargetType05 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface Func { + R call(A a); + } + + static Func f; + + public static void main(String[] args) { + f = i -> { return i == 1 ? 1 : f.call(i-1) * i; }; + assertTrue(f.call(5) == 120); + assertTrue(assertionCount == 1); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType06.java b/langtools/test/tools/javac/lambda/TargetType06.java new file mode 100644 index 00000000000..1a764156949 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType06.java @@ -0,0 +1,27 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check complex case of target typing + * @author Maurizio Cimadamore + * @compile/fail/ref=TargetType06.out -XDrawDiagnostics TargetType06.java + */ + +import java.util.List; + +class TargetType06 { + + class Foo { + Foo getFoo() { return null; } + } + + interface Function { + R invoke(A a); + } + + static List map(Function function) { return null; } + + void test() { + List l = map(foo -> foo.getFoo()); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType06.out b/langtools/test/tools/javac/lambda/TargetType06.out new file mode 100644 index 00000000000..ddfd542c129 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType06.out @@ -0,0 +1,2 @@ +TargetType06.java:25:23: compiler.err.cant.apply.symbol: kindname.method, map, TargetType06.Function, @510, kindname.class, TargetType06, (compiler.misc.cyclic.inference: B) +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType07.java b/langtools/test/tools/javac/lambda/TargetType07.java new file mode 100644 index 00000000000..bb897e6a00f --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType07.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that explicit generic target type parses w/o problems + * @author Peter Levart + * @author Maurizio Cimadamore + * @compile TargetType07.java + */ + +class TargetType07 { + + public interface SAM1 { X m(); } + public interface SAM2 { X m(); } + + public static void call(SAM1 s) { } + public static void call(SAM2 s) { } + + public static void main(String[] args) { + call((SAM1)()-> 1 ); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType08.java b/langtools/test/tools/javac/lambda/TargetType08.java new file mode 100644 index 00000000000..21711efd017 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType08.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that explicit non-generic target type parses w/o problems + * @author Peter Levart + * @author Maurizio Cimadamore + * @compile TargetType08.java + */ + +class TargetType07 { + + public interface SAM1 { String m(); } + public interface SAM2 { Comparable m(); } + + public static void call(SAM1 s) { } + public static void call(SAM2 s) { } + + public static void main(String[] args) { + call((SAM1)()-> "Hello!" ); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType10.java b/langtools/test/tools/javac/lambda/TargetType10.java new file mode 100644 index 00000000000..39afaee727a --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType10.java @@ -0,0 +1,19 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that wildcards in the target method of a lambda conversion is handled correctly + * @author Maurizio Cimadamore + * @compile/fail/ref=TargetType10.out -XDrawDiagnostics TargetType10.java + */ + +class TargetType10 { + interface Function { + R apply(A a); + } + + static class Test { + Function compose(Function g, Function f) { return null; } + { compose(x -> "a" + x, x -> x + "b"); } + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType10.out b/langtools/test/tools/javac/lambda/TargetType10.out new file mode 100644 index 00000000000..fa904091c0e --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType10.out @@ -0,0 +1,2 @@ +TargetType10.java:17:11: compiler.err.cant.apply.symbol: kindname.method, compose, TargetType10.Function,TargetType10.Function, @500,@515, kindname.class, TargetType10.Test, (compiler.misc.cyclic.inference: B,A) +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType11.java b/langtools/test/tools/javac/lambda/TargetType11.java new file mode 100644 index 00000000000..94ec8e9d536 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType11.java @@ -0,0 +1,22 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that wildcards in the target method of a lambda conversion is handled correctly + * @author Maurizio Cimadamore + * @compile/fail/ref=TargetType11.out -Xlint:unchecked -XDrawDiagnostics TargetType11.java + */ + +class TargetType11 { + interface Predicate { + boolean apply(X c); + } + + static class Test { + public Predicate and(Predicate... first) { return null; } + public Predicate forPredicate(Predicate predicate) { return null; } + + Predicate c2 = forPredicate(c -> c.compareTo('e') < 0); + Predicate k = and(i -> i > 0, i -> i % 2 == 0); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType11.out b/langtools/test/tools/javac/lambda/TargetType11.out new file mode 100644 index 00000000000..01cf0cb1bcd --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType11.out @@ -0,0 +1,4 @@ +TargetType11.java:16:61: compiler.warn.unchecked.varargs.non.reifiable.type: TargetType11.Predicate +TargetType11.java:20:32: compiler.err.cant.apply.symbol: kindname.method, and, TargetType11.Predicate[], @706,@718, kindname.class, TargetType11.Test, (compiler.misc.cyclic.inference: T) +1 error +1 warning diff --git a/langtools/test/tools/javac/lambda/TargetType12.java b/langtools/test/tools/javac/lambda/TargetType12.java new file mode 100644 index 00000000000..a04ec71902f --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType12.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * Flow should not analyze lambda body that contains errors due to partially specified parameter types + * @author Maurizio Cimadamore + * @compile TargetType12.java + */ + +import java.util.*; + +class TargetType12 { + + interface Extractor { + Y get(X x); + } + + static > void sortBy2(T[] array, Extractor extractor) { + Comparator comparator = (left,right) -> extractor.get(left).compareTo(extractor.get(right)); + Arrays.sort(array, comparator); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType13.java b/langtools/test/tools/javac/lambda/TargetType13.java new file mode 100644 index 00000000000..d3913151fcb --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType13.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * failure to infer exception thrown types from lambda body causes checked exception to be skipped + * @author Maurizio Cimadamore + * @compile/fail/ref=TargetType13.out -XDlambdaInferenceDiags=false -XDrawDiagnostics TargetType13.java + */ + +class TargetType13 { + + interface SAM { + void m(Integer x) throws E; + } + + static void call(SAM s) throws E { } + + void test() { + call(i -> { if (i == 2) throw new Exception(); return; }); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType13.out b/langtools/test/tools/javac/lambda/TargetType13.out new file mode 100644 index 00000000000..cd75acd2b3a --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType13.out @@ -0,0 +1,2 @@ +TargetType13.java:19:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType14.java b/langtools/test/tools/javac/lambda/TargetType14.java new file mode 100644 index 00000000000..c976a3bbf83 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType14.java @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that return type is inferred from target type when cyclic inference found + * @author Maurizio Cimadamore + * @compile/fail/ref=TargetType14.out -XDrawDiagnostics TargetType14.java + */ + +class TargetType14 { + + interface SAM { + X m(int i, int j); + } + + static void test() { + SAM s1 = (i, j) -> i + j; + m((i, j) -> i + j); + SAM s2 = m2((i, j) -> i + j); //ok + SAM s3 = m2((i, j) -> "" + i + j); //no + } + + static void m(SAM s) { } + static SAM m2(SAM s) { return null; } +} diff --git a/langtools/test/tools/javac/lambda/TargetType14.out b/langtools/test/tools/javac/lambda/TargetType14.out new file mode 100644 index 00000000000..0ca94aa932c --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType14.out @@ -0,0 +1,2 @@ +TargetType14.java:20:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TargetType14.SAM, TargetType14.SAM) +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType15.java b/langtools/test/tools/javac/lambda/TargetType15.java new file mode 100644 index 00000000000..fe49639c109 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType15.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * bad target-type inference lead to compiler crash + * @author Maurizio Cimadamore + * @compile TargetType15.java + */ + +class TargetType15 { + + interface SAM { + T foo(T a, T b); + } + + void m1(SAM f_1) {} + void m2(SAM f_2) {} + void m3(SAM f_3) {} + + SAM f_1 = (a, b) -> a; + SAM f_2 = (a, b) -> a; + SAM f_3 = (a, b) -> a; + + { + m1((a, b) -> a); + m2((a, b) -> a); + m3((a, b) -> a); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType16.java b/langtools/test/tools/javac/lambda/TargetType16.java new file mode 100644 index 00000000000..1de0d125b99 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType16.java @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Check void-compatibility in strict vs. loose conversion contexts + * @compile/fail/ref=TargetType16.out -XDrawDiagnostics TargetType16.java + */ + +class TargetType16 { + + interface SAM1 { + void m1(); + } + + interface SAM2 { + X m2(); + } + + static void m(SAM1 s1) { } + static void m(SAM2 s2) { } + + public static void main(String[] args) { + m(() -> { throw new AssertionError(); }); //ambiguous + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType16.out b/langtools/test/tools/javac/lambda/TargetType16.out new file mode 100644 index 00000000000..f803ca37b38 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType16.out @@ -0,0 +1,2 @@ +TargetType16.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(TargetType16.SAM1), TargetType16, kindname.method, m(TargetType16.SAM2), TargetType16 +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType17.java b/langtools/test/tools/javac/lambda/TargetType17.java new file mode 100644 index 00000000000..cc1d9cf2f3c --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType17.java @@ -0,0 +1,22 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that javac recovers succesfully from bad cast conversion to primitive type + * @compile/fail/ref=TargetType17.out -XDrawDiagnostics TargetType17.java + */ + +class TargetType17 { + interface SAM { + boolean m(X x); + } + + byte b = (byte) ()-> true; + short s = (short) ()-> 1; + int i = (int) ()-> 1; + long l = (long) ()-> 1L; + float f = (float) ()-> 1.0F; + double d = (double) ()-> 1.0; + char c = (char) ()-> 'c'; + boolean z = (boolean) ()-> true; +} diff --git a/langtools/test/tools/javac/lambda/TargetType17.out b/langtools/test/tools/javac/lambda/TargetType17.out new file mode 100644 index 00000000000..0bb985f699b --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType17.out @@ -0,0 +1,9 @@ +TargetType17.java:14:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +TargetType17.java:15:23: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +TargetType17.java:16:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +TargetType17.java:17:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +TargetType17.java:18:23: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +TargetType17.java:19:25: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +TargetType17.java:20:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +TargetType17.java:21:27: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +8 errors diff --git a/langtools/test/tools/javac/lambda/TargetType18.java b/langtools/test/tools/javac/lambda/TargetType18.java new file mode 100644 index 00000000000..cadffed5c9a --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType18.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that javac doesn't crash if implicit lambda parameter is involved in cast + * @compile TargetType18.java + */ + +class TargetType18 { + + interface Folder { + public T fold(T a, T b); + } + + + public static Folder max() { + return (a, b) -> (((Comparable)a).compareTo(b)<0)? b: a; + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType19.java b/langtools/test/tools/javac/lambda/TargetType19.java new file mode 100644 index 00000000000..736168ded6f --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType19.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * complex case of generic method call with lambda argument where target + * is a wildcard SAM + * @compile TargetType19.java + */ +import java.util.List; + +class TargetType19 { + + interface SAM { + void f(List i); + } + + void call(SAM s, Z z) { } + + { call((List p) -> { }, 1); } +} diff --git a/langtools/test/tools/javac/lambda/TargetType19.out b/langtools/test/tools/javac/lambda/TargetType19.out new file mode 100644 index 00000000000..60a8b1d407a --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType19.out @@ -0,0 +1,2 @@ +TargetType19.java:40:10: compiler.err.invalid.inferred.types: (compiler.misc.no.conforming.assignment.exists: TargetType19.SAM, TargetType19.SAM) +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType20.java b/langtools/test/tools/javac/lambda/TargetType20.java new file mode 100644 index 00000000000..06577a63b49 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType20.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * complex case of lambda return type that depends on generic method + * inference variable + * @compile/fail/ref=TargetType20.out -XDrawDiagnostics TargetType20.java + */ +import java.util.*; + +class TargetType20 { + + interface SAM2 { + List f(); + } + + class Test { + void call(SAM2 x, SAM2 y) { } + { call(() -> Collections.emptyList(), () -> new ArrayList()); } + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType20.out b/langtools/test/tools/javac/lambda/TargetType20.out new file mode 100644 index 00000000000..7bbbefe44ac --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType20.out @@ -0,0 +1,2 @@ +TargetType20.java:19:10: compiler.err.cant.apply.symbol: kindname.method, call, TargetType20.SAM2,TargetType20.SAM2, @428,@459, kindname.class, TargetType20.Test, (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object) +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType21.java b/langtools/test/tools/javac/lambda/TargetType21.java new file mode 100644 index 00000000000..89375143a2b --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType21.java @@ -0,0 +1,33 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that candidates with cyclic type-inference are removed from the + * set of applicable methods + * @compile/fail/ref=TargetType21.out -XDrawDiagnostics TargetType21.java + */ + +class TargetType21 { + interface SAM1 { + String m1(Integer n) throws Exception; + } + + interface SAM2 { + void m2(Integer n); + } + + interface SAM3 { + R m3(A n); + } + + void call(SAM1 sam) { } + void call(SAM2 sam) { } + void call(SAM3 sam) { } + + void test() { + call(x -> { throw new Exception(); }); //ok - resolves to call(SAM1) + call(x -> { System.out.println(""); }); //ok - resolves to call(SAM2) + call(x -> { return (Object) null; }); //error - call(SAM3) is not applicable because of cyclic inference + call(x -> { return null; }); ////ok - resolves to call(SAM1) + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType21.out b/langtools/test/tools/javac/lambda/TargetType21.out new file mode 100644 index 00000000000..14895540288 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType21.out @@ -0,0 +1,3 @@ +TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, call(TargetType21.SAM2), TargetType21 +TargetType21.java:30:9: compiler.err.cant.apply.symbols: kindname.method, call, @755,{(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM3), (compiler.misc.cyclic.inference: A))} +2 errors diff --git a/langtools/test/tools/javac/lambda/TargetType22.java b/langtools/test/tools/javac/lambda/TargetType22.java new file mode 100644 index 00000000000..5407f846b62 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType22.java @@ -0,0 +1,44 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that candidates with incompatible SAM descriptor args length + are removed from the set of applicable methods + * @compile/fail/ref=TargetType22.out -Xlint:unchecked -XDrawDiagnostics TargetType22.java + */ + +class TargetType22 { + + interface Sam0 { + void m(); + } + + interface Sam1 { + void m(A a); + } + + interface Sam2 { + void m(A a1, A a2); + } + + interface Sam3 { + void m(A a1, A a2, A a3); + } + + interface SamX { + void m(A... as); + } + + void call(Sam0 s) { } + void call(Sam1 s) { } + void call(Sam2 s) { } + void call(Sam3 s) { } + void call(SamX s) { } + + void test() { + call(() -> { }); + call(a1 -> { }); //ambiguous - both call(Sam1) and call(SamX) match + call((a1, a2) -> { }); + call((a1, a2, a3) -> { }); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType22.out b/langtools/test/tools/javac/lambda/TargetType22.out new file mode 100644 index 00000000000..d94b2cc60b3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType22.out @@ -0,0 +1,4 @@ +TargetType22.java:29:21: compiler.warn.unchecked.varargs.non.reifiable.type: A +TargetType22.java:40:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType22.Sam1), TargetType22, kindname.method, call(TargetType22.SamX), TargetType22 +1 error +1 warning diff --git a/langtools/test/tools/javac/lambda/TargetType23.java b/langtools/test/tools/javac/lambda/TargetType23.java new file mode 100644 index 00000000000..0786af38318 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType23.java @@ -0,0 +1,37 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check case of ambiguous method call with lambda whose body cannot + complete normally + * @compile/fail/ref=TargetType23.out -XDrawDiagnostics TargetType23.java + */ + +class TargetType23 { + + interface Sam0 { + void m(); + } + + interface Sam1 { + int m(); + } + + interface Sam2 { + String m(); + } + + interface Sam3 { + A m(); + } + + + void call(Sam0 s) { } + void call(Sam1 s) { } + void call(Sam2 s) { } + void call(Sam3 s) { } + + void test() { + call(()-> { throw new RuntimeException(); }); //ambiguous - both call(Sam0), call(Sam2), call(Sam3) match + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType23.out b/langtools/test/tools/javac/lambda/TargetType23.out new file mode 100644 index 00000000000..2b40d26ccc1 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType23.out @@ -0,0 +1,2 @@ +TargetType23.java:35:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType23.Sam2), TargetType23, kindname.method, call(TargetType23.Sam3), TargetType23 +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType24.java b/langtools/test/tools/javac/lambda/TargetType24.java new file mode 100644 index 00000000000..b470a9169f9 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType24.java @@ -0,0 +1,39 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check case of nested method calls with lambda expression + * @compile/fail/ref=TargetType24.out -XDrawDiagnostics TargetType24.java + */ + +class TargetType24 { + + interface F { + B f(A a); + } + + interface FSub extends F { } + + static class Array { + boolean forAll(final F f) { + return false; + } + + String forAll(final FSub f) { + return ""; + } + + String forAll2(final FSub f) { + return ""; + } + } + + void test(Array as, final Array ac) { + final boolean b1 = as.forAll(s -> ac.forAll(c -> false)); //ok + final String s1 = as.forAll2(s -> ac.forAll2(c -> "")); //ok + final boolean b2 = as.forAll(s -> ac.forAll(c -> "" )); //fail + final String s2 = as.forAll2(s -> ac.forAll2(c -> false)); //fail + final boolean b3 = as.forAll((F)s -> ac.forAll((F)c -> "")); //fail + final String s3 = as.forAll((FSub)s -> ac.forAll((FSub)c -> false)); //fail + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType24.out b/langtools/test/tools/javac/lambda/TargetType24.out new file mode 100644 index 00000000000..7554a6dd2c3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType24.out @@ -0,0 +1,5 @@ +TargetType24.java:34:37: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, boolean) +TargetType24.java:35:45: compiler.err.cant.apply.symbol: kindname.method, forAll2, TargetType24.FSub, @945, kindname.class, TargetType24.Array, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String))) +TargetType24.java:36:101: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Boolean)) +TargetType24.java:37:104: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String)) +4 errors diff --git a/langtools/test/tools/javac/lambda/TargetType25.java b/langtools/test/tools/javac/lambda/TargetType25.java new file mode 100644 index 00000000000..4ea78f83c4a --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType25.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that lambda expression can appear in + * @compile TargetType25.java + */ + +class TargetType25 { + + interface F { + B f(A a); + } + + void m1(F f) { } + void m2(F> f) { } + void m3(F>> f) { } + + void testExprLambdaInMethodContext() { + m1(s1 -> 1); + m2(s1 -> s2 -> 1); + m3(s1 -> s2 -> s3 -> 1); + } + + void testExprLambdaInAssignmentContext() { + F fn1 = s1 -> 1; + F> fn2 = s1 -> s2 -> 1; + F>> fn3 = s1 -> s2 -> s3 -> 1; + } + + void testStatementLambdaInMethodContext() { + m1(s1 -> { return 1; }); + m2(s1 -> { return s2 -> { return 1; }; }); + m3(s1 -> { return s2 -> { return s3 -> { return 1; }; }; }); + } + + void testStatementLambdaInAssignmentContext() { + F fn1 = s1 -> { return 1; }; + F> fn2 = s1 -> { return s2 -> { return 1; }; }; + F>> fn3 = s1 -> { return s2 -> { return s3 -> { return 1; }; }; }; + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType26.java b/langtools/test/tools/javac/lambda/TargetType26.java new file mode 100644 index 00000000000..92fe58dce03 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType26.java @@ -0,0 +1,17 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * case of cyclic type inference (lambda passed where inference var expected) + * @compile/fail/ref=TargetType26.out -XDrawDiagnostics TargetType26.java + */ + +class TargetType26 { + interface SAM { + void m(); + } + + void call(Z z) { } + + { call(() -> { }); } +} diff --git a/langtools/test/tools/javac/lambda/TargetType26.out b/langtools/test/tools/javac/lambda/TargetType26.out new file mode 100644 index 00000000000..912df88f9f7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType26.out @@ -0,0 +1,2 @@ +TargetType26.java:16:7: compiler.err.cant.apply.symbol: kindname.method, call, Z, @340, kindname.class, TargetType26, (compiler.misc.cyclic.inference: Z) +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType27.java b/langtools/test/tools/javac/lambda/TargetType27.java new file mode 100644 index 00000000000..407c1aea18b --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType27.java @@ -0,0 +1,20 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * complex case of cyclic type inference (lambda returned where inference var expected) + * @compile/fail/ref=TargetType27.out -XDrawDiagnostics TargetType27.java + * @compile/fail/ref=TargetType27.out -XDrawDiagnostics -XDcomplexinference TargetType27.java + */ + +class TargetType27 { + interface F { + Y f(X a); + } + + F m(F f) { return null; } + + void test() { + m((String s1) -> (String s2) -> new Integer(1)); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType27.out b/langtools/test/tools/javac/lambda/TargetType27.out new file mode 100644 index 00000000000..3edf2b92cb3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType27.out @@ -0,0 +1,2 @@ +TargetType27.java:18:9: compiler.err.cant.apply.symbol: kindname.method, m, TargetType27.F, @490, kindname.class, TargetType27, (compiler.misc.cyclic.inference: R) +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType28.java b/langtools/test/tools/javac/lambda/TargetType28.java new file mode 100644 index 00000000000..4e4679baf15 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType28.java @@ -0,0 +1,23 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * target type inference in a case where lambda expression returns diamond + * @compile/fail/ref=TargetType28.out -XDrawDiagnostics TargetType28.java + */ + +class TargetType28 { + static class SuperFoo {} + + static class Foo extends SuperFoo {} + + interface A { + SuperFoo m(X x); + } + + SuperFoo apply(A ax, Z x) { return null; } + + SuperFoo ls = apply(x-> new Foo<>(), 1); + SuperFoo li = apply(x-> new Foo<>(), 1); + SuperFoo lw = apply(x-> new Foo<>(), 1); +} diff --git a/langtools/test/tools/javac/lambda/TargetType28.out b/langtools/test/tools/javac/lambda/TargetType28.out new file mode 100644 index 00000000000..e157c4866ef --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType28.out @@ -0,0 +1,3 @@ +TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TargetType28.SuperFoo, TargetType28.SuperFoo) +TargetType28.java:21:33: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TargetType28.SuperFoo, TargetType28.SuperFoo) +2 errors diff --git a/langtools/test/tools/javac/lambda/TargetType29.java b/langtools/test/tools/javac/lambda/TargetType29.java new file mode 100644 index 00000000000..fba06bce5b6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType29.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check type-substitution in SAM type wildcards inference + * @compile TargetType29.java + */ + +import java.util.*; + +class TargetType29 { + interface Reducer { + public V reduce(E element, V value); + } + + private static int reduce(Iterable iterable, Reducer reducer) { return 0; } + + void test(List li) { + reduce(li, (e, v) -> e + v); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType30.java b/langtools/test/tools/javac/lambda/TargetType30.java new file mode 100644 index 00000000000..678d743e0e3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType30.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that target type is propagated through parenthesized expressions + * @compile TargetType30.java + */ + +class TargetType30 { + + interface SAM { + void m(int x); + } + + void m(SAM s) { } + + void testAssignmentContext() { + SAM s1 = (x-> { System.out.println("Hello!"); }); + SAM s2 = ((x-> { System.out.println("Hello!"); })); + SAM s3 = (((x-> { System.out.println("Hello!"); }))); + } + + void testMethodContext() { + m((x-> { System.out.println("Hello!"); })); + m(((x-> { System.out.println("Hello!"); }))); + m((((x-> { System.out.println("Hello!"); })))); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType31.java b/langtools/test/tools/javac/lambda/TargetType31.java new file mode 100644 index 00000000000..4940142b602 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType31.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that target type of a cast is propagated through parenthesized expressions + * @compile TargetType31.java + */ + +class TargetType31 { + + interface SAM { + void m(int x); + } + + void m(SAM s) { } + + void testAssignmentContext() { + SAM s1 = (SAM)(x-> { System.out.println("Hello!"); }); + SAM s2 = (SAM)((x-> { System.out.println("Hello!"); })); + SAM s3 = (SAM)(((x-> { System.out.println("Hello!"); }))); + } + + void testMethodContext() { + m((SAM)(x-> { System.out.println("Hello!"); })); + m((SAM)((x-> { System.out.println("Hello!"); }))); + m((SAM)(((x-> { System.out.println("Hello!"); })))); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType32.java b/langtools/test/tools/javac/lambda/TargetType32.java new file mode 100644 index 00000000000..d9b20b7a6eb --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType32.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * target-typing and conditional operator + */ + +public class TargetType32 { + + interface A { + X m(); + } + + interface B extends A {} + + void m(A a) { } + void m(B b) { } + + void m2(A a) { } + void m2(B b) { } + + void m3(A a) { } + void m3(B b) { } + + void m4(A a) { } + void m4(B b) { } + + int intRes() { return 42; } + + void testLambda(boolean flag) { + A c = flag ? (() -> 23) : (() -> 42); + m(flag ? (() -> 23) : (() -> 42)); + m2(flag ? (() -> 23) : (() -> 23)); + } + + void testMethodRef(boolean flag) { + A c = flag ? this::intRes : this::intRes; + m(flag ? this::intRes : this::intRes); + m2(flag ? this::intRes : this::intRes); + } + + void testConstrRef(boolean flag) { + A c = flag ? TargetType32::new : TargetType32::new; + m3(flag ? TargetType32::new : TargetType32::new); + m4(flag ? TargetType32::new : TargetType32::new); + } + + public static void main(String[] args) { + TargetType32 test = new TargetType32(); + test.testLambda(true); + test.testMethodRef(true); + test.testConstrRef(true); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType33.java b/langtools/test/tools/javac/lambda/TargetType33.java new file mode 100644 index 00000000000..567aec480fd --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType33.java @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * crash when incompatible method reference is found in conditional expression + * @compile/fail/ref=TargetType33.out -XDrawDiagnostics TargetType33.java + */ + +class TargetType33 { + + interface A { + X m(); + } + + void m(A a) { } + void m2(A a) { } + + int intRes(Object o) { return 42; } + + void testMethodRef(boolean flag) { + A c = flag ? this::intRes : this::intRes; + m(flag ? this::intRes : this::intRes); + m2(flag ? this::intRes : this::intRes); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType33.out b/langtools/test/tools/javac/lambda/TargetType33.out new file mode 100644 index 00000000000..9a090de2df5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType33.out @@ -0,0 +1,5 @@ +TargetType33.java:21:31: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch)))) +TargetType33.java:21:46: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch)))) +TargetType33.java:22:9: compiler.err.cant.apply.symbol: kindname.method, m, TargetType33.A, @509, kindname.class, TargetType33, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch))))) +TargetType33.java:23:9: compiler.err.cant.apply.symbol: kindname.method, m2, TargetType33.A, @557, kindname.class, TargetType33, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch))))) +4 errors diff --git a/langtools/test/tools/javac/lambda/TargetType34.java b/langtools/test/tools/javac/lambda/TargetType34.java new file mode 100644 index 00000000000..f361f93025a --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType34.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * spurious resolution diagnostics when diamond constructor contains poly expression + * @compile -XDcomplexinference TargetType34.java + */ + +class TargetType34 { + + TargetType34(X x) {} + + Object next; + + void test() { + new TargetType34<>(next==null ? null : null); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType35.java b/langtools/test/tools/javac/lambda/TargetType35.java new file mode 100644 index 00000000000..facb7bddda7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType35.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * missing erasure on intersection supertype of generated lambda class + */ +public class TargetType35 { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + interface A {} + + interface B {} + + static class C implements A, B {} + + static class D implements A, B {} + + interface SAM { + Y invoke(X arg); + } + + static class Sup { + Z m(Z z) { return z; } + } + + static class Sub extends Sup { + Z m(Z z) { return z; } + + void test(C c, D d) { + choose(c, d, x->x); + choose(c, d, this::m); + choose(c, d, super::m); + } + + void choose(T t1, T t2, SAM t3) { + assertTrue(true); + } + } + + public static void main(String[] args) + { + new Sub().test(null, null); + assertTrue(assertionCount == 3); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType36.java b/langtools/test/tools/javac/lambda/TargetType36.java new file mode 100644 index 00000000000..54feffc50c6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType36.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @ignore + * @bug 8003280 + * @summary Add lambda tests + * check that target type of cast is propagated to conditional subexpressions + * @compile TargetType36.java + */ +class TargetType36 { //awaits spec wording on cast vs. poly + + interface SAM { + int m(int i, int j); + } + + void test() { + SAM s1 = (SAM)((a,b)->a+b); + SAM s2 = (SAM)(true? (SAM)((a,b)->a+b) : (SAM)((a,b)->a+b)); + SAM s3 = (SAM)(true? (a,b)->a+b : (a,b)->a+b); + } +} diff --git a/langtools/test/tools/javac/diags/examples/CantAccessThrownTypesInFunctionalDesc.java b/langtools/test/tools/javac/lambda/TargetType37.java similarity index 77% rename from langtools/test/tools/javac/diags/examples/CantAccessThrownTypesInFunctionalDesc.java rename to langtools/test/tools/javac/lambda/TargetType37.java index e8ad7932cd3..235da3388be 100644 --- a/langtools/test/tools/javac/diags/examples/CantAccessThrownTypesInFunctionalDesc.java +++ b/langtools/test/tools/javac/lambda/TargetType37.java @@ -21,14 +21,18 @@ * questions. */ -// key: compiler.err.cant.access.thrown.in.functional.desc -// options: -XDallowLambda +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that cast conversion context is propagated to conditional subexpressions + * @compile TargetType37.java + */ +class TargetType37 { -interface SAM_InaccessibleThrown { - void m() throws Foo.Bar; - static class Foo { private class Bar extends Exception { } } -} + interface I { } -class CantAccessThrownTypesInFunctionalDesc { - SAM_InaccessibleThrown s = ()-> { }; + void test(Object o, boolean cond) { + I i = (I)(cond ? o : o); + } } diff --git a/langtools/test/tools/javac/lambda/TargetType38.java b/langtools/test/tools/javac/lambda/TargetType38.java new file mode 100644 index 00000000000..e6ec4d1b381 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType38.java @@ -0,0 +1,22 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that cast conversion context does not affect compatibility of lambda + * @compile/fail/ref=TargetType38.out -XDrawDiagnostics TargetType38.java + */ +class TargetType38 { + + interface I { } + + interface SAM { + I m(); + } + + static Object m() { return null; } + + void test() { + Object o1 = (SAM)()->new Object(); + Object o2 = (SAM)TargetType38::m; + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType38.out b/langtools/test/tools/javac/lambda/TargetType38.out new file mode 100644 index 00000000000..df741eb6681 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType38.out @@ -0,0 +1,3 @@ +TargetType38.java:19:30: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I)) +TargetType38.java:20:26: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I)) +2 errors diff --git a/langtools/test/tools/javac/lambda/TargetType39.java b/langtools/test/tools/javac/lambda/TargetType39.java new file mode 100644 index 00000000000..bcca0271d35 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType39.java @@ -0,0 +1,22 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that type-checking fails because of recursive analysis of stuck expressions + * @compile/fail/ref=TargetType39.out -XDrawDiagnostics TargetType39.java + */ +class TargetType39 { + + interface I { } + + interface SAM { + R m(A a); + } + + void call(SAM s) { } + + void test(boolean cond, SAM ssv) { + call(cond ? x-> null : ssv); + call((String s)-> cond ? x-> null : ssv); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType39.out b/langtools/test/tools/javac/lambda/TargetType39.out new file mode 100644 index 00000000000..c4eb33ef2d5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType39.out @@ -0,0 +1,3 @@ +TargetType39.java:19:9: compiler.err.cant.apply.symbol: kindname.method, call, TargetType39.SAM, @442, kindname.class, TargetType39, (compiler.misc.cyclic.inference: U) +TargetType39.java:20:9: compiler.err.cant.apply.symbol: kindname.method, call, TargetType39.SAM, @479, kindname.class, TargetType39, (compiler.misc.cyclic.inference: V) +2 errors diff --git a/langtools/test/tools/javac/lambda/TargetType40.java b/langtools/test/tools/javac/lambda/TargetType40.java new file mode 100644 index 00000000000..831c0591975 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType40.java @@ -0,0 +1,18 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * compiler silently crashes when void method is passed as argument in overloaded call site + * @compile/fail/ref=TargetType40.out -XDrawDiagnostics TargetType40.java + */ + +class TargetType40 { + void m(String s) { } + void m(Integer i) { } + + void void_method() {} + + void test() { + m(void_method()); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType40.out b/langtools/test/tools/javac/lambda/TargetType40.out new file mode 100644 index 00000000000..c01b3d12eb3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType40.out @@ -0,0 +1,2 @@ +TargetType40.java:16:21: compiler.err.void.not.allowed.here +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType41.java b/langtools/test/tools/javac/lambda/TargetType41.java new file mode 100644 index 00000000000..d48f3690ecd --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType41.java @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * out-of-order method checking should check as many arguments as possible + * @compile/fail/ref=TargetType41.out -XDrawDiagnostics TargetType41.java + */ + +class TargetType41 { + void m(String s, java.util.List lx) { } + + void test() { + m(1, new java.util.ArrayList<>()); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType41.out b/langtools/test/tools/javac/lambda/TargetType41.out new file mode 100644 index 00000000000..87d99ad4dc5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType41.out @@ -0,0 +1,2 @@ +TargetType41.java:13:9: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.String,java.util.List, int,java.util.ArrayList, kindname.class, TargetType41, (compiler.misc.infer.no.conforming.assignment.exists: X, (compiler.misc.inconvertible.types: int, java.lang.String)) +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType42.java b/langtools/test/tools/javac/lambda/TargetType42.java new file mode 100644 index 00000000000..a476134bf88 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType42.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * effects of speculative attribution are undone on a per-argument basis rather than on a per-resolution basis + * @compile TargetType42.java + */ +class TargetType42 { + + interface SAM { + Y f(X x); + } + + void m(SAM> s, Z z) { } + + void test(Object obj) { + m((x)->{ class Foo { }; return (x2)-> { new Foo(); return null; }; }, obj); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType43.java b/langtools/test/tools/javac/lambda/TargetType43.java new file mode 100644 index 00000000000..9b9876b2105 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType43.java @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * recovery attribution step for unchecked arguments + * @compile/fail/ref=TargetType43.out -XDrawDiagnostics TargetType43.java + */ +class TargetType43 { + + void m(Object o) { } + + void test(Object obj) { + Object o = x-> { new NonExistentClass(x); return 5; }; + m(x-> { new NonExistentClass(x); return 5; }); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType43.out b/langtools/test/tools/javac/lambda/TargetType43.out new file mode 100644 index 00000000000..b7b8766c516 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType43.out @@ -0,0 +1,5 @@ +TargetType43.java:13:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +TargetType43.java:13:30: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null) +TargetType43.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Object, @359, kindname.class, TargetType43, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf)) +TargetType43.java:14:21: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null) +4 errors diff --git a/langtools/test/tools/javac/lambda/TargetType44.java b/langtools/test/tools/javac/lambda/TargetType44.java new file mode 100644 index 00000000000..d36f0c3ce58 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType44.java @@ -0,0 +1,27 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * compiler throw AssertionError while backtracing from speculative attribution round + * @compile/fail/ref=TargetType44.out -XDrawDiagnostics TargetType44.java + */ +class TargetType44 { + + interface Unary { + void m(int i1); + } + + interface Binary { + void m(int i1, int i2); + } + + void m(Unary u) { } + void m(Binary u) { } + + void test() { + m(()-> { new Object() { }; }); //fail + m(x -> { new Object() { }; }); //ok + m((x, y) -> { new Object() { }; }); //ok + m((x, y, z) -> { new Object() { }; }); //fail + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType44.out b/langtools/test/tools/javac/lambda/TargetType44.out new file mode 100644 index 00000000000..43e01a080d4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType44.out @@ -0,0 +1,3 @@ +TargetType44.java:22:9: compiler.err.cant.apply.symbols: kindname.method, m, @458,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)))} +TargetType44.java:25:9: compiler.err.cant.apply.symbols: kindname.method, m, @597,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)))} +2 errors diff --git a/langtools/test/tools/javac/lambda/TargetType45.java b/langtools/test/tools/javac/lambda/TargetType45.java new file mode 100644 index 00000000000..be38d176473 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType45.java @@ -0,0 +1,29 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * compiler crashes during flow analysis as it fails to report diagnostics during attribution + * @compile/fail/ref=TargetType45.out -XDrawDiagnostics TargetType45.java + */ +class TargetType45 { + + interface Predicate { + boolean apply(X x); + } + + interface Mapper { + Y apply(X x); + } + + class Foo { + Foo filter(Predicate p) { return null; } + } + + static Predicate compose(Predicate pi, Mapper m) { return null; } + + static Predicate isOdd = i -> i % 2 != 0; + + void top10Counties(Foo foos) { + foos.filter(compose(isOdd, (String e) -> e.length())); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType45.out b/langtools/test/tools/javac/lambda/TargetType45.out new file mode 100644 index 00000000000..062dd71710d --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType45.out @@ -0,0 +1,2 @@ +TargetType45.java:27:28: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U,V, (compiler.misc.inconvertible.types: TargetType45.Mapper, TargetType45.Mapper)) +1 error diff --git a/langtools/test/tools/javac/lambda/TargetType46.java b/langtools/test/tools/javac/lambda/TargetType46.java new file mode 100644 index 00000000000..da371231427 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType46.java @@ -0,0 +1,29 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * compiler doesn't report accessibility problem due to inaccessible target + * @compile/fail/ref=TargetType46.out -XDrawDiagnostics TargetType46.java + */ +import java.util.*; + +class TargetType46Outer { + + private interface PI { + void m(); + } + + void m(PI p) { } + void m(List p) { } +} + +class TargetType46 { + void test(TargetType46Outer outer) { + outer.m(()->{}); //access error + outer.m(this::g); //access error + outer.m(new ArrayList<>()); //ok + outer.m(Collections.emptyList()); //ok + } + + void g() { } +} diff --git a/langtools/test/tools/javac/lambda/TargetType46.out b/langtools/test/tools/javac/lambda/TargetType46.out new file mode 100644 index 00000000000..ac3a1254589 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType46.out @@ -0,0 +1,3 @@ +TargetType46.java:22:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer +TargetType46.java:23:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer +2 errors diff --git a/langtools/test/tools/javac/lambda/TargetType47.java b/langtools/test/tools/javac/lambda/TargetType47.java new file mode 100644 index 00000000000..920e44b7115 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType47.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * spurious functional interface conversion errors with default methods in target type + * @compile TargetType47.java + */ + +class TargetType47 { + interface A { + void a(); + void b(); + default void c() { }; + } + + interface B extends A { + default void b() { }; + } + + B b = ()-> {}; +} diff --git a/langtools/test/tools/javac/lambda/TargetType48.java b/langtools/test/tools/javac/lambda/TargetType48.java new file mode 100644 index 00000000000..675737e252e --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType48.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * spurious functional interface conversion errors with default methods in target type + * @compile TargetType48.java + */ + +class TargetType48 { + interface I1 { + void a(); + void b(); + void c(); + } + + interface I2 extends I1 { + default void a() { } + } + + interface I3 extends I2 { + default void b() { } + } + + I3 i3 = ()->{ }; +} diff --git a/langtools/test/tools/javac/lambda/TargetType49.java b/langtools/test/tools/javac/lambda/TargetType49.java new file mode 100644 index 00000000000..64aa7810f1d --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType49.java @@ -0,0 +1,19 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * javac accepts ill-formed lambda/method reference targets + * @compile/fail/ref=TargetType49.out -XDrawDiagnostics TargetType49.java + */ +class TargetType49 { + + interface F { + default Object clone() { return null; } + void m(); + } + + F f1 = ()->{}; + F f2 = this::g; + + void g() { } +} diff --git a/langtools/test/tools/javac/lambda/TargetType49.out b/langtools/test/tools/javac/lambda/TargetType49.out new file mode 100644 index 00000000000..df13b275baf --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType49.out @@ -0,0 +1,3 @@ +TargetType49.java:15:12: compiler.err.override.weaker.access: (compiler.misc.cant.implement: clone(), java.lang.Object, clone(), TargetType49.F), public +TargetType49.java:16:12: compiler.err.override.weaker.access: (compiler.misc.cant.implement: clone(), java.lang.Object, clone(), TargetType49.F), public +2 errors diff --git a/langtools/test/tools/javac/lambda/TargetType50.java b/langtools/test/tools/javac/lambda/TargetType50.java new file mode 100644 index 00000000000..ab9d3a43a3a --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType50.java @@ -0,0 +1,28 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * bad stuck check for method reference leads to javac crash + * @compile/fail/ref=TargetType50.out -XDrawDiagnostics TargetType50.java + */ +import java.util.*; + +class TargetType50 { + + interface Factory { + F make(); + } + + static class Sink { + static Sink make() { return null; } + } + + > List m(Factory factory) { } + + void test() { + List l1 = m(Sink::new); + List l2 = m(Sink::make); + List l3 = m(Sink::new); + List l4 = m(Sink::make); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType50.out b/langtools/test/tools/javac/lambda/TargetType50.out new file mode 100644 index 00000000000..14ec13ba3e4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType50.out @@ -0,0 +1,3 @@ +TargetType50.java:25:28: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object) +TargetType50.java:26:28: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object) +2 errors diff --git a/langtools/test/tools/javac/lambda/TestInvokeDynamic.java b/langtools/test/tools/javac/lambda/TestInvokeDynamic.java index d74adefbce7..155bfdf0cce 100644 --- a/langtools/test/tools/javac/lambda/TestInvokeDynamic.java +++ b/langtools/test/tools/javac/lambda/TestInvokeDynamic.java @@ -25,7 +25,9 @@ * @test * @bug 7194586 * - * @summary Add back-end support for invokedynamic + * @bug 8003280 + * @summary Add lambda tests + * Add back-end support for invokedynamic * */ diff --git a/langtools/test/tools/javac/lambda/TestSelfRef.java b/langtools/test/tools/javac/lambda/TestSelfRef.java new file mode 100644 index 00000000000..967673e9fc2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TestSelfRef.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * Check that self/forward references from lambda expressions behave + * consistently w.r.t. local inner classes + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +public class TestSelfRef { + + static int checkCount = 0; + + enum RefKind { + SELF_LAMBDA("SAM s = x->{ System.out.println(s); };", true, false), + FORWARD_LAMBDA("SAM s = x->{ System.out.println(f); };\nObject f = null;", false, true), + SELF_ANON("Object s = new Object() { void test() { System.out.println(s); } };", true, false), + FORWARD_ANON("Object s = new Object() { void test() { System.out.println(f); } }; Object f = null;", false, true); + + String refStr; + boolean selfRef; + boolean forwardRef; + + private RefKind(String refStr, boolean selfRef, boolean forwardRef) { + this.refStr = refStr; + this.selfRef = selfRef; + this.forwardRef = forwardRef; + } + } + + enum EnclosingKind { + TOPLEVEL("class C { #S }"), + MEMBER_INNER("class Outer { class C { #S } }"), + NESTED_INNER("class Outer { static class C { #S } }"); + + String enclStr; + + private EnclosingKind(String enclStr) { + this.enclStr = enclStr; + } + } + + enum InnerKind { + NONE("#R"), + LOCAL_NONE("class Local { #R }"), + LOCAL_MTH("class Local { void test() { #R } }"), + ANON_NONE("new Object() { #R };"), + ANON_MTH("new Object() { void test() { #R } };"); + + String innerStr; + + private InnerKind(String innerStr) { + this.innerStr = innerStr; + } + + boolean inMethodContext(SiteKind sk) { + switch (this) { + case LOCAL_MTH: + case ANON_MTH: return true; + case NONE: return sk != SiteKind.NONE; + default: + return false; + } + } + } + + enum SiteKind { + NONE("#I"), + STATIC_INIT("static { #I }"), + INSTANCE_INIT("{ #I }"), + CONSTRUCTOR("C() { #I }"), + METHOD("void test() { #I }"); + + String siteStr; + + private SiteKind(String siteStr) { + this.siteStr = siteStr; + } + } + + public static void main(String... args) throws Exception { + + //create default shared JavaCompiler - reused across multiple compilations + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + for (EnclosingKind ek : EnclosingKind.values()) { + for (SiteKind sk : SiteKind.values()) { + if (sk == SiteKind.STATIC_INIT && ek == EnclosingKind.MEMBER_INNER) + continue; + for (InnerKind ik : InnerKind.values()) { + if (ik != InnerKind.NONE && sk == SiteKind.NONE) + break; + for (RefKind rk : RefKind.values()) { + new TestSelfRef(ek, sk, ik, rk).run(comp, fm); + } + } + } + } + System.out.println("Total check executed: " + checkCount); + } + + EnclosingKind ek; + SiteKind sk; + InnerKind ik; + RefKind rk; + JavaSource source; + DiagnosticChecker diagChecker; + + TestSelfRef(EnclosingKind ek, SiteKind sk, InnerKind ik, RefKind rk) { + this.ek = ek; + this.sk = sk; + this.ik = ik; + this.rk = rk; + this.source = new JavaSource(); + this.diagChecker = new DiagnosticChecker(); + } + + class JavaSource extends SimpleJavaFileObject { + + String bodyTemplate = "interface SAM { void test(Object o); }\n#B"; + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = bodyTemplate.replace("#B", + ek.enclStr.replace("#S", sk.siteStr.replace("#I", ik.innerStr.replace("#R", rk.refStr)))); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, + null, null, Arrays.asList(source)); + try { + ct.analyze(); + } catch (Throwable ex) { + throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true)); + } + check(); + } + + void check() { + //illegal forward ref + boolean errorExpected = ik.inMethodContext(sk) && + (rk.selfRef || rk.forwardRef); + if (diagChecker.errorFound != errorExpected) { + throw new Error("invalid diagnostics for source:\n" + + source.getCharContent(true) + + "\nFound error: " + diagChecker.errorFound + + "\nExpected error: " + errorExpected); + } + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } +} diff --git a/langtools/test/tools/javac/lambda/VoidCompatibility.java b/langtools/test/tools/javac/lambda/VoidCompatibility.java new file mode 100644 index 00000000000..90205da7f79 --- /dev/null +++ b/langtools/test/tools/javac/lambda/VoidCompatibility.java @@ -0,0 +1,26 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * check that that void compatibility affects overloading as expected + * @compile/fail/ref=VoidCompatibility.out -XDrawDiagnostics VoidCompatibility.java + */ +class VoidCompatibility { + + interface Runnable { void run(); } //1 + interface Thunk { T get(); } //2 + + void schedule(Runnable r) { } + void schedule(Thunk t) { } + + void test() { + schedule(() -> System.setProperty("done", "true")); //2 + schedule(() -> { System.setProperty("done", "true"); }); //1 + schedule(() -> { return System.setProperty("done", "true"); }); //2 + schedule(() -> System.out.println("done")); //1 + schedule(() -> { System.out.println("done"); }); //1 + schedule(Thread::yield); //1 + schedule(Thread::getAllStackTraces); //ambiguous + schedule(Thread::interrupted); //1 (most specific) + } +} diff --git a/langtools/test/tools/javac/lambda/VoidCompatibility.out b/langtools/test/tools/javac/lambda/VoidCompatibility.out new file mode 100644 index 00000000000..7686554c58e --- /dev/null +++ b/langtools/test/tools/javac/lambda/VoidCompatibility.out @@ -0,0 +1,2 @@ +VoidCompatibility.java:23:9: compiler.err.ref.ambiguous: schedule, kindname.method, schedule(VoidCompatibility.Runnable), VoidCompatibility, kindname.method, schedule(VoidCompatibility.Thunk), VoidCompatibility +1 error diff --git a/langtools/test/tools/javac/lambda/abort/Abort.java b/langtools/test/tools/javac/lambda/abort/Abort.java new file mode 100644 index 00000000000..9a7638ea063 --- /dev/null +++ b/langtools/test/tools/javac/lambda/abort/Abort.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that all diagnostics are dumped to output when compiler exits abruptly + */ + +import com.sun.source.util.JavacTask; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.StringWriter; +import java.net.URI; +import java.net.URL; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +public class Abort { + + public static void main(String... args) throws Exception { + + String SCRATCH_DIR = System.getProperty("user.dir"); + JavaCompiler javacTool = ToolProvider.getSystemJavaCompiler(); + java.io.File testDir = new java.io.File(SCRATCH_DIR); + + sourceA.dumpTo(testDir); + sourceB.dumpTo(testDir); + + DiagnosticChecker diagChecker = new DiagnosticChecker(); + JavacTask ct = (JavacTask)javacTool.getTask(null, null, diagChecker, + Arrays.asList("-XDrawDiagnostics", "-cp", testDir.getAbsolutePath()), + null, Arrays.asList(sourceA.asJFO(testDir))); + try { + ct.analyze(); + } catch (Throwable ex) { + //ignore abort exception thrown by javac + } + + if (!diagChecker.errorFound) { + throw new AssertionError("Missing diagnostic"); + } + } + + static class JavaSource { + String contents; + String filename; + + public JavaSource(String filename, String contents) { + this.filename = filename; + this.contents = contents; + } + + void dumpTo(java.io.File loc) throws Exception { + java.io.File file = new java.io.File(loc, filename); + java.io.BufferedWriter bw = new java.io.BufferedWriter(new java.io.FileWriter(file)); + bw.append(contents); + bw.close(); + } + + SimpleJavaFileObject asJFO(java.io.File dir) { + return new SimpleJavaFileObject(URI.create(dir.getAbsolutePath() + "/" + filename), JavaFileObject.Kind.SOURCE) { + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return contents; + } + }; + } + } + + static JavaSource sourceA = new JavaSource("Abort.java", "public class Abort {\n" + + " public static void main(String[] args) {\n" + + " System.out.println(C.m());\n" + + " }\n" + + "}"); + + static JavaSource sourceB = new JavaSource("C.java", "package com.example;\n" + + "public class C {\n" + + " public static String m() { return null; }\n" + + "}"); + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR && + diagnostic.getCode().contains("compiler.err.cant.access")) { + errorFound = true; + } + } + } +} diff --git a/langtools/test/tools/javac/lambda/badMemberRefBytecode/Main.java b/langtools/test/tools/javac/lambda/badMemberRefBytecode/Main.java new file mode 100644 index 00000000000..4c834cf3741 --- /dev/null +++ b/langtools/test/tools/javac/lambda/badMemberRefBytecode/Main.java @@ -0,0 +1,9 @@ +import java.util.Collections; + +public class Main { + + public static void main(String[] args) { + Collections.sort(null, String::compareTo); + } + +} diff --git a/langtools/test/tools/javac/lambda/badMemberRefBytecode/TestBadMemberRefBytecode.java b/langtools/test/tools/javac/lambda/badMemberRefBytecode/TestBadMemberRefBytecode.java new file mode 100644 index 00000000000..b3149988e6b --- /dev/null +++ b/langtools/test/tools/javac/lambda/badMemberRefBytecode/TestBadMemberRefBytecode.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * check that classfiles with member ref CP entries are read correctly + * @author Jan Lahoda + * @compile Main.java + * @compile Use.java + */ diff --git a/langtools/test/tools/javac/lambda/badMemberRefBytecode/Use.java b/langtools/test/tools/javac/lambda/badMemberRefBytecode/Use.java new file mode 100644 index 00000000000..bb5a77a06ef --- /dev/null +++ b/langtools/test/tools/javac/lambda/badMemberRefBytecode/Use.java @@ -0,0 +1,3 @@ +public class Use { + private Main m; +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/Helper.java b/langtools/test/tools/javac/lambda/funcInterfaces/Helper.java new file mode 100644 index 00000000000..ebc0f519ad8 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/Helper.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/*SAM types: + 1. An interface that has a single abstract method + 2. Having more than one distinct methods, but only one is "real", the others are overriden public methods in Object - example: Comparator + 3. Having more than one methods due to inheritance, but they have the same signature + 4. Having more than one methods due to inheritance, but one of them has a subsignature of all other methods + a) parameter types compatible + b) return type substitutable + c) thrown type not conflicting with the thrown clause of any other method + d) mixed up + 5. Type-dependent SAM types + non-SAM types: + 6. An interface that has a single abstract method, which is also public method in Object + 7. Having more than one methods due to inheritance, and none of them has a subsignature of all other methods +*/ + +import java.util.List; +import java.util.Collection; +import java.sql.SQLException; +import java.sql.SQLTransientException; +import java.util.concurrent.TimeoutException; +import java.io.*; + +interface A {int getOldest(List list);} +interface B {int getOldest(List list);} +interface C {int getOldest(List list);} +interface D {int getOldest(List list);} +interface E {int getOldest(Collection collection);} +//Not SAM type, case #7 +interface DE extends D, E {} + +interface Foo {int getAge(Number n);} +interface Bar {int getAge(Integer i);} +//Not SAM type, case #7 +interface FooBar extends Foo, Bar {} + +//Not SAM type, case #6 +interface Planet {boolean equals(Object o);} + +// SAM type interfaces: +// type #2: +//only one abstract non-Ojbect method getAge() +interface Mars extends Planet {int getAge(T t);} +//only one abstract non-Ojbect method increment() +interface Jupiter { + boolean equals(Object o); + String toString(); + int increment(int i); +} + +// type #3: +interface X {int getTotal(List arg);} +interface Y {int getTotal(List strs);} +//SAM type ([List], int, {}) +interface XY extends X, Y {} +//SAM type ([List], int, {}) +interface XYZ extends X, Y, XY {} + +// type #4 a): +//SAM type ([List], int, {}) +interface AB extends A, B {} + +// type #4 b): +interface F {Number getValue(String str);} +interface G {Integer getValue(String str);} +interface H {Serializable getValue(String str);} +interface I {Object getValue(String str);} +//SAM type ([String], Integer, {}) +interface FGHI extends F, G, H, I {} + +interface J {List getAll(String str);} +interface K {List getAll(String str);} +interface L {List getAll(String str);} +interface M {Collection getAll(String str);} +//SAM type ([String], List/List, {}) - the return type is flexible to some degree +interface JK extends J, K {} +//SAM type ([String], List/List, {}) +interface JL extends J, L {} +//SAM type ([String], List/List, {}) +interface JKL extends J, K, L {} +//SAM type ([String], List/List, {}) +interface JKLM extends J, K, L, M {} + +// type #4 c): +interface N {String getText(File f) throws IOException;} +interface O {String getText(File f) throws FileNotFoundException;} +interface P {String getText(File f) throws NullPointerException;} +//SAM type ([File], String, {FileNotFoundException}) +interface NO extends N, O {} +//SAM type ([File], String, {}) +interface NOP extends N, O, P {} + +interface Boo {int getAge(String s) throws IOException;} +interface Doo {int getAge(String s) throws SQLException;} +//SAM type ([String], int, {}) +interface BooDoo extends Boo, Doo {} + +// type #4 d): +interface Q {Iterable m(Iterable arg);} +interface R {Iterable m(Iterable arg);} +//SAM type ([Iterable], Iterable/Iterable, {}) +interface QR extends Q, R {} + +interface U {Collection foo(List arg) throws IOException, SQLTransientException;} +interface V {List foo(List arg) throws EOFException, SQLException, TimeoutException;} +interface W {List foo(List arg) throws Exception;} +//SAM type ([List], List/List, {EOFException, SQLTransientException}) +interface UV extends U, V {} +// SAM type ([List], List/List, {EOFException, SQLTransientException}) +interface UVW extends U, V, W {} + +// type #5: +// Not a SAM because sam-ness depends on instantiation of type-variables +interface Qoo {void m(T arg);} +interface Roo {void m(S arg);} +interface QooRoo extends Qoo, Roo {} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1.java b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1.java new file mode 100644 index 00000000000..022c94c8c21 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * This test is for lambda expressions + * @compile LambdaTest1.java + * @run main LambdaTest1 + */ + +import java.util.Collections; +import java.util.List; +import java.util.ArrayList; + +public class LambdaTest1 { + public static void main(String[] args) { + + LambdaTest1 test = new LambdaTest1(); + + test.method2((int n) -> { }); + test.method2((int n) -> { }); + test.method2((int n) -> { return; }); // ";" is mandatory here + test.method2((int n) -> { System.out.println(n); }); // ";" is optional here + test.method2(n -> { System.out.println(n); }); //warning, explict type required for n? + + test.method3(()-> { System.out.println("implementing VoidVoid.vvMethod()"); }); + test.method3(() -> {}); + + test.method4(()-> 42); + test.method4(()-> { return 42; });//";" is mandatory here + + test.method5((int n)-> n+1); + test.method5((int n) -> 42); + test.method5((int n) -> { return 42; }); + test.method5( + (int n) -> { //"{" optional here + if(n > 0) + return n++; + else + return n--; + } + ); + + Runnable r = ()-> { System.out.println("Runnable.run() method implemented"); }; + r.run(); + ((Runnable)()-> { System.out.println("Runnable.run() method implemented"); }).run(); + } + + void method2(VoidInt a) { + System.out.println("method2()"); + final int N = 1; + int n = 2; //effectively final variable + System.out.println("method2() \"this\":" + this); + ((Runnable) + ()->{ + System.out.println("inside lambda \"this\":" + this); + System.out.println("inside lambda accessing final variable N:" + N); + System.out.println("inside lambda accessing effectively final variable n:" + n); + } + ).run(); + //n++; //compile error if n is modified + a.viMethod(2); + } + + void method3(VoidVoid a) { + System.out.println("method3()"); + a.vvMethod(); + } + + void method4(IntVoid a) { + System.out.println("method4()"); + System.out.println(a.ivMethod()); + } + + void method5(IntInt a) { + System.out.println("method5()"); + System.out.println(a.iiMethod(5)); + } + + + //SAM type interfaces + interface VoidInt { + void viMethod(int n); + } + + interface VoidVoid { + void vvMethod(); + } + + interface IntVoid { + int ivMethod(); + } + + interface IntInt { + int iiMethod(int n); + } +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.java b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.java new file mode 100644 index 00000000000..90226c0dd88 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.java @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * This test is to verify invalid lambda expressions + * @compile/fail/ref=LambdaTest1_neg1.out -XDrawDiagnostics LambdaTest1_neg1.java + */ + +import java.util.Comparator; + +public class LambdaTest1_neg1 { + void method() { + Comparator c = (Number n1, Number n2) -> { 42; } //compile error, not a statement + } +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.out b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.out new file mode 100644 index 00000000000..2ea34b7e750 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.out @@ -0,0 +1,3 @@ +LambdaTest1_neg1.java:13:60: compiler.err.not.stmt +LambdaTest1_neg1.java:13:65: compiler.err.expected: ';' +2 errors diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.java b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.java new file mode 100644 index 00000000000..62e452d717e --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.java @@ -0,0 +1,17 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * This test is to verify mis-use of accessing "this" from within lambda expression + * @compile/fail/ref=LambdaTest1_neg2.out -XDrawDiagnostics LambdaTest1_neg2.java + */ + +public class LambdaTest1_neg2 { + static void method() { + ((Runnable) + ()-> { + Object o = this; //use "this" inside lambda expression which is inside a static method, not allowed + } + ).run(); + } +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.out b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.out new file mode 100644 index 00000000000..55ebd7f2e80 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.out @@ -0,0 +1,2 @@ +LambdaTest1_neg2.java:13:28: compiler.err.non-static.cant.be.ref: kindname.variable, this +1 error diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.java b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.java new file mode 100644 index 00000000000..338a31000c4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.java @@ -0,0 +1,19 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * This test is to verify mis-use of capturing local variable within lambda expression + * @compile/fail/ref=LambdaTest1_neg3.out -XDrawDiagnostics LambdaTest1_neg3.java + */ + +public class LambdaTest1_neg3 { + void method() { + int n = 2; //effectively final variable + ((Runnable) + ()-> { + int n2 = n; //inside lambda accessing effectively final variable; + } + ).run(); + n++; //compile error if n is modified + } +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.out b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.out new file mode 100644 index 00000000000..b93fb0426c0 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.out @@ -0,0 +1,2 @@ +LambdaTest1_neg3.java:14:26: compiler.err.cant.ref.non.effectively.final.var: n, (compiler.misc.lambda) +1 error diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM1.java b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM1.java new file mode 100644 index 00000000000..050ae2a1e7f --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM1.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * This test is for identifying SAM types 2 and 3, see Helper.java for SAM types + * @compile LambdaTest2_SAM1.java Helper.java + * @run main LambdaTest2_SAM1 + */ + +import java.util.Collections; +import java.util.List; +import java.util.ArrayList; +import java.io.*; + +public class LambdaTest2_SAM1 { + private static List strs = new ArrayList(); + private static List files = new ArrayList(); + + public static void main(String[] args) { + strs.add("copy"); + strs.add("paste"); + strs.add("delete"); + strs.add("rename"); + + files.add(new File("a.txt")); + files.add(new File("c.txt")); + files.add(new File("b.txt")); + + //type #2: Comparator + Collections.sort(files, (File f1, File f2) -> f1.getName().compareTo(f2.getName())); + for(File f : files) + System.out.println(f.getName()); + System.out.println(); + Collections.sort(files, (File f1, File f2) -> (int)(f1.length() - f2.length())); + for(File f : files) + System.out.println(f.getName() + " " + f.length()); + System.out.println(); + + LambdaTest2_SAM1 test = new LambdaTest2_SAM1(); + + //type #2: + test.methodMars((File f) -> { + System.out.println("implementing Mars.getAge(File f)..."); + return (int)f.length(); + }); + test.methodJupiter((int n) -> n+1); + + //type #3: + test.methodXY((List strList) -> strList.size() ); + test.methodXYZ((List strList) -> 20 ); + } + + //type #2: + void methodMars(Mars m) { + System.out.println("methodMars(): SAM type interface Mars object instantiated: " + m); + System.out.println(m.getAge(new File("a.txt"))); + } + + //type #2: + void methodJupiter(Jupiter j) { + System.out.println("methodJupiter(): SAM type interface Jupiter object instantiated: " + j); + System.out.println(j.increment(33)); + } + + //type #3: + void methodXY(XY xy) { + System.out.println("methodXY(): SAM type interface XY object instantiated: " + xy); + System.out.println(xy.getTotal(strs)); + } + + //type #3: + void methodXYZ(XYZ xyz) { + System.out.println("methodXYZ(): SAM type interface XYZ object instantiated: " + xyz); + System.out.println(xyz.getTotal(strs)); + } +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM2.java b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM2.java new file mode 100644 index 00000000000..464cd4a1ca9 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM2.java @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * This test is for identifying SAM types #4, see Helper.java for SAM types + * @compile LambdaTest2_SAM2.java Helper.java + * @run main LambdaTest2_SAM2 + */ + +import java.util.Collection; +import java.util.List; +import java.util.ArrayList; +import java.util.concurrent.TimeoutException; +import java.io.*; +import java.sql.SQLException; +import java.sql.SQLTransientException; + +public class LambdaTest2_SAM2 { + private static List strs = new ArrayList(); + + public static void main(String[] args) { + strs.add("copy"); + strs.add("paste"); + strs.add("delete"); + strs.add("rename"); + + LambdaTest2_SAM2 test = new LambdaTest2_SAM2(); + + //type #4 a): + test.methodAB((List list) -> 100); + + //type #4 b): + test.methodFGHI((String s) -> new Integer(22)); + //type #4 b): + test.methodJK((String s) -> new ArrayList()); + test.methodJK((String s) -> new ArrayList()); + //type #4 b): + test.methodJL((String s) -> new ArrayList()); + test.methodJL((String s) -> new ArrayList()); + //type #4 b): + test.methodJKL((String s) -> new ArrayList()); + test.methodJKL((String s) -> new ArrayList()); + //type #4 b): + test.methodJKLM((String s) -> new ArrayList()); + test.methodJKLM((String s) -> new ArrayList()); + + // tyep #4 c): + test.methodNO((File f) -> { + String temp = null; + StringBuffer sb = new StringBuffer(); + try + { + BufferedReader br = new BufferedReader(new FileReader(f)); + while((temp=br.readLine()) != null) + sb.append(temp).append("\n"); + } + catch(FileNotFoundException fne){throw fne;} + catch(IOException e){e.printStackTrace();} + return sb.toString(); + }); + // tyep #4 c): + test.methodNOP((File f) -> { + String temp = null; + StringBuffer sb = new StringBuffer(); + try + { + BufferedReader br = new BufferedReader(new FileReader(f)); + while((temp=br.readLine()) != null) + sb.append(temp).append("\n"); + } + catch(IOException e){e.printStackTrace();} + return sb.toString(); + }); + // type #4 c): + test.methodBooDoo((String s) -> s.length()); + + //type #4 d): + test.methodQR((Iterable i) -> new ArrayList()); + test.methodQR((Iterable i) -> new ArrayList()); + //type #4 d): + test.methodUV((List list) -> { + test.exceptionMethod1(); + test.exceptionMethod2(); + return new ArrayList(); + }); + test.methodUV((List list) -> { + test.exceptionMethod1(); + test.exceptionMethod2(); + return new ArrayList(); + }); + //type #4 d): + test.methodUVW((List list) -> { + test.exceptionMethod1(); + test.exceptionMethod2(); + return new ArrayList(); + }); + test.methodUVW((List list) -> { + test.exceptionMethod1(); + test.exceptionMethod2(); + return new ArrayList(); + }); + } + + private void exceptionMethod1() throws EOFException{ + } + + private void exceptionMethod2() throws SQLTransientException{ + } + + //type #4 a): SAM type ([List], int, {}) + void methodAB (AB ab) { + System.out.println("methodAB(): SAM type interface AB object instantiated: " + ab); + System.out.println(ab.getOldest(strs)); + } + + //type #4 b): SAM type ([String], Integer, {}) + void methodFGHI(FGHI f) { + System.out.println("methodFGHI(): SAM type interface FGHI object instantiated: " + f); + System.out.println(f.getValue("str")); + } + + //type #4 b): SAM type ([String], List, {}) + void methodJK(JK jk) { + System.out.println("methodJK(): SAM type interface JK object instantiated: " + jk); + for(Number n : jk.getAll("in")) + System.out.println(n); + } + + //type #4 b): SAM type ([String], List, {}) + void methodJL(JL jl) { + System.out.println("methodJL(): SAM type interface JL object instantiated: " + jl); + for(Number n : ((J)jl).getAll("in")) //cast should be redundant - see 7062745 + System.out.println(n); + } + + //type #4 b): SAM type ([String], List, {}) + void methodJKL(JKL jkl) { //commented - see 7062745 + System.out.println("methodJKL(): SAM type interface JKL object instantiated: " + jkl); + for(Number n : ((J)jkl).getAll("in")) + System.out.println(n); + } + + //type #4 b): SAM type ([String], List, {}) + void methodJKLM(JKLM jklm) { //commented - see 7062745 + System.out.println("methodJKLM(): SAM type interface JKLM object instantiated: " + jklm); + for(Number n : ((J)jklm).getAll("in")) + System.out.println(n); + } + + //type #4 c): SAM type ([File], String, {FileNotFoundException}) + void methodNO(NO no) { + System.out.println("methodNO(): SAM type interface \"NO\" object instantiated: " + no); + try { + System.out.println("text=" + no.getText(new File("a.txt"))); + System.out.println("got here, no exception thrown"); + } + catch(FileNotFoundException e){e.printStackTrace();} + } + + //type #4 c): SAM type ([File]), String, {}) + void methodNOP(NOP nop) { + System.out.println("methodNOP(): SAM type interface \"NOP\" object instantiated: " + nop); + System.out.println("text=" + nop.getText(new File("a.txt"))); + } + + //type #4 c): SAM type ([String], int, {}) + void methodBooDoo(BooDoo bd) { + System.out.println("methodBooDoo(): SAM type interface BooDoo object instantiated: " + bd); + System.out.println("result=" + bd.getAge("lambda")); + } + + //type #4 d): SAM type ([Iterable], Iterable, {}) + void methodQR(QR qr) { + System.out.println("methodQR(): SAM type interface QR object instantiated: " + qr); + System.out.println("Iterable returned: " + qr.m(new SQLException())); + } + + //type #4 d): SAM type ([List], List/List, {EOFException, SQLTransientException}) + void methodUV(UV uv) { + System.out.println("methodUV(): SAM type interface UV object instantiated: " + uv); + try{ + System.out.println("result returned: " + uv.foo(strs)); + }catch(EOFException e){ + System.out.println(e.getMessage()); + }catch(SQLTransientException ex){ + System.out.println(ex.getMessage()); + } + } + + //type #4 d): SAM type ([List], List/List, {EOFException, SQLTransientException}) + void methodUVW(UVW uvw) { + System.out.println("methodUVW(): SAM type interface UVW object instantiated: " + uvw); + try{ + System.out.println("passing List: " + uvw.foo(strs)); + System.out.println("passing List: " + uvw.foo(new ArrayList())); + }catch(EOFException e){ + System.out.println(e.getMessage()); + }catch(SQLTransientException ex){ + System.out.println(ex.getMessage()); + } + } +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM3.java b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM3.java new file mode 100644 index 00000000000..f9b2a35f953 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM3.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * This test is for identifying SAM types #5 and instantiating non-SAM types #7 through inner class, + see Helper.java for SAM types + * @compile LambdaTest2_SAM3.java Helper.java + * @run main LambdaTest2_SAM3 + */ + +import java.util.Collection; +import java.util.List; +import java.util.ArrayList; + +public class LambdaTest2_SAM3 { + private static List strs = new ArrayList(); + private static List integers = new ArrayList(); + + public static void main(String[] args) { + LambdaTest2_SAM3 test = new LambdaTest2_SAM3(); + + //type #7, Not SAM-convertible, through inner class only: + test.methodFooBar(new FooBar() { + public int getAge(Number n) { + System.out.println("getAge(Number n) called"); + return 100; + } + public int getAge(Integer i) { + System.out.println("getAge(Integer i) called"); + return 200; + } + } + ); + + //type #7: + test.methodDE(new DE(){ + public int getOldest(List list) { + System.out.println("getOldest(List list) called"); + return 100; + } + public int getOldest(Collection collection) { + System.out.println("getOldest(Collection collection) called"); + return 200; + } + } + ); + + } + + //type #7: Not SAM type + void methodFooBar(FooBar fb) { + System.out.println("methodFooBar(): interface FooBar object instantiated: " + fb); + System.out.println("result=" + fb.getAge(new Byte("10"))); + System.out.println("result=" + fb.getAge(new Integer(10))); + } + + //type #7: Not SAM type + void methodDE (DE de) { + System.out.println("methodDE(): interface DE object instantiated: " + de); + System.out.println(de.getOldest(integers)); + System.out.println(de.getOldest(strs)); + } +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.java b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.java new file mode 100644 index 00000000000..2375733dea0 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.java @@ -0,0 +1,19 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * This test is for identifying SAM types #5 and instantiating non-SAM types #7 through inner class, + see Helper.java for SAM types + * @compile/fail/ref=LambdaTest2_neg1.out -XDrawDiagnostics LambdaTest2_neg1.java Helper.java + */ + +public class LambdaTest2_neg1 { + + public static void main(String[] args) { + LambdaTest2_neg1 test = new LambdaTest2_neg1(); + //not convertible - QooRoo is not a SAM + test.methodQooRoo((Integer i) -> { }); + } + + void methodQooRoo(QooRoo qooroo) { } +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.out b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.out new file mode 100644 index 00000000000..4780e80fec6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.out @@ -0,0 +1,2 @@ +LambdaTest2_neg1.java:15:13: compiler.err.cant.apply.symbol: kindname.method, methodQooRoo, QooRoo, @531, kindname.class, LambdaTest2_neg1, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, QooRoo))) +1 error diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.java b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.java new file mode 100644 index 00000000000..41fd7424621 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.java @@ -0,0 +1,14 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * This test is for identifying a non-SAM type 6: An interface that has a single abstract method, which is also public method in Object + * @compile/fail/ref=NonSAM1.out -XDrawDiagnostics NonSAM1.java Helper.java + */ + +public class NonSAM1 { + void method() { + Planet n = (Object o) -> true; + System.out.println("never reach here " + n); + } +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.out b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.out new file mode 100644 index 00000000000..c2472263c0a --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.out @@ -0,0 +1,2 @@ +NonSAM1.java:11:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, Planet)) +1 error diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.java b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.java new file mode 100644 index 00000000000..7bbefb64607 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * This test is for identifying a non-SAM type: Having more than one methods due to inheritance, and none of them has a subsignature of all other methods + * @compile/fail/ref=NonSAM2.out -XDrawDiagnostics NonSAM2.java Helper.java + */ + +import java.util.List; + +interface Foo1 { int getAge(String s);} +interface Bar1 { Integer getAge(String s);} +interface Foo1Bar1 extends Foo1, Bar1 {} //types Bar1 and Foo1 are incompatible; both define getAge(String), but with unrelated return types + +interface AC extends A, C {} //name clash: getOldest(List) in C and getOldest(List) in A have the same erasure, yet neither overrides the other +interface ABC extends A, B, C {} //name clash: getOldest(List) in C and getOldest(List) in A have the same erasure, yet neither overrides the other +interface AD extends A, D {} //name clash: getOldest(List) in D and getOldest(List) in A have the same erasure, yet neither overrides the other + +interface Foo2 { void m(T arg);} +interface Bar2 { void m(S arg);} +interface Foo2Bar2 extends Foo2, Bar2 {} //name clash: m(S) in Bar and m(T) in Foo have the same erasure, yet neither overrides the other diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.out b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.out new file mode 100644 index 00000000000..00da6787e4e --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.out @@ -0,0 +1,6 @@ +NonSAM2.java:13:1: compiler.err.types.incompatible.diff.ret: Bar1, Foo1, getAge(java.lang.String) +NonSAM2.java:15:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List), C, getOldest(java.util.List), A +NonSAM2.java:16:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List), C, getOldest(java.util.List), A +NonSAM2.java:17:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List), D, getOldest(java.util.List), A +NonSAM2.java:21:1: compiler.err.name.clash.same.erasure.no.override: m(S), Bar2, m(T), Foo2 +5 errors diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.java b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.java new file mode 100644 index 00000000000..bafbfb232f0 --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.java @@ -0,0 +1,24 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * This test is for identifying a non-SAM type: Having overloaded methods due to inheritance + * @compile/fail/ref=NonSAM3.out -XDrawDiagnostics NonSAM3.java Helper.java + */ + +import java.util.Collection; +import java.util.List; + +public class NonSAM3 { + void method() { + //all of the following will have compile error: "the target type of a lambda conversion has multiple non-overriding abstract methods" + FooBar fb = (Number n) -> 100; + FooBar fb2 = (Integer i) -> 100; + DE de = (List list) -> 100; + DE de2 = (List list) -> 100; + DE de3 = (List list) -> 100; + DE de4 = (Collection collection) -> 100; + DE de5 = (Collection collection) -> 100; + DE de6 = (Collection collection) -> 100; + } +} diff --git a/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.out b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.out new file mode 100644 index 00000000000..8c9ff08b5ae --- /dev/null +++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.out @@ -0,0 +1,9 @@ +NonSAM3.java:15:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, FooBar)) +NonSAM3.java:16:22: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, FooBar)) +NonSAM3.java:17:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE)) +NonSAM3.java:18:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE)) +NonSAM3.java:19:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE)) +NonSAM3.java:20:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE)) +NonSAM3.java:21:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE)) +NonSAM3.java:22:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE)) +8 errors diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.java b/langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.java new file mode 100644 index 00000000000..ac8db55ffc2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.java @@ -0,0 +1,18 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Test that lambda conversion is only for SAM interface, not abstract class + * @compile/fail/ref=AbstractClass_neg.out -XDrawDiagnostics AbstractClass_neg.java + */ + +public class AbstractClass_neg { + + abstract class SAM { + abstract int m(); + } + + void test() { + SAM s = ()-> 6; + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.out b/langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.out new file mode 100644 index 00000000000..2fc5555b1e6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.out @@ -0,0 +1,2 @@ +AbstractClass_neg.java:16:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +1 error diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.java b/langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.java new file mode 100644 index 00000000000..af4e5c9c5c7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.java @@ -0,0 +1,26 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Test accessing non-static variable from lambda expressions in static context + * @compile/fail/ref=AccessNonStatic_neg.out -XDrawDiagnostics AccessNonStatic_neg.java + */ + +public class AccessNonStatic_neg { + + private int n = 0; + + static { + ((Runnable) ()-> { + System.out.println(this); + System.out.println(n); + }).run(); + } + + public static void test() { + ((Runnable) ()-> { + Object o = this; + n++; + }).run(); + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.out b/langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.out new file mode 100644 index 00000000000..78b649a9e44 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.out @@ -0,0 +1,5 @@ +AccessNonStatic_neg.java:15:32: compiler.err.non-static.cant.be.ref: kindname.variable, this +AccessNonStatic_neg.java:16:32: compiler.err.non-static.cant.be.ref: kindname.variable, n +AccessNonStatic_neg.java:22:24: compiler.err.non-static.cant.be.ref: kindname.variable, this +AccessNonStatic_neg.java:23:13: compiler.err.non-static.cant.be.ref: kindname.variable, n +4 errors diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.java b/langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.java new file mode 100644 index 00000000000..d5f2b5293a5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.java @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Negative test of capture of "effectively final" local variable in lambda expressions + * @compile/fail/ref=EffectivelyFinal_neg.out -XDrawDiagnostics EffectivelyFinal_neg.java + */ + +public class EffectivelyFinal_neg { + + void test() { + String s = "a"; + String s2 = "a"; + int n = 1; + ((Runnable) + ()-> { + s2 = "b"; //re-assign illegal here + System.out.println(n); + System.out.println(s); + s = "b"; // not effectively final + } + ).run(); + n = 2; // not effectively final + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.out b/langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.out new file mode 100644 index 00000000000..00abf40835c --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.out @@ -0,0 +1,5 @@ +EffectivelyFinal_neg.java:17:17: compiler.err.cant.ref.non.effectively.final.var: s2, (compiler.misc.lambda) +EffectivelyFinal_neg.java:18:36: compiler.err.cant.ref.non.effectively.final.var: n, (compiler.misc.lambda) +EffectivelyFinal_neg.java:19:36: compiler.err.cant.ref.non.effectively.final.var: s, (compiler.misc.lambda) +EffectivelyFinal_neg.java:20:17: compiler.err.cant.ref.non.effectively.final.var: s, (compiler.misc.lambda) +4 errors diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.java b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.java new file mode 100644 index 00000000000..095350fba84 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.java @@ -0,0 +1,17 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Test invalid lambda expressions + * @compile/fail/ref=InvalidExpression1.out -XDrawDiagnostics InvalidExpression1.java + */ + +import java.util.Comparator; + +public class InvalidExpression1 { + + void test() { + Comparator c = (Number n1, Number n2)-> { 42; }; //not a statement + Comparator c = (Number n1, Number n2)-> { return 42 }; //";" expected + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.out b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.out new file mode 100644 index 00000000000..276f0f994c3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.out @@ -0,0 +1,3 @@ +InvalidExpression1.java:14:59: compiler.err.not.stmt +InvalidExpression1.java:15:68: compiler.err.expected: ';' +2 errors diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.java b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.java new file mode 100644 index 00000000000..37cfa3bc24a --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.java @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Test invalid lambda expressions + * @compile/fail/ref=InvalidExpression3.out -XDrawDiagnostics InvalidExpression3.java + */ + +import java.util.Comparator; + +public class InvalidExpression3 { + + void test() { + Comparator c2 = (Integer i1, Integer i2) -> { return "0"; }; //return type need to match + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.out b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.out new file mode 100644 index 00000000000..8c4f9e8c3e7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.out @@ -0,0 +1,2 @@ +InvalidExpression3.java:14:71: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, int)) +1 error diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.java b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.java new file mode 100644 index 00000000000..7a6e59b646c --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.java @@ -0,0 +1,18 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Test invalid lambda expressions + * @compile/fail/ref=InvalidExpression4.out -XDrawDiagnostics InvalidExpression4.java + */ + +public class InvalidExpression4 { + + interface SAM { + void m(int i); + } + + void test() { + SAM s = (Integer i) -> { }; //parameters not match, boxing not allowed here + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.out b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.out new file mode 100644 index 00000000000..03831725452 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.out @@ -0,0 +1,2 @@ +InvalidExpression4.java:16:17: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda) +1 error diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.java b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.java new file mode 100644 index 00000000000..145734c8413 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.java @@ -0,0 +1,14 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Test invalid lambda expressions + * @compile/fail/ref=InvalidExpression5.out -XDrawDiagnostics InvalidExpression5.java + */ + +public class InvalidExpression5 { + + void test() { + Object o = (int n) -> { }; // Invalid target type + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.out b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.out new file mode 100644 index 00000000000..251425e6675 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.out @@ -0,0 +1,2 @@ +InvalidExpression5.java:12:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf) +1 error diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.java b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.java new file mode 100644 index 00000000000..8a641855181 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.java @@ -0,0 +1,19 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Test invalid lambda expressions + * @compile/fail/ref=InvalidExpression6.out -XDrawDiagnostics InvalidExpression6.java + */ + +public class InvalidExpression6 { + + interface SAM { + void m(int i); + } + + void test() { + SAM s = (int n) -> { break; }; //break not allowed + s = (int n) -> { continue; }; //continue not allowed + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.out b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.out new file mode 100644 index 00000000000..aea9cfb8910 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.out @@ -0,0 +1,3 @@ +InvalidExpression6.java:16:30: compiler.err.break.outside.switch.loop +InvalidExpression6.java:17:26: compiler.err.cont.outside.loop +2 errors diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java new file mode 100644 index 00000000000..699ad5d3a67 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test lambda expressions for existing SAM interfaces like Runnable and Comparator + * @compile LambdaTest1.java + * @run main LambdaTest1 + */ + +import java.util.Collections; +import java.util.List; +import java.util.ArrayList; +import java.util.Date; + +public class LambdaTest1 { + + private static String assertionStr = ""; + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + private static void test1(Runnable r) { + r.run(); + } + + void test2(Object o) { + if(o instanceof Runnable) + ((Runnable)o).run(); + } + + Runnable test3() { + return ()-> { assertionStr += "Runnable6"; }; + } + + public static void main(String[] args) { + + //lambda expressions for SAM interface Runnable: + //assign: + Runnable r = ()-> { assertionStr += "Runnable1 "; }; + r.run(); + + //cast: + ((Runnable)()-> { assertionStr += "Runnable2 "; }).run(); + + Object o = (Runnable)()-> {}; + + o = (Runnable)()-> { + switch (assertionStr) { + case "Runnable1 Runnable2 ": + assertionStr += "Runnable3 "; + break; + default: + throw new AssertionError(); + } + return; + }; + + //method parameter: + test1(()-> { assertionStr += "Runnable4 "; return; }); + + LambdaTest1 test = new LambdaTest1(); + test.test2((Runnable)()-> { assertionStr += "Runnable5 "; }); + + //return type: + r = test.test3(); + r.run(); + + assertTrue(assertionStr.equals("Runnable1 Runnable2 Runnable4 Runnable5 Runnable6")); + + //lambda expressions for SAM interface Comparator: + List list = new ArrayList(); + list.add(4); + list.add(10); + list.add(-5); + list.add(100); + list.add(9); + Collections.sort(list, (Integer i1, Integer i2)-> i2 - i1); + String result = ""; + for(int i : list) + result += i + " "; + assertTrue(result.equals("100 10 9 4 -5 ")); + + Collections.sort(list, + (i1, i2) -> { + String s1 = i1.toString(); + String s2 = i2.toString(); + return s1.length() - s2.length(); + }); + result = ""; + for(int i : list) + result += i + " "; + assertTrue(result.equals("9 4 10 -5 100 ")); + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest2.java b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest2.java new file mode 100644 index 00000000000..4c0c7afb5e5 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest2.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test lambda expressions for different method signatures (parameter and return type) + * @compile LambdaTest2.java + * @run main LambdaTest2 + */ + +public class LambdaTest2 { + + private static int count = 0; + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + public static void main(String[] args) { + LambdaTest2 test = new LambdaTest2(); + + test.method2((int n) -> { ; }); + test.method2(n -> { }); // "int" is optional here + test.method2((int n) -> { }); // ";" is optional here + test.method2((int n) -> { return; }); // ";" is mandatory here + test.method2((int n) -> { count += n; }); + assertTrue(count == 10); + + VoidInt vi = (int i) -> { + switch (i) { + case 0: + System.out.println("normal"); + break; + default: + System.out.println("invalid"); + } + }; + + test.method3(()-> { count++; }); + test.method3(() -> {}); + assertTrue(count == 11); + + VoidVoid vv = ()-> { while(true) + if(false) + break; + else + continue; + }; + + IntVoid iv1 = () -> 42; + IntVoid iv2 = () -> { return 43; };//";" is mandatory here + assertTrue(iv1.ivMethod() == 42); + assertTrue(iv2.ivMethod() == 43); + + IntInt ii1 = (int n) -> n+1; + IntInt ii2 = n -> 42; + IntInt ii3 = n -> { return 43; }; + IntInt ii4 = + (int n) -> { + if(n > 0) + return n+1; + else + return n-1; + }; + assertTrue(ii1.iiMethod(1) == 2); + assertTrue(ii2.iiMethod(1) == 42); + assertTrue(ii3.iiMethod(1) == 43); + assertTrue(ii4.iiMethod(-1) == -2); + } + + void method2(VoidInt a) { + a.viMethod(10); + } + + void method3(VoidVoid a) { + a.vvMethod(); + } + + //SAM type interfaces + interface VoidInt { + void viMethod(int n); + } + + interface VoidVoid { + void vvMethod(); + } + + interface IntVoid { + int ivMethod(); + } + + interface IntInt { + int iiMethod(int n); + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest3.java b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest3.java new file mode 100644 index 00000000000..9275ae8714c --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest3.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test capture of "effectively final" local variable in lambda expressions + * @compile LambdaTest3.java + * @run main LambdaTest3 + */ + +public class LambdaTest3 { + + private static int count = 0; + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + public static void main(String[] args) { + final int N = 100; + int n = 2; //effectively final variable + + Runnable r = ((Runnable) + () -> { + count += N; + count += n; + } + ); + assertTrue(count == 0); + r.run(); + assertTrue(count == 102); + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest4.java b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest4.java new file mode 100644 index 00000000000..14af25eba95 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest4.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test accessing "this" in lambda expressions + * @compile LambdaTest4.java + * @run main LambdaTest4 + */ + +public class LambdaTest4 { + + private String thisStr; + private static int count = 0; + + { + ((Runnable) + ()-> { + this.init(); + assertTrue(this.toString().equals(thisStr)); + count++; + } + ).run(); + } + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + private void init() { + thisStr = this.toString(); + } + + private void m() { + String s1 = this.toString(); + ((Runnable) + ()-> { + assertTrue(this.toString().equals(thisStr)); + assertTrue(this.toString().equals(s1)); + } + ).run(); + } + + public static void main(String[] args) { + LambdaTest4 test = new LambdaTest4(); + assertTrue(count == 1); + test.m(); + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest5.java b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest5.java new file mode 100644 index 00000000000..0db7b51aff9 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest5.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test lambda expressions inside lambda expressions + * @compile LambdaTest5.java + * @run main LambdaTest5 + */ + +public class LambdaTest5 { + + interface A { + int m(); + } + + interface B { + int make (int i); + } + + private static int count = 0; + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + static A a; + static A a2; + static A a3; + static A a4; + + public static void main(String[] args) { + B b = (int i) -> ((A)()-> 5).m(); + assertTrue(b.make(0) == 5); + + a = () -> ((A)()-> { return 6; }).m(); //self reference + assertTrue(a.m() == 6); + + a2 = ()-> { + A an = ()-> { return 7; }; //self reference + return an.m(); + }; + assertTrue(a2.m() == 7); + + a3 = () -> a3.m(); //self reference + try { + a3.m(); + } catch(StackOverflowError e) { + count++; + } + assertTrue(count==1); + + a4 = ()-> ((B)(int i)-> ((A)()-> 9).m() ).make(0); + assertTrue(a4.m() == 9); + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest6.java b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest6.java new file mode 100644 index 00000000000..9ee5c9308f2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest6.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test bridge methods for certain SAM conversions + * @compile LambdaTest6.java + * @run main LambdaTest6 + */ + +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Set; + +public class LambdaTest6 { + + interface H {Object m();} + + interface K {void m(U element);} + + interface L extends K {} //generic substitution + + interface M {void m(String s);} + + interface KM extends K, M{} //generic substitution + + interface N extends H {String m();} //covariant return + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + private Set setOfStringObject() { + Set s = new HashSet<>(); + s.add("java.lang.String"); + s.add("java.lang.Object"); + return s; + } + + private void test1() + { + L la = s -> { }; + la.m("hi"); + Class c1 = la.getClass(); + Method[] methods = c1.getDeclaredMethods(); + Set types = setOfStringObject(); + for(Method m : methods) { + assertTrue(m.getName().equals("m")); + Class[] parameterTypes = m.getParameterTypes(); + assertTrue(parameterTypes.length == 1); + assertTrue(types.remove(parameterTypes[0].getName())); + } + assertTrue(types.isEmpty() || (types.size() == 1 && types.contains("java.lang.String"))); + } + + private void test2() + { + KM km = s -> { }; + //km.m("hi"); + Class c2 = km.getClass(); + Method[] methods = c2.getDeclaredMethods(); + Set types = setOfStringObject(); + for(Method m : methods) { + assertTrue(m.getName().equals("m")); + Class[] parameterTypes = m.getParameterTypes(); + assertTrue(parameterTypes.length == 1); + assertTrue(types.remove(parameterTypes[0].getName())); + } + assertTrue(types.isEmpty()); + } + + private void test3() + { + N na = ()-> "hi"; + assertTrue( na.m().equals("hi") ); + assertTrue( ((H)na).m().equals("hi") ); + Class c3 = na.getClass(); + Method[] methods = c3.getDeclaredMethods(); + Set types = setOfStringObject(); + for(Method m : methods) { + assertTrue(m.getName().equals("m")); + Class returnType = m.getReturnType(); + assertTrue(types.remove(returnType.getName())); + } + assertTrue(types.isEmpty()); + } + + + public static void main(String[] args) { + LambdaTest6 test = new LambdaTest6(); + test.test1(); + test.test2(); + test.test3(); + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/SamConversion.java b/langtools/test/tools/javac/lambda/lambdaExpression/SamConversion.java new file mode 100644 index 00000000000..5dfb4da514f --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/SamConversion.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test SAM conversion of lambda expressions in context of assignment, method call, return statement and cast. + * @compile SamConversion.java + * @run main SamConversion + */ + +public class SamConversion { + + static interface Foo { + Integer m(int i); + } + + static interface Bar { + int m(Integer i) throws Exception; + } + + private static String assertionStr = ""; + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + private static void test1(Foo foo) { + assertTrue(foo.m(1) == 2); + } + + private static void test2(Bar bar) { + try { + assertTrue(bar.m(1) == 2); + } catch (Exception e){ + assertTrue(false); + } + } + + private static Bar test3(int i) { + switch (i) { + case 0: + return n -> n + 1; + case 1: + return (Integer n) -> 2 * n; + case 2: + return (Integer n) -> {return new Integer(n-1);}; + case 3: + return n -> {throw new Exception();}; + default: + return null; + } + } + + public static void main(String[] args) { + + //assign: + Foo foo = (int n) -> n + 1; //explicit type and boxing + assertTrue(foo.m(1) == 2); + + foo = n -> n + 1; //type inferrred and boxing + assertTrue(foo.m(1) == 2); + + Bar bar = (Integer n) -> n + 1; //explicit type and unboxing + try { + assertTrue(bar.m(1) == 2); + } catch (Exception e) { + assertTrue(false); + } + + bar = (Integer n) -> new Integer(n+1); //explicit type and unboxing twice + try { + assertTrue(bar.m(1) == 2); + } catch (Exception e) { + assertTrue(false); + } + + bar = n -> n.intValue() + 1; //type inferred + try { + assertTrue(bar.m(1) == 2); + } catch (Exception e) { + assertTrue(false); + } + + bar = n -> n + 1; // type inferred and unboxing + try { + assertTrue(bar.m(1) == 2); + } catch (Exception e) { + assertTrue(false); + } + + //cast: + assertTrue(((Foo)n -> {return n+1;}).m(1) == 2); //statement (instead of expression) in lambda body + try { + assertTrue(((Bar)n -> {return n+1;}).m(1) == 2); //statement in lambda body + } catch (Exception e) { + assertTrue(false); + } + + //method parameter: + test1((int n) -> new Integer(n+1)); //explicit type + test2((Integer n) -> n.intValue() + 1); //explicit type + + //return statement: + bar = test3(0); + try { + assertTrue(bar.m(1) == 2); + } catch (Exception e) { + assertTrue(false); + } + bar = test3(1); + try { + assertTrue(bar.m(3) == 6); + } catch (Exception e) { + assertTrue(false); + } + bar = test3(2); + try { + assertTrue(bar.m(10) == 9); + } catch (Exception e) { + assertTrue(false); + } + bar = test3(3); + try { + bar.m(10); + assertTrue(false); + } catch (Exception e) {} + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java b/langtools/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java new file mode 100644 index 00000000000..b64ca3df279 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test SAM conversion of lambda expressions in combinations of different contexts, + * lambda body types(statement/expression), explict/implicit target type etc, to verify + * SAM conversion being conducted successfully as expected. + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class SamConversionComboTest { + + enum FInterface { + A("A", "interface A { Integer m(int i); }"), + B("B", "interface B { int m(Integer i); }"), + C("C", "interface C { int m(Integer i) throws Exception; }"); + + String interfaceType; + String interfaceDef; + + FInterface(String interfaceType, String interfaceDef) { + this.interfaceType = interfaceType; + this.interfaceDef = interfaceDef; + } + + String getParameterType() { + switch(this) { + case A: + return "int"; + case B: + case C: + return "Integer"; + default: + return null; + } + } + } + + enum Context { + ASSIGNMENT("#FType f = #LBody;"), + METHOD_CALL("void method1(#FType f) { }\n" + + " void method2() {\n" + + " method1(#LBody);\n" + + " }"), + CONSTRUCTOR("X x = new X(#LBody);"), + RETURN_OF_METHOD("#FType method1() {\n" + + " return #LBody;\n" + + "}"), + ARRAY_INITIALIZER("Object[] oarray = {\"a\", 1, (#FType)#LBody};"), + LAMBDA_BODY("#FType f = n -> ((#FType)#LBody).m(n);"), + CAST("void test() throws Exception { int n = ((#FType)#LBody).m(1); }"), + CONDITIONAL_EXPRESSION("#FType f = 2 > 1 ? #LBody : null;"); + + String context; + + Context(String context) { + this.context = context; + } + + String getContext(FInterface f, LambdaKind lk, LambdaBody lb, ReturnValue rv) { + return context.replace("#FType", f.interfaceType).replace("#LBody", lb.getLambdaBody(f, lk, rv)); + } + } + + enum LambdaKind { + EXPRESSION("#VAL"), + STATEMENT("{return #VAL;}"), + EXCEPTION_STMT("{throw new Exception();}"); + + String stmt; + + LambdaKind(String stmt) { + this.stmt = stmt; + } + } + + enum ReturnValue { + INT("i + 1"), + INTEGER("new Integer(i+1)"), + INT2("i.intValue() + 1"), + STRING("i + \"\""), + DOUBLE("i * 1.0"); + + String rValue; + + ReturnValue(String rValue) { + this.rValue = rValue; + } + } + + enum LambdaBody { + IMPLICIT("i -> #RET"),//type inferred + EXPLICIT("(#Type i) -> #RET");//explicit type + + String bodyStr; + + LambdaBody(String bodyStr) { + this.bodyStr = bodyStr; + } + + String getLambdaBody(FInterface fi, LambdaKind lk, ReturnValue rv) { + return bodyStr.replace("#Type", fi.getParameterType()).replace("#RET", lk.stmt.replace("#VAL", rv.rValue)); + } + } + + boolean checkSamConversion() { + if(lambdaKind != LambdaKind.EXCEPTION_STMT && (returnValue == ReturnValue.DOUBLE || returnValue == ReturnValue.STRING)) //return type mismatch + return false; + if(context != Context.CONSTRUCTOR) {//context other than construcotr argument + if(fInterface != FInterface.C && lambdaKind == LambdaKind.EXCEPTION_STMT) + return false; + if(fInterface == FInterface.A && returnValue == ReturnValue.INT2) + return false; + } + else { //constructor argument context + //match X(A a) or X(B b) or X(C c) + if (lambdaKind == LambdaKind.EXCEPTION_STMT) { + return false; //ambiguous target type + } + else if(lambdaBody == LambdaBody.IMPLICIT) { + if(returnValue != ReturnValue.INTEGER) //ambiguous target type + return false; + } + else { //explicit parameter type + if(fInterface.getParameterType().equals("Integer")) //ambiguous target type + //e.g. X x = new X((Integer i) -> i + 1); + return false; + if(returnValue == ReturnValue.INT2) + //e.g. X x = new X(int i -> i.intValue() + 1); + return false; + } + } + return true; + } + + SourceFile samSourceFile = new SourceFile("FInterface.java", "#C") { + public String toString() { + String interfaces = ""; + for(FInterface fi : FInterface.values()) + interfaces += fi.interfaceDef + "\n"; + return template.replace("#C", interfaces); + } + }; + + String clientTemplate = "class Client {\n" + + " #Context\n" + + "}\n\n" + + + "class X {\n" + + " int value = 0;\n\n" + + + " X(A a) {\n" + + " value = a.m(6);\n" + + " }\n\n" + + + " X(B b) {\n" + + " value = b.m(7);\n" + + " }\n\n" + + + " X(C c) {\n" + + " try {\n" + + " value = c.m(8);\n" + + " } catch (Exception e){}\n" + + " }\n" + + "}"; + SourceFile clientSourceFile = new SourceFile("Client.java", clientTemplate) { + public String toString() { + return template.replace("#Context", context.getContext(fInterface, lambdaKind, lambdaBody, returnValue)); + } + }; + + void test() throws Exception { + System.out.println("\n===================================="); + System.out.println(fInterface + ", " + context + ", " + lambdaKind + ", " + lambdaBody + ", " + returnValue); + System.out.println(samSourceFile + "\n"); + String clientFileStr = clientSourceFile.toString(); + System.out.println(clientFileStr.substring(0, clientFileStr.indexOf("\n\n"))); + + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + DiagnosticChecker dc = new DiagnosticChecker(); + JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile)); + ct.analyze(); + if (dc.errorFound == checkSamConversion()) { + throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile); + } + count++; + } + + abstract class SourceFile extends SimpleJavaFileObject { + + protected String template; + + public SourceFile(String filename, String template) { + super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE); + this.template = template; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return toString(); + } + + public abstract String toString(); + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound = false; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } + + FInterface fInterface; + Context context; + LambdaBody lambdaBody; + LambdaKind lambdaKind; + ReturnValue returnValue; + static int count = 0; + + SamConversionComboTest(FInterface f, Context c, LambdaBody lb, LambdaKind lk, ReturnValue rv) { + fInterface = f; + context = c; + lambdaKind = lk; + lambdaBody = lb; + returnValue = rv; + } + + public static void main(String[] args) throws Exception { + for(Context ct : Context.values()) { + for (FInterface fi : FInterface.values()) { + for (LambdaKind lk: LambdaKind.values()) { + for (LambdaBody lb : LambdaBody.values()) { + for(ReturnValue rv : ReturnValue.values()) { + new SamConversionComboTest(fi, ct, lb, lk, rv).test(); + } + } + } + } + } + System.out.println("total tests: " + count); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/BridgeMethod.java b/langtools/test/tools/javac/lambda/methodReference/BridgeMethod.java new file mode 100644 index 00000000000..e1df4bc8556 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/BridgeMethod.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test bridge methods in certain SAM conversion + * @compile BridgeMethod.java + * @run main BridgeMethod + */ + +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Set; + +public class BridgeMethod { + + interface H {Object m();} + + interface K {void m(T t);} + + interface L extends K {} //generic substitution + + interface M {void m(String s);} + + interface KM extends K, M{} //generic substitution + + interface N extends H {String m();} //covariant return + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + static void bar(String s) { + System.out.println("BridgeMethod.bar(String) " + s); + } + + String moo() { + return "moo"; + } + + private static Set setOfStringObject() { + Set s = new HashSet<>(); + s.add("java.lang.String"); + s.add("java.lang.Object"); + return s; + } + + public static void main(String[] args) { + L la = BridgeMethod::bar; //static reference + la.m("hi"); + Class c1 = la.getClass(); + Method[] methods = c1.getDeclaredMethods(); + Set types = setOfStringObject(); + System.out.println("methods in SAM conversion of L:"); + for(Method m : methods) { + System.out.println(m.toGenericString()); + assertTrue(m.getName().equals("m")); + Class[] parameterTypes = m.getParameterTypes(); + assertTrue(parameterTypes.length == 1); + assertTrue(types.remove(parameterTypes[0].getName())); + } + assertTrue(types.isEmpty() || (types.size() == 1 && types.contains("java.lang.String"))); + + KM km = BridgeMethod::bar; + //km.m("hi"); //will be uncommented when CR7028808 fixed + Class c2 = km.getClass(); + methods = c2.getDeclaredMethods(); + types = setOfStringObject(); + System.out.println("methods in SAM conversion of KM:"); + for(Method m : methods) { + System.out.println(m.toGenericString()); + assertTrue(m.getName().equals("m")); + Class[] parameterTypes = m.getParameterTypes(); + assertTrue(parameterTypes.length == 1); + assertTrue(types.remove(parameterTypes[0].getName())); + } + assertTrue(types.isEmpty()); + + N n = new BridgeMethod()::moo; //instance reference + assertTrue( n.m().equals("moo") ); + assertTrue( ((H)n).m().equals("moo") ); + Class c3 = n.getClass(); + methods = c3.getDeclaredMethods(); + types = setOfStringObject(); + System.out.println("methods in SAM conversion of N:"); + for(Method m : methods) { + System.out.println(m.toGenericString()); + assertTrue(m.getName().equals("m")); + Class returnType = m.getReturnType(); + assertTrue(types.remove(returnType.getName())); + } + assertTrue(types.isEmpty()); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRef1.java b/langtools/test/tools/javac/lambda/methodReference/MethodRef1.java new file mode 100644 index 00000000000..2f79439fbd2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef1.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test static method reference + * @compile MethodRef1.java + * @run main MethodRef1 + */ + +public class MethodRef1 { + + static interface A {void m();} + + static interface B {void m(int i);} + + static interface C {String m(String s);} + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + static void foo(int x) { + System.out.println("MethodRef1.foo(int) " + x); + } + + static void bar() { + System.out.println("MethodRef1.bar()"); + } + + static void bar(int x) { + System.out.println("MethodRef1.bar(int) " + x); + } + + static String bar(String s) { + return "MethodRef1.bar(String) " + s; + } + + public static void main(String[] args) { + + A a = MethodRef1::bar; //static reference to bar() + a.m(); + + B b = MethodRef1::foo; //static reference to foo(int), (int) omitted because method foo is not overloaded + b.m(1); + + b = MethodRef1::foo; //static reference to foo(int) + b.m(1); + + b = new MethodRef1()::foo; //instance reference to static methods, supported for now + b.m(1); + + b = MethodRef1::bar; //static reference to bar(int) + b.m(2); + + C c = MethodRef1::bar; //static reference to bar(String) + assertTrue( c.m("hi").equals("MethodRef1.bar(String) hi") ); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRef2.java b/langtools/test/tools/javac/lambda/methodReference/MethodRef2.java new file mode 100644 index 00000000000..60f41baf075 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef2.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test instance method reference + * @compile MethodRef2.java + * @run main MethodRef2 + */ + +public class MethodRef2 { + + static interface A {String m();} + + static interface B {String m(int i);} + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + String moo() { + return "moo"; + } + + String wahoo() { + return "wahoo"; + } + + String wahoo(int x) { + return "wahoo " + x; + } + + public static void main(String[] args) { + + MethodRef2 mr = new MethodRef2(); + + A a = mr::moo; //instance reference to moo() + assertTrue( a.m().equals("moo") ); + + a = new MethodRef2()::wahoo; //instance reference to wahoo() + assertTrue( a.m().equals("wahoo") ); + + B b = mr::wahoo; //instance reference to wahoo(int) + assertTrue( b.m(4).equals("wahoo 4") ); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRef3.java b/langtools/test/tools/javac/lambda/methodReference/MethodRef3.java new file mode 100644 index 00000000000..ec2780d48c2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef3.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test unbound method reference + * @compile MethodRef3.java + * @run main MethodRef3 + */ + +public class MethodRef3 { + + static interface A { String m(MethodRef3 mr); } + + static interface B { String m(MethodRef3 mr, String s); } + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + String moo() { + return "moo"; + } + + String wahoo(String s) { + return "wahoo " + s; + } + + public static void main(String[] args) { + + MethodRef3 mr = new MethodRef3(); + A a = MethodRef3::moo; //unbound reference to moo() + assertTrue( a.m(mr).equals("moo") ); + B b = MethodRef3::wahoo; //unbound reference to wahoo() + assertTrue( b.m(mr, "hi").equals("wahoo hi") ); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRef4.java b/langtools/test/tools/javac/lambda/methodReference/MethodRef4.java new file mode 100644 index 00000000000..a05b3fbeb13 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef4.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test constructor reference + * @compile MethodRef4.java + * @run main MethodRef4 + */ + +public class MethodRef4 { + + static interface A {Fee m();} + + static interface B {Fee m(String s);} + + static interface C {Object m();} + + static class Fee { + + private T t; + + public Fee() { + System.out.println("Fee instantiated"); + } + + public Fee(T t) { + this.t = t; + System.out.println("Fee instantiated: " + t); + } + + public void make() { + System.out.println(this + ": make()"); + } + } + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + public static void main(String[] args) { + + A a = Fee::new; //constructor reference to Fee() + a.m().make(); + + B b = Fee::new; //constructor reference to Fee(String) + b.m("hi").make(); + + C c = MethodRef4::new; //constructor reference to MethodRef4() + assertTrue( c.m() instanceof MethodRef4 ); + c = MethodRef4::new; //constructor reference to MethodRef4() + assertTrue( c.m() instanceof MethodRef4 ); + c = Fee::new; //constructor reference to Fee() + assertTrue( c.m() instanceof Fee ); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRef5.java b/langtools/test/tools/javac/lambda/methodReference/MethodRef5.java new file mode 100644 index 00000000000..47381088abc --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef5.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test method reference with SAM interface Comparator + * @compile MethodRef5.java + * @run main MethodRef5 + */ + +import java.util.Collections; +import java.util.List; +import java.util.ArrayList; + +public class MethodRef5 { + + static class Person { + + private String firstName; + private String lastName; + private int age; + + public Person() { } + + public Person(String fn, String ln, int a) { + firstName = fn; + lastName = ln; + age = a; + } + + public String getLastName() { + return lastName; + } + + public int getAge() { + return age; + } + + //the following 2 methods are signature-compatible with Comparator.compare(): + public static int compareByAge(Person a, Person b) { + return a.age - b.age; + } + + public int compareByLastName(Person a, Person b) { + return a.lastName.compareToIgnoreCase(b.lastName); + } + } + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + public static void main(String[] args) { + + List persons = new ArrayList(); + persons.add(new Person("John", "Smith", 49)); + persons.add(new Person("Abraham", "Lincoln", 30)); + persons.add(new Person("George", "Washington", 29)); + persons.add(new Person("Peter", "Derby", 50)); + Collections.sort(persons, Person::compareByAge);//static method reference to compareByAge(Person, Person) + String age = ""; + for (Person p : persons) { + age += p.getAge() + " "; + } + assertTrue( (age.equals("29 30 49 50 ")) ); + Collections.sort(persons, new Person()::compareByLastName);//instance method reference to compareByLastName(Person, Person) + String lastName = ""; + for (Person p : persons) { + lastName += p.getLastName() + " "; + } + assertTrue( lastName.equals("Derby Lincoln Smith Washington ") ); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRef6.java b/langtools/test/tools/javac/lambda/methodReference/MethodRef6.java new file mode 100644 index 00000000000..0cd740f2131 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef6.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test that the most specific reference is selected when method parameters are elided + * @compile MethodRef6.java + * @run main MethodRef6 + */ + +public class MethodRef6 { + + static interface A { String make(Integer i); } + + static interface B { String make(Number i); } + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + static String m(Object o) { + return "Object " + o; + } + + static String m(Number n) { + return "Number " + n; + } + + static String m(Integer i) { + return "Integer " + i; + } + + static String m(int i) { + return "int " + i; + } + + public static void main(String[] args) { + A a = MethodRef6::m; + assertTrue(a.make(1).equals("Integer 1"));//method parameter type inferred from SAM descriptor, boxing applied + B b = MethodRef6::m; + assertTrue(b.make(1).equals("Number 1"));//method parameter type inferred from SAM descriptor, boxing and widen applied + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRef7.java b/langtools/test/tools/javac/lambda/methodReference/MethodRef7.java new file mode 100644 index 00000000000..edcb6d48769 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef7.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test that parameter types are inferred from SAM descriptor when method parameters are elided, + with different types of method references + * @compile MethodRef7.java + * @run main MethodRef7 + */ + +public class MethodRef7 { + + static interface A {void m();} + + static interface A2 {void m(int n);} + + static interface B {String m();} + + static interface B2 {String m(int n);} + + static interface C {String m(MethodRef7 mr);} + + static interface C2 {String m(MethodRef7 mr, int n);} + + static interface D {Fee m();} + + static interface D2 {Fee m(String s);} + + static class Fee { + + public Fee() { + System.out.println("Fee instantiated"); + } + + public Fee(String s) { + System.out.println("Fee instantiated: " + s); + } + } + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + static void bar() { + System.out.println("MethodRef_neg1.bar()"); + } + + static void bar(int x) { + System.out.println("MethodRef_neg1.bar(int) " + x); + } + + String wahoo() { + return "wahoo"; + } + + String wahoo(int x) { + return "wahoo " + x; + } + + public static void main(String[] args) { + + A a = MethodRef7::bar; //static reference to bar() + a.m(); + A2 a2 = MethodRef7::bar; //static reference to bar(int x) + a2.m(10); + + MethodRef7 mr = new MethodRef7(); + B b = mr::wahoo; //instance reference to wahoo() + assertTrue(b.m().equals("wahoo")); + B2 b2 = mr::wahoo; //instance reference to wahoo(int x) + assertTrue(b2.m(1).equals("wahoo 1")); + + C c = MethodRef7::wahoo; //unbound reference to wahoo() + assertTrue(c.m(mr).equals("wahoo")); + C2 c2 = MethodRef7::wahoo; //unbound reference to wahoo(int x) + assertTrue(c2.m(mr, 2).equals("wahoo 2")); + + D d = Fee::new; //constructor reference to Fee() + D2 d2 = Fee::new; //constructor reference to Fee(String s) + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.java b/langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.java new file mode 100644 index 00000000000..0a890973ae4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.java @@ -0,0 +1,36 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * This is negative test for wrong parameter/return type in method references + * @compile/fail/ref=MethodRef_neg.out -XDrawDiagnostics MethodRef_neg.java + */ + +public class MethodRef_neg { + + static interface A {void m(Integer i);} + + static interface B {void m(String s);} + + static interface C {Integer m();} + + static interface D {String m();} + + + static void bar(int x) { } + + int foo() { + return 5; + } + + static void make() { } + + void method() { + A a = MethodRef_neg::bar; //boxing on parameter type is ok + B b = MethodRef_neg::bar; //wrong parameter type, required: String, actual: int + C c = this::foo; //boxing on return type is ok + D d = this::foo; //wrong return type, required: String, actual: int + a = MethodRef_neg::make; //missing parameter + c = MethodRef_neg::make; //missing return type + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.out b/langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.out new file mode 100644 index 00000000000..58b77bc49fc --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.out @@ -0,0 +1,5 @@ +MethodRef_neg.java:30:15: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, bar, int, java.lang.String, kindname.class, MethodRef_neg, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, int)))) +MethodRef_neg.java:32:15: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int, java.lang.String)) +MethodRef_neg.java:33:13: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, make, compiler.misc.no.args, java.lang.Integer, kindname.class, MethodRef_neg, (compiler.misc.arg.length.mismatch))) +MethodRef_neg.java:34:13: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: void, java.lang.Integer)) +4 errors diff --git a/langtools/test/tools/javac/lambda/methodReference/SamConversion.java b/langtools/test/tools/javac/lambda/methodReference/SamConversion.java new file mode 100644 index 00000000000..fbbbb0f80bb --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/SamConversion.java @@ -0,0 +1,337 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test SAM conversion of method references in contexts of assignment, method/constructor argument, + * return statement, array initializer, lambda expression body, conditional expression and cast. + * @compile SamConversion.java + * @run main SamConversion + */ + +public class SamConversion { + + static int assertionCount = 0; + + static interface Foo { + Integer m(int i); + } + + static interface Bar { + int m(Integer i) throws MyException; + } + + private static void assertTrue(boolean b) { + assertionCount++; + if(!b) + throw new AssertionError(); + } + + private static int test1(Foo foo) { + return foo.m(1); + } + + private static void test2(Bar bar, int result) { + try { + assertTrue(bar.m(1) == result); + } catch (Exception e){ + assertTrue(false); + } + } + + private static Bar test3(int i) { + switch (i) { + case 0: + return A::method1; + case 1: + return new A()::method2; + case 2: + return A::method3; + case 3: + return new A()::method4; + case 4: + return new A()::method5; + case 5: + return A::method6; + default: + return null; + } + } + + /** + * Test SAM conversion of method reference in assignment context + */ + private static void testAssignment() { + Foo foo = A::method1; //static reference, parameter type matching and return type matching + assertTrue(foo.m(1) == 2); + + foo = new A()::method2; //instance reference, parameter type unboxing and return type boxing + assertTrue(foo.m(1) == 3); + + foo = A::method3; //static reference, parameter type matching and return type boxing + assertTrue(foo.m(1) == 4); + + foo = new A()::method4; //instance reference, parameter type unboxing and return type matching + assertTrue(foo.m(1) == 5); + + foo = new A()::method5; //instance reference, parameter type unboxing and return type matching + assertTrue(foo.m(1) == 6); + + Bar bar = A::method1; + try { + assertTrue(bar.m(1) == 2); + } catch (Exception e) { + assertTrue(false); + } + + bar = new A()::method2; + try { + assertTrue(bar.m(1) == 3); + } catch (Exception e) { + assertTrue(false); + } + + bar = A::method3; + try { + assertTrue(bar.m(1) == 4); + } catch (Exception e) { + assertTrue(false); + } + + bar = new A()::method4; + try { + assertTrue(bar.m(1) == 5); + } catch (Exception e) { + assertTrue(false); + } + + bar = new A()::method5; + try { + assertTrue(bar.m(1) == 6); + } catch (Exception e) { + assertTrue(false); + } + + bar = new A()::method6; + try { + bar.m(1); + assertTrue(false); + } catch (MyException e) { + } catch (Exception e) { + assertTrue(false); + } + } + + /** + * Test SAM conversion of method reference in method/constructor argument context + */ + private static void testMethodArgument() { + assertTrue(test1(A::method1) == 2); + assertTrue(test1(new A()::method2) == 3); + assertTrue(test1(A::method3) == 4); + assertTrue(test1(new A()::method4) == 5); + assertTrue(test1(new A()::method5) == 6); + test2(A::method1, 2); + test2(new A()::method2, 3); + test2(A::method3, 4); + test2(new A()::method4, 5); + test2(new A()::method5, 6); + A a = new A(A::method1); //A(Foo f) called + assertTrue(a.method2(1) == 11); + assertTrue(a.method4(1) == 11); + assertTrue(a.method5(1) == 11); + A a2 = new A(new A()::method2); //A(Bar b) called + assertTrue(a2.method2(1) == 12); + assertTrue(a2.method4(1) == 12); + assertTrue(a2.method5(1) == 12); + } + + /** + * Test SAM conversion of method reference in return statement context + */ + private static void testReturnStatement() { + Bar bar = test3(0); + try { + assertTrue(bar.m(1) == 2); + } catch (Exception e) { + assertTrue(false); + } + bar = test3(1); + try { + assertTrue(bar.m(1) == 3); + } catch (Exception e) { + assertTrue(false); + } + bar = test3(2); + try { + assertTrue(bar.m(1) == 4); + } catch (Exception e) { + assertTrue(false); + } + bar = test3(3); + try { + assertTrue(bar.m(1) == 5); + } catch (Exception e) { + assertTrue(false); + } + bar = test3(4); + try { + assertTrue(bar.m(1) == 6); + } catch (Exception e) { + assertTrue(false); + } + bar = test3(5); + try { + bar.m(1); + assertTrue(false); + } catch (MyException e) { + } catch (Exception e) { + assertTrue(false); + } + } + + /** + * Test SAM conversion of method reference in cast context + */ + private static void testCast() { + assertTrue(((Foo)A::method1).m(1) == 2); + try { + assertTrue(((Bar)new A()::method2).m(1) == 3); + } catch (Exception e) { + assertTrue(false); + } + } + + /** + * Test SAM conversion of method reference in array initializer context + */ + private static void testArrayInitializer() { + Object[] oarray = {"a", 1, (Foo)A::method3}; //last element need a cast + Object[] oarray2 = {"a", 1, (Bar)new A()::method4}; //last element need a cast + Foo[] farray = {A::method1, new A()::method2, A::method3, new A()::method4, new A()::method5}; + Bar[] barray = {A::method1, new A()::method2, A::method3, new A()::method4, new A()::method5, A::method6}; + } + + /** + * Test SAM conversion of method reference in conditional expression context + */ + private static void testConditionalExpression(boolean b) { + Foo f = b ? A::method3 : new A()::method5; + if(b) + assertTrue(f.m(1) == 4); + else + assertTrue(f.m(1) == 6); + + Bar bar = b ? A::method1 : A::method6; + if(b) { + try { + assertTrue(bar.m(1) == 2); + } catch (Exception e) { + assertTrue(false); + } + } + else { + try { + bar.m(1); + assertTrue(false); + } catch (MyException e) { + } catch (Exception e) { + assertTrue(false); + } + } + } + + /** + * Test SAM conversion of method reference in lambda expression body + */ + private static void testLambdaExpressionBody() { + Foo f = n -> ((Foo)A::method3).m(n); + assertTrue(f.m(1) == 4); + + Bar b = n -> { return ((Foo)new A()::method5).m(n); }; + try { + assertTrue(b.m(1) == 6); + } catch (Exception e) { + assertTrue(false); + } + } + + public static void main(String[] args) { + testAssignment(); + testMethodArgument(); + testReturnStatement(); + testCast(); + testArrayInitializer(); + testConditionalExpression(true); + testConditionalExpression(false); + testLambdaExpressionBody(); + + assertTrue(assertionCount == 38); + } + + static class MyException extends Exception {} + + static class A { + + int value = 0; + + A() { + } + + A(Foo f) { + value = f.m(9); + } + + A(Bar b) { + try { + value = b.m(9); + } catch (MyException e){} + } + + static Integer method1(int n) { + return n + 1; + } + + int method2(Integer n) { + return value == 0 ? n + 2 : n + value; + } + + static int method3(int n) { + return n + 3; + } + + Integer method4(Integer n) { + return value == 0 ? n + 4 : n + value; + } + + Integer method5(Integer n) { + return value == 0 ? new Integer(n + 5) : new Integer(n + value); + } + + static int method6(Integer n) throws MyException{ + throw new MyException(); + } + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/SamConversionComboTest.java b/langtools/test/tools/javac/lambda/methodReference/SamConversionComboTest.java new file mode 100644 index 00000000000..d705cdc38fd --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/SamConversionComboTest.java @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Test SAM conversion of method references in combinations of different contexts, + * lambda body types(statement/expression), boxing/unboxing etc, to verify + * SAM conversion being conducted successfully as expected. + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; +import javax.tools.StandardJavaFileManager; + +public class SamConversionComboTest { + + enum FInterface { + A("A", "interface A { Integer m(int i); }"), + B("B", "interface B { int m(Integer i); }"), + C("C", "interface C { int m(int i) throws Exception; }"); + + String interfaceType; + String interfaceDef; + + FInterface(String interfaceType, String interfaceDef) { + this.interfaceType = interfaceType; + this.interfaceDef = interfaceDef; + } + } + + enum Context { + ASSIGNMENT("#FType f = #MR;"), + METHOD_CALL("void method1(#FType f) { }\n" + + "void method2() {\n" + + " method1(#MR);\n" + + "}"), + CONSTRUCTOR("X x = new X(#MR);"), + RETURN_OF_METHOD("#FType method1() {\n" + + " return #MR;\n" + + "}"), + ARRAY_INITIALIZER("#FType[] oarray = {#MR};"), + LAMBDA_BODY("#FType f = n -> ((#FType)#MR).m(n);"), + CAST("void test() throws Exception { int n = ((#FType)#MR).m(1); }"), + CONDITIONAL_EXPRESSION("#FType f = 2 > 1 ? #MR : null;"); + + String context; + + Context(String context) { + this.context = context; + } + + String getContext(FInterface f, MethodReference mr) { + return context.replace("#FType", f.interfaceType).replace("#MR", mr.mrValue); + } + } + + enum MethodReference { + METHOD1("X::method1"), + METHOD2("new X()::method2"), + METHOD3("X::method3"), + METHOD4("new X()::method4"), + METHOD5("new X()::method5"), + METHOD6("X::method6"), + METHOD7("X::method7"), + METHOD8("X::method8"); + + String mrValue; + + MethodReference(String mr) { + mrValue = mr; + } + } + + enum MethodDef { + METHOD1(" static Integer method1(int n) {\n" + + " return n + 1;\n" + + " }\n", 0), + METHOD2(" int method2(Integer n) {\n" + + " return value == 0 ? n + 2 : n + value;\n" + + " }\n", 1), + METHOD3(" static int method3(int n) {\n" + + " return n + 3;\n" + + " }\n", 2), + METHOD4(" Integer method4(Integer n) {\n" + + " return value == 0 ? n + 4 : n + value;\n" + + " }\n", 3), + METHOD5(" Integer method5(Integer n) {\n" + + " return value == 0 ? new Integer(n + 5) : new Integer(n + value);\n" + + " }\n", 4), + METHOD6(" static int method6(Integer n) throws Exception{\n" + + " throw new Exception();\n" + + " }\n", 5), + METHOD7(" static int method7(String s){\n" + + " return s.length();\n" + + " }\n", 6), + METHOD8(" static String method8(Integer n){\n" + + " return n + \"\";\n" + + " }\n", 7); + + String methodStr; + int index; + + MethodDef(String ms, int i) { + methodStr = ms; + index = i; + } + + MethodReference getMethodReference() { + return MethodReference.values()[index]; + } + } + + SourceFile samSourceFile = new SourceFile("FInterface.java", "#C") { + public String toString() { + String interfaces = ""; + for(FInterface fi : FInterface.values()) + interfaces += fi.interfaceDef + "\n"; + return template.replace("#C", interfaces); + } + }; + + String clientTemplate = "class Client {\n" + + " #Context\n" + + "}\n\n" + + + "class X {\n" + + " int value = 0;\n\n" + + + " X() {\n" + + " }\n\n" + + + " X(A a) {\n" + + " value = a.m(9);\n" + + " }\n\n" + + + " X(B b) {\n" + + " value = b.m(9);\n" + + " }\n\n" + + + " X(C c) {\n" + + " try {\n" + + " value = c.m(9);\n" + + " } catch (Exception e){}\n" + + " }\n\n" + + + "#MethodDef" + + "}"; + + SourceFile clientSourceFile = new SourceFile("Client.java", clientTemplate) { + public String toString() { + return template.replace("#Context", context.getContext(fInterface, methodReference)).replace("#MethodDef", methodDef.methodStr); + } + }; + + boolean checkSamConversion() { + if(methodDef == MethodDef.METHOD7 || methodDef == MethodDef.METHOD8)//method signature mismatch + return false; + if(context != Context.CONSTRUCTOR && fInterface != FInterface.C && methodDef == MethodDef.METHOD6) + //method that throws exceptions not thrown by the interface method is a mismatch + return false; + if(context == Context.CONSTRUCTOR && + methodReference != MethodReference.METHOD1 && + methodReference != MethodReference.METHOD2 && + methodReference != MethodReference.METHOD3)//ambiguous reference + return false; + return true; + } + + void test() throws Exception { + System.out.println("\n===================================="); + System.out.println(fInterface + ", " + context + ", " + methodReference); + System.out.println(samSourceFile + "\n" + clientSourceFile); + + DiagnosticChecker dc = new DiagnosticChecker(); + JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile)); + ct.analyze(); + if (dc.errorFound == checkSamConversion()) { + throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile); + } + count++; + } + + abstract class SourceFile extends SimpleJavaFileObject { + + protected String template; + + public SourceFile(String filename, String template) { + super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE); + this.template = template; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return toString(); + } + + public abstract String toString(); + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound = false; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } + + FInterface fInterface; + Context context; + MethodDef methodDef; + MethodReference methodReference; + static int count = 0; + + static JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + SamConversionComboTest(FInterface f, Context c, MethodDef md) { + fInterface = f; + context = c; + methodDef = md; + methodReference = md.getMethodReference(); + } + + public static void main(String[] args) throws Exception { + for(Context ct : Context.values()) { + for (FInterface fi : FInterface.values()) { + for (MethodDef md: MethodDef.values()) { + new SamConversionComboTest(fi, ct, md).test(); + } + } + } + System.out.println("total tests: " + count); + } +} diff --git a/langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java b/langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java new file mode 100644 index 00000000000..486b51e1dcd --- /dev/null +++ b/langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java @@ -0,0 +1,303 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * Automatic test for checking correctness of structural most specific test routine + * @run main/timeout=360 StructuralMostSpecificTest + */ + +import com.sun.source.util.JavacTask; +import com.sun.tools.javac.api.ClientCodeWrapper; +import com.sun.tools.javac.util.JCDiagnostic; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +public class StructuralMostSpecificTest { + + static int checkCount = 0; + + enum RetTypeKind { + SHORT("short"), + INT("int"), + OBJECT("Object"), + INTEGER("Integer"), + VOID("void"), + J_L_VOID("Void"); + + String retTypeStr; + + RetTypeKind(String retTypeStr) { + this.retTypeStr = retTypeStr; + } + + boolean moreSpecificThan(RetTypeKind rk) { + return moreSpecificThan[this.ordinal()][rk.ordinal()]; + } + + static boolean[][] moreSpecificThan = { + // SHORT | INT | OBJECT | INTEGER | VOID | J_L_VOID + /* SHORT */ { true , true , true , false , false , false }, + /* INT */ { false , true , true , true , false , false }, + /* OBJECT */ { false , false , true , false , false , false }, + /* INTEGER */ { false , false , true , true , false , false }, + /* VOID */ { false , false , false , false , true , true }, + /* J_L_VOID */{ false , false , true , false , false , true } }; + } + + enum ArgTypeKind { + SHORT("short"), + INT("int"), + BOOLEAN("boolean"), + OBJECT("Object"), + INTEGER("Integer"), + DOUBLE("Double"); + + String argTypeStr; + + ArgTypeKind(String typeStr) { + this.argTypeStr = typeStr; + } + } + + enum ExceptionKind { + NONE(""), + EXCEPTION("throws Exception"), + SQL_EXCEPTION("throws java.sql.SQLException"), + IO_EXCEPTION("throws java.io.IOException"); + + String exceptionStr; + + ExceptionKind(String exceptionStr) { + this.exceptionStr = exceptionStr; + } + } + + enum LambdaReturnKind { + VOID("return;"), + SHORT("return (short)0;"), + INT("return 0;"), + INTEGER("return (Integer)null"), + NULL("return null;"); + + String retStr; + + LambdaReturnKind(String retStr) { + this.retStr = retStr; + } + + boolean compatibleWith(RetTypeKind rk) { + return compatibleWith[rk.ordinal()][ordinal()]; + } + + static boolean[][] compatibleWith = { + // VOID | SHORT | INT | INTEGER | NULL + /* SHORT */ { false , true , false , false , false }, + /* INT */ { false , true , true , true , false }, + /* OBJECT */ { false , true , true , true , true }, + /* INTEGER */ { false , false , true , true , true }, + /* VOID */ { true , false , false , false , false }, + /* J_L_VOID */{ false , false , false , false , true } }; + + boolean needsConversion(RetTypeKind rk) { + return needsConversion[rk.ordinal()][ordinal()]; + } + + static boolean[][] needsConversion = { + // VOID | SHORT | INT | INTEGER | NULL + /* SHORT */ { false , false , false , false , false }, + /* INT */ { false , false , false , true , false }, + /* OBJECT */ { false , true , true , false , false }, + /* INTEGER */ { false , false , true , false , false }, + /* VOID */ { false , false , false , false , false }, + /* J_L_VOID */{ true , false , false , false , false } }; + } + + public static void main(String... args) throws Exception { + + //create default shared JavaCompiler - reused across multiple compilations + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + for (LambdaReturnKind lrk : LambdaReturnKind.values()) { + for (RetTypeKind rk1 : RetTypeKind.values()) { + for (RetTypeKind rk2 : RetTypeKind.values()) { + for (ExceptionKind ek1 : ExceptionKind.values()) { + for (ExceptionKind ek2 : ExceptionKind.values()) { + for (ArgTypeKind ak11 : ArgTypeKind.values()) { + for (ArgTypeKind ak12 : ArgTypeKind.values()) { + new StructuralMostSpecificTest(lrk, rk1, rk2, ek1, ek2, ak11, ak12).run(comp, fm); + } + } + } + } + } + } + } + System.out.println("Total check executed: " + checkCount); + } + + LambdaReturnKind lrk; + RetTypeKind rt1, rt2; + ArgTypeKind ak1, ak2; + ExceptionKind ek1, ek2; + JavaSource source; + DiagnosticChecker diagChecker; + + StructuralMostSpecificTest(LambdaReturnKind lrk, RetTypeKind rt1, RetTypeKind rt2, + ExceptionKind ek1, ExceptionKind ek2, ArgTypeKind ak1, ArgTypeKind ak2) { + this.lrk = lrk; + this.rt1 = rt1; + this.rt2 = rt2; + this.ek1 = ek1; + this.ek2 = ek2; + this.ak1 = ak1; + this.ak2 = ak2; + this.source = new JavaSource(); + this.diagChecker = new DiagnosticChecker(); + } + + class JavaSource extends SimpleJavaFileObject { + + String template = "interface SAM1 {\n" + + " #R1 m(#A1 a1) #E1;\n" + + "}\n" + + "interface SAM2 {\n" + + " #R2 m(#A2 a1) #E2;\n" + + "}\n" + + "class Test {\n" + + " void m(SAM1 s) { }\n" + + " void m(SAM2 s) { }\n" + + " { m(x->{ #LR }); }\n" + + "}\n"; + + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = template.replaceAll("#LR", lrk.retStr) + .replaceAll("#R1", rt1.retTypeStr) + .replaceAll("#R2", rt2.retTypeStr) + .replaceAll("#A1", ak1.argTypeStr) + .replaceAll("#A2", ak2.argTypeStr) + .replaceAll("#E1", ek1.exceptionStr) + .replaceAll("#E2", ek2.exceptionStr); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, + Arrays.asList("-XDverboseResolution=all,-predef,-internal,-object-init"), + null, Arrays.asList(source)); + try { + ct.analyze(); + } catch (Throwable ex) { + throw new AssertionError("Error thron when analyzing the following source:\n" + source.getCharContent(true)); + } + check(); + } + + void check() { + checkCount++; + + if (!lrk.compatibleWith(rt1) || !lrk.compatibleWith(rt2)) + return; + + if (lrk.needsConversion(rt1) != lrk.needsConversion(rt2)) + return; + + boolean m1MoreSpecific = moreSpecific(rt1, rt2, ek1, ek2, ak1, ak2); + boolean m2MoreSpecific = moreSpecific(rt2, rt1, ek2, ek1, ak2, ak1); + + boolean ambiguous = (m1MoreSpecific == m2MoreSpecific); + + if (ambiguous != diagChecker.ambiguityFound) { + throw new Error("invalid diagnostics for source:\n" + + source.getCharContent(true) + + "\nAmbiguity found: " + diagChecker.ambiguityFound + + "\nm1 more specific: " + m1MoreSpecific + + "\nm2 more specific: " + m2MoreSpecific + + "\nexpected ambiguity: " + ambiguous); + } + + if (!ambiguous) { + String sigToCheck = m1MoreSpecific ? "m(SAM1)" : "m(SAM2)"; + if (!sigToCheck.equals(diagChecker.mostSpecificSig)) { + throw new Error("invalid most specific method selected:\n" + + source.getCharContent(true) + + "\nMost specific found: " + diagChecker.mostSpecificSig + + "\nm1 more specific: " + m1MoreSpecific + + "\nm2 more specific: " + m2MoreSpecific); + } + } + } + + boolean moreSpecific(RetTypeKind rk1, RetTypeKind rk2, ExceptionKind ek1, ExceptionKind ek2, + ArgTypeKind ak1, ArgTypeKind ak2) { + if (!rk1.moreSpecificThan(rk2)) + return false; + + if (ak1 != ak2) + return false; + + return true; + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean ambiguityFound; + String mostSpecificSig; + + public void report(Diagnostic diagnostic) { + try { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR && + diagnostic.getCode().equals("compiler.err.ref.ambiguous")) { + ambiguityFound = true; + } else if (diagnostic.getKind() == Diagnostic.Kind.NOTE && + diagnostic.getCode().equals("compiler.note.verbose.resolve.multi")) { + ClientCodeWrapper.DiagnosticSourceUnwrapper dsu = + (ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic; + JCDiagnostic.MultilineDiagnostic mdiag = (JCDiagnostic.MultilineDiagnostic)dsu.d; + int mostSpecificIndex = (Integer)mdiag.getArgs()[2]; + mostSpecificSig = ((JCDiagnostic)mdiag.getSubdiagnostics().get(mostSpecificIndex)).getArgs()[1].toString(); + } + } catch (RuntimeException t) { + t.printStackTrace(); + throw t; + } + } + } +} diff --git a/langtools/test/tools/javac/diags/examples/CantAccessReturnTypeInFunctionalDesc.java b/langtools/test/tools/javac/lambda/speculative/A.java similarity index 79% rename from langtools/test/tools/javac/diags/examples/CantAccessReturnTypeInFunctionalDesc.java rename to langtools/test/tools/javac/lambda/speculative/A.java index 6a9ab5f6ae8..da3436ed130 100644 --- a/langtools/test/tools/javac/diags/examples/CantAccessReturnTypeInFunctionalDesc.java +++ b/langtools/test/tools/javac/lambda/speculative/A.java @@ -21,14 +21,6 @@ * questions. */ -// key: compiler.err.cant.access.return.in.functional.desc -// options: -XDallowLambda - -interface SAM_InaccessibleRet { - Foo.Bar m(); - static class Foo { private class Bar { } } -} - -class CantAccessReturnTypeInFunctionalDesc { - SAM_InaccessibleRet s = ()->null; +public class A { + public A(NonExistentClass nec) {} } diff --git a/langtools/test/tools/javac/diags/examples/CantAccessArgTypeInFunctionalDesc.java b/langtools/test/tools/javac/lambda/speculative/DiamondFinder.java similarity index 77% rename from langtools/test/tools/javac/diags/examples/CantAccessArgTypeInFunctionalDesc.java rename to langtools/test/tools/javac/lambda/speculative/DiamondFinder.java index 7a7a65b8ed7..35f56afaacb 100644 --- a/langtools/test/tools/javac/diags/examples/CantAccessArgTypeInFunctionalDesc.java +++ b/langtools/test/tools/javac/lambda/speculative/DiamondFinder.java @@ -21,15 +21,15 @@ * questions. */ -// key: compiler.err.cant.access.arg.type.in.functional.desc -// key: compiler.err.report.access -// options: -XDallowLambda +/* + * @test + * @bug 8003280 + * @summary Add lambda tests + * spurious crashes when running in 'diamond finder' mode + * @compile -XDfindDiamond DiamondFinder.java + */ +import java.util.*; -interface SAM_InaccessibleArg { - void m(Foo.Bar bar); - static class Foo { private class Bar { } } -} - -class CantAccessArgTypeInFunctionalDesc { - SAM_InaccessibleArg s = x-> { }; +class DiamondFinder { + Collection f = new HashSet(Arrays.asList("a")); } diff --git a/langtools/test/tools/javac/lambda/speculative/Main.java b/langtools/test/tools/javac/lambda/speculative/Main.java new file mode 100644 index 00000000000..cf379494aba --- /dev/null +++ b/langtools/test/tools/javac/lambda/speculative/Main.java @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * On-demand symbol completion during speculative attribution round fails to report error messages + * @compile/fail/ref=Main.out -XDrawDiagnostics Main.java + */ +class Main { + void test() { + m(new A(new Object())); + m(new A(null)); + } + + void m(Object o) {} +} diff --git a/langtools/test/tools/javac/lambda/speculative/Main.out b/langtools/test/tools/javac/lambda/speculative/Main.out new file mode 100644 index 00000000000..91348ae9906 --- /dev/null +++ b/langtools/test/tools/javac/lambda/speculative/Main.out @@ -0,0 +1,2 @@ +A.java:25:14: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, A, null) +1 error diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest11.java b/langtools/test/tools/javac/lambda/typeInference/InferenceTest11.java new file mode 100644 index 00000000000..402b1c11fd4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest11.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * This test is for self referential and recursive lambda expression that have type inference + * @compile InferenceTest11.java + * @run main InferenceTest11 + */ + +public class InferenceTest11 { + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + static Func f1; + static Func f2; + + public static void main(String[] args) { + + f1 = n -> { + if(n <= 0) + return 0; + if(n == 1) + return 1; + return f1.m(n-1) + f1.m(n-2); + }; + assertTrue(f1.m(-1) == 0); + assertTrue(f1.m(0) == 0); + assertTrue(f1.m(10) == 55); + + f2 = n -> { + if(n <= 1) + return 1.0; + return 2 * (Double)f2.m(n-1) + 1; + }; + assertTrue(f2.m(4).doubleValue() == 15.0); + } + + interface Func { + V m(T t); + } +} diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest2.java b/langtools/test/tools/javac/lambda/typeInference/InferenceTest2.java new file mode 100644 index 00000000000..6fe90b99d23 --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest2.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; +import java.io.Serializable; +import java.io.File; + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Parameter types inferred from target type in generics without wildcard + * @compile InferenceTest2.java + * @run main InferenceTest2 + */ + +public class InferenceTest2 { + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + public static void main(String[] args) { + + InferenceTest2 test = new InferenceTest2(); + + //test SAM1 + SAM1 sam1 = para -> { String result = ""; + for(String s : para) + if(s.compareTo(result) > 0) + result = s; + return result; }; + List list = Arrays.asList("a", "b", "c"); + assertTrue(sam1.m1(list).equals("c")); + + test.method1(para -> para.get(0)); + + //test SAM2 + SAM2 sam2 = para -> {para = para.substring(0);}; + SAM2 sam2_2 = para -> {}; + SAM2 sam2_3 = para -> { if(para.isDirectory()) + System.out.println("directory"); + }; + + //test SAM3 + SAM3 sam3 = para -> para[0].substring(0, para[0].length()-1); + assertTrue(sam3.m3("hello+").equals("hello")); + + SAM3 sam3_2 = para -> para[0] - para[1]; + assertTrue(sam3_2.m3(1, -1) == 2); + + SAM3 sam3_3 = para -> para[0] + para[1] + para[2] + para[3]; + assertTrue(sam3_3.m3(1.0, 2.0, 3.0, 4.0) == 10.0); + + test.method3(para -> para[0] + 1); + + //test SAM6 + SAM6 sam6 = (para1, para2) -> para1.concat(para2); + assertTrue(sam6.m6("hello", "world").equals("helloworld")); + + test.method6((para1, para2) -> para1 >= para2? para1 : para2); + } + + void method1(SAM1 sam1) { + List list = Arrays.asList(3,2,1); + assertTrue(sam1.m1(list) == 3); + } + + void method3(SAM3 sam3) { + assertTrue(sam3.m3(2.5) == 3.5); + } + + void method6(SAM6 sam6) { + assertTrue(sam6.m6(5L, -5L) == 5); + } + + interface SAM1 { + T m1(List x); + } + + interface SAM2 { + void m2(T x); + } + + interface SAM3 { + T m3(T... x); + } + + interface SAM6 { + T m6(T a, T b); + } +} diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest2b.java b/langtools/test/tools/javac/lambda/typeInference/InferenceTest2b.java new file mode 100644 index 00000000000..8ab215afbdb --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest2b.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.*; + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Parameter types inferred from target type in generics with wildcard + * @compile InferenceTest2b.java + * @run main InferenceTest2b + */ + +public class InferenceTest2b { + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + public static void main(String[] args) { + + InferenceTest2b test = new InferenceTest2b(); + + test.m1((a, b) -> {return a;}); + test.m2((a, b) -> {return a;}); + test.m3((a, b) -> a); + } + + interface SAM6 { + T m6(T a, T b); + } + + void m1(SAM6> s) { + System.out.println("m1()"); + Stack a = new Stack(); + ArrayList b = new ArrayList(); + assertTrue(s.m6(a, b) == a); + + Vector c = null; + assertTrue(s.m6(c, b) == c); + } + + void m2(SAM6 s) { + System.out.println("m2()"); + assertTrue(s.m6(1, 2) == 1); + } + + void m3(SAM6 s) { + System.out.println("m3()"); + Calendar gc = Calendar.getInstance(); + GregorianCalendar gc2 = new GregorianCalendar(); + assertTrue(s.m6(gc, gc2) == gc); + } +} diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest3.java b/langtools/test/tools/javac/lambda/typeInference/InferenceTest3.java new file mode 100644 index 00000000000..b5ea9b6235d --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest3.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * Interface inheritance, sub-interface resolves the type of the super interface. + * @compile InferenceTest3.java + * @run main InferenceTest3 + */ + +import java.io.File; +import java.io.Serializable; +import java.util.Date; +import java.util.Calendar; +import java.util.TimeZone; + +public class InferenceTest3 { + + private static void assertTrue(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + public static void main(String[] args) { + InferenceTest3 test = new InferenceTest3(); + test.m1(a -> a.getTime()); + test.m2(a -> a.toString()); + + C c = a -> a.length(); + assertTrue(c.m("lambda") == 6); + + E e = a -> Double.toHexString(a); + assertTrue(e.m(Double.MAX_VALUE).equals("0x1.fffffffffffffp1023")); + assertTrue(e.m(Double.MIN_VALUE).equals("0x0.0000000000001p-1022")); + assertTrue(e.m(1.0).equals("0x1.0p0")); + } + + private void m1(C c) { + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + cal.set(1970, 0, 1, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + Date date = cal.getTime(); + assertTrue(c.m(date) == 0L); + } + + private void m2(E e) { + assertTrue(e.m(2).equals("2")); + } + + interface A { + U m(T t); + } + + interface C extends A {} + + interface E extends A {} +} diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest4.java b/langtools/test/tools/javac/lambda/typeInference/InferenceTest4.java new file mode 100644 index 00000000000..477f5785450 --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest4.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * This test is for generic methods whose type is the same as the type + of the generic SAM interface that is taken as the parameter of the + generic method; the type can be inferred from the value of the other + type arguments + * @compile InferenceTest4.java + * @run main InferenceTest4 + */ + +import java.util.List; +import java.util.ArrayList; + +public class InferenceTest4 { + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + public static void main(String[] args) { + InferenceTest4 test = new InferenceTest4(); + test.method1(n -> n.size(), "abc", "java.lang.String"); + test.method1(n -> n.size(), 'c', "java.lang.Character"); + test.method1(n -> n.size(), 0, "java.lang.Integer"); + test.method1(n -> n.size(), 0.1, "java.lang.Double"); + test.method1(n -> n.size(), 0.1f, "java.lang.Float"); + test.method1(n -> n.size(), 0L, "java.lang.Long"); + test.method1(n -> n.size(), (short)0, "java.lang.Short"); + test.method1(n -> n.size(), (byte)0, "java.lang.Byte"); + test.method1(n -> n.size(), true, "java.lang.Boolean"); + test.method1(n -> n.size(), new int[]{1, 2, 3}, "[I"); + test.method1(n -> n.size(), new double[]{1.0}, "[D"); + test.method1(n -> n.size(), new String[]{}, "[Ljava.lang.String;"); + } + + void method1(SAM1 s, T t, String className) { + List list = new ArrayList(); + System.out.println(className + "-" + t.getClass().getName()); + assertTrue(t.getClass().getName().equals(className)); + list.add(t); + assertTrue(s.m1(list) == 1); + } + + interface SAM1 { + int m1(List x); + } +} diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest5.java b/langtools/test/tools/javac/lambda/typeInference/InferenceTest5.java new file mode 100644 index 00000000000..291068070a4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest5.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * This test is for overloaded methods, verify that the specific method is + selected when type inference occurs + * @compile InferenceTest5.java + * @run main InferenceTest5 + */ + +import java.util.List; +import java.io.File; + +public class InferenceTest5 { + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + public static void main(String[] args) { + InferenceTest5 test = new InferenceTest5(); + int n = test.method1((a, b) -> {} ); + assertTrue(n == 1); + + n = test.method1(() -> null); + assertTrue(n == 2); + + n = test.method1(a -> null); + assertTrue(n == 3); + + n = test.method1(a -> {}); + assertTrue(n == 4); + + n = test.method1(() -> {}); + assertTrue(n == 5); + + n = test.method1((a, b) -> 0); + assertTrue(n == 6); + + n = test.method1((a, b) -> null); + assertTrue(n == 6); + + n = test.method1((a, b) -> null, (a, b) -> null); + assertTrue(n == 7); + } + + int method1(SAM1 s) { + return 1; + } + + int method1(SAM2 s) { + return 2; + } + + int method1(SAM3 s) { + return 3; + } + + int method1(SAM4 s) { + return 4; + } + + int method1(SAM5 s) { + return 5; + } + + int method1(SAM6 s) { + return 6; + } + + int method1(SAM6... s) { + return 7; + } + + static interface SAM1 { + void foo(List a, List b); + } + + static interface SAM2 { + List foo(); + } + + static interface SAM3 { + String foo(int a); + } + + static interface SAM4 { + void foo(List a); + } + + static interface SAM5 { + void foo(); + } + + static interface SAM6 { + V get(T t, T t2); + } +} diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest789.java b/langtools/test/tools/javac/lambda/typeInference/InferenceTest789.java new file mode 100644 index 00000000000..6bc00167d17 --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest789.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.Serializable; +import java.util.Calendar; + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * This test is for when lambda return type is inferred from target type + * @compile InferenceTest789.java + * @run main InferenceTest789 + */ + +public class InferenceTest789 { + + private static void assertTrue(boolean b) { + if(!b) + throw new AssertionError(); + } + + public static void main(String[] args) { + InferenceTest789 test = new InferenceTest789(); + test.method1(() -> 1); + SAM1 sam1 = () -> 1.0; + SAM1 sam1_2 = () -> "a"; + SAM1> sam1_3 = () -> Calendar.getInstance(); + SAM1 sam1_4 = () -> 1.5f; + + SAM2 sam2 = a -> 1; + SAM2 sam2_2 = a -> 1; + } + + void method1(SAM1 s) { + System.out.println("s.m1()=" + s.m1() + " s.m1().getClass()=" + s.m1().getClass()); + assertTrue(s.m1().equals(new Integer(1))); + } + + interface SAM1 { + T m1(); + } + + interface SAM2 { + T m2(T t); + } +} diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.java b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.java new file mode 100644 index 00000000000..3d77c95fd5a --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.java @@ -0,0 +1,58 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Overloaded methods take raw SAM types that have type inference according to SAM descriptor + should have ambiguous resolution of method + * @compile/fail/ref=InferenceTest_neg1_2.out -XDrawDiagnostics InferenceTest_neg1_2.java + */ + +public class InferenceTest_neg1_2 { + + public static void main(String[] args) { + InferenceTest_neg1_2 test = new InferenceTest_neg1_2(); + test.method(n -> null); //method 1-5 all match + test.method(n -> "a"); //method 2, 4 match + test.method(n -> 0); //method 1, 3, 5 match + } + + void method(SAM1 s) { //method 1 + Integer i = s.foo("a"); + } + + void method(SAM2 s) { //method 2 + String str = s.foo(0); + } + + void method(SAM3 s) { //method 3 + Integer i = s.get(0); + } + + void method(SAM4 s) { //method 4 + String str = s.get(0.0); + } + + void method(SAM5 s) { //method 5 + Integer i = s.get(0.0); + } + + interface SAM1 { + Integer foo(String a); + } + + interface SAM2 { + String foo(Integer a); + } + + interface SAM3 { + T get(T t); + } + + interface SAM4 { + V get(T t); + } + + interface SAM5 { + T get(Double i); + } +} diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out new file mode 100644 index 00000000000..cf0d1d587bf --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out @@ -0,0 +1,4 @@ +InferenceTest_neg1_2.java:14:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM4), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5), InferenceTest_neg1_2 +InferenceTest_neg1_2.java:15:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM2), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM4), InferenceTest_neg1_2 +InferenceTest_neg1_2.java:16:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM3), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5), InferenceTest_neg1_2 +3 errors diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java new file mode 100644 index 00000000000..d5f757e1379 --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java @@ -0,0 +1,26 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8003280 + * @summary Add lambda tests + * Missing cast to SAM type that causes type inference to not work. + * @compile/fail/ref=InferenceTest_neg5.out -XDrawDiagnostics InferenceTest_neg5.java + */ + +import java.util.*; + +public class InferenceTest_neg5 { + public static void main(String[] args) { + InferenceTest_neg5 test = new InferenceTest_neg5(); + test.method1(n -> {}); + test.method1((SAM1)n -> {}); + test.method1((SAM1)n -> {n++;}); + test.method1((SAM1>)n -> {List list = Arrays.asList("string1", "string2"); Collections.sort(list,n);}); + test.method1((SAM1)n -> {n.start();}); + } + + interface SAM1 { + void m1(X arg); + } + + void method1(SAM1 s) {} +} diff --git a/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out new file mode 100644 index 00000000000..83b93f0e098 --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out @@ -0,0 +1,2 @@ +InferenceTest_neg5.java:14:13: compiler.err.cant.apply.symbol: kindname.method, method1, InferenceTest_neg5.SAM1, @419, kindname.class, InferenceTest_neg5, (compiler.misc.cyclic.inference: X) +1 error diff --git a/langtools/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java b/langtools/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java new file mode 100644 index 00000000000..7de9276f1b0 --- /dev/null +++ b/langtools/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java @@ -0,0 +1,338 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003280 + * @summary Add lambda tests + * perform automated checks in type inference in lambda expressions in different contexts + * @compile TypeInferenceComboTest.java + * @run main/timeout=360 TypeInferenceComboTest + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; +import javax.tools.StandardJavaFileManager; + +public class TypeInferenceComboTest { + enum Context { + ASSIGNMENT("SAM#Type s = #LBody;"), + METHOD_CALL("#GenericDeclKind void method1(SAM#Type s) { }\n" + + "void method2() {\n" + + " method1(#LBody);\n" + + "}"), + RETURN_OF_METHOD("SAM#Type method1() {\n" + + " return #LBody;\n" + + "}"), + LAMBDA_RETURN_EXPRESSION("SAM2 s2 = () -> {return (SAM#Type)#LBody;};\n"), + ARRAY_INITIALIZER("Object[] oarray = {\"a\", 1, (SAM#Type)#LBody};"); + + String context; + + Context(String context) { + this.context = context; + } + + String getContext(SamKind sk, TypeKind samTargetT, Keyword kw, TypeKind parameterT, TypeKind returnT, LambdaKind lk, ParameterKind pk, GenericDeclKind gdk, LambdaBody lb) { + String result = context; + if (sk == SamKind.GENERIC) { + if(this == Context.METHOD_CALL) { + result = result.replaceAll("#GenericDeclKind", gdk.getGenericDeclKind(samTargetT)); + if(gdk == GenericDeclKind.NON_GENERIC) + result = result.replaceAll("#Type", "<" + samTargetT.typeStr + ">"); + else //#GenericDeclKind is or + result = result.replaceAll("#Type", ""); + } + else { + if(kw == Keyword.VOID) + result = result.replaceAll("#Type", "<" + samTargetT.typeStr + ">"); + else + result = result.replaceAll("#Type", ""); + } + } + else + result = result.replaceAll("#Type", "").replaceAll("#GenericDeclKind", ""); + + return result.replaceAll("#LBody", lb.getLambdaBody(samTargetT, parameterT, returnT, lk, pk)); + } + } + + enum SamKind { + GENERIC("interface SAM { #R m(#ARG); }"), + NON_GENERIC("interface SAM { #R m(#ARG); }"); + + String sam_str; + + SamKind(String sam_str) { + this.sam_str = sam_str; + } + + String getSam(TypeKind parameterT, TypeKind returnT) { + return sam_str.replaceAll("#ARG", parameterT == TypeKind.VOID ? "" : parameterT.typeStr + " arg") + .replaceAll("#R", returnT.typeStr); + } + } + + enum TypeKind { + VOID("void", ""), + STRING("String", "\"hello\""), + INTEGER("Integer", "1"), + INT("int", "0"), + COMPARATOR("java.util.Comparator", "(java.util.Comparator)(a, b) -> a.length()-b.length()"), + SAM("SAM2", "null"), + GENERIC("T", null); + + String typeStr; + String valStr; + + TypeKind(String typeStr, String valStr) { + this.typeStr = typeStr; + this.valStr = valStr; + } + } + + enum LambdaKind { + EXPRESSION("#VAL"), + STATEMENT("{return #VAL;}"); + + String stmt; + + LambdaKind(String stmt) { + this.stmt = stmt; + } + } + + enum ParameterKind { + EXPLICIT("#TYPE"), + IMPLICIT(""); + + String paramTemplate; + + ParameterKind(String paramTemplate) { + this.paramTemplate = paramTemplate; + } + } + + enum Keyword { + SUPER("super"), + EXTENDS("extends"), + VOID(""); + + String keyStr; + + Keyword(String keyStr) { + this.keyStr = keyStr; + } + } + + enum LambdaBody { + RETURN_VOID("() -> #RET"),//no parameters, return type is one of the TypeKind + RETURN_ARG("(#PK arg) -> #RET");//has parameters, return type is one of the TypeKind + + String bodyStr; + + LambdaBody(String bodyStr) { + this.bodyStr = bodyStr; + } + + String getLambdaBody(TypeKind samTargetT, TypeKind parameterT, TypeKind returnT, LambdaKind lk, ParameterKind pk) { + String result = bodyStr.replaceAll("#PK", pk.paramTemplate); + + if(result.contains("#TYPE")) { + if (parameterT == TypeKind.GENERIC && this != RETURN_VOID) + result = result.replaceAll("#TYPE", samTargetT == null? "": samTargetT.typeStr); + else + result = result.replaceAll("#TYPE", parameterT.typeStr); + } + if (this == RETURN_ARG && parameterT == returnT) + return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", "arg")); + else { + if(returnT != TypeKind.GENERIC) + return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", (returnT==TypeKind.VOID && lk==LambdaKind.EXPRESSION)? "{}" : returnT.valStr)); + else + return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", samTargetT.valStr)); + } + } + } + + enum GenericDeclKind { + NON_GENERIC(""), + GENERIC_NOBOUND(""), + GENERIC_BOUND(""); + String typeStr; + + GenericDeclKind(String typeStr) { + this.typeStr = typeStr; + } + + String getGenericDeclKind(TypeKind et) { + return typeStr.replaceAll("#ExtendedType", et==null? "":et.typeStr); + } + } + + boolean checkTypeInference() { + if (parameterType == TypeKind.VOID) { + if (lambdaBodyType != LambdaBody.RETURN_VOID) + return false; + } + else if (lambdaBodyType != LambdaBody.RETURN_ARG) + return false; + if ( genericDeclKind == GenericDeclKind.GENERIC_NOBOUND || genericDeclKind == GenericDeclKind.GENERIC_BOUND ) { + if ( parameterType == TypeKind.GENERIC && parameterKind == ParameterKind.IMPLICIT) //cyclic inference + return false; + } + return true; + } + + String templateStr = "#C\n" + + "interface SAM2 {\n" + + " SAM m();\n" + + "}\n"; + SourceFile samSourceFile = new SourceFile("Sam.java", templateStr) { + public String toString() { + return template.replaceAll("#C", samKind.getSam(parameterType, returnType)); + } + }; + + SourceFile clientSourceFile = new SourceFile("Client.java", + "class Client { \n" + + " #Context\n" + + "}") { + public String toString() { + return template.replaceAll("#Context", context.getContext(samKind, samTargetType, keyword, parameterType, returnType, lambdaKind, parameterKind, genericDeclKind, lambdaBodyType)); + } + }; + + void test() throws Exception { + System.out.println("kk:"); + StringBuilder sb = new StringBuilder("SamKind:"); + sb.append(samKind).append(" SamTargetType:").append(samTargetType).append(" ParameterType:").append(parameterType) + .append(" ReturnType:").append(returnType).append(" Context:").append(context).append(" LambdaKind:").append(lambdaKind) + .append(" LambdaBodyType:").append(lambdaBodyType).append(" ParameterKind:").append(parameterKind).append(" Keyword:").append(keyword); + System.out.println(sb); + DiagnosticChecker dc = new DiagnosticChecker(); + JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile)); + ct.analyze(); + if (dc.errorFound == checkTypeInference()) { + throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile + "\n" + parameterType + " " + returnType); + } + } + + abstract class SourceFile extends SimpleJavaFileObject { + + protected String template; + + public SourceFile(String filename, String template) { + super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE); + this.template = template; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return toString(); + } + + public abstract String toString(); + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound = false; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } + + SamKind samKind; + TypeKind samTargetType; + TypeKind parameterType; + TypeKind returnType; + Context context; + LambdaBody lambdaBodyType; + LambdaKind lambdaKind; + ParameterKind parameterKind; + Keyword keyword; + GenericDeclKind genericDeclKind; + + static JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + TypeInferenceComboTest(SamKind sk, TypeKind samTargetT, TypeKind parameterT, TypeKind returnT, LambdaBody lb, Context c, LambdaKind lk, ParameterKind pk, Keyword kw, GenericDeclKind gdk) { + samKind = sk; + samTargetType = samTargetT; + parameterType = parameterT; + returnType = returnT; + context = c; + lambdaKind = lk; + parameterKind = pk; + keyword = kw; + lambdaBodyType = lb; + genericDeclKind = gdk; + } + + public static void main(String[] args) throws Exception { + for(Context ct : Context.values()) { + for (TypeKind returnT : TypeKind.values()) { + for (TypeKind parameterT : TypeKind.values()) { + for(LambdaBody lb : LambdaBody.values()) { + for (ParameterKind parameterK : ParameterKind.values()) { + for(LambdaKind lambdaK : LambdaKind.values()) { + for (SamKind sk : SamKind.values()) { + if (sk == SamKind.NON_GENERIC) { + if(parameterT != TypeKind.GENERIC && returnT != TypeKind.GENERIC ) + new TypeInferenceComboTest(sk, null, parameterT, returnT, lb, ct, lambdaK, parameterK, null, null).test(); + } + else if (sk == SamKind.GENERIC) { + for (Keyword kw : Keyword.values()) { + for (TypeKind samTargetT : TypeKind.values()) { + if(samTargetT != TypeKind.VOID && samTargetT != TypeKind.INT && samTargetT != TypeKind.GENERIC + && (parameterT == TypeKind.GENERIC || returnT == TypeKind.GENERIC)) { + if(ct != Context.METHOD_CALL) { + new TypeInferenceComboTest(sk, samTargetT, parameterT, returnT, lb, ct, lambdaK, parameterK, kw, null).test(); + } + else {//Context.METHOD_CALL + for (GenericDeclKind gdk : GenericDeclKind.values()) + new TypeInferenceComboTest(sk, samTargetT, parameterT, returnT, lb, ct, lambdaK, parameterK, kw, gdk).test(); + } + } + } + } + } + } + } + } + } + } + } + } + } +} diff --git a/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out index 6204b0e6419..eecd7f7e638 100644 --- a/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out +++ b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out @@ -10,7 +10,6 @@ BasicTest.java:52:22: compiler.err.illegal.start.of.expr BasicTest.java:52:31: compiler.err.expected: ';' BasicTest.java:52:37: compiler.err.expected: token.identifier BasicTest.java:53:30: compiler.err.expected: token.identifier -BasicTest.java:53:32: compiler.err.lambda.not.supported.in.source: 1.8 BasicTest.java:53:31: compiler.err.expected: -> BasicTest.java:56:23: compiler.err.expected: token.identifier BasicTest.java:56:24: compiler.err.expected2: '(', '[' @@ -59,4 +58,4 @@ BasicTest.java:74:24: compiler.err.expected: ';' BasicTest.java:74:25: compiler.err.illegal.start.of.type BasicTest.java:74:33: compiler.err.expected: ';' BasicTest.java:77:2: compiler.err.premature.eof -61 errors +60 errors From 5a30b6af0cb354629120e3b0263984d42aeb255c Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 19 Nov 2012 11:38:49 -0800 Subject: [PATCH 39/94] 8001098: Provide a simple light-weight "plug-in" mechanism for javac Reviewed-by: mcimadamore --- .../classes/com/sun/source/util/Plugin.java | 64 +++++++ .../classes/com/sun/source/util/Trees.java | 4 +- .../sun/tools/javac/api/BasicJavacTask.java | 8 + .../sun/tools/javac/api/JavacTaskImpl.java | 16 -- .../com/sun/tools/javac/api/JavacTrees.java | 4 +- .../sun/tools/javac/main/JavaCompiler.java | 3 +- .../com/sun/tools/javac/main/Main.java | 61 ++++++- .../com/sun/tools/javac/main/Option.java | 10 + .../JavacProcessingEnvironment.java | 61 +++++-- .../tools/javac/resources/javac.properties | 10 + .../javac/plugin/showtype/Identifiers.java | 7 + .../javac/plugin/showtype/Identifiers.out | 21 +++ .../javac/plugin/showtype/Identifiers_PI.out | 6 + .../javac/plugin/showtype/ShowTypePlugin.java | 106 +++++++++++ .../tools/javac/plugin/showtype/Test.java | 171 ++++++++++++++++++ 15 files changed, 509 insertions(+), 43 deletions(-) create mode 100644 langtools/src/share/classes/com/sun/source/util/Plugin.java create mode 100644 langtools/test/tools/javac/plugin/showtype/Identifiers.java create mode 100644 langtools/test/tools/javac/plugin/showtype/Identifiers.out create mode 100644 langtools/test/tools/javac/plugin/showtype/Identifiers_PI.out create mode 100644 langtools/test/tools/javac/plugin/showtype/ShowTypePlugin.java create mode 100644 langtools/test/tools/javac/plugin/showtype/Test.java diff --git a/langtools/src/share/classes/com/sun/source/util/Plugin.java b/langtools/src/share/classes/com/sun/source/util/Plugin.java new file mode 100644 index 00000000000..66886aa8dec --- /dev/null +++ b/langtools/src/share/classes/com/sun/source/util/Plugin.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.source.util; + +import java.util.ServiceLoader; +import javax.tools.StandardLocation; + +/** + * The interface for a javac plug-in. + * + *

The javac plug-in mechanism allows a user to specify one or more plug-ins + * on the javac command line, to be started soon after the compilation + * has begun. Plug-ins are identified by a user-friendly name. Each plug-in that + * is started will be passed an array of strings, which may be used to + * provide the plug-in with values for any desired options or other arguments. + * + *

Plug-ins are located via a {@link ServiceLoader}, + * using the same class path as annotation processors (i.e. + * {@link StandardLocation#PROCESSOR_PATH PROCESSOR_PATH} or + * {@code -processorpath}). + * + *

It is expected that a typical plug-in will simply register a + * {@link TaskListener} to be informed of events during the execution + * of the compilation, and that the rest of the work will be done + * by the task listener. + * + * @since 1.8 + */ +public interface Plugin { + /** + * Get the user-friendly name of this plug-in. + * @return the user-friendly name of the plug-in + */ + String getName(); + + /** + * Invoke the plug-in for a given compilation task. + * @param task The compilation task that has just been started + * @param args Arguments, if any, for the plug-in + */ + void call(JavacTask task, String... args); +} diff --git a/langtools/src/share/classes/com/sun/source/util/Trees.java b/langtools/src/share/classes/com/sun/source/util/Trees.java index 139066ebbd7..7ee8b291b94 100644 --- a/langtools/src/share/classes/com/sun/source/util/Trees.java +++ b/langtools/src/share/classes/com/sun/source/util/Trees.java @@ -58,7 +58,9 @@ public abstract class Trees { * @throws IllegalArgumentException if the task does not support the Trees API. */ public static Trees instance(CompilationTask task) { - if (!task.getClass().getName().equals("com.sun.tools.javac.api.JavacTaskImpl")) + String taskClassName = task.getClass().getName(); + if (!taskClassName.equals("com.sun.tools.javac.api.JavacTaskImpl") + && !taskClassName.equals("com.sun.tools.javac.api.BasicJavacTask")) throw new IllegalArgumentException(); return getJavacTrees(CompilationTask.class, task); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java b/langtools/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java index e485804e124..38cff74c8ca 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java @@ -136,6 +136,14 @@ public class BasicJavacTask extends JavacTask { throw new IllegalStateException(); } + /** + * For internal use only. This method will be + * removed without warning. + */ + public Context getContext() { + return context; + } + /** * For internal use only. This method will be * removed without warning. diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java index fbb22ff2d73..4cc7075f310 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java @@ -485,22 +485,6 @@ public class JavacTaskImpl extends BasicJavacTask { abstract void process(Env env); } - /** - * For internal use only. This method will be - * removed without warning. - */ - public Context getContext() { - return context; - } - - /** - * For internal use only. This method will be - * removed without warning. - */ - public void updateContext(Context newContext) { - context = newContext; - } - /** * For internal use only. This method will be * removed without warning. diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java index 13fa76c8d08..8a7db1f181c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -121,9 +121,9 @@ public class JavacTrees extends DocTrees { // called reflectively from Trees.instance(CompilationTask task) public static JavacTrees instance(JavaCompiler.CompilationTask task) { - if (!(task instanceof JavacTaskImpl)) + if (!(task instanceof BasicJavacTask)) throw new IllegalArgumentException(); - return instance(((JavacTaskImpl)task).getContext()); + return instance(((BasicJavacTask)task).getContext()); } // called reflectively from Trees.instance(ProcessingEnvironment env) diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java index 1003436fa65..3181727e45a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -1040,7 +1040,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter { if (options.isSet(PROC, "none")) { processAnnotations = false; } else if (procEnvImpl == null) { - procEnvImpl = new JavacProcessingEnvironment(context, processors); + procEnvImpl = JavacProcessingEnvironment.instance(context); + procEnvImpl.setProcessors(processors); processAnnotations = procEnvImpl.atLeastOneProcessor(); if (processAnnotations) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java index 64d9d67e60f..f23b196f716 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java @@ -33,24 +33,29 @@ import java.security.DigestInputStream; import java.security.MessageDigest; import java.util.Arrays; import java.util.Collection; +import java.util.Iterator; import java.util.LinkedHashSet; +import java.util.ServiceLoader; import java.util.Set; + +import javax.annotation.processing.Processor; import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; -import javax.annotation.processing.Processor; +import com.sun.source.util.JavacTask; +import com.sun.source.util.Plugin; import com.sun.tools.javac.code.Source; import com.sun.tools.javac.file.CacheFSInfo; import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.jvm.Target; -import com.sun.tools.javac.util.*; -import com.sun.tools.javac.util.Log.WriterKind; -import com.sun.tools.javac.util.Log.PrefixKind; import com.sun.tools.javac.processing.AnnotationProcessingError; - +import com.sun.tools.javac.processing.JavacProcessingEnvironment; +import com.sun.tools.javac.util.*; +import com.sun.tools.javac.util.Log.PrefixKind; +import com.sun.tools.javac.util.Log.WriterKind; import static com.sun.tools.javac.main.Option.*; -/** This class provides a commandline interface to the GJC compiler. +/** This class provides a command line interface to the javac compiler. * *

This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. @@ -423,6 +428,42 @@ public class Main { if (batchMode) CacheFSInfo.preRegister(context); + // invoke any available plugins + String plugins = options.get(PLUGIN); + if (plugins != null) { + JavacProcessingEnvironment pEnv = JavacProcessingEnvironment.instance(context); + ClassLoader cl = pEnv.getProcessorClassLoader(); + ServiceLoader sl = ServiceLoader.load(Plugin.class, cl); + Set> pluginsToCall = new LinkedHashSet>(); + for (String plugin: plugins.split("\\x00")) { + pluginsToCall.add(List.from(plugin.split("\\s+"))); + } + JavacTask task = null; + Iterator iter = sl.iterator(); + while (iter.hasNext()) { + Plugin plugin = iter.next(); + for (List p: pluginsToCall) { + if (plugin.getName().equals(p.head)) { + pluginsToCall.remove(p); + try { + if (task == null) + task = JavacTask.instance(pEnv); + plugin.call(task, p.tail.toArray(new String[p.tail.size()])); + } catch (Throwable ex) { + if (apiMode) + throw new RuntimeException(ex); + pluginMessage(ex); + return Result.SYSERR; + } + + } + } + } + for (List p: pluginsToCall) { + log.printLines(PrefixKind.JAVAC, "msg.plugin.not.found", p.head); + } + } + fileManager = context.get(JavaFileManager.class); comp = JavaCompiler.instance(context); @@ -537,6 +578,14 @@ public class Main { ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE)); } + /** Print a message reporting an uncaught exception from an + * annotation processor. + */ + void pluginMessage(Throwable ex) { + log.printLines(PrefixKind.JAVAC, "msg.plugin.uncaught.exception"); + ex.printStackTrace(log.getWriter(WriterKind.NOTICE)); + } + /** Display the location and checksum of a class. */ void showClass(String className) { PrintWriter pw = log.getWriter(WriterKind.NOTICE); diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/Option.java b/langtools/src/share/classes/com/sun/tools/javac/main/Option.java index d90010d0fc8..8a44ac4345c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/Option.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/Option.java @@ -393,6 +393,16 @@ public enum Option { /* -Xjcov produces tables to support the code coverage tool jcov. */ XJCOV("-Xjcov", null, HIDDEN, BASIC), + PLUGIN("-Xplugin:", "opt.arg.plugin", "opt.plugin", EXTENDED, BASIC) { + @Override + public boolean process(OptionHelper helper, String option) { + String p = option.substring(option.indexOf(':') + 1); + String prev = helper.get(PLUGIN); + helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p.trim()); + return false; + } + }, + /* This is a back door to the compiler's option table. * -XDx=y sets the option x to the value y. * -XDx sets the option x to the value x. diff --git a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index a3e0e26272f..061d571478c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -145,6 +145,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea Source source; private ClassLoader processorClassLoader; + private SecurityException processorClassLoaderException; /** * JavacMessages object used for localization @@ -155,7 +156,15 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea private Context context; - public JavacProcessingEnvironment(Context context, Iterable processors) { + /** Get the JavacProcessingEnvironment instance for this context. */ + public static JavacProcessingEnvironment instance(Context context) { + JavacProcessingEnvironment instance = context.get(JavacProcessingEnvironment.class); + if (instance == null) + instance = new JavacProcessingEnvironment(context); + return instance; + } + + protected JavacProcessingEnvironment(Context context) { this.context = context; log = Log.instance(context); source = Source.instance(context); @@ -184,6 +193,11 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea unmatchedProcessorOptions = initUnmatchedProcessorOptions(); messages = JavacMessages.instance(context); taskListener = MultiTaskListener.instance(context); + initProcessorClassLoader(); + } + + public void setProcessors(Iterable processors) { + Assert.checkNull(discoveredProcs); initProcessorIterator(context, processors); } @@ -199,6 +213,23 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea return Collections.unmodifiableSet(platformAnnotations); } + private void initProcessorClassLoader() { + JavaFileManager fileManager = context.get(JavaFileManager.class); + try { + // If processorpath is not explicitly set, use the classpath. + processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH) + ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH) + : fileManager.getClassLoader(CLASS_PATH); + + if (processorClassLoader != null && processorClassLoader instanceof Closeable) { + JavaCompiler compiler = JavaCompiler.instance(context); + compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader); + } + } catch (SecurityException e) { + processorClassLoaderException = e; + } + } + private void initProcessorIterator(Context context, Iterable processors) { Log log = Log.instance(context); Iterator processorIterator; @@ -217,18 +248,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea processorIterator = processors.iterator(); } else { String processorNames = options.get(PROCESSOR); - JavaFileManager fileManager = context.get(JavaFileManager.class); - try { - // If processorpath is not explicitly set, use the classpath. - processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH) - ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH) - : fileManager.getClassLoader(CLASS_PATH); - - if (processorClassLoader != null && processorClassLoader instanceof Closeable) { - JavaCompiler compiler = JavaCompiler.instance(context); - compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader); - } - + if (processorClassLoaderException == null) { /* * If the "-processor" option is used, search the appropriate * path for the named class. Otherwise, use a service @@ -239,14 +259,15 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea } else { processorIterator = new ServiceIterator(processorClassLoader, log); } - } catch (SecurityException e) { + } else { /* * A security exception will occur if we can't create a classloader. * Ignore the exception if, with hindsight, we didn't need it anyway * (i.e. no processor was specified either explicitly, or implicitly, * in service configuration file.) Otherwise, we cannot continue. */ - processorIterator = handleServiceLoaderUnavailability("proc.cant.create.loader", e); + processorIterator = handleServiceLoaderUnavailability("proc.cant.create.loader", + processorClassLoaderException); } } discoveredProcs = new DiscoveredProcessors(processorIterator); @@ -1473,13 +1494,19 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea } /** - * For internal use only. This method will be - * removed without warning. + * For internal use only. This method may be removed without warning. */ public Context getContext() { return context; } + /** + * For internal use only. This method may be removed without warning. + */ + public ClassLoader getProcessorClassLoader() { + return processorClassLoader; + } + public String toString() { return "javac ProcessingEnvironment"; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties index 355781296ea..c5de12197f6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties @@ -99,6 +99,10 @@ javac.opt.arg.release=\ javac.opt.arg.number=\ +javac.opt.plugin=\ + Name and optional arguments for a plug-in to be run +javac.opt.arg.plugin=\ + "name args" ## extended options @@ -185,6 +189,8 @@ javac.err.file.not.directory=\ not a directory: {0} javac.err.file.not.file=\ not a file: {0} +javac.msg.plugin.not.found=\ + plug-in not found: {0} ## messages javac.msg.usage.header=\ @@ -212,6 +218,10 @@ javac.msg.proc.annotation.uncaught.exception=\ \n\nAn annotation processor threw an uncaught exception.\n\ Consult the following stack trace for details.\n +javac.msg.plugin.uncaught.exception=\ +\n\nA plugin threw an uncaught exception.\n\ +Consult the following stack trace for details.\n + javac.msg.resource=\ \n\nThe system is out of resources.\n\ Consult the following stack trace for details.\n diff --git a/langtools/test/tools/javac/plugin/showtype/Identifiers.java b/langtools/test/tools/javac/plugin/showtype/Identifiers.java new file mode 100644 index 00000000000..9bcac670b84 --- /dev/null +++ b/langtools/test/tools/javac/plugin/showtype/Identifiers.java @@ -0,0 +1,7 @@ +/* /nodynamiccopyright */ + +public class Identifiers { + public double E = Math.E; + public double PI = Math.PI; + public double PIE = PI + E; +} diff --git a/langtools/test/tools/javac/plugin/showtype/Identifiers.out b/langtools/test/tools/javac/plugin/showtype/Identifiers.out new file mode 100644 index 00000000000..d7d7d1b695d --- /dev/null +++ b/langtools/test/tools/javac/plugin/showtype/Identifiers.out @@ -0,0 +1,21 @@ +Identifiers.java:3: Note: type is ()void +public class Identifiers { + ^ +Identifiers.java:4: Note: type is double + public double E = Math.E; + ^ +Identifiers.java:4: Note: type is java.lang.Math + public double E = Math.E; + ^ +Identifiers.java:5: Note: type is double + public double PI = Math.PI; + ^ +Identifiers.java:5: Note: type is java.lang.Math + public double PI = Math.PI; + ^ +Identifiers.java:6: Note: type is double + public double PIE = PI + E; + ^ +Identifiers.java:6: Note: type is double + public double PIE = PI + E; + ^ diff --git a/langtools/test/tools/javac/plugin/showtype/Identifiers_PI.out b/langtools/test/tools/javac/plugin/showtype/Identifiers_PI.out new file mode 100644 index 00000000000..91b3b43e98f --- /dev/null +++ b/langtools/test/tools/javac/plugin/showtype/Identifiers_PI.out @@ -0,0 +1,6 @@ +Identifiers.java:5: Note: type is double + public double PI = Math.PI; + ^ +Identifiers.java:6: Note: type is double + public double PIE = PI + E; + ^ diff --git a/langtools/test/tools/javac/plugin/showtype/ShowTypePlugin.java b/langtools/test/tools/javac/plugin/showtype/ShowTypePlugin.java new file mode 100644 index 00000000000..61de3c15ce2 --- /dev/null +++ b/langtools/test/tools/javac/plugin/showtype/ShowTypePlugin.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.IdentifierTree; +import com.sun.source.tree.MemberSelectTree; +import com.sun.source.tree.Tree; +import com.sun.source.util.JavacTask; +import com.sun.source.util.Plugin; +import com.sun.source.util.TaskEvent; +import com.sun.source.util.TaskListener; +import com.sun.source.util.TreePathScanner; +import com.sun.source.util.Trees; +import java.util.regex.Pattern; +import javax.lang.model.type.TypeMirror; +import javax.tools.Diagnostic.Kind; + +public class ShowTypePlugin implements Plugin { + + public String getName() { + return "showtype"; + } + + public void call(JavacTask task, String... args) { + Pattern pattern = null; + if (args.length == 1) + pattern = Pattern.compile(args[0]); + task.addTaskListener(new PostAnalyzeTaskListener(task, pattern)); + } + + private static class PostAnalyzeTaskListener implements TaskListener { + private final ShowTypeTreeVisitor visitor; + + PostAnalyzeTaskListener(JavacTask task, Pattern pattern) { + visitor = new ShowTypeTreeVisitor(task, pattern); + } + + @Override + public void started(TaskEvent taskEvent) { } + + @Override + public void finished(TaskEvent taskEvent) { + if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) { + CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit(); + visitor.scan(compilationUnit, null); + } + } + } + + private static class ShowTypeTreeVisitor extends TreePathScanner { + private final Trees trees; + private final Pattern pattern; + private CompilationUnitTree currCompUnit; + + ShowTypeTreeVisitor(JavacTask task, Pattern pattern) { + trees = Trees.instance(task); + this.pattern = pattern; + } + + @Override + public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) { + currCompUnit = tree; + return super.visitCompilationUnit(tree, ignore); + } + + @Override + public Void visitIdentifier(IdentifierTree tree, Void ignore) { + show(tree, tree.getName()); + return super.visitIdentifier(tree, ignore); + } + + @Override + public Void visitMemberSelect(MemberSelectTree tree, Void ignore) { + show(tree, tree.getIdentifier()); + return super.visitMemberSelect(tree, ignore); + } + + void show(Tree tree, CharSequence name) { + if (pattern == null || pattern.matcher(name).matches()) { + TypeMirror type = trees.getTypeMirror(getCurrentPath()); + trees.printMessage(Kind.NOTE, "type is " + type, tree, currCompUnit); + } + } + } + +} diff --git a/langtools/test/tools/javac/plugin/showtype/Test.java b/langtools/test/tools/javac/plugin/showtype/Test.java new file mode 100644 index 00000000000..a0c5f2f2a2f --- /dev/null +++ b/langtools/test/tools/javac/plugin/showtype/Test.java @@ -0,0 +1,171 @@ + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileManager; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8001098 + * @summary Provide a simple light-weight "plug-in" mechanism for javac + */ + +public class Test { + public static void main(String... args) throws Exception { + new Test().run(); + } + + final File testSrc; + final File pluginSrc; + final File pluginClasses ; + final File pluginJar; + final List ref1; + final List ref2; + final JavaCompiler compiler; + final StandardJavaFileManager fm; + + Test() throws Exception { + testSrc = new File(System.getProperty("test.src")); + pluginSrc = new File(testSrc, "ShowTypePlugin.java"); + pluginClasses = new File("plugin"); + pluginJar = new File("plugin.jar"); + ref1 = readFile(testSrc, "Identifiers.out"); + ref2 = readFile(testSrc, "Identifiers_PI.out"); + compiler = ToolProvider.getSystemJavaCompiler(); + fm = compiler.getStandardFileManager(null, null, null); + } + + void run() throws Exception { + // compile the plugin explicitly, to a non-standard directory + // so that we don't find it on the wrong path by accident + pluginClasses.mkdirs(); + compile("-d", pluginClasses.getPath(), pluginSrc.getPath()); + writeFile(new File(pluginClasses, "META-INF/services/com.sun.source.util.Plugin"), + "ShowTypePlugin\n"); + jar("cf", pluginJar.getPath(), "-C", pluginClasses.getPath(), "."); + + testCommandLine("-Xplugin:showtype", ref1); + testCommandLine("-Xplugin:showtype PI", ref2); + testAPI("-Xplugin:showtype", ref1); + testAPI("-Xplugin:showtype PI", ref2); + + if (errors > 0) + throw new Exception(errors + " errors occurred"); + } + + void testAPI(String opt, List ref) throws Exception { + File identifiers = new File(testSrc, "Identifiers.java"); + fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, Arrays.asList(pluginJar)); + fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File("."))); + List options = Arrays.asList(opt); + Iterable files = fm.getJavaFileObjects(identifiers); + + System.err.println("test api: " + options + " " + files); + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + boolean ok = compiler.getTask(pw, fm, null, options, null, files).call(); + String out = sw.toString(); + System.err.println(out); + if (!ok) + error("testCommandLine: compilation failed"); + checkOutput(out, ref); + } + + void testCommandLine(String opt, List ref) { + File identifiers = new File(testSrc, "Identifiers.java"); + String[] args = { + "-d", ".", + "-processorpath", pluginJar.getPath(), + opt, + identifiers.getPath() }; + + System.err.println("test command line: " + Arrays.asList(args)); + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = com.sun.tools.javac.Main.compile(args, pw); + String out = sw.toString(); + System.err.println(out); + if (rc != 0) + error("testCommandLine: compilation failed"); + checkOutput(out, ref); + } + + private void checkOutput(String out, List ref) { + List lines = Arrays.asList(out + .replaceAll(".*?([A-Za-z.]+:[0-9]+: .*)", "$1") // remove file directory + .split("[\r\n]+")); // allow for newline formats + if (!lines.equals(ref)) { + error("unexpected output"); + } + } + + private void compile(String... args) throws Exception { + System.err.println("compile: " + Arrays.asList(args)); + int rc = com.sun.tools.javac.Main.compile(args); + if (rc != 0) + throw new Exception("compiled failed, rc=" + rc); + } + + private void jar(String... args) throws Exception { + System.err.println("jar: " + Arrays.asList(args)); + boolean ok = new sun.tools.jar.Main(System.out, System.err, "jar").run(args); + if (!ok) + throw new Exception("jar failed"); + } + + private List readFile(File dir, String name) throws IOException { + return Files.readAllLines(new File(dir, name).toPath(), Charset.defaultCharset()); + } + + private void writeFile(File f, String body) throws IOException { + f.getParentFile().mkdirs(); + try (FileWriter out = new FileWriter(f)) { + out.write(body); + } + } + + private void error(String msg) { + System.err.println(msg); + errors++; + } + + int errors; +} From 4850bec745b4e44edc8311e4e7bbb8b733c245a8 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Mon, 19 Nov 2012 14:06:30 -0800 Subject: [PATCH 40/94] 8003300: build-infra: fails on solaris when objcopy is not found Only call BASIC_FIXUP_EXECUTABLE() if objcopy was found. Reviewed-by: tbell --- common/autoconf/generated-configure.sh | 5 ++++- common/autoconf/toolchain.m4 | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index c6803908a23..dced36f3f3a 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3068,7 +3068,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1352917083 +DATE_WHEN_GENERATED=1353361797 ############################################################################### # @@ -26313,6 +26313,8 @@ esac fi fi + # Only call fixup if objcopy was found. + if test -n "$OBJCOPY"; then if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -26576,6 +26578,7 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJCOPY" >&2;} $as_echo "$as_me: Rewriting OBJCOPY to \"$new_complete\"" >&6;} fi + fi fi if test -n "$ac_tool_prefix"; then diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index eb8d2b1ccc5..8dc3fc7bb4b 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -437,7 +437,10 @@ fi # full debug symbols are enabled. if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then AC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy]) - BASIC_FIXUP_EXECUTABLE(OBJCOPY) + # Only call fixup if objcopy was found. + if test -n "$OBJCOPY"; then + BASIC_FIXUP_EXECUTABLE(OBJCOPY) + fi fi AC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump]) From 55e7dd8b71563b04834c0c3721b47c1b88868c61 Mon Sep 17 00:00:00 2001 From: Bhavesh Patel Date: Mon, 19 Nov 2012 16:10:34 -0800 Subject: [PATCH 41/94] 8002304: Group methods by types in methods summary section Reviewed-by: jjg --- .../formats/html/AbstractMemberWriter.java | 51 ++++++- .../doclets/formats/html/HtmlDoclet.java | 7 +- .../formats/html/HtmlDocletWriter.java | 12 ++ .../formats/html/SubWriterHolderWriter.java | 60 +++++++- .../formats/html/markup/HtmlStyle.java | 2 + .../doclets/formats/html/markup/HtmlTree.java | 34 +++++ .../formats/html/markup/HtmlWriter.java | 53 ++++++- .../internal/toolkit/MemberSummaryWriter.java | 10 +- .../builders/MemberSummaryBuilder.java | 11 +- .../toolkit/resources/activetitlebar.gif | Bin 0 -> 10824 bytes .../toolkit/resources/activetitlebar_end.gif | Bin 0 -> 909 bytes .../internal/toolkit/resources/script.js | 30 ++++ .../internal/toolkit/resources/stylesheet.css | 43 ++++++ .../internal/toolkit/util/DocPaths.java | 3 + .../internal/toolkit/util/MethodTypes.java | 68 +++++++++ .../testHtmlTableTags/TestHtmlTableTags.java | 10 +- .../testMethodTypes/TestMethodTypes.java | 139 ++++++++++++++++++ .../sun/javadoc/testMethodTypes/pkg1/A.java | 77 ++++++++++ .../sun/javadoc/testMethodTypes/pkg1/B.java | 56 +++++++ .../sun/javadoc/testMethodTypes/pkg1/D.java | 53 +++++++ .../test/tools/javadoc/api/basic/APITest.java | 3 + 21 files changed, 702 insertions(+), 20 deletions(-) create mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar.gif create mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar_end.gif create mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js create mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java create mode 100644 langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java create mode 100644 langtools/test/com/sun/javadoc/testMethodTypes/pkg1/A.java create mode 100644 langtools/test/com/sun/javadoc/testMethodTypes/pkg1/B.java create mode 100644 langtools/test/com/sun/javadoc/testMethodTypes/pkg1/D.java diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java index 262abc8e50f..3ea59576fb6 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java @@ -52,6 +52,9 @@ public abstract class AbstractMemberWriter { protected final ConfigurationImpl configuration; protected final SubWriterHolderWriter writer; protected final ClassDoc classdoc; + protected Map typeMap = new LinkedHashMap(); + protected Set methodTypes = EnumSet.noneOf(MethodTypes.class); + private int methodTypesOr = 0; public final boolean nodepr; protected boolean printedSummaryHeader = false; @@ -524,11 +527,11 @@ public abstract class AbstractMemberWriter { * @param classDoc the class that is being documented * @param member the member being documented * @param firstSentenceTags the first sentence tags to be added to the summary - * @param tableTree the content tree to which the documentation will be added - * @param counter the counter for determing style for the table row + * @param tableContents the list of contents to which the documentation will be added + * @param counter the counter for determining id and style for the table row */ public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member, - Tag[] firstSentenceTags, Content tableTree, int counter) { + Tag[] firstSentenceTags, List tableContents, int counter) { HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD); tdSummaryType.addStyle(HtmlStyle.colFirst); writer.addSummaryType(this, member, tdSummaryType); @@ -538,11 +541,46 @@ public abstract class AbstractMemberWriter { writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary); HtmlTree tr = HtmlTree.TR(tdSummaryType); tr.addContent(tdSummary); + if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) { + int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() : + MethodTypes.INSTANCE.value(); + methodType = (classdoc.isInterface() || ((MethodDoc)member).isAbstract()) ? + methodType | MethodTypes.ABSTRACT.value() : + methodType | MethodTypes.CONCRETE.value(); + if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) { + methodType = methodType | MethodTypes.DEPRECATED.value(); + } + methodTypesOr = methodTypesOr | methodType; + String tableId = "i" + counter; + typeMap.put(tableId, methodType); + tr.addAttr(HtmlAttr.ID, tableId); + } if (counter%2 == 0) tr.addStyle(HtmlStyle.altColor); else tr.addStyle(HtmlStyle.rowColor); - tableTree.addContent(tr); + tableContents.add(tr); + } + + /** + * Generate the method types set and return true if the method summary table + * needs to show tabs. + * + * @return true if the table should show tabs + */ + public boolean showTabs() { + int value; + for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) { + value = type.value(); + if ((value & methodTypesOr) == value) { + methodTypes.add(type); + } + } + boolean showTabs = methodTypes.size() > 1; + if (showTabs) { + methodTypes.add(MethodTypes.ALL); + } + return showTabs; } /** @@ -595,10 +633,11 @@ public abstract class AbstractMemberWriter { * Get the summary table tree for the given class. * * @param classDoc the class for which the summary table is generated + * @param tableContents list of contents to be displayed in the summary table * @return a content tree for the summary table */ - public Content getSummaryTableTree(ClassDoc classDoc) { - return writer.getSummaryTableTree(this, classDoc); + public Content getSummaryTableTree(ClassDoc classDoc, List tableContents) { + return writer.getSummaryTableTree(this, classDoc, tableContents, showTabs()); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java index 3e12036ef16..45453823fe3 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java @@ -117,6 +117,8 @@ public class HtmlDoclet extends AbstractDoclet { copyResourceFile("tab.gif"); copyResourceFile("titlebar.gif"); copyResourceFile("titlebar_end.gif"); + copyResourceFile("activetitlebar.gif"); + copyResourceFile("activetitlebar_end.gif"); // do early to reduce memory footprint if (configuration.classuse) { ClassUseWriter.generate(configuration, classtree); @@ -152,10 +154,13 @@ public class HtmlDoclet extends AbstractDoclet { } // If a stylesheet file is not specified, copy the default stylesheet // and replace newline with platform-specific newline. + DocFile f; if (configuration.stylesheetfile.length() == 0) { - DocFile f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET); + f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET); f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), false, true); } + f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT); + f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java index 83388a6728e..57609a10b48 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java @@ -327,6 +327,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { } } head.addContent(getStyleSheetProperties()); + head.addContent(getScriptProperties()); Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head, body); Content htmlDocument = new HtmlDocument(htmlDocType, @@ -1687,6 +1688,17 @@ public class HtmlDocletWriter extends HtmlDocWriter { return link; } + /** + * Returns a link to the JavaScript file. + * + * @return an HtmlTree for the Script tag which provides the JavaScript location + */ + public HtmlTree getScriptProperties() { + HtmlTree script = HtmlTree.SCRIPT("text/javascript", + pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath()); + return script; + } + /** * According to * The Java™ Language Specification, diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java index 8f00a359a83..f3af8432e24 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java @@ -26,6 +26,7 @@ package com.sun.tools.doclets.formats.html; import java.io.*; +import java.util.*; import com.sun.javadoc.*; import com.sun.tools.doclets.formats.html.markup.*; @@ -77,15 +78,70 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter { * * @param mw the writer for the member being documented * @param cd the classdoc to be documented + * @param tableContents list of summary table contents + * @param showTabs true if the table needs to show tabs * @return the content tree for the summary table */ - public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) { + public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd, + List tableContents, boolean showTabs) { + Content caption; + if (showTabs) { + caption = getTableCaption(mw.methodTypes); + generateMethodTypesScript(mw.typeMap, mw.methodTypes); + } + else { + caption = getTableCaption(mw.getCaption()); + } Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, - mw.getTableSummary(), getTableCaption(mw.getCaption())); + mw.getTableSummary(), caption); table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col")); + for (int i = 0; i < tableContents.size(); i++) { + table.addContent(tableContents.get(i)); + } return table; } + /** + * Get the summary table caption. + * + * @param methodTypes set comprising of method types to show as table caption + * @return the caption for the summary table + */ + public Content getTableCaption(Set methodTypes) { + Content tabbedCaption = new HtmlTree(HtmlTag.CAPTION); + for (MethodTypes type : methodTypes) { + Content captionSpan; + Content span; + if (type.isDefaultTab()) { + captionSpan = HtmlTree.SPAN(new StringContent(type.text())); + span = HtmlTree.SPAN(type.tabId(), + HtmlStyle.activeTableTab, captionSpan); + } else { + captionSpan = HtmlTree.SPAN(getMethodTypeLinks(type)); + span = HtmlTree.SPAN(type.tabId(), + HtmlStyle.tableTab, captionSpan); + } + Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, getSpace()); + span.addContent(tabSpan); + tabbedCaption.addContent(span); + } + return tabbedCaption; + } + + /** + * Get the method type links for the table caption. + * + * @param methodType the method type to be displayed as link + * @return the content tree for the method type link + */ + public Content getMethodTypeLinks(MethodTypes methodType) { + StringBuilder jsShow = new StringBuilder("javascript:show("); + jsShow.append(methodType.value()).append(");"); + HtmlTree link = HtmlTree.A(jsShow.toString(), + new StringContent(methodType.text())); + return link; + } + /** * Add the inherited summary header. * diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java index 61bb800cbef..a1719bbe8cf 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java @@ -37,6 +37,7 @@ package com.sun.tools.doclets.formats.html.markup; */ public enum HtmlStyle { aboutLanguage, + activeTableTab, altColor, bar, block, @@ -75,6 +76,7 @@ public enum HtmlStyle { summary, deprecatedContent, tabEnd, + tableTab, title, topNav; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java index 99543d1fdf0..6c761050c7a 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java @@ -493,6 +493,20 @@ public class HtmlTree extends Content { return htmltree; } + /** + * Generates a SCRIPT tag with the type and src attributes. + * + * @param type type of link + * @param src the path for the script + * @return an HtmlTree object for the SCRIPT tag + */ + public static HtmlTree SCRIPT(String type, String src) { + HtmlTree htmltree = new HtmlTree(HtmlTag.SCRIPT); + htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type)); + htmltree.addAttr(HtmlAttr.SRC, nullCheck(src)); + return htmltree; + } + /** * Generates a SMALL tag with some content. * @@ -539,6 +553,23 @@ public class HtmlTree extends Content { return htmltree; } + /** + * Generates a SPAN tag with id and style class attributes. It also encloses + * a content. + * + * @param id the id for the tag + * @param styleClass stylesheet class for the tag + * @param body content for the tag + * @return an HtmlTree object for the SPAN tag + */ + public static HtmlTree SPAN(String id, HtmlStyle styleClass, Content body) { + HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body)); + htmltree.addAttr(HtmlAttr.ID, nullCheck(id)); + if (styleClass != null) + htmltree.addStyle(styleClass); + return htmltree; + } + /** * Generates a Table tag with border, width and summary attributes and * some content. @@ -742,6 +773,9 @@ public class HtmlTree extends Content { return (hasAttr(HtmlAttr.HREF) && !hasContent()); case META : return (hasAttr(HtmlAttr.CONTENT) && !hasContent()); + case SCRIPT : + return ((hasAttr(HtmlAttr.TYPE) && hasAttr(HtmlAttr.SRC) && !hasContent()) || + (hasAttr(HtmlAttr.TYPE) && hasContent())); default : return hasContent(); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java index bd6be7a5c36..01238cfeb91 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java @@ -26,6 +26,7 @@ package com.sun.tools.doclets.formats.html.markup; import java.io.*; +import java.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; @@ -144,6 +145,8 @@ public class HtmlWriter { private final Writer writer; + private Content script; + /** * Constructor. * @@ -301,7 +304,8 @@ public class HtmlWriter { // Don't print windowtitle script for overview-frame, allclasses-frame // and package-frame if (includeScript) { - body.addContent(getWinTitleScript()); + this.script = getWinTitleScript(); + body.addContent(script); Content noScript = HtmlTree.NOSCRIPT( HtmlTree.DIV(getResource("doclet.No_Script_Message"))); body.addContent(noScript); @@ -309,6 +313,53 @@ public class HtmlWriter { return body; } + /** + * Generated javascript variables for the document. + * + * @param typeMap map comprising of method and type relationship + * @param methodTypes set comprising of all methods types for this class + */ + public void generateMethodTypesScript(Map typeMap, + Set methodTypes) { + String sep = ""; + StringBuilder vars = new StringBuilder("var methods = {"); + for (Map.Entry entry : typeMap.entrySet()) { + vars.append(sep); + sep = ","; + vars.append("\""); + vars.append(entry.getKey()); + vars.append("\":"); + vars.append(entry.getValue()); + } + vars.append("};").append(DocletConstants.NL); + sep = ""; + vars.append("var tabs = {"); + for (MethodTypes entry : methodTypes) { + vars.append(sep); + sep = ","; + vars.append(entry.value()).append(":"); + vars.append("[").append("\"").append(entry.tabId()); + vars.append("\"").append(sep).append("\"").append(entry.text()).append("\"]"); + } + vars.append("};").append(DocletConstants.NL); + addStyles(HtmlStyle.altColor, vars); + addStyles(HtmlStyle.rowColor, vars); + addStyles(HtmlStyle.tableTab, vars); + addStyles(HtmlStyle.activeTableTab, vars); + script.addContent(new RawHtml(vars.toString())); + } + + /** + * Adds javascript style variables to the document. + * + * @param style style to be added as a javascript variable + * @param vars variable string to which the style variable will be added + */ + public void addStyles(HtmlStyle style, StringBuilder vars) { + vars.append("var ").append(style).append(" = \"").append(style) + .append("\";").append(DocletConstants.NL); + } + /** * Returns an HtmlTree for the TITLE tag. * diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java index 53e0b5b260f..79ec354448d 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java @@ -58,9 +58,11 @@ public interface MemberSummaryWriter { * Get the summary table for the given class. * * @param classDoc the class the summary table belongs to + * @param tableContents list of contents that will be added to the summary table * @return a content tree for the member summary table */ - public Content getSummaryTableTree(ClassDoc classDoc); + public Content getSummaryTableTree(ClassDoc classDoc, + List tableContents); /** * Add the member summary for the given class and member. @@ -68,11 +70,11 @@ public interface MemberSummaryWriter { * @param classDoc the class the summary belongs to * @param member the member that is documented * @param firstSentenceTags the tags for the sentence being documented - * @param tableTree the content treeto which the information will be added - * @param counter the counter for determing style for the table row + * @param tableContents list of contents to which the summary will be added + * @param counter the counter for determining id and style for the table row */ public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member, - Tag[] firstSentenceTags, Content tableTree, int counter); + Tag[] firstSentenceTags, List tableContents, int counter); /** * Get the inherited member summary header for the given class. diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java index 955950ffab5..aef27a1501a 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java @@ -308,7 +308,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { configuration)); if (members.size() > 0) { Collections.sort(members); - Content tableTree = writer.getSummaryTableTree(classDoc); + List tableContents = new LinkedList(); for (int i = 0; i < members.size(); i++) { ProgramElementDoc member = members.get(i); Tag[] firstSentenceTags = member.firstSentenceTags(); @@ -317,14 +317,15 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { //necessary. DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) member)); - if (inheritedDoc.holder != null && - inheritedDoc.holder.firstSentenceTags().length > 0) { + if (inheritedDoc.holder != null + && inheritedDoc.holder.firstSentenceTags().length > 0) { firstSentenceTags = inheritedDoc.holder.firstSentenceTags(); } } - writer.addMemberSummary(classDoc, member, firstSentenceTags, tableTree, i); + writer.addMemberSummary(classDoc, member, firstSentenceTags, + tableContents, i); } - summaryTreeList.add(tableTree); + summaryTreeList.add(writer.getSummaryTableTree(classDoc, tableContents)); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar.gif b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar.gif new file mode 100644 index 0000000000000000000000000000000000000000..7b6e08fff67297c2ac27ebadbb93ecf459a4890f GIT binary patch literal 10824 zcmb{0-A3Kt-QjI>`P*R1q;B>@T}*i|6ZAUXgh}e2+eq7;iF|A z^47}lx!FH8)4#8Odwumv(69|uxA8LxNc-dw`}(){_u%x8Zqa&wBMp3#jeJvngk|ae zjnH)lz4+n!@~4MBFj>bb{N)d~pJ7?*HvT`uG7Wu`wH!lD0%6}n(m#2`{S3`C@`HYG zh5QK1{1KAzJtV_CEbEO0@PiA)$S?I<0MsNf?W1e7X%PH{nTxSM)GQdGVHfztGyc5` z_~lRcSLU8Cez@s6fy~3ROatMse|f%lftUoszj`KUIfNMdL4W*Te#&z*mk+K{Z>)R` zfXQ#Id^KzX)NTDW?SsvN(?5H}>HUjTw+(n>>GRgw@3pz-2iNFVKRwh;|9$q1)3Oi# z;+dciOfvLM(fu2#{U_|@Pd5!)e_f~WN!mUH(?zG#0ssHz*3kt90Kftu^?#B7*9m}` z?q~4}pui9k8Ws+Uhy+8TqGMv?;u8{+l2cNlX)rh)Jrp4BKZEZ zA-9)iwMB`(0tso9Wo!IU&_#ahD9hP%oLL%9&H~CabwBUhcoz;4x8O zWlrU+C-NP&+Gy_8I}4+q>>ivSKmNPblE*AZSNV51w$$fV3?~zumL`V&%GMbZeEMf& zTB#lkAKT#87mJvm2kZzNP<{KB+ot?zFZj%YuN%pY2TfXAQLWluSbg^;{|H5dp8q~f z55Ee^PxmG|sUtieE9R$0aLR;bfzC_Yjlg%W^3FnpN15+N_6CcI(4+3%_xK5{xT0{! z;oVoOp9wdO4(}#PDvr;@zS&Q{oAgA}+B|Lp{q}z90WkbWvRwf7{vTULg+&+Bb1REz z_Yk+m5U<-Q7U^FX#!b2I-@O#T98oqU#uDx^#gu(hz4K*O)LTXI+$4$4d}fHN(QqX1QI2h9^(KcSI`9x>QqGAdJXNAto^ja@nPPIYTOx?CED9=V3 zJ77CzaK(h;$HtCD^aYS39vL99i9MZEdWgALw`$XTrn-ivXVV%b9~H6B7CNaP-NVnI1Tzg2k&$Q}XFBXMb>z4b=UfMZc<}KCB%+B$zhjlS>tLo8-@}s^5 ziJq;NS5UH3!G|oRr`_v{XiU`?diTGkCt93OvrJ@-w;K)X?4FL9G1--K|DF{(7=4&^ zRywh{?!DPMR|za5?)IwKQ}z~~`>|fQtLt|qOvEAJisw^mV;fD=|eL>vQd?8e=|Z=e&&f)E6vTUTC~o~^n%K2oL*K1^caA@-4@DepQ}c>c*GYA1 z-g{wYviSWuOTDv$#bPy|?Rh5Z*?F7FXa~1%!m7yWcBtx%VV@t9w%LX7y!s`E_r5n? ze`nZRR9U(q>vwex&a}$=e7D6hV3$N;V8u3arRw@ol%{tdx4*pc_My)cj$176teW^9 z_xsAAOxS<()eBvX2~@^Ub33&)EyH@lw1$PQ%M$CaOT>Vl+hy*A@V(jh*!0hsz0H%- zju&@$?`>iC4Xjq^W3W`Ri77R z!k0BQ%LY^G%YXluQ>|%J>zqjB$a$uu(PMpHmK3LKDII6n+nlqL+z@G@^sb=S;^#K3 zFLLqOVu!YEz%|79uRO(`@lHMGziCZE`AXap@3lhy!m7N*o*Wds_v9Hy)Wzqkb{KxJ zu(_T=KDBzaV?FSBA}(WlEnn^tn_evB3G@tQ@s>fNHwiS9^(0vA&9wMnyyBC*Ya_q( z+%yN17o78jf-Ng}e34HJywHo^Z!jAm z?(b(t&~o($QuP3l0Jbabb{6*EnYt|!FWfC*V0|b#(c}6RlV0I(tx`BXlKHH>$R2HT zr{1u;tg^EBhP1WDWfDtvWz`id&00-xVqh?_s$96p5lkWt3sjYN{H8f(ktU{Wc&eI5 zXiiXe>H|hxRwd*mS{DAHU-w`v=`cJyEP8 zoYU4ltf7;u5(jl8&P}fb67?98RLfjhOb^`Aq8wVd)$+8;`U&Hy7fGY_tH2VU4bl`# zgnT{!+lL-HcuUk}h8s|DEe&P5b!_C(%`Ru;uC-Gw_>!%nV0>dQ$$6L{$kL=UTYJ3eW77qiz#2quEc^Wx%VJly%6i3UyJ}oqZ z*&5?&hVw^VP#-9^-@=ELf zyE*jJrMrll!E362eIKaIpA;#MxfQvTM4hetI8Yqxxw%_L`nL3oeoWGb?3?3M7XK7` zjm|^dYO;)Jk1bDnHYRuIc)H3+4iByyEaOtkJGrrQNxAjnhEvOG&2plg_ng0vN28L- zq`-mqgfQJB{0@BgtD5pC1D79fJ>U|TAA!k&JCIMle!n>C1&58}$#~o3J~l~(=D*=Z z9XsDIzYjOfduAZ8ARi1A6fO!qZL0TzAGo1Ex2djBnCGdHEoeJE+*;LID

0~)V2P1s>JbBnpw2Mx z;8G-6oerKRf(s784apHC7Vunh#DaRn91${c7&(><={bbds)Lu>BTKN5z4oXYB4m^Z z-jRn)ErIFD;4}583kqOn4@e$1icK7{<{o_@7QGn;zRC|dCq^?IMGF={IK-n0lcR+c zVg;;YZ)-%{GK{`q9mSObY0Hn2SdM+lAJ~^p76MlWcd>rH4^2*6K@_t zY^>vdYQ)wO6LrLsK6fOVuqIwRN}RHaH%>|7ONkOMNHDNY6!l2@T@d|GBl+bxD14co z#Lb$()R7dpocwq^d61ZFWu3Bqm}G99{M;Inst}p69ACr|6A+#>-=1=p6(IQM!i~+; zVt&S3?-_1Qr4|`NO{XrF@k23&&>MfCcnxR~E3|wZTB!kTScaCSq%|3)H6B45Q=quz zv|84*VTH7wYUl_*tVRJk#tIv^PU{bcQaaLRt>MM|@IDXdJ5ktV0j%u^K2x36QUE7u zz=v27i$}2C0>nZGeEkT~-htTXN6-x6RF5=95MsL;&a{H)=g(m6gdK^)M_DsCk!jaD z)7e4ri;8e&qYSR&3;-yd&nDwKGUM1V^R_2q=_q}tI^$Mq#@2F1Ni{uFTq6B$YL?(} zrc!5yN+;ssN;(%?w!CJR+;QeR#VldXbU9GwTTrH2XZFjQ>~)1427zooWcGW_oOd=^ z>?=7RkF(!M)x3gX{HW}8R8x@X2C5DeIv8KIah(U}uyl;>xYAJv)lH?`oyahm%C3^b8#Y?Nc7 zng4Vp8v)9n>L{@FL|zs^8VO{@umR*t7_OIGsM2J({=E=i!%#VK(WK-87F38cLe<(7 zHg^`{6j3!uR9k9cYYnO<6@>$#dTda&nhf<4sQwkyxF#B3L%%R8fbOe7cWV~)u@#LR z7dChnO)3`kf(kc5=(SGtN@~%VK+(_yYG4B=0^O>KnwltHMWSgECFjVJE}N41 z)RF^G@zQZIhh*uN5o*S$blj#$V724|w3rK5dKp^G>{ZM!Sb9C8>=v|4lvK*ng_b-i z1K>*T9JHhf}WR-?eRmVz|Vqy73T&1s8k?Tp3dLg|mL<#E{4t_5U}Ka@ zQ*agUNEKkoYCo-NSVWb5L^YzYI6jz<(RVvI5xaY_8ssw=1!m)qH$w%YZ>o0!u zW2*APRVd-AS8?^m_-11~wh-4YiSJ^^myz&II2_>wR|&v=3P)I4B@CV5XkLU?cETKqP z6)z-Izlv+*N^9hctQAnca6gh>FXr9w09E^x+`w&Dr_|jjZ`X9?v`JQ|c^TSp=GFK> zyHP~Dz8l*7+PjIm2Y*X zJtOz?F7C@0F{c2dO+ZCtS7mosRazI0+=XB3s^REvk?O{OWBd@^U9Q|+wbor>*VU@r z-JRCe{;j8r+}&{6-K9s?QV*9cgtG$ zqFvt@s&}uucSopaFS2JI-`7s=BPsVW3in=s^{~PEm+<{_sD7GI@5WmHv0XRES^qU~ zFTlQ=r>A$@u76j#|A=GoRD1BAaNh%1mk4^Wo;dF*ywj!?`M;)FTmlCz)>sokUg!}5k1B%JSqqqduc!F z%sCREGNMeNkN!dT0ab`zIs!_ni(I)mBZ zu{_$a17#d(LVU*wcp=L0Sd?`2J?XJ1lZGgh{(F*!D1$~n31?5jqDgoYQke?5!Jb?N zBQ;P+jXmU6G#RTy>eC_D(n$5vlzt#(M3{`BP+HDNSEI>Y_LN~DnM5JY=uEbokf-cP z6ZVu97-fS-Ub3I;1WwLV$V8RNtsd%zFr^Dkr2#3cXVi5dbrL*vNten7r|waxYp_WU zT?+MVigTTM<>u6c&eV0EDM83IZ!LA2Hg%VadWCCdi8j40JuTHsmGGI_2hwL4RVjB& zr*_cOe5$h-eP%@*W-gx3+$)-WY&xwvIr9iId!u(s6Fzsnce+n{j$d_J`h4;o*X;9J z%18L@wc2?ZpZQn1^8m>7(@D~I)p?HISrTyJo5P&-`phleSv#&prP{d-!jw3CenDkX z*L40@@1m#b!V@^vPj^m}YhKcH=_h>ZLD7-}d@9XPaJaf^q3uK8&cjb-4JnZHY!gLPaONrxJj^J7iJf8$?UVIVFR0C%cn_?8Ze4%cA zwdUppnfGfl^{cg9Yt0Zw+~jKA%{4q^t*>^i2fo%nxjI<1RRs>g988GX7ki%lSglxWn*28 zx^;!VC1$q8@4F>kye?3;{g}GW>ATHbxAnw#hlRQ$+qb#kuyZ+TM@D2**=$qQaZ7`~ zd0%Ab1$Fn{#@6$?O|{}(O|xBn`sUZ-ZAHC3!>HZY^j#6zy=~Q-7k7u zFV$$~-2313w(RP5ANd{_`EIipAN->4v&wEh@?G=MJJ?XAA6S_k_|sRzHuisTALvsL zjr%rC5IgVb2T>x2!HC1q;(bW*;bHIL!;S4^?&Dh`2iCqvA!=KxvPaq*$BBB!JGDm$ zy`$)jJ!IbzDr%!#?Wl3`#GCt|o_jBWz6I!KGJD9tn|^vN{ghYqVkh@mk1xY;-)S%R zS)bb35aMj4?sQD#Y=V9^;&?VJd$D8VY@Yj^RCl`6cQ!~pC;Boh)}0Y$&wBgLce&4Z zWY71xS$G4k@m>q!{TLJ;6cP{~Xcie76%iU790vk}!$P4!G0BkBw4}6nL{?xdBqJ|7 z5e0*lMe!D;l$T~=!m-GNfZXZ`eC4%_IzkApm|orrujtIrsmSgR7%FKTg-z6uTd57v zl)0w*0!(J!Z1;3;OK;V}Mj)|vZ{%>LZT)2H_|0q;hv*~!!scaL*AhV$pG!k$=0uxY zRpFZgKh5P>X9<2>Dw)RjKT_ZR;!(3n3+?}^;UoJ39$EdEw=GmuoJUz)dS2Z|&{}iX zI`;SD%*!4ULHXB~lr!$eRNi45Dd_R}Qmm5T`Ed2WtZzdKb_xuBVK;>yX1Dk;*c);E zAwia3B>nHi{242ADI8rl#XHfqM~FkF7hm;L1fGuKNe6c8>ox4$^|*FEoZrW zWXsQiK#Y(X;NBFm+{jBS1%>Ikoq73zu|`XoC5%Y%!phnj+nlOnPsxn%A~w4`JY1px zmBA)hfI*$xNR-tJDA6#lC54{5tOW(l^}1{Gn_z+@t3@eW$L+&BR3mP zjzKa_offI3HTQgxws>a8waw1Uh&7qEhmI?yUDpF8cIqxtl^?YWV^CXtlObu+9g7P# zOTD~~UAt|1vQkc+nzD3ur^cxnj`E@p*MOE|pYtO3DvWr~N{RvG@AW*kg5LpG9GYnR z*BsSKTdw`96Rsj%nnNE@z3I|!RPQbo?35P^fah$DmS>L5s6o#R9_1vC+JRiJHr@zD!u2@`lgKFJkl{8S|uYKtLjBLtf-=;cE zi*~yAn#^sORL`#aKJ@KeI&&zC^4Q43aFJor>mTIb+(?83Gc-@_2OKH^o=jbmOMb}* zt@nGJxOM5*F92VY{M-NFkHDYQv-sQi-pL`aK%AA$g;(XIjP@m)3q18`|G;)NHsM$OJrYs< zO^eDBn|>`k zcH`Ih_A)k=UQmAjnWIOi6*4yQm)-nhujL*~hq&Y+p}ePEti69V<6!L^ix0pWy&gXQ z!4KB51orHUU_-9ePs7#}-C0=p35G7fDj1=4e&3i`t7PFho&Q#V^(ALdiwkGqSu}U0J`cID%nf6$pkT)XZ;k0TzSCdq{m{4S~Q)qNF zIa)zBku^Vqnyz0xtT-je0;{1@M~nv5jHa9Z{L0e@ABnYG5E*Y~ z(>UaB%DA?L%+Pp`#i(=Y7T)5iu|l8yxhb$4w#b}6gQjhAm3gkv=tHIO}?duMc-20 zcDKdNow_~)h`#q@EU#aXtMllw)x8Mc!CzFMR`>Zk{LNs3Eh$nx`eGb*)0lya+Pt29 z>Q>$($?9Be<^@q7ljanjy*^T1lKb}y;eds(Dz8!GFwS*iz|wx#aOQfm)_ zi;pMFsK-s*YP(8^gY7`ybG)V6Hl+`^7lAl;dgl$U@|kRH= z$qS?>`CfGQWe)QJgt(7EBl?IM_+AS00HgyhrvoJN1H_X9#8?;}h6Oxs z5BQHI@R3-c%u>LU*MA+PyDJ&8f?EFsSMA=Y9c4(>s2>LEb}!GEkmBa_3x*swsBaHHhV7;I>iRk%Ab z)Hp0G);-KWIV|olJi0wRnGY1a6zZc6$`AXW^M=0>1LcGT7qy3i3_$SwP>gzTwLy5H zdx$DF0*MWdV~H#Y163JB5W+%Qu;E?Akocu=yZ;fbdL+&Y)ZQLB(hkaVj~qG-4ORz_ zEk)wPz|-oX0eq1&`H@pZ@F-uJSn@gzTt8*2E&Vbv!b5$dTzdGiMLJT)+tgvAW zr$+4U>KL)*XtCuO-lG_4>sWz~81atS%Z9Q1;V}>R zYw@_31+i-4ac>J^g_h&wk7AWP;%>9XX|N_d36IxFi8DxvHyDrS6i?9CNO(1#VBQgD z(GmYiA?{~N;B%B)T*C`c;OfFcy2S_RNh*3?4Q1a}WQG~g)NM7 z__TGxl16G_3ZmpF&3PQU)PZO=OqJ9?EVHJRS*QOiNIx@7;}%Z`YNVgB0tC_-7}J?< zNB|7dnHb+^2-#%tAesJWwSp5F0-G7a$P5wBOi^U!eNg7znoK@q#-oXhJ1dztQ!{UQ zX5CB8lAg$t>dbnK%;J^EmbJ;^XUl$Ql&ztdttOFmYa;vIMCNUY9M#lJP0h?lHre_$ zSzkRfU#I3g0cCw-%l&MWtCgB#rAg2JVw9y?lWTdLW6hSsyOQDDnfnKn^AB{mWATz%O|B=T4h(*%Y==~gtSWU zos{z1mP)Udiu?~)yUN6D%N`Y$$=H_4ip4*l^6D(CDVHB0h-`SQcNS3~a zmOqg!e+ceVR%wzLMr*VTESm}d0kk}f4TC7Ql&Po;?Z9uTpo(D$l}l9WAWoYSpL0%3vH;hrJ@ItMZo@)t|!n$}>yeX{kQmVEStoBzb{mEYAC0P@5QvLU&${$*tYg<`_tATgbC<)@gl9l-p z6-Y0fHL1K3N3X6^s&P@mMV!-RgHz!9fjB&NgVd1yg{qlpS_w(iI5S2FVMpM zkG2#d2u|#^s1vLs4&N$BfGOc)Nd#Tv@)<46#tCj~m9T6~Sna~m3d?sSvAxjBMXkCJ zTwR(i7RnA_`BTs0UH{}c6N}%4Cw>>0IT|=P8rYN@xYO!cO6obg>se6^T-psRYYjr= zhC4!yJlYLc$@TZ~4Wi!~1S1>xy&JEjHAt*Aif}aDj%<9w(WnsFaGRs)QFr5i$_Hwz`M=$wCyjdJw&M8Agw(Z-xQ(Up{Lw#@7?hS)nRMb5X;f-#?cywZ-k$=Lr`rt z-EBd3o!J~6X&haMZ=Hp9EzZha<*3eTyN(i6i*t8Z7)M7Vx&60tXN6Q(tx#h@cPGKS z`yII(tK4me@9I_VMyGX;qyFc%-3c5$`F1@+cHJZ1U6H3fL}e?`&jm!&)!(Tkir#XOVXY;4*+A8o(;re^ICZf_=YX^hH+tekO1~n@T@7h2GDs zGH_9)-%xab1vnsNKfpy8VC(7UMGssC58Txm5HT5KE$Qb34hm5QM8N~MrTb-s2bj@= z57C2CDuZ%51N@XBVVyy7+R%S0!$N06H>C%j5{4yBhPA=Nk6=TuDTB}L`#%DQbxlU@ zqesNfh7DoEl0Cz3RYo7{jC|)DkR>Xe3>?)KCfceHy?aLdR7S$kLqN_^OTrigO?06UuiF!SVPlFW!^zU)ZaU*2 z^q4DfI7)gV@odlrHtu6WETD~Nb52B~hka-hUnvt=_Cwz(<5h%_Qee(dC2#^OJYpj} zjuRd&v7dO-Gg8Az##2WBsgPR0qb9-=P+>}r38fo6*sek*5y%}n#5UnE;u$5JLTZLl zCSemOlkqu~@de=#z-8*T3U$|nx(}ot!l=gt>M4bKenth{oMKd+x?nnW$!CfMKE+l$ z#W6X>bv||Z=JZw7>FcJ`JU-KW@M(eCX`#vKo9EM_H)n3E&fGPfx$iS0wm$6-04V)G D5diYx literal 0 HcmV?d00001 diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar_end.gif b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar_end.gif new file mode 100644 index 0000000000000000000000000000000000000000..feabf0bf6c8e2356544f2f2c60ea39595522703d GIT binary patch literal 909 zcmZ?wbhEHb6lTz1c*ekx)VbIpt|XweH?e)8b8@9?TAf3DiCad4cW#?YYPC;(M{woj zpz;YGSq=7a#Yr8DT~ccjS{L{i_e9mtbV{mpOe~9Sn&X|{?pxTI*s(aGZbn%3)bQFF zp4rWwIn7BOi(;B)M>WijZJz6q)fm+<%dfaQxN?$TQCC9S!ld>^vCZ=WO8bJ!CWKZ^ zaZD_CN-U3Rn3>SFAhBana_3@~l&Zk8KG%$TzrwD#mU)r&Gs3E-#x~D!O{-08TNvNE zz&W`pxnr?YQblybY=`*L=*HRct@FL}+8pCc1IzjYOZ(!Q=eZ*P!L@;5Loz#ufLNJ|OU6RQL(M7-9Eyr99GpsuP7`)$s3f}y88A#} zoS4kSGg-BG%A5n2RM;6JH)T95v8&YsChjD?|R9@YtybBu>GXfV`Md>hXNH{o+ zRn4cu@M4K~$O>Oc28Tlp+RVl}6Mzy6bRsutGpIx=Iym%hHGLJfXYIvpZ@DxXygY84 zcFB+5EA-{n)FS2s)1}o7H2iuPKXxAJ%#UFxaBO_aJwsP}#hM46&$&4md<>fsxSB36 z5nR&O)UcJELC&V+#RZpdZ*KZ-sJQTUAtQrffSXB%fs;j{#^F}(?Til^ilxK(Vm1mM z+xhi5D?@>1K!SDoI~%SK9P;}ZSQrF^93tk&?fuR2;V$zJ$7Z%hdG9)b1qCObpfli)u)y literal 0 HcmV?d00001 diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js new file mode 100644 index 00000000000..b3463569314 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css index 0aeaa97fe05..ce3df208de2 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css @@ -381,6 +381,31 @@ caption a:link, caption a:hover, caption a:active, caption a:visited { background-image:url(resources/titlebar.gif); height:18px; } +.contentContainer ul.blockList li.blockList caption span.activeTableTab span { + white-space:nowrap; + padding-top:8px; + padding-left:8px; + display:block; + float:left; + background-image:url(resources/activetitlebar.gif); + height:18px; +} +.contentContainer ul.blockList li.blockList caption span.tableTab span { + white-space:nowrap; + padding-top:8px; + padding-left:8px; + display:block; + float:left; + background-image:url(resources/titlebar.gif); + height:18px; +} +.contentContainer ul.blockList li.blockList caption span.tableTab, .contentContainer ul.blockList li.blockList caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + background-image:none; + float:none; + display:inline; +} .overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { width:10px; background-image:url(resources/titlebar_end.gif); @@ -389,6 +414,24 @@ caption a:link, caption a:hover, caption a:active, caption a:visited { position:relative; float:left; } +.contentContainer ul.blockList li.blockList .activeTableTab .tabEnd { + width:10px; + margin-right:5px; + background-image:url(resources/activetitlebar_end.gif); + background-repeat:no-repeat; + background-position:top right; + position:relative; + float:left; +} +.contentContainer ul.blockList li.blockList .tableTab .tabEnd { + width:10px; + margin-right:5px; + background-image:url(resources/titlebar_end.gif); + background-repeat:no-repeat; + background-position:top right; + position:relative; + float:left; +} ul.blockList ul.blockList li.blockList table { margin:0 0 12px 0px; width:100%; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java index 9625be7b346..f1c2a13a30d 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java @@ -72,6 +72,9 @@ public class DocPaths { return DocPath.create("index-" + n + ".html"); } + /** The name of the default javascript file. */ + public static final DocPath JAVASCRIPT = DocPath.create("script.js"); + /** The name of the file for the overview frame. */ public static final DocPath OVERVIEW_FRAME = DocPath.create("overview-frame.html"); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java new file mode 100644 index 00000000000..d1211fc1c91 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.doclets.internal.toolkit.util; + +/** + * Enum representing method types. + * + * @author Bhavesh Patel + */ +public enum MethodTypes { + ALL(0xffff, "All Methods", "t0", true), + STATIC(0x1, "Static Methods", "t1", false), + INSTANCE(0x2, "Instance Methods", "t2", false), + ABSTRACT(0x4, "Abstract Methods", "t3", false), + CONCRETE(0x8, "Concrete Methods", "t4", false), + DEPRECATED(0x10, "Deprecated Methods", "t5", false); + + private final int value; + private final String text; + private final String tabId; + private final boolean isDefaultTab; + + MethodTypes(int v, String t, String id, boolean dt) { + this.value = v; + this.text = t; + this.tabId = id; + this.isDefaultTab = dt; + } + + public int value() { + return value; + } + + public String text() { + return text; + } + + public String tabId() { + return tabId; + } + + public boolean isDefaultTab() { + return isDefaultTab; + } +} diff --git a/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java b/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java index df87249969e..683d1d9dcc2 100644 --- a/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java +++ b/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java @@ -201,7 +201,15 @@ public class TestHtmlTableTags extends JavadocTester { "Fields " }, {BUG_ID + FS + "pkg1" + FS + "C1.html", - "Methods " + "All " + + "Methods " + + "" + + "Instance Methods " + + "" + + "Concrete Methods " + + "" + + "Deprecated Methods " + + "" }, {BUG_ID + FS + "pkg2" + FS + "C2.html", "Nested Classes " diff --git a/langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java b/langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java new file mode 100644 index 00000000000..6a60b5036bd --- /dev/null +++ b/langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8002304 + * @summary Test for various method types in the method summary table + * @author Bhavesh Patel + * @library ../lib/ + * @build JavadocTester TestMethodTypes + * @run main TestMethodTypes + */ + +public class TestMethodTypes extends JavadocTester { + + //Test information. + private static final String BUG_ID = "8002304"; + + //Javadoc arguments. + private static final String[] ARGS = new String[] { + "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1" + }; + + private static final String[][] TEST = { + {BUG_ID + FS + "pkg1" + FS + "A.html", + "var methods = {" + }, + + {BUG_ID + FS + "pkg1" + FS + "A.html", + "All " + + "Methods " + + "" + + "Static Methods " + + "" + + "Instance Methods " + + "" + + "Concrete Methods " + + "" + + "Deprecated Methods " + + "" + }, + + {BUG_ID + FS + "pkg1" + FS + "A.html", + "" + }, + + {BUG_ID + FS + "pkg1" + FS + "B.html", + "All " + + "Methods " + + "" + + "Instance Methods " + + "" + + "Abstract Methods " + + "" + }, + + {BUG_ID + FS + "pkg1" + FS + "D.html", + "var methods = {" + }, + + {BUG_ID + FS + "pkg1" + FS + "D.html", + "All " + + "Methods " + + "" + + "Instance Methods " + + "" + + "Abstract Methods " + + "" + + "Concrete Methods " + + "" + + "Deprecated Methods " + + "" + }, + + {BUG_ID + FS + "pkg1" + FS + "D.html", + "" + }, + }; + private static final String[][] NEGATED_TEST = { + {BUG_ID + FS + "pkg1" + FS + "A.html", + "Methods " + + "" + }, + + {BUG_ID + FS + "pkg1" + FS + "B.html", + "Methods " + + "" + }, + + {BUG_ID + FS + "pkg" + FS + "D.html", + "Methods " + + "" + }, + }; + + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String[] args) { + TestMethodTypes tester = new TestMethodTypes(); + run(tester, ARGS, TEST, NEGATED_TEST); + tester.printSummary(); + } + + /** + * {@inheritDoc} + */ + public String getBugId() { + return BUG_ID; + } + + /** + * {@inheritDoc} + */ + public String getBugName() { + return getClass().getName(); + } +} diff --git a/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/A.java b/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/A.java new file mode 100644 index 00000000000..6a75d86eebd --- /dev/null +++ b/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/A.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg1; + +/** + * This class has a mixture of different types of methods. The methods summary + * table should appear with "All Methods", "Static Methods", "Instance Methods", + * "Concrete Methods" and "Deprecated Methods". + */ +public class A { + + /** + * This is the first concrete instance method. + */ + public void readObject() { + } + + /** + * This is the second concrete instance method. + */ + public final void setStub() { + } + + /** + * This is the third concrete instance method. + */ + public String getParameter() { + return "test"; + } + + /** + * This is the first concrete instance deprecated method. + * @deprecated This is a deprecated method that should appear in the tab. + */ + public void resize() { + } + + /** + * This is the fourth concrete instance method. + */ + public void showStatus() { + } + + /** + * This is the first concrete static method. + */ + public final static void staticMethod() { + } + + /** + * This is the second concrete instance deprecated method. + */ + @Deprecated + public void init() { + } +} diff --git a/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/B.java b/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/B.java new file mode 100644 index 00000000000..1404e095645 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/B.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg1; + +/** + * This interface has different types of methods such as "Instance Methods" and + * "Abstract Methods". All the tabs will display same list of methods. + */ +public interface B { + + /** + * This is the first abstract instance method. + */ + public void setName(); + + /** + * This is the second abstract instance method. + */ + public String getName(); + + /** + * This is the third abstract instance method. + */ + public boolean addEntry(); + + /** + * This is the fourth abstract instance method. + */ + public boolean removeEntry(); + + /** + * This is the fifth abstract instance method. + */ + public String getPermissions(); +} diff --git a/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/D.java b/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/D.java new file mode 100644 index 00000000000..2d6b36c697c --- /dev/null +++ b/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/D.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg1; + +/** + * This class is marked as deprecated and has a mixture of different types of + * methods such as "Instance Methods", "Abstract Methods" and "Concrete + * Methods". None of the methods are marked as deprecated but since the class is + * deprecated, the methods will also be deprecated and "Deprecated Methods" tab + * will also be shown with all the methods. + */ +@Deprecated +public abstract class D { + + /** + * This is the first abstract instance method. + */ + public abstract void readObject(); + + /** + * This is the first concrete instance method. + */ + public final void setStub() { + } + + /** + * This is the second concrete instance method. + */ + public String getParameter() { + return "test"; + } +} diff --git a/langtools/test/tools/javadoc/api/basic/APITest.java b/langtools/test/tools/javadoc/api/basic/APITest.java index c9da54f0eb2..358b6b3bc48 100644 --- a/langtools/test/tools/javadoc/api/basic/APITest.java +++ b/langtools/test/tools/javadoc/api/basic/APITest.java @@ -201,8 +201,11 @@ class APITest { "pkg/package-tree.html", "resources/background.gif", "resources/tab.gif", + "resources/activetitlebar_end.gif", + "resources/activetitlebar.gif", "resources/titlebar_end.gif", "resources/titlebar.gif", + "script.js", "stylesheet.css" )); } From 61235e9c09b2fcb7d1662a9519e3cceed554e173 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 19 Nov 2012 16:40:54 -0800 Subject: [PATCH 42/94] 8003655: Add javac.jvm.ClassFile.V52 Reviewed-by: ksrini --- .../src/share/classes/com/sun/tools/javac/jvm/ClassFile.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java index f01b97a18d0..86307ab39c8 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java @@ -104,7 +104,8 @@ public class ClassFile { V45_3(45, 3), // base level for all attributes V49(49, 0), // JDK 1.5: enum, generics, annotations V50(50, 0), // JDK 1.6: stackmaps - V51(51, 0); // JDK 1.7 + V51(51, 0), // JDK 1.7 + V52(52, 0); // JDK 1.8: lambda, type annos, param names Version(int major, int minor) { this.major = major; this.minor = minor; From f19ad0fb5b7508bdeec06cd33204f3ae54299bfe Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 20 Nov 2012 18:56:01 +0400 Subject: [PATCH 43/94] 8003333: Regression: java/beans/EventHandler/Test6277266.java fails with ACE Reviewed-by: art --- jdk/test/java/beans/EventHandler/Test6277266.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/test/java/beans/EventHandler/Test6277266.java b/jdk/test/java/beans/EventHandler/Test6277266.java index 60bc13727e0..72383f4217d 100644 --- a/jdk/test/java/beans/EventHandler/Test6277266.java +++ b/jdk/test/java/beans/EventHandler/Test6277266.java @@ -51,9 +51,11 @@ public class Test6277266 { ) ); throw new Error("SecurityException expected"); + } catch (SecurityException exception) { + return; // expected security exception in JDK 7 } catch (InvocationTargetException exception) { if (exception.getCause() instanceof SecurityException){ - return; // expected security exception + return; // expected security exception in JDK 8 } throw new Error("unexpected exception", exception); } catch (InterruptedException exception) { From f0fe027b508843fce713fdbe3b824d806b109b99 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 20 Nov 2012 07:21:07 -0800 Subject: [PATCH 44/94] 8003649: regression/langtools: tools/javac/doctree Reviewed-by: ksrini --- langtools/test/tools/javac/doctree/DocCommentTester.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/langtools/test/tools/javac/doctree/DocCommentTester.java b/langtools/test/tools/javac/doctree/DocCommentTester.java index 48973e0600d..8a6775ab298 100644 --- a/langtools/test/tools/javac/doctree/DocCommentTester.java +++ b/langtools/test/tools/javac/doctree/DocCommentTester.java @@ -176,6 +176,7 @@ public class DocCommentTester { * Verify the structure of the DocTree AST by comparing it against golden text. */ static class ASTChecker extends Checker { + static final String NEWLINE = System.getProperty("line.separator"); Printer printer = new Printer(); String source; @@ -197,7 +198,7 @@ public class DocCommentTester { DocCommentTree dc = trees.getDocCommentTree(path); printer.print(dc, out); out.flush(); - String found = out.toString(); + String found = out.toString().replace(NEWLINE, "\n"); // Look for the first block comment after the first occurrence of name int start = source.indexOf("\n/*\n", findName(source, name)); From f2fa2a199cca9df10e4d055bb2c5b79c6aedaed6 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 20 Nov 2012 07:25:11 -0800 Subject: [PATCH 45/94] 8003650: java.lang.Exception: expected string not found: pkg/package-frame.html Reviewed-by: ksrini --- .../test/tools/javadoc/api/basic/GetTask_WriterTest.java | 5 +++-- langtools/test/tools/javadoc/api/basic/RunTest.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java b/langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java index 1ba40228689..389b8d60be1 100644 --- a/langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java +++ b/langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java @@ -67,8 +67,9 @@ public class GetTask_WriterTest extends APITest { String out = sw.toString(); System.err.println(">>" + out + "<<"); for (String f: standardExpectFiles) { - if (f.endsWith(".html") && !out.contains(f)) - throw new Exception("expected string not found: " + f); + String f1 = f.replace('/', File.separatorChar); + if (f1.endsWith(".html") && !out.contains(f1)) + throw new Exception("expected string not found: " + f1); } } else { throw new Exception("task failed"); diff --git a/langtools/test/tools/javadoc/api/basic/RunTest.java b/langtools/test/tools/javadoc/api/basic/RunTest.java index aa006e0a7d7..2e6c65252df 100644 --- a/langtools/test/tools/javadoc/api/basic/RunTest.java +++ b/langtools/test/tools/javadoc/api/basic/RunTest.java @@ -64,8 +64,9 @@ public class RunTest extends APITest { checkFiles(outDir, standardExpectFiles); String out = stdout.toString(); for (String f: standardExpectFiles) { - if (f.endsWith(".html") && !out.contains(f)) - error("expected string not found: " + f); + String f1 = f.replace('/', File.separatorChar); + if (f1.endsWith(".html") && !out.contains(f1)) + error("expected string not found: " + f1); } } else { error("call failed"); From d1eede168bf02ab84c8d8177cf282e4dc0324336 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 20 Nov 2012 15:43:28 +0000 Subject: [PATCH 46/94] 8003663: lambda test fails on Windows Fix path separator issue in test Reviewed-by: jjg --- langtools/test/tools/javac/lambda/abort/Abort.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langtools/test/tools/javac/lambda/abort/Abort.java b/langtools/test/tools/javac/lambda/abort/Abort.java index 9a7638ea063..5f20a93c4f4 100644 --- a/langtools/test/tools/javac/lambda/abort/Abort.java +++ b/langtools/test/tools/javac/lambda/abort/Abort.java @@ -85,7 +85,7 @@ public class Abort { } SimpleJavaFileObject asJFO(java.io.File dir) { - return new SimpleJavaFileObject(URI.create(dir.getAbsolutePath() + "/" + filename), JavaFileObject.Kind.SOURCE) { + return new SimpleJavaFileObject(new java.io.File(dir, filename).toURI(), JavaFileObject.Kind.SOURCE) { @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { return contents; From d1a78e20211a8a7db48d2ebf1d1e0aa3bb899b53 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Tue, 20 Nov 2012 09:58:55 -0800 Subject: [PATCH 47/94] 8003639: convert lambda testng tests to jtreg and add them Reviewed-by: mcimadamore --- .../DefaultMethodRegressionTests.java | 137 +++ .../defaultMethods/fd/shapegen/RuleGroup.java | 206 ----- .../lambda/lambdaExecution/InInterface.java | 64 ++ .../lambdaExecution/InnerConstructor.java | 75 ++ .../LambdaTranslationTest1.java | 234 +++++ .../LambdaTranslationTest2.java | 355 ++++++++ .../javac/lambda/lambdaExecution/TBlock.java | 36 + .../javac/lambda/lambdaExecution/TMapper.java | 68 ++ .../lambda/lambdaExecution/TPredicate.java | 64 ++ .../MethodReferenceTestFDCCE.java | 154 ++++ .../MethodReferenceTestInnerDefault.java | 88 ++ .../MethodReferenceTestInnerInstance.java | 95 ++ .../MethodReferenceTestInnerVarArgsThis.java | 250 ++++++ .../MethodReferenceTestInstance.java | 70 ++ .../MethodReferenceTestKinds.java | 194 ++++ .../MethodReferenceTestNew.java | 138 +++ .../MethodReferenceTestNewInner.java | 157 ++++ .../MethodReferenceTestSueCase1.java | 54 ++ .../MethodReferenceTestSueCase2.java | 54 ++ .../MethodReferenceTestSueCase4.java | 59 ++ .../MethodReferenceTestSuper.java | 120 +++ .../MethodReferenceTestSuperDefault.java | 82 ++ .../MethodReferenceTestTypeConversion.java | 62 ++ .../MethodReferenceTestVarArgs.java | 204 +++++ .../MethodReferenceTestVarArgsExt.java | 191 ++++ .../MethodReferenceTestVarArgsSuper.java | 207 +++++ ...ethodReferenceTestVarArgsSuperDefault.java | 189 ++++ .../MethodReferenceTestVarArgsThis.java | 186 ++++ .../tools/javac/lambdaShapes/TEST.properties | 2 + .../org/openjdk/tests/javac}/FDTest.java | 82 +- .../tests/separate/AttributeInjector.java | 73 ++ .../org/openjdk/tests/separate/ClassFile.java | 454 ++++++++++ .../tests/separate/ClassFilePreprocessor.java | 30 + .../separate/ClassToInterfaceConverter.java | 94 ++ .../org/openjdk/tests/separate/Compiler.java | 232 +++++ .../tests/separate/DirectedClassLoader.java | 101 +++ .../openjdk/tests/separate/SourceModel.java | 582 ++++++++++++ .../openjdk/tests/separate/TestHarness.java | 354 ++++++++ .../openjdk/tests}/shapegen/ClassCase.java | 6 +- .../openjdk/tests}/shapegen/Hierarchy.java | 86 +- .../tests}/shapegen/HierarchyGenerator.java | 22 +- .../org/openjdk/tests}/shapegen/Rule.java | 2 +- .../org/openjdk/tests/shapegen/RuleGroup.java | 206 +++++ .../org/openjdk/tests}/shapegen/TTNode.java | 6 +- .../org/openjdk/tests}/shapegen/TTParser.java | 2 +- .../org/openjdk/tests}/shapegen/TTShape.java | 2 +- .../openjdk/tests/vm/DefaultMethodsTest.java | 826 ++++++++++++++++++ .../tests/vm/FDSeparateCompilationTest.java | 197 +++++ 48 files changed, 6900 insertions(+), 252 deletions(-) create mode 100644 langtools/test/tools/javac/defaultMethodExecution/DefaultMethodRegressionTests.java delete mode 100644 langtools/test/tools/javac/defaultMethods/fd/shapegen/RuleGroup.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExecution/InInterface.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExecution/InnerConstructor.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest1.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest2.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExecution/TBlock.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExecution/TMapper.java create mode 100644 langtools/test/tools/javac/lambda/lambdaExecution/TPredicate.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestFDCCE.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerDefault.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerInstance.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerVarArgsThis.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInstance.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestKinds.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNew.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInner.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase1.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase2.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase4.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuper.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuperDefault.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestTypeConversion.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgs.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsExt.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuper.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuperDefault.java create mode 100644 langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsThis.java create mode 100644 langtools/test/tools/javac/lambdaShapes/TEST.properties rename langtools/test/tools/javac/{defaultMethods/fd => lambdaShapes/org/openjdk/tests/javac}/FDTest.java (64%) create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/AttributeInjector.java create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFile.java create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFilePreprocessor.java create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassToInterfaceConverter.java create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/DirectedClassLoader.java create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java rename langtools/test/tools/javac/{defaultMethods/fd => lambdaShapes/org/openjdk/tests}/shapegen/ClassCase.java (98%) rename langtools/test/tools/javac/{defaultMethods/fd => lambdaShapes/org/openjdk/tests}/shapegen/Hierarchy.java (59%) rename langtools/test/tools/javac/{defaultMethods/fd => lambdaShapes/org/openjdk/tests}/shapegen/HierarchyGenerator.java (92%) rename langtools/test/tools/javac/{defaultMethods/fd => lambdaShapes/org/openjdk/tests}/shapegen/Rule.java (97%) create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/RuleGroup.java rename langtools/test/tools/javac/{defaultMethods/fd => lambdaShapes/org/openjdk/tests}/shapegen/TTNode.java (96%) rename langtools/test/tools/javac/{defaultMethods/fd => lambdaShapes/org/openjdk/tests}/shapegen/TTParser.java (98%) rename langtools/test/tools/javac/{defaultMethods/fd => lambdaShapes/org/openjdk/tests}/shapegen/TTShape.java (98%) create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java create mode 100644 langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/FDSeparateCompilationTest.java diff --git a/langtools/test/tools/javac/defaultMethodExecution/DefaultMethodRegressionTests.java b/langtools/test/tools/javac/defaultMethodExecution/DefaultMethodRegressionTests.java new file mode 100644 index 00000000000..e22f44b01d3 --- /dev/null +++ b/langtools/test/tools/javac/defaultMethodExecution/DefaultMethodRegressionTests.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng DefaultMethodRegressionTests + */ + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + +/** + * This set of classes/interfaces (K/I/C) is specially designed to expose a + * bug in the JVM where it did not find some overloaded methods in some + * specific situations. (fixed by hotspot changeset ffb9316fd9ed) + */ +interface K { + int bbb(Long l); +} + +interface I extends K { + default void aaa() {} + default void aab() {} + default void aac() {} + + default int bbb(Integer i) { return 22; } + default int bbb(Float f) { return 33; } + default int bbb(Long l) { return 44; } + default int bbb(Double d) { return 55; } + default int bbb(String s) { return 66; } + + default void caa() {} + default void cab() {} + default void cac() {} +} + +class C implements I {} + +public class DefaultMethodRegressionTests { + + @Test(groups = "vm") + public void testLostOverloadedMethod() { + C c = new C(); + assertEquals(c.bbb(new Integer(1)), 22); + assertEquals(c.bbb(new Float(1.1)), 33); + assertEquals(c.bbb(new Long(1L)), 44); + assertEquals(c.bbb(new Double(0.01)), 55); + assertEquals(c.bbb(new String("")), 66); + } + + // Test to ensure that the inference verifier accepts older classfiles + // with classes that implement interfaces with defaults. + @Test(groups = "vm") + public void testInferenceVerifier() { + // interface I { int m() default { return 99; } } + byte I_bytes[] = { + (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x33, + 0x00, 0x08, 0x07, 0x00, 0x06, 0x07, 0x00, 0x07, + 0x01, 0x00, 0x03, 0x66, 0x6f, 0x6f, 0x01, 0x00, + 0x03, 0x28, 0x29, 0x49, 0x01, 0x00, 0x04, 0x43, + 0x6f, 0x64, 0x65, 0x01, 0x00, 0x01, 0x49, 0x01, + 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, + 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x06, 0x00, 0x00, 0x01, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01, + 0x00, 0x03, 0x00, 0x04, 0x00, 0x01, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x03, 0x10, 0x63, (byte)0xac, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 + }; + // public class C implements I {} /* -target 1.5 */ + byte C_bytes[] = { + (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x31, + 0x00, 0x0c, 0x0a, 0x00, 0x03, 0x00, 0x08, 0x07, + 0x00, 0x09, 0x07, 0x00, 0x0a, 0x07, 0x00, 0x0b, + 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, + 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01, + 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x0c, 0x00, + 0x05, 0x00, 0x06, 0x01, 0x00, 0x01, 0x43, 0x01, + 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, + 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x01, 0x00, 0x01, 0x49, 0x00, 0x21, + 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x05, + 0x00, 0x06, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, + 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x05, 0x2a, (byte)0xb7, 0x00, 0x01, (byte)0xb1, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + ClassLoader cl = new ClassLoader() { + protected Class findClass(String name) { + if (name.equals("I")) { + return defineClass("I", I_bytes, 0, I_bytes.length); + } else if (name.equals("C")) { + return defineClass("C", C_bytes, 0, C_bytes.length); + } else { + return null; + } + } + }; + try { + Class.forName("C", true, cl); + } catch (Exception e) { + // unmodified verifier will throw VerifyError + fail("No exception should be thrown"); + } + } +} diff --git a/langtools/test/tools/javac/defaultMethods/fd/shapegen/RuleGroup.java b/langtools/test/tools/javac/defaultMethods/fd/shapegen/RuleGroup.java deleted file mode 100644 index 98911e47632..00000000000 --- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/RuleGroup.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package shapegen; - -import java.util.HashSet; -import java.util.Set; - -import static shapegen.ClassCase.Kind.*; - -/** - * - * @author Robert Field - */ -public class RuleGroup { - - final String name; - private final Rule[] rules; - - public RuleGroup(String name, Rule[] rules) { - this.name = name; - this.rules = rules; - } - - public boolean exec(ClassCase cc) { - boolean found = false; - for (Rule rule : rules) { - if (rule.guard(cc)) { - if (found) { - throw new RuntimeException("Bad rules -- multiple matches " + toString() + " for " + cc); - } else { - rule.eval(cc); - found = true; - } - } - } - return found; - } - - @Override - public String toString() { - return name; - } - - public static RuleGroup PROVENENCE = new RuleGroup("Provenence", new Rule[] { - new Rule("P-CDeclare") { - boolean guard(ClassCase cc) { - return cc.isa(CCONCRETE, CABSTRACT); - } - - void eval(ClassCase cc) { - cc.set_mprov(cc); - cc.set_HasClassMethod(true); - } - }, - - new Rule("P-IDeclare") { - boolean guard(ClassCase cc) { - return cc.isa(IDEFAULT, IPRESENT); - } - - void eval(ClassCase cc) { - cc.set_mprov(cc); - } - }, - - new Rule("P-IntfInh") { - boolean guard(ClassCase cc) { - return cc.isa(IVAC, CNONE) && !(cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod()); - } - - void eval(ClassCase cc) { - Set _S = new HashSet<>(); - for (ClassCase t : cc.getSupertypes()) { - _S.addAll(t.get_mprov()); - } - Set tops = new HashSet<>(); - for (ClassCase _W : _S) { - for (ClassCase _V : _S) { - if (_V.equals(_W) || !(_V.isSubtypeOf(_W))) { - tops.add(_W); - } - } - } - cc.set_mprov(tops); - } - }, - - new Rule("P-ClassInh") { - boolean guard(ClassCase cc) { - return cc.isa(CNONE) && (cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod()); - } - - void eval(ClassCase cc) { - cc.set_mprov(cc.getSuperclass()); - cc.set_HasClassMethod(true); - } - }, - - }); - - public static RuleGroup MARKER = new RuleGroup("Marker", new Rule[] { - new Rule("M-Default") { - boolean guard(ClassCase cc) { - return cc.isa(IDEFAULT); - } - - void eval(ClassCase cc) { - cc.set_HasDefault(true); - } - }, - - new Rule("M-Conc") { - boolean guard(ClassCase cc) { - return cc.isa(CCONCRETE); - } - - void eval(ClassCase cc) { - cc.set_IsConcrete(true); - } - }, - - }); - - public static RuleGroup RESOLUTION = new RuleGroup("Resolution", new Rule[] { - new Rule("R-Resolve") { - boolean guard(ClassCase cc) { - if (!(cc.isClass() && cc.get_mprov().size() == 1)) { - return false; - } - ClassCase _V = cc.get_mprov().iterator().next(); - return _V.get_IsConcrete() || _V.get_HasDefault(); - } - - void eval(ClassCase cc) { - ClassCase _V = cc.get_mprov().iterator().next(); - cc.set_mres(_V); - } - }, - - }); - - public static RuleGroup DEFENDER = new RuleGroup("Defender", new Rule[] { - new Rule("D-Defend") { - boolean guard(ClassCase cc) { - ClassCase mresSuper = cc.hasSuperclass() ? cc.getSuperclass().get_mres() : null; - boolean eq = cc.get_mres() == null ? mresSuper == null : cc.get_mres().equals(mresSuper); - return cc.isa(CNONE) && !eq; - } - - void eval(ClassCase cc) { - cc.set_mdefend(cc.get_mres()); - } - }, - - }); - - public static RuleGroup CHECKING = new RuleGroup("Checking", new Rule[] { - new Rule("C-Check") { - boolean guard(ClassCase cc) { - for (ClassCase t : cc.getSupertypes()) { - if (! t.get_OK()) { - return false; - } - } - int defenderCount = 0; - int provCount = 0; - for (ClassCase prov : cc.get_mprov()) { - if (prov.get_HasDefault()) { - defenderCount++; - } - provCount++; - } - return provCount <= 1 || defenderCount == 0; - } - - void eval(ClassCase cc) { - cc.set_OK(true); - } - }, - - }); - -} diff --git a/langtools/test/tools/javac/lambda/lambdaExecution/InInterface.java b/langtools/test/tools/javac/lambda/lambdaExecution/InInterface.java new file mode 100644 index 00000000000..778ee492c9c --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExecution/InInterface.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng InInterface + */ + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Test; + +interface LTII { + + interface ILsp1 { + String m(); + } + + interface ILsp2 { + String m(String x); + } + + default ILsp1 t1() { + return () -> { return "yo"; }; + } + + default ILsp2 t2() { + return (x) -> { return "snur" + x; }; + } + +} + +@Test +public class InInterface implements LTII { + + public void testLambdaInDefaultMethod() { + assertEquals(t1().m(), "yo"); + assertEquals(t2().m("p"), "snurp"); + } + +} diff --git a/langtools/test/tools/javac/lambda/lambdaExecution/InnerConstructor.java b/langtools/test/tools/javac/lambda/lambdaExecution/InnerConstructor.java new file mode 100644 index 00000000000..21b747dfd55 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExecution/InnerConstructor.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng InnerConstructor + */ + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Test; + +@Test +public class InnerConstructor { + + public void testLambdaWithInnerConstructor() { + assertEquals(seq1().m().toString(), "Cbl:nada"); + assertEquals(seq2().m("rats").toString(), "Cbl:rats"); + } + + Ib1 seq1() { + return () -> { return new Cbl(); }; + } + + Ib2 seq2() { + return (x) -> { return new Cbl(x); }; + } + + class Cbl { + String val; + + Cbl() { + this.val = "nada"; + } + + Cbl(String z) { + this.val = z; + } + + public String toString() { + return "Cbl:" + val; + } + } + + interface Ib1 { + Object m(); + } + + interface Ib2 { + Object m(String x); + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest1.java b/langtools/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest1.java new file mode 100644 index 00000000000..083d2ce43b0 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest1.java @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng LambdaTranslationTest1 + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +@Test +public class LambdaTranslationTest1 extends LT1Sub { + + String cntxt = "blah"; + + private static final ThreadLocal result = new ThreadLocal<>(); + + private static void setResult(Object s) { result.set(s); } + private static void appendResult(Object s) { result.set(result.get().toString() + s); } + + private static void assertResult(String expected) { + assertEquals(result.get().toString(), expected); + } + + static Integer count(String s) { + return s.length(); + } + + static int icount(String s) { + return s.length(); + } + + static void eye(Integer i) { + setResult(String.format("I:%d", i)); + } + + static void ieye(int i) { + setResult(String.format("i:%d", i)); + } + + static void deye(double d) { + setResult(String.format("d:%f", d)); + } + + public void testLambdas() { + TBlock b = t -> {setResult("Sink0::" + t);}; + b.apply("Howdy"); + assertResult("Sink0::Howdy"); + + TBlock b1 = t -> {setResult("Sink1::" + t);}; + b1.apply("Rowdy"); + assertResult("Sink1::Rowdy"); + + for (int i = 5; i < 10; ++i) { + TBlock b2 = t -> {setResult("Sink2::" + t);}; + b2.apply(i); + assertResult("Sink2::" + i); + } + + TBlock b3 = t -> {setResult("Sink3::" + t);}; + for (int i = 900; i > 0; i -= 100) { + b3.apply(i); + assertResult("Sink3::" + i); + } + + cntxt = "blah"; + TBlock b4 = t -> {setResult(String.format("b4: %s .. %s", cntxt, t));}; + b4.apply("Yor"); + assertResult("b4: blah .. Yor"); + + String flaw = "flaw"; + TBlock b5 = t -> {setResult(String.format("b5: %s .. %s", flaw, t));}; + b5.apply("BB"); + assertResult("b5: flaw .. BB"); + + cntxt = "flew"; + TBlock b6 = t -> {setResult(String.format("b6: %s .. %s .. %s", t, cntxt, flaw));}; + b6.apply("flee"); + assertResult("b6: flee .. flew .. flaw"); + + TBlock b7 = t -> {setResult(String.format("b7: %s %s", t, this.protectedSuperclassMethod()));}; + b7.apply("this:"); + assertResult("b7: this: instance:flew"); + + TBlock b8 = t -> {setResult(String.format("b8: %s %s", t, super.protectedSuperclassMethod()));}; + b8.apply("super:"); + assertResult("b8: super: I'm the sub"); + + TBlock b7b = t -> {setResult(String.format("b9: %s %s", t, protectedSuperclassMethod()));}; + b7b.apply("implicit this:"); + assertResult("b9: implicit this: instance:flew"); + + TBlock b10 = t -> {setResult(String.format("b10: new LT1Thing: %s", (new LT1Thing(t)).str));}; + b10.apply("thing"); + assertResult("b10: new LT1Thing: thing"); + + TBlock b11 = t -> {setResult(String.format("b11: %s", (new LT1Thing(t) { + String get() { + return "*" + str.toString() + "*"; + } + }).get()));}; + b11.apply(999); + assertResult("b11: *999*"); + } + + public void testMethodRefs() { + LT1IA ia = LambdaTranslationTest1::eye; + ia.doit(1234); + assertResult("I:1234"); + + LT1IIA iia = LambdaTranslationTest1::ieye; + iia.doit(1234); + assertResult("i:1234"); + + LT1IA da = LambdaTranslationTest1::deye; + da.doit(1234); + assertResult("d:1234.000000"); + + LT1SA a = LambdaTranslationTest1::count; + assertEquals((Integer) 5, a.doit("howdy")); + + a = LambdaTranslationTest1::icount; + assertEquals((Integer) 6, a.doit("shower")); + } + + public void testInner() throws Exception { + (new In()).doInner(); + } + + protected String protectedSuperclassMethod() { + return "instance:" + cntxt; + } + + private class In { + + private int that = 1234; + + void doInner() { + TBlock i4 = t -> {setResult(String.format("i4: %d .. %s", that, t));}; + i4.apply("=1234"); + assertResult("i4: 1234 .. =1234"); + + TBlock i5 = t -> {setResult(""); appendResult(t); appendResult(t);}; + i5.apply("fruit"); + assertResult("fruitfruit"); + + cntxt = "human"; + TBlock b4 = t -> {setResult(String.format("b4: %s .. %s", cntxt, t));}; + b4.apply("bin"); + assertResult("b4: human .. bin"); + + final String flaw = "flaw"; + +/** + Callable c5 = () -> "["+flaw+"]" ; + System.out.printf("c5: %s\n", c5.call() ); + **/ + + TBlock b5 = t -> {setResult(String.format("b5: %s .. %s", flaw, t));}; + b5.apply("BB"); + assertResult("b5: flaw .. BB"); + + cntxt = "borg"; + TBlock b6 = t -> {setResult(String.format("b6: %s .. %s .. %s", t, cntxt, flaw));}; + b6.apply("flee"); + assertResult("b6: flee .. borg .. flaw"); + + TBlock b7b = t -> {setResult(String.format("b7b: %s %s", t, protectedSuperclassMethod()));}; + b7b.apply("implicit outer this"); + assertResult("b7b: implicit outer this instance:borg"); + + /** + TBlock b9 = t -> { System.out.printf("New: %s\n", (new LT1Thing(t)).str); }; + b9.apply("thing"); + + TBlock ba = t -> { System.out.printf("Def: %s\n", (new LT1Thing(t) { String get() { return "*" + str.toString() +"*";}}).get() ); }; + ba.apply(999); + + */ + } + } +} + +class LT1Sub { + protected String protectedSuperclassMethod() { + return "I'm the sub"; + } +} + +class LT1Thing { + final Object str; + + LT1Thing(Object s) { + str = s; + } +} + +interface LT1SA { + Integer doit(String s); +} + +interface LT1IA { + void doit(int i); +} + +interface LT1IIA { + void doit(Integer i); +} diff --git a/langtools/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest2.java b/langtools/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest2.java new file mode 100644 index 00000000000..574bca37ab7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest2.java @@ -0,0 +1,355 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng LambdaTranslationTest2 + */ + +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * LambdaTranslationTest2 -- end-to-end smoke tests for lambda evaluation + */ + +@Test +public class LambdaTranslationTest2 { + + final String dummy = "dummy"; + + public void testLambdas() { + TPredicate isEmpty = s -> s.isEmpty(); + assertTrue(isEmpty.test("")); + assertTrue(!isEmpty.test("foo")); + + TPredicate oIsEmpty = s -> ((String) s).isEmpty(); + assertTrue(oIsEmpty.test("")); + assertTrue(!oIsEmpty.test("foo")); + + TPredicate alwaysTrue = o -> true; + assertTrue(alwaysTrue.test("")); + assertTrue(alwaysTrue.test(null)); + + TPredicate alwaysFalse = o -> false; + assertTrue(!alwaysFalse.test("")); + assertTrue(!alwaysFalse.test(null)); + + // tests local capture + String foo = "foo"; + TPredicate equalsFoo = s -> s.equals(foo); + assertTrue(!equalsFoo.test("")); + assertTrue(equalsFoo.test("foo")); + + // tests instance capture + TPredicate equalsDummy = s -> s.equals(dummy); + assertTrue(!equalsDummy.test("")); + assertTrue(equalsDummy.test("dummy")); + + TMapper ident = s -> s; + + assertEquals("blarf", ident.map("blarf")); + assertEquals("wooga", ident.map("wooga")); + assertTrue("wooga" == ident.map("wooga")); + + // constant capture + TMapper prefixer = s -> "p" + s; + assertEquals("pblarf", prefixer.map("blarf")); + assertEquals("pwooga", prefixer.map("wooga")); + + // instance capture + TMapper prefixer2 = s -> dummy + s; + assertEquals("dummyblarf", prefixer2.map("blarf")); + assertEquals("dummywooga", prefixer2.map("wooga")); + } + + interface Factory { + T make(); + } + + interface StringFactory extends Factory { } + + interface StringFactory2 extends Factory { + String make(); + } + + public void testBridges() { + Factory of = () -> "y"; + Factory ef = () -> "z"; + + assertEquals("y", of.make()); + assertEquals("y", ((Factory) of).make()); + assertEquals("y", ((Factory) of).make()); + + assertEquals("z", ef.make()); + assertEquals("z", ((Factory) ef).make()); + } + + public void testBridgesImplicitSpecialization() { + StringFactory sf = () -> "x"; + + assertEquals("x", sf.make()); + assertEquals("x", ((Factory) sf).make()); + assertEquals("x", ((Factory) sf).make()); + assertEquals("x", ((Factory) sf).make()); + } + + public void testBridgesExplicitSpecialization() { + StringFactory2 sf = () -> "x"; + + assertEquals("x", sf.make()); + assertEquals("x", ((Factory) sf).make()); + assertEquals("x", ((Factory) sf).make()); + assertEquals("x", ((Factory) sf).make()); + } + + public void testSuperCapture() { + class A { + String make() { return "x"; } + } + + class B extends A { + void testSuperCapture() { + StringFactory sf = () -> super.make(); + assertEquals("x", sf.make()); + } + } + + new B().testSuperCapture(); + } + + interface WidenD { + public String m(float a0, double a1); + } + + interface WidenS { + public String m(byte a0, short a1); + } + + interface WidenI { + public String m(byte a0, short a1, char a2, int a3); + } + + interface WidenL { + public String m(byte a0, short a1, char a2, int a3, long a4); + } + + interface Box { + public String m(byte a0, short a1, char a2, int a3, long a4, boolean a5, float a6, double a7); + } + + static String pb(Byte a0, Short a1, Character a2, Integer a3, Long a4, Boolean a5, Float a6, Double a7) { + return String.format("b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7); + } + + static String pwI1(int a0, int a1, int a2, int a3) { + return String.format("b%d s%d c%d i%d", a0, a1, a2, a3); + } + + static String pwI2(Integer a0, Integer a1, Integer a2, Integer a3) { + return String.format("b%d s%d c%d i%d", a0, a1, a2, a3); + } + + static String pwL1(long a0, long a1, long a2, long a3, long a4) { + return String.format("b%d s%d c%d i%d j%d", a0, a1, a2, a3, a4); + } + + static String pwL2(Long a0, Long a1, Long a2, Long a3, Long a4) { + return String.format("b%d s%d c%d i%d j%d", a0, a1, a2, a3, a4); + } + + static String pwS1(short a0, short a1) { + return String.format("b%d s%d", a0, a1); + } + + static String pwS2(Short a0, Short a1) { + return String.format("b%d s%d", a0, a1); + } + + static String pwD1(double a0, double a1) { + return String.format("f%f d%f", a0, a1); + } + + static String pwD2(Double a0, Double a1) { + return String.format("f%f d%f", a0, a1); + } + + public void testPrimitiveWidening() { + WidenS ws1 = LambdaTranslationTest2::pwS1; + assertEquals("b1 s2", ws1.m((byte) 1, (short) 2)); + + WidenD wd1 = LambdaTranslationTest2::pwD1; + assertEquals("f1.000000 d2.000000", wd1.m(1.0f, 2.0)); + + WidenI wi1 = LambdaTranslationTest2::pwI1; + assertEquals("b1 s2 c3 i4", wi1.m((byte) 1, (short) 2, (char) 3, 4)); + + WidenL wl1 = LambdaTranslationTest2::pwL1; + assertEquals("b1 s2 c3 i4 j5", wl1.m((byte) 1, (short) 2, (char) 3, 4, 5L)); + + // @@@ TODO: clarify spec on widen+box conversion + } + + interface Unbox { + public String m(Byte a0, Short a1, Character a2, Integer a3, Long a4, Boolean a5, Float a6, Double a7); + } + + static String pu(byte a0, short a1, char a2, int a3, long a4, boolean a5, float a6, double a7) { + return String.format("b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7); + } + + public void testUnboxing() { + Unbox u = LambdaTranslationTest2::pu; + assertEquals("b1 s2 cA i4 j5 ztrue f6.000000 d7.000000", u.m((byte)1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0)); + } + + public void testBoxing() { + Box b = LambdaTranslationTest2::pb; + assertEquals("b1 s2 cA i4 j5 ztrue f6.000000 d7.000000", b.m((byte) 1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0)); + } + + static boolean cc(Object o) { + return ((String) o).equals("foo"); + } + + public void testArgCastingAdaptation() { + TPredicate p = LambdaTranslationTest2::cc; + assertTrue(p.test("foo")); + assertTrue(!p.test("bar")); + } + + interface SonOfPredicate extends TPredicate { } + + public void testExtendsSAM() { + SonOfPredicate p = s -> s.isEmpty(); + assertTrue(p.test("")); + assertTrue(!p.test("foo")); + } + + public void testConstructorRef() { + Factory> lf = ArrayList::new; + List list = lf.make(); + assertTrue(list instanceof ArrayList); + assertTrue(list != lf.make()); + list.add("a"); + assertEquals("[a]", list.toString()); + } + + private static String privateMethod() { + return "private"; + } + + public void testPrivateMethodRef() { + Factory sf = LambdaTranslationTest2::privateMethod; + assertEquals("private", sf.make()); + } + + private interface PrivateIntf { + String make(); + } + + public void testPrivateIntf() { + PrivateIntf p = () -> "foo"; + assertEquals("foo", p.make()); + } + + interface Op { + public T op(T a, T b); + } + + public void testBoxToObject() { + Op maxer = Math::max; + for (int i=-100000; i < 100000; i += 100) + for (int j=-100000; j < 100000; j += 99) { + assertEquals((int) maxer.op(i,j), Math.max(i,j)); + } + } + + protected static String protectedMethod() { + return "protected"; + } + + public void testProtectedMethodRef() { + Factory sf = LambdaTranslationTest2::protectedMethod; + assertEquals("protected", sf.make()); + } + + class Inner1 { + String m1() { + return "Inner1.m1()"; + } + + class Inner2 { + public String m1() { + return "Inner1.Inner2.m1()"; + } + + protected String m2() { + return "Inner1.Inner2.m2()"; + } + + String m3() { + return "Inner1.Inner2.m3()"; + } + + class Inner3 { + T t = null; + Inner3(T t) { + this.t = t; + } + T m1() { + return t; + } + } + } + } + + public void testInnerClassMethodRef() { + Factory fs = new Inner1()::m1; + assertEquals("Inner1.m1()", fs.make()); + + fs = new Inner1().new Inner2()::m1; + assertEquals("Inner1.Inner2.m1()", fs.make()); + + fs = new Inner1().new Inner2()::m2; + assertEquals("Inner1.Inner2.m2()", fs.make()); + + fs = new Inner1().new Inner2()::m3; + assertEquals("Inner1.Inner2.m3()", fs.make()); + + fs = new Inner1().new Inner2().new Inner3("Inner1.Inner2.Inner3")::m1; + assertEquals("Inner1.Inner2.Inner3", fs.make()); + + Factory fsi = new Inner1().new Inner2().new Inner3(100)::m1; + assertEquals(100, (int)fsi.make()); + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExecution/TBlock.java b/langtools/test/tools/javac/lambda/lambdaExecution/TBlock.java new file mode 100644 index 00000000000..329eaf25de1 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExecution/TBlock.java @@ -0,0 +1,36 @@ +/** + * Performs operations upon an input object which may modify that object and/or + * external state (other objects). + * + *

All block implementations are expected to: + *

    + *
  • When used for aggregate operations upon many elements blocks + * should not assume that the {@code apply} operation will be called upon + * elements in any specific order.
  • + *
+ * + * @param The type of input objects to {@code apply}. + */ +public interface TBlock { + + /** + * Performs operations upon the provided object which may modify that object + * and/or external state. + * + * @param t an input object + */ + void apply(T t); + + /** + * Returns a Block which performs in sequence the {@code apply} methods of + * multiple Blocks. This Block's {@code apply} method is performed followed + * by the {@code apply} method of the specified Block operation. + * + * @param other an additional Block which will be chained after this Block + * @return a Block which performs in sequence the {@code apply} method of + * this Block and the {@code apply} method of the specified Block operation + */ + public default TBlock chain(TBlock other) { + return (T t) -> { apply(t); other.apply(t); }; + } +} diff --git a/langtools/test/tools/javac/lambda/lambdaExecution/TMapper.java b/langtools/test/tools/javac/lambda/lambdaExecution/TMapper.java new file mode 100644 index 00000000000..6a7096b7616 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExecution/TMapper.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Given an input object maps to an appropriate output object. A mapper may + * variously provide a mapping between types, object instances or keys and + * values or any other form of transformation upon the input. + * + *

All mapper implementations are expected to: + *

    + *
  • Provide stable results such that for any {@code t} the result of two + * {@code map} operations are always equivalent. ie.
    + * Foo one = mapper.map(a);
    + * Foo two = mapper.map(a);
    + *
    + * assert one.equals(two) && two.equals(one);
    + * 
  • + *
  • Equivalent input objects should map to equivalent output objects. ie.
    + * assert a.equals(b);  // a and b are equivalent
    + *
    + * Foo x = mapper.map(a);
    + * Foo y = mapper.map(b);
    + *
    + * assert x.equals(y); // their mapped results should be as equivalent.
    + * 
  • + *
  • The mapper should not modify the input object in any way that would + * change the mapping.
  • + *
  • When used for aggregate operations upon many elements mappers + * should not assume that the {@code map} operation will be called upon elements + * in any specific order.
  • + *
+ * + * @param the type of output objects from {@code map} operation. May be the + * @param the type of input objects provided to the {@code map} operation. + * same type as {@code }. + */ +public interface TMapper { + + /** + * Map the provided input object to an appropriate output object. + * + * @param t the input object to be mapped. + * @return the mapped output object. + */ + R map(T t); +} diff --git a/langtools/test/tools/javac/lambda/lambdaExecution/TPredicate.java b/langtools/test/tools/javac/lambda/lambdaExecution/TPredicate.java new file mode 100644 index 00000000000..2e98df26934 --- /dev/null +++ b/langtools/test/tools/javac/lambda/lambdaExecution/TPredicate.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Determines if the input object matches some criteria. + * + *

All predicate implementations are expected to: + *

    + *
  • Provide stable results such that for any {@code t} the result of two + * {@code eval} operations are always equivalent. ie.
    + * boolean one = predicate.test(a);
    + * boolean two = predicate.test(a);
    + *
    + * assert one == two;
    + * 
  • + *
  • Equivalent input objects should map to equivalent output objects. ie.
    + * assert a.equals(b);  // a and b are equivalent
    + *
    + * boolean x = predicate.test(a);
    + * boolean y = predicate.test(ab;
    + *
    + * assert x == y; // their test results should be the same.
    + * 
  • + *
  • The predicate should not modify the input object in any way that would + * change the evaluation.
  • + *
  • When used for aggregate operations upon many elements predicates + * should not assume that the {@code test} operation will be called upon + * elements in any specific order.
  • + *
+ * + * @param the type of input objects provided to {@code test}. + */ +public interface TPredicate { + + /** + * Return {@code true} if the input object matches some criteria. + * + * @param t the input object. + * @return {@code true} if the input object matched some criteria. + */ + boolean test(T t); +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestFDCCE.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestFDCCE.java new file mode 100644 index 00000000000..00eed0641da --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestFDCCE.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestFDCCE + */ + +import org.testng.annotations.Test; +import java.lang.reflect.Array; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +/** + * Method references and raw types. + * @author Robert Field + */ + +@Test +@SuppressWarnings({"rawtypes", "unchecked"}) +public class MethodReferenceTestFDCCE { + + static void assertCCE(Throwable t) { + assertEquals(t.getClass().getName(), "java.lang.ClassCastException"); + } + + interface Pred { boolean accept(T x); } + + interface Ps { boolean accept(short x); } + + interface Oo { Object too(int x); } + + interface Reto { T m(); } + + class A {} + class B extends A {} + + static boolean isMinor(int x) { + return x < 18; + } + + static boolean tst(A x) { + return true; + } + + static Object otst(Object x) { + return x; + } + + static boolean stst(Short x) { + return x < 18; + } + + static short ritst() { + return 123; + } + + public void testMethodReferenceFDPrim1() { + Pred p = MethodReferenceTestFDCCE::isMinor; + Pred p2 = p; + assertTrue(p2.accept((Byte)(byte)15)); + } + + public void testMethodReferenceFDPrim2() { + Pred p = MethodReferenceTestFDCCE::isMinor; + Pred p2 = p; + assertTrue(p2.accept((byte)15)); + } + + public void testMethodReferenceFDPrimICCE() { + Pred p = MethodReferenceTestFDCCE::isMinor; + Pred p2 = p; + try { + p2.accept(15); // should throw CCE + fail("Exception should have been thrown"); + } catch (Throwable t) { + assertCCE(t); + } + } + + public void testMethodReferenceFDPrimOCCE() { + Pred p = MethodReferenceTestFDCCE::isMinor; + Pred p2 = p; + try { + p2.accept(new Object()); // should throw CCE + fail("Exception should have been thrown"); + } catch (Throwable t) { + assertCCE(t); + } + } + + public void testMethodReferenceFDRef() { + Pred p = MethodReferenceTestFDCCE::tst; + Pred p2 = p; + assertTrue(p2.accept(new B())); + } + + public void testMethodReferenceFDRefCCE() { + Pred p = MethodReferenceTestFDCCE::tst; + Pred p2 = p; + try { + p2.accept(new A()); // should throw CCE + fail("Exception should have been thrown"); + } catch (Throwable t) { + assertCCE(t); + } + } + + public void testMethodReferenceFDPrimPrim() { + Ps p = MethodReferenceTestFDCCE::isMinor; + assertTrue(p.accept((byte)15)); + } + + public void testMethodReferenceFDPrimBoxed() { + Ps p = MethodReferenceTestFDCCE::stst; + assertTrue(p.accept((byte)15)); + } + + public void testMethodReferenceFDPrimRef() { + Oo p = MethodReferenceTestFDCCE::otst; + assertEquals(p.too(15).getClass().getName(), "java.lang.Integer"); + } + + public void testMethodReferenceFDRet1() { + Reto p = MethodReferenceTestFDCCE::ritst; + assertEquals(p.m(), (Short)(short)123); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerDefault.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerDefault.java new file mode 100644 index 00000000000..cdc9ef8f533 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerDefault.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestInnerDefault + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +interface IDSs { String m(String a); } + +interface InDefA { + default String xsA__(String s) { + return "A__xsA:" + s; + } + + default String xsAB_(String s) { + return "AB_xsA:" + s; + } + +} + +interface InDefB extends InDefA { + + default String xsAB_(String s) { + return "AB_xsB:" + s; + } + + default String xs_B_(String s) { + return "_B_xsB:" + s; + } +} + +@Test +public class MethodReferenceTestInnerDefault implements InDefB { + + public void testMethodReferenceInnerDefault() { + (new In()).testMethodReferenceInnerDefault(); + } + + class In { + + public void testMethodReferenceInnerDefault() { + IDSs q; + + q = MethodReferenceTestInnerDefault.this::xsA__; + assertEquals(q.m("*"), "A__xsA:*"); + + q = MethodReferenceTestInnerDefault.this::xsAB_; + assertEquals(q.m("*"), "AB_xsB:*"); + + q = MethodReferenceTestInnerDefault.this::xs_B_; + assertEquals(q.m("*"), "_B_xsB:*"); + } + } + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerInstance.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerInstance.java new file mode 100644 index 00000000000..165b470996e --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerInstance.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestInnerInstance + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +@Test +public class MethodReferenceTestInnerInstance { + + public void testMethodReferenceInnerInstance() { + cia().cib().testMethodReferenceInstance(); + } + + public void testMethodReferenceInnerExternal() { + cia().cib().testMethodReferenceExternal(); + } + + interface SI { + String m(Integer a); + } + + class CIA { + + String xI(Integer i) { + return "xI:" + i; + } + + public class CIB { + + public void testMethodReferenceInstance() { + SI q; + + q = CIA.this::xI; + assertEquals(q.m(55), "xI:55"); + } + + public void testMethodReferenceExternal() { + SI q; + + q = (new E())::xI; + assertEquals(q.m(77), "ExI:77"); + } + } + + CIB cib() { + return new CIB(); + } + + class E { + + String xI(Integer i) { + return "ExI:" + i; + } + } + + } + + CIA cia() { + return new CIA(); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerVarArgsThis.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerVarArgsThis.java new file mode 100644 index 00000000000..791bafb9d13 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerVarArgsThis.java @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestInnerVarArgsThis + */ + +import org.testng.annotations.Test; +import java.lang.reflect.Array; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +@Test +public class MethodReferenceTestInnerVarArgsThis { + + interface NsII { + + String m(Integer a, Integer b); + } + + interface Nsiii { + + String m(int a, int b, int c); + } + + interface Nsi { + + String m(int a); + } + + interface NsaO { + + String m(Object[] a); + } + + interface Nsai { + + String m(int[] a); + } + + interface Nsvi { + + String m(int... va); + } + + class CIA { + + String xvI(Integer... vi) { + StringBuilder sb = new StringBuilder("xvI:"); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + String xIvI(Integer f, Integer... vi) { + StringBuilder sb = new StringBuilder("xIvI:"); + sb.append(f); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + String xvi(int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xvi:" + sum; + } + + String xIvi(Integer f, int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xIvi:(" + f + ")" + sum; + } + + String xvO(Object... vi) { + StringBuilder sb = new StringBuilder("xvO:"); + for (Object i : vi) { + if (i.getClass().isArray()) { + sb.append("["); + int len = Array.getLength(i); + for (int x = 0; x < len; ++x) { + sb.append(Array.get(i, x)); + sb.append(","); + } + sb.append("]"); + + } else { + sb.append(i); + } + sb.append("*"); + } + return sb.toString(); + } + + public class CIB { + + // These should be processed as var args + public void testVarArgsNsSuperclass() { + NsII q; + + q = CIA.this::xvO; + assertEquals(q.m(55, 66), "xvO:55*66*"); + } + + public void testVarArgsNsArray() { + Nsai q; + + q = CIA.this::xvO; + assertEquals(q.m(new int[]{55, 66}), "xvO:[55,66,]*"); + } + + public void testVarArgsNsII() { + NsII q; + + q = CIA.this::xvI; + assertEquals(q.m(33, 7), "xvI:33-7-"); + + q = CIA.this::xIvI; + assertEquals(q.m(50, 40), "xIvI:5040-"); + + q = CIA.this::xvi; + assertEquals(q.m(100, 23), "xvi:123"); + + q = CIA.this::xIvi; + assertEquals(q.m(9, 21), "xIvi:(9)21"); + } + + public void testVarArgsNsiii() { + Nsiii q; + + q = CIA.this::xvI; + assertEquals(q.m(3, 2, 1), "xvI:3-2-1-"); + + q = CIA.this::xIvI; + assertEquals(q.m(888, 99, 2), "xIvI:88899-2-"); + + q = CIA.this::xvi; + assertEquals(q.m(900, 80, 7), "xvi:987"); + + q = CIA.this::xIvi; + assertEquals(q.m(333, 27, 72), "xIvi:(333)99"); + } + + public void testVarArgsNsi() { + Nsi q; + + q = CIA.this::xvI; + assertEquals(q.m(3), "xvI:3-"); + + q = CIA.this::xIvI; + assertEquals(q.m(888), "xIvI:888"); + + q = CIA.this::xvi; + assertEquals(q.m(900), "xvi:900"); + + q = CIA.this::xIvi; + assertEquals(q.m(333), "xIvi:(333)0"); + } + + // These should NOT be processed as var args + public void testVarArgsNsaO() { + NsaO q; + + q = CIA.this::xvO; + assertEquals(q.m(new String[]{"yo", "there", "dude"}), "xvO:yo*there*dude*"); + } + } + + CIB cib() { + return new CIB(); + } + + class E { + + String xI(Integer i) { + return "ExI:" + i; + } + } + } + + CIA cia() { + return new CIA(); + } + + // These should be processed as var args + public void testVarArgsNsSuperclass() { + cia().cib().testVarArgsNsSuperclass(); + } + + public void testVarArgsNsArray() { + cia().cib().testVarArgsNsArray(); + } + + public void testVarArgsNsII() { + cia().cib().testVarArgsNsII(); + } + + public void testVarArgsNsiii() { + cia().cib().testVarArgsNsiii(); + } + + public void testVarArgsNsi() { + cia().cib().testVarArgsNsi(); + } + + // These should NOT be processed as var args + + public void testVarArgsNsaO() { + cia().cib().testVarArgsNsaO(); + } + + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInstance.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInstance.java new file mode 100644 index 00000000000..7aba6d9b26c --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInstance.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestInstance + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +class MethodReferenceTestInstance_E { + String xI(Integer i) { + return "ExI:" + i; + } +} + +@Test +public class MethodReferenceTestInstance { + + interface SI { String m(Integer a); } + + String xI(Integer i) { + return "xI:" + i; + } + + public void testMethodReferenceInstance() { + SI q; + + q = this::xI; + assertEquals(q.m(55), "xI:55"); + } + + public void testMethodReferenceExternal() { + SI q; + + q = (new MethodReferenceTestInstance_E())::xI; + assertEquals(q.m(77), "ExI:77"); + } + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestKinds.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestKinds.java new file mode 100644 index 00000000000..c8f1aa1a0db --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestKinds.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestKinds + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +@Test +public class MethodReferenceTestKinds extends MethodReferenceTestKindsSup { + + interface S0 { String get(); } + interface S1 { String get(MethodReferenceTestKinds x); } + interface S2 { String get(MethodReferenceTestKinds x, MethodReferenceTestKinds y); } + + interface SXN0 { MethodReferenceTestKindsBase make(MethodReferenceTestKinds x); } + interface SXN1 { MethodReferenceTestKindsBase make(MethodReferenceTestKinds x, String str); } + + interface SN0 { MethodReferenceTestKindsBase make(); } + interface SN1 { MethodReferenceTestKindsBase make(String x); } + + class In extends MethodReferenceTestKindsBase { + In(String val) { + this.val = val; + } + + In() { + this("blank"); + } + } + + String instanceMethod0() { return "IM:0-" + this; } + String instanceMethod1(MethodReferenceTestKinds x) { return "IM:1-" + this + x; } + + static String staticMethod0() { return "SM:0"; } + static String staticMethod1(MethodReferenceTestKinds x) { return "SM:1-" + x; } + + MethodReferenceTestKinds(String val) { + super(val); + } + + MethodReferenceTestKinds() { + super("blank"); + } + + MethodReferenceTestKinds inst(String val) { + return new MethodReferenceTestKinds(val); + } + + public void testMRBound() { + S0 var = this::instanceMethod0; + assertEquals(var.get(), "IM:0-MethodReferenceTestKinds(blank)"); + } + + public void testMRBoundArg() { + S1 var = this::instanceMethod1; + assertEquals(var.get(inst("arg")), "IM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)"); + } + + public void testMRUnbound() { + S1 var = MethodReferenceTestKinds::instanceMethod0; + assertEquals(var.get(inst("rcvr")), "IM:0-MethodReferenceTestKinds(rcvr)"); + } + + public void testMRUnboundArg() { + S2 var = MethodReferenceTestKinds::instanceMethod1; + assertEquals(var.get(inst("rcvr"), inst("arg")), "IM:1-MethodReferenceTestKinds(rcvr)MethodReferenceTestKinds(arg)"); + } + + public void testMRSuper() { + S0 var = super::instanceMethod0; + assertEquals(var.get(), "SIM:0-MethodReferenceTestKinds(blank)"); + } + + public void testMRSuperArg() { + S1 var = super::instanceMethod1; + assertEquals(var.get(inst("arg")), "SIM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)"); + } + + public void testMRStatic() { + S0 var = MethodReferenceTestKinds::staticMethod0; + assertEquals(var.get(), "SM:0"); + } + + public void testMRStaticArg() { + S1 var = MethodReferenceTestKinds::staticMethod1; + assertEquals(var.get(inst("arg")), "SM:1-MethodReferenceTestKinds(arg)"); + } + + public void testMRStaticEval() { + MethodReferenceTestKinds evalCheck; + S0 var = (evalCheck = inst("discard"))::staticMethod0; + assertEquals(evalCheck.toString(), "MethodReferenceTestKinds(discard)"); + assertEquals(var.get(), "SM:0"); + } + + public void testMRStaticEvalArg() { + MethodReferenceTestKinds evalCheck; + S1 var = (evalCheck = inst("discard"))::staticMethod1; + assertEquals(evalCheck.toString(), "MethodReferenceTestKinds(discard)"); + assertEquals(var.get(inst("arg")), "SM:1-MethodReferenceTestKinds(arg)"); + } + + public void testMRTopLevel() { + SN0 var = MethodReferenceTestKindsBase::new; + assertEquals(var.make().toString(), "MethodReferenceTestKindsBase(blank)"); + } + + public void testMRTopLevelArg() { + SN1 var = MethodReferenceTestKindsBase::new; + assertEquals(var.make("name").toString(), "MethodReferenceTestKindsBase(name)"); + } +/* unbound inner case not supported anymore (dropped by EG) + public void testMRUnboundInner() { + SXN0 var = MethodReferenceTestKinds.In::new; + assertEquals(var.make(inst("out")).toString(), "In(blank)"); + } + + public void testMRUnboundInnerArg() { + SXN1 var = MethodReferenceTestKinds.In::new; + assertEquals(var.make(inst("out"), "name").toString(), "In(name)"); + } +*/ + public void testMRImplicitInner() { + SN0 var = MethodReferenceTestKinds.In::new; + assertEquals(var.make().toString(), "In(blank)"); + } + + public void testMRImplicitInnerArg() { + SN1 var = MethodReferenceTestKinds.In::new; + assertEquals(var.make("name").toString(), "In(name)"); + } + +} + + +class MethodReferenceTestKindsBase { + String val = "unset"; + + public String toString() { + return getClass().getSimpleName() + "(" + val + ")"; + } + + MethodReferenceTestKindsBase(String val) { + this.val = val; + } + + MethodReferenceTestKindsBase() { + this("blank"); + } + +} + +class MethodReferenceTestKindsSup extends MethodReferenceTestKindsBase { + String instanceMethod0() { return "SIM:0-" + this; } + String instanceMethod1(MethodReferenceTestKinds x) { return "SIM:1-" + this + x; } + + MethodReferenceTestKindsSup(String val) { + super(val); + } + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNew.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNew.java new file mode 100644 index 00000000000..c2f377f2b9b --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNew.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestNew + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +@Test +public class MethodReferenceTestNew { + + interface M0 { + + T m(); + } + + static class N0 { + + N0() { + } + } + + interface M1 { + + T m(Integer a); + } + + static class N1 { + + int i; + + N1(int i) { + this.i = i; + } + } + + interface M2 { + + T m(Integer n, String o); + } + + static class N2 { + + Number n; + Object o; + + N2(Number n, Object o) { + this.n = n; + this.o = o; + } + + public String toString() { + return "N2(" + n + "," + o + ")"; + } + } + + interface MV { + + NV m(Integer ai, int i); + } + + static class NV { + + int i; + + NV(int... v) { + i = 0; + for (int x : v) { + i += x; + } + } + + public String toString() { + return "NV(" + i + ")"; + } + } + + public void testConstructorReference0() { + M0 q; + + q = N0::new; + assertEquals(q.m().getClass().getSimpleName(), "N0"); + } + + public void testConstructorReference1() { + M1 q; + + q = N1::new; + assertEquals(q.m(14).getClass().getSimpleName(), "N1"); + } + + public void testConstructorReference2() { + M2 q; + + q = N2::new; + assertEquals(q.m(7, "hi").toString(), "N2(7,hi)"); + } + + public void testConstructorReferenceVarArgs() { + MV q; + + q = NV::new; + assertEquals(q.m(5, 45).toString(), "NV(50)"); + } + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInner.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInner.java new file mode 100644 index 00000000000..966495712b6 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInner.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestNewInner + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +@Test +public class MethodReferenceTestNewInner { + + String note = "NO NOTE"; + + interface M0 { + + T m(); + } + + interface MP { + + T m(MethodReferenceTestNewInner m); + } + + class N0 { + + N0() { + } + } + + interface M1 { + + T m(Integer a); + } + + class N1 { + + int i; + + N1(int i) { + this.i = i; + } + } + + interface M2 { + + T m(Integer n, String o); + } + + class N2 { + + Number n; + Object o; + + N2(Number n, Object o) { + this.n = n; + this.o = o; + } + + public String toString() { + return note + ":N2(" + n + "," + o + ")"; + } + } + + interface MV { + + NV m(Integer ai, int i); + } + + class NV { + + int i; + + NV(int... v) { + i = 0; + for (int x : v) { + i += x; + } + } + + public String toString() { + return note + ":NV(" + i + ")"; + } + } + +/* unbound constructor case not supported anymore (dropped by EG) + public static void testConstructorReferenceP() { + MP q; + + q = N0::new; + assertEquals(q.m(new MethodReferenceTestNewInner()).getClass().getSimpleName(), "N0"); + } +*/ + public void testConstructorReference0() { + M0 q; + + q = N0::new; + assertEquals(q.m().getClass().getSimpleName(), "N0"); + } + + public void testConstructorReference1() { + M1 q; + + q = N1::new; + assertEquals(q.m(14).getClass().getSimpleName(), "N1"); + } + + public void testConstructorReference2() { + M2 q; + + note = "T2"; + q = N2::new; + assertEquals(q.m(7, "hi").toString(), "T2:N2(7,hi)"); + } + + /*** + public void testConstructorReferenceVarArgs() { + MV q; + + note = "TVA"; + q = NV::new; + assertEquals(q.m(5, 45).toString(), "TNV:NV(50)"); + } + ***/ + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase1.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase1.java new file mode 100644 index 00000000000..6ec94e4192b --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase1.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestSueCase1 + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +@Test +public class MethodReferenceTestSueCase1 { + + public interface Sam2 { public String get(T target, String s); } + + String instanceMethod(String s) { return "2"; } + Sam2 var = MethodReferenceTestSueCase1::instanceMethod; + + String m() { return var.get(new MethodReferenceTestSueCase1(), ""); } + + public void testSueCase1() { + assertEquals(m(), "2"); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase2.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase2.java new file mode 100644 index 00000000000..460137f83bb --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase2.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestSueCase2 + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +@Test +public class MethodReferenceTestSueCase2 { + + public interface Sam2 { public String get(T target, String s); } + + String instanceMethod(String s) { return "2"; } + static Sam2 var = MethodReferenceTestSueCase2::instanceMethod; + + String m() { return var.get(new MethodReferenceTestSueCase2(), ""); } + + public void testSueCase2() { + assertEquals(m(), "2"); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase4.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase4.java new file mode 100644 index 00000000000..3c9657f0abe --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase4.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestSueCase4 + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +@Test +public class MethodReferenceTestSueCase4 { + + public interface Sam2 { public String get(T target, String s); } + + Sam2 var = new Object().equals(new Object()) ? Target::instanceMethod : Target::instanceMethod; + + String m() { + return var.get(new Target(), ""); + } + + static class Target { + String instanceMethod(String s) { return "2"; } + } + + public void testSueCase4() { + assertEquals(m(), "2"); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuper.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuper.java new file mode 100644 index 00000000000..9449b2646d9 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuper.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestSuper + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +interface SPRI { String m(String a); } + +class SPRA { + String xsA__(String s) { + return "A__xsA:" + s; + } + + String xsA_M(String s) { + return "A_MxsA:" + s; + } + + String xsAB_(String s) { + return "AB_xsA:" + s; + } + + String xsABM(String s) { + return "ABMxsA:" + s; + } + +} + +class SPRB extends SPRA { + + String xsAB_(String s) { + return "AB_xsB:" + s; + } + + String xsABM(String s) { + return "ABMxsB:" + s; + } + + String xs_B_(String s) { + return "_B_xsB:" + s; + } + + String xs_BM(String s) { + return "_BMxsB:" + s; + } + +} + +@Test +public class MethodReferenceTestSuper extends SPRB { + + String xsA_M(String s) { + return "A_MxsM:" + s; + } + + + String xsABM(String s) { + return "ABMxsM:" + s; + } + + String xs_BM(String s) { + return "_BMxsM:" + s; + } + + public void testMethodReferenceSuper() { + SPRI q; + + q = super::xsA__; + assertEquals(q.m("*"), "A__xsA:*"); + + q = super::xsA_M; + assertEquals(q.m("*"), "A_MxsA:*"); + + q = super::xsAB_; + assertEquals(q.m("*"), "AB_xsB:*"); + + q = super::xsABM; + assertEquals(q.m("*"), "ABMxsB:*"); + + q = super::xs_B_; + assertEquals(q.m("*"), "_B_xsB:*"); + + q = super::xs_BM; + assertEquals(q.m("*"), "_BMxsB:*"); + } + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuperDefault.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuperDefault.java new file mode 100644 index 00000000000..753baceaf1f --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuperDefault.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestSuperDefault + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +interface DSPRI { String m(String a); } + +interface DSPRA { + default String xsA__(String s) { + return "A__xsA:" + s; + } + + default String xsAB_(String s) { + return "AB_xsA:" + s; + } + +} + +interface DSPRB extends DSPRA { + + default String xsAB_(String s) { + return "AB_xsB:" + s; + } + + default String xs_B_(String s) { + return "_B_xsB:" + s; + } + +} + +@Test +public class MethodReferenceTestSuperDefault implements DSPRB { + + public void testMethodReferenceSuper() { + DSPRI q; + + q = DSPRB.super::xsA__; + assertEquals(q.m("*"), "A__xsA:*"); + + q = DSPRB.super::xsAB_; + assertEquals(q.m("*"), "AB_xsB:*"); + + q = DSPRB.super::xs_B_; + assertEquals(q.m("*"), "_B_xsB:*"); + } + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestTypeConversion.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestTypeConversion.java new file mode 100644 index 00000000000..6fd6de4a3b2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestTypeConversion.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestTypeConversion + */ + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +class MethodReferenceTestTypeConversion_E { + T xI(T t) { return t; } +} + +@Test +public class MethodReferenceTestTypeConversion { + + interface ISi { int m(Short a); } + + interface ICc { char m(Character a); } + + public void testUnboxObjectToNumberWiden() { + ISi q = (new MethodReferenceTestTypeConversion_E())::xI; + assertEquals(q.m((short)77), (short)77); + } + + public void testUnboxObjectToChar() { + ICc q = (new MethodReferenceTestTypeConversion_E())::xI; + assertEquals(q.m('@'), '@'); + } + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgs.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgs.java new file mode 100644 index 00000000000..bd811df87ee --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgs.java @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestVarArgs + */ + +import org.testng.annotations.Test; +import java.lang.reflect.Array; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +@Test +public class MethodReferenceTestVarArgs { + + interface SII { + + String m(Integer a, Integer b); + } + + interface Siii { + + String m(int a, int b, int c); + } + + interface Si { + + String m(int a); + } + + interface SaO { + + String m(Object[] a); + } + + interface Sai { + + String m(int[] a); + } + + interface Svi { + + String m(int... va); + } + + // These should be processed as var args + + static String xvI(Integer... vi) { + StringBuilder sb = new StringBuilder("xvI:"); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + static String xIvI(Integer f, Integer... vi) { + StringBuilder sb = new StringBuilder("xIvI:"); + sb.append(f); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + static String xvi(int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xvi:" + sum; + } + + static String xIvi(Integer f, int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xIvi:(" + f + ")" + sum; + } + + static String xvO(Object... vi) { + StringBuilder sb = new StringBuilder("xvO:"); + for (Object i : vi) { + if (i.getClass().isArray()) { + sb.append("["); + int len = Array.getLength(i); + for (int x = 0; x < len; ++x) { + sb.append(Array.get(i, x)); + sb.append(","); + } + sb.append("]"); + + } else { + sb.append(i); + } + sb.append("*"); + } + return sb.toString(); + } + + public void testVarArgsSuperclass() { + SII q; + + q = MethodReferenceTestVarArgs::xvO; + assertEquals(q.m(55,66), "xvO:55*66*"); + } + + public void testVarArgsArray() { + Sai q; + + q = MethodReferenceTestVarArgs::xvO; + assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*"); + } + + public void testVarArgsII() { + SII q; + + q = MethodReferenceTestVarArgs::xvI; + assertEquals(q.m(33,7), "xvI:33-7-"); + + q = MethodReferenceTestVarArgs::xIvI; + assertEquals(q.m(50,40), "xIvI:5040-"); + + q = MethodReferenceTestVarArgs::xvi; + assertEquals(q.m(100,23), "xvi:123"); + + q = MethodReferenceTestVarArgs::xIvi; + assertEquals(q.m(9,21), "xIvi:(9)21"); + } + + public void testVarArgsiii() { + Siii q; + + q = MethodReferenceTestVarArgs::xvI; + assertEquals(q.m(3, 2, 1), "xvI:3-2-1-"); + + q = MethodReferenceTestVarArgs::xIvI; + assertEquals(q.m(888, 99, 2), "xIvI:88899-2-"); + + q = MethodReferenceTestVarArgs::xvi; + assertEquals(q.m(900,80,7), "xvi:987"); + + q = MethodReferenceTestVarArgs::xIvi; + assertEquals(q.m(333,27, 72), "xIvi:(333)99"); + } + + public void testVarArgsi() { + Si q; + + q = MethodReferenceTestVarArgs::xvI; + assertEquals(q.m(3), "xvI:3-"); + + q = MethodReferenceTestVarArgs::xIvI; + assertEquals(q.m(888), "xIvI:888"); + + q = MethodReferenceTestVarArgs::xvi; + assertEquals(q.m(900), "xvi:900"); + + q = MethodReferenceTestVarArgs::xIvi; + assertEquals(q.m(333), "xIvi:(333)0"); + } + + // These should NOT be processed as var args + + public void testVarArgsaO() { + SaO q; + + q = MethodReferenceTestVarArgs::xvO; + assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*"); + } + + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsExt.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsExt.java new file mode 100644 index 00000000000..c5152855d49 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsExt.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestVarArgsExt + */ + +import org.testng.annotations.Test; +import java.lang.reflect.Array; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +interface NXII { String m(Integer a, Integer b); } + +interface NXiii { String m(int a, int b, int c); } + +interface NXi { String m(int a); } + +interface NXaO { String m(Object[] a); } + +interface NXai { String m(int[] a); } + +interface NXvi { String m(int... va); } + +@Test +public class MethodReferenceTestVarArgsExt { + + // These should be processed as var args + + public void testVarArgsNXSuperclass() { + NXII q; + + q = (new Ext())::xvO; + assertEquals(q.m(55,66), "xvO:55*66*"); + } + + public void testVarArgsNXArray() { + NXai q; + + q = (new Ext())::xvO; + assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*"); + } + + public void testVarArgsNXII() { + NXII q; + + q = (new Ext())::xvI; + assertEquals(q.m(33,7), "xvI:33-7-"); + + q = (new Ext())::xIvI; + assertEquals(q.m(50,40), "xIvI:5040-"); + + q = (new Ext())::xvi; + assertEquals(q.m(100,23), "xvi:123"); + + q = (new Ext())::xIvi; + assertEquals(q.m(9,21), "xIvi:(9)21"); + } + + public void testVarArgsNXiii() { + NXiii q; + + q = (new Ext())::xvI; + assertEquals(q.m(3, 2, 1), "xvI:3-2-1-"); + + q = (new Ext())::xIvI; + assertEquals(q.m(888, 99, 2), "xIvI:88899-2-"); + + q = (new Ext())::xvi; + assertEquals(q.m(900,80,7), "xvi:987"); + + q = (new Ext())::xIvi; + assertEquals(q.m(333,27, 72), "xIvi:(333)99"); + } + + public void testVarArgsNXi() { + NXi q; + + q = (new Ext())::xvI; + assertEquals(q.m(3), "xvI:3-"); + + q = (new Ext())::xIvI; + assertEquals(q.m(888), "xIvI:888"); + + q = (new Ext())::xvi; + assertEquals(q.m(900), "xvi:900"); + + q = (new Ext())::xIvi; + assertEquals(q.m(333), "xIvi:(333)0"); + } + + // These should NOT be processed as var args + + public void testVarArgsNXaO() { + NXaO q; + + q = (new Ext())::xvO; + assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*"); + } + + +} + +class Ext { + + String xvI(Integer... vi) { + StringBuilder sb = new StringBuilder("xvI:"); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + String xIvI(Integer f, Integer... vi) { + StringBuilder sb = new StringBuilder("xIvI:"); + sb.append(f); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + String xvi(int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xvi:" + sum; + } + + String xIvi(Integer f, int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xIvi:(" + f + ")" + sum; + } + + String xvO(Object... vi) { + StringBuilder sb = new StringBuilder("xvO:"); + for (Object i : vi) { + if (i.getClass().isArray()) { + sb.append("["); + int len = Array.getLength(i); + for (int x = 0; x < len; ++x) { + sb.append(Array.get(i, x)); + sb.append(","); + } + sb.append("]"); + + } else { + sb.append(i); + } + sb.append("*"); + } + return sb.toString(); + } + + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuper.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuper.java new file mode 100644 index 00000000000..88c4cd23e00 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuper.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestVarArgsSuper + */ + +import org.testng.annotations.Test; +import java.lang.reflect.Array; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +class MethodReferenceTestVarArgsSuper_Sub { + + String xvI(Integer... vi) { + StringBuilder sb = new StringBuilder("xvI:"); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + String xIvI(Integer f, Integer... vi) { + StringBuilder sb = new StringBuilder("xIvI:"); + sb.append(f); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + String xvi(int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xvi:" + sum; + } + + String xIvi(Integer f, int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xIvi:(" + f + ")" + sum; + } + + String xvO(Object... vi) { + StringBuilder sb = new StringBuilder("xvO:"); + for (Object i : vi) { + if (i.getClass().isArray()) { + sb.append("["); + int len = Array.getLength(i); + for (int x = 0; x < len; ++x) { + sb.append(Array.get(i, x)); + sb.append(","); + } + sb.append("]"); + + } else { + sb.append(i); + } + sb.append("*"); + } + return sb.toString(); + } +} + +@Test +public class MethodReferenceTestVarArgsSuper extends MethodReferenceTestVarArgsSuper_Sub { + + interface SPRII { String m(Integer a, Integer b); } + + interface SPRiii { String m(int a, int b, int c); } + + interface SPRi { String m(int a); } + + interface SPRaO { String m(Object[] a); } + + interface SPRai { String m(int[] a); } + + interface SPRvi { String m(int... va); } + + String xvI(Integer... vi) { + return "ERROR"; + } + + String xIvI(Integer f, Integer... vi) { + return "ERROR"; + } + + String xvi(int... vi) { + return "ERROR"; + } + + String xIvi(Integer f, int... vi) { + return "ERROR"; + } + + String xvO(Object... vi) { + return "ERROR"; + } + + // These should be processed as var args + + public void testVarArgsSPRSuperclass() { + SPRII q; + + q = super::xvO; + assertEquals(q.m(55,66), "xvO:55*66*"); + } + + public void testVarArgsSPRArray() { + SPRai q; + + q = super::xvO; + assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*"); + } + + public void testVarArgsSPRII() { + SPRII q; + + q = super::xvI; + assertEquals(q.m(33,7), "xvI:33-7-"); + + q = super::xIvI; + assertEquals(q.m(50,40), "xIvI:5040-"); + + q = super::xvi; + assertEquals(q.m(100,23), "xvi:123"); + + q = super::xIvi; + assertEquals(q.m(9,21), "xIvi:(9)21"); + } + + public void testVarArgsSPRiii() { + SPRiii q; + + q = super::xvI; + assertEquals(q.m(3, 2, 1), "xvI:3-2-1-"); + + q = super::xIvI; + assertEquals(q.m(888, 99, 2), "xIvI:88899-2-"); + + q = super::xvi; + assertEquals(q.m(900,80,7), "xvi:987"); + + q = super::xIvi; + assertEquals(q.m(333,27, 72), "xIvi:(333)99"); + } + + public void testVarArgsSPRi() { + SPRi q; + + q = super::xvI; + assertEquals(q.m(3), "xvI:3-"); + + q = super::xIvI; + assertEquals(q.m(888), "xIvI:888"); + + q = super::xvi; + assertEquals(q.m(900), "xvi:900"); + + q = super::xIvi; + assertEquals(q.m(333), "xIvi:(333)0"); + } + + // These should NOT be processed as var args + + public void testVarArgsSPRaO() { + SPRaO q; + + q = super::xvO; + assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*"); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuperDefault.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuperDefault.java new file mode 100644 index 00000000000..6e00605eca2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuperDefault.java @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestVarArgsSuperDefault + */ + +import org.testng.annotations.Test; +import java.lang.reflect.Array; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +interface MethodReferenceTestVarArgsSuperDefault_I { + + default String xvI(Integer... vi) { + StringBuilder sb = new StringBuilder("xvI:"); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + default String xIvI(Integer f, Integer... vi) { + StringBuilder sb = new StringBuilder("xIvI:"); + sb.append(f); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + default String xvi(int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xvi:" + sum; + } + + default String xIvi(Integer f, int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xIvi:(" + f + ")" + sum; + } + + default String xvO(Object... vi) { + StringBuilder sb = new StringBuilder("xvO:"); + for (Object i : vi) { + if (i.getClass().isArray()) { + sb.append("["); + int len = Array.getLength(i); + for (int x = 0; x < len; ++x) { + sb.append(Array.get(i, x)); + sb.append(","); + } + sb.append("]"); + + } else { + sb.append(i); + } + sb.append("*"); + } + return sb.toString(); + } +} + +@Test +public class MethodReferenceTestVarArgsSuperDefault implements MethodReferenceTestVarArgsSuperDefault_I { + + interface DSPRII { String m(Integer a, Integer b); } + + interface DSPRiii { String m(int a, int b, int c); } + + interface DSPRi { String m(int a); } + + interface DSPRaO { String m(Object[] a); } + + interface DSPRai { String m(int[] a); } + + interface DSPRvi { String m(int... va); } + + // These should be processed as var args + + public void testVarArgsSPRSuperclass() { + DSPRII q; + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO; + assertEquals(q.m(55,66), "xvO:55*66*"); + } + + public void testVarArgsSPRArray() { + DSPRai q; + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO; + assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*"); + } + + public void testVarArgsSPRII() { + DSPRII q; + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI; + assertEquals(q.m(33,7), "xvI:33-7-"); + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI; + assertEquals(q.m(50,40), "xIvI:5040-"); + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi; + assertEquals(q.m(100,23), "xvi:123"); + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi; + assertEquals(q.m(9,21), "xIvi:(9)21"); + } + + public void testVarArgsSPRiii() { + DSPRiii q; + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI; + assertEquals(q.m(3, 2, 1), "xvI:3-2-1-"); + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI; + assertEquals(q.m(888, 99, 2), "xIvI:88899-2-"); + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi; + assertEquals(q.m(900,80,7), "xvi:987"); + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi; + assertEquals(q.m(333,27, 72), "xIvi:(333)99"); + } + + public void testVarArgsSPRi() { + DSPRi q; + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI; + assertEquals(q.m(3), "xvI:3-"); + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI; + assertEquals(q.m(888), "xIvI:888"); + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi; + assertEquals(q.m(900), "xvi:900"); + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi; + assertEquals(q.m(333), "xIvi:(333)0"); + } + + // These should NOT be processed as var args + + public void testVarArgsSPRaO() { + DSPRaO q; + + q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO; + assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*"); + } + + +} diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsThis.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsThis.java new file mode 100644 index 00000000000..9c5e0d6f102 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsThis.java @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003639 + * @summary convert lambda testng tests to jtreg and add them + * @run testng MethodReferenceTestVarArgsThis + */ + +import org.testng.annotations.Test; +import java.lang.reflect.Array; + +import static org.testng.Assert.assertEquals; + +/** + * @author Robert Field + */ + +interface NsII { String m(Integer a, Integer b); } + +interface Nsiii { String m(int a, int b, int c); } + +interface Nsi { String m(int a); } + +interface NsaO { String m(Object[] a); } + +interface Nsai { String m(int[] a); } + +interface Nsvi { String m(int... va); } + +@Test +public class MethodReferenceTestVarArgsThis { + + // These should be processed as var args + + String xvI(Integer... vi) { + StringBuilder sb = new StringBuilder("xvI:"); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + String xIvI(Integer f, Integer... vi) { + StringBuilder sb = new StringBuilder("xIvI:"); + sb.append(f); + for (Integer i : vi) { + sb.append(i); + sb.append("-"); + } + return sb.toString(); + } + + String xvi(int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xvi:" + sum; + } + + String xIvi(Integer f, int... vi) { + int sum = 0; + for (int i : vi) { + sum += i; + } + return "xIvi:(" + f + ")" + sum; + } + + String xvO(Object... vi) { + StringBuilder sb = new StringBuilder("xvO:"); + for (Object i : vi) { + if (i.getClass().isArray()) { + sb.append("["); + int len = Array.getLength(i); + for (int x = 0; x < len; ++x) { + sb.append(Array.get(i, x)); + sb.append(","); + } + sb.append("]"); + + } else { + sb.append(i); + } + sb.append("*"); + } + return sb.toString(); + } + + public void testVarArgsNsSuperclass() { + NsII q; + + q = this::xvO; + assertEquals(q.m(55,66), "xvO:55*66*"); + } + + public void testVarArgsNsArray() { + Nsai q; + + q = this::xvO; + assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*"); + } + + public void testVarArgsNsII() { + NsII q; + + q = this::xvI; + assertEquals(q.m(33,7), "xvI:33-7-"); + + q = this::xIvI; + assertEquals(q.m(50,40), "xIvI:5040-"); + + q = this::xvi; + assertEquals(q.m(100,23), "xvi:123"); + + q = this::xIvi; + assertEquals(q.m(9,21), "xIvi:(9)21"); + } + + public void testVarArgsNsiii() { + Nsiii q; + + q = this::xvI; + assertEquals(q.m(3, 2, 1), "xvI:3-2-1-"); + + q = this::xIvI; + assertEquals(q.m(888, 99, 2), "xIvI:88899-2-"); + + q = this::xvi; + assertEquals(q.m(900,80,7), "xvi:987"); + + q = this::xIvi; + assertEquals(q.m(333,27, 72), "xIvi:(333)99"); + } + + public void testVarArgsNsi() { + Nsi q; + + q = this::xvI; + assertEquals(q.m(3), "xvI:3-"); + + q = this::xIvI; + assertEquals(q.m(888), "xIvI:888"); + + q = this::xvi; + assertEquals(q.m(900), "xvi:900"); + + q = this::xIvi; + assertEquals(q.m(333), "xIvi:(333)0"); + } + + // These should NOT be processed as var args + + public void testVarArgsNsaO() { + NsaO q; + + q = this::xvO; + assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*"); + } + + +} diff --git a/langtools/test/tools/javac/lambdaShapes/TEST.properties b/langtools/test/tools/javac/lambdaShapes/TEST.properties new file mode 100644 index 00000000000..51a8537d11d --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/TEST.properties @@ -0,0 +1,2 @@ +TestNG.dirs = tools/javac/lambdaShapes + diff --git a/langtools/test/tools/javac/defaultMethods/fd/FDTest.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java similarity index 64% rename from langtools/test/tools/javac/defaultMethods/fd/FDTest.java rename to langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java index 04a295209e1..3819221a736 100644 --- a/langtools/test/tools/javac/defaultMethods/fd/FDTest.java +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java @@ -21,14 +21,12 @@ * questions. */ -/* - * @test - * @summary Automatic test for checking correctness of default resolution - */ +package org.openjdk.tests.javac; -import shapegen.*; +import org.openjdk.tests.shapegen.*; import com.sun.source.util.JavacTask; +import com.sun.tools.javac.util.Pair; import java.net.URI; import java.util.Arrays; @@ -43,9 +41,14 @@ import javax.tools.SimpleJavaFileObject; import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider; +import org.testng.annotations.Test; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.DataProvider; +import static org.testng.Assert.*; + public class FDTest { - enum TestKind { + public enum TestKind { POSITIVE, NEGATIVE; @@ -55,17 +58,58 @@ public class FDTest { } } - public static void main(String[] args) throws Exception { - //create default shared JavaCompiler - reused across multiple compilations - JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); - StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + public static JavaCompiler comp; + public static StandardJavaFileManager fm; + @BeforeSuite + static void init() { + // create default shared JavaCompiler - reused across multiple + // compilations + + comp = ToolProvider.getSystemJavaCompiler(); + fm = comp.getStandardFileManager(null, null, null); + } + + public static void main(String[] args) throws Exception { + init(); + + for (Pair fdtest : generateCases()) { + runTest(fdtest.fst, fdtest.snd, comp, fm); + } + } + + @Test(dataProvider = "fdCases") + public void testOneCase(TestKind tk, Hierarchy hs) + throws Exception { + FDTest.runTest(tk, hs, comp, fm); + } + + @DataProvider(name = "fdCases") + public Object[][] caseGenerator() { + List> cases = generateCases(); + Object[][] fdCases = new Object[cases.size()][]; + for (int i = 0; i < cases.size(); ++i) { + fdCases[i] = new Object[2]; + fdCases[i][0] = cases.get(i).fst; + fdCases[i][1] = cases.get(i).snd; + } + return fdCases; + } + + public static List> generateCases() { + ArrayList> list = new ArrayList<>(); HierarchyGenerator hg = new HierarchyGenerator(); for (TestKind tk : TestKind.values()) { for (Hierarchy hs : tk.getHierarchy(hg)) { - new FDTest(tk, hs).run(comp, fm); + list.add(new Pair<>(tk, hs)); } } + return list; + } + + public static void runTest(TestKind tk, Hierarchy hs, + JavaCompiler comp, StandardJavaFileManager fm) throws Exception { + new FDTest(tk, hs).run(comp, fm); } TestKind tk; @@ -73,6 +117,8 @@ public class FDTest { DefenderTestSource source; DiagnosticChecker diagChecker; + public FDTest() {} + FDTest(TestKind tk, Hierarchy hs) { this.tk = tk; this.hs = hs; @@ -86,7 +132,7 @@ public class FDTest { try { ct.analyze(); } catch (Throwable ex) { - throw new AssertionError("Error thrown when analyzing the following source:\n" + source.getCharContent(true)); + fail("Error thrown when analyzing the following source:\n" + source.getCharContent(true)); } check(); } @@ -94,11 +140,11 @@ public class FDTest { void check() { boolean errorExpected = tk == TestKind.NEGATIVE; if (errorExpected != diagChecker.errorFound) { - throw new AssertionError("problem in source: \n" + - "\nerror found = " + diagChecker.errorFound + - "\nerror expected = " + errorExpected + - "\n" + dumpHierarchy() + - "\n" + source.getCharContent(true)); + fail("problem in source: \n" + + "\nerror found = " + diagChecker.errorFound + + "\nerror expected = " + errorExpected + + "\n" + dumpHierarchy() + + "\n" + source.getCharContent(true)); } } @@ -123,7 +169,7 @@ public class FDTest { StringBuilder buf = new StringBuilder(); List defaultRef = new ArrayList<>(); for (ClassCase cc : hs.all) { - hs.genClassDef(buf, cc, null, defaultRef); + Hierarchy.genClassDef(buf, cc, null, defaultRef); } source = buf.toString(); } diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/AttributeInjector.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/AttributeInjector.java new file mode 100644 index 00000000000..dc4285bdb8d --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/AttributeInjector.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.separate; + +import java.io.*; + +public class AttributeInjector implements ClassFilePreprocessor { + + private String attributeName; + private byte[] attributeData; + + public AttributeInjector(String attributeName, byte[] attributeData) { + this.attributeName = attributeName; + this.attributeData = attributeData; + } + + public byte[] preprocess(String name, byte[] cf) { + ClassFile classfile = new ClassFile(cf); + + short cpIndex = (short)classfile.constant_pool.size(); + + ClassFile.CpUtf8 entry = new ClassFile.CpUtf8(); + entry.bytes = new byte[attributeName.length()]; + for (int i = 0; i < attributeName.length(); ++i) { + entry.bytes[i] = (byte)attributeName.charAt(i); + } + + classfile.constant_pool.add(entry); + + ClassFile.Attribute attr = new ClassFile.Attribute(); + attr.attribute_name_index = cpIndex; + attr.info = attributeData; + + classfile.attributes.add(attr); + return classfile.toByteArray(); + } + +/* + public static void main(String argv[]) throws Exception { + File input = new File(argv[0]); + byte[] buffer = new byte[(int)input.length()]; + new FileInputStream(input).read(buffer); + + ClassFilePreprocessor cfp = + new AttributeInjector("RequiresBridges", new byte[0]); + byte[] cf = cfp.preprocess(argv[0], buffer); + new FileOutputStream(argv[0] + ".mod").write(cf); + } +*/ +} diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFile.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFile.java new file mode 100644 index 00000000000..249097d2d12 --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFile.java @@ -0,0 +1,454 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.separate; + +import java.io.*; +import java.util.*; + +class CfInputStream extends ByteArrayInputStream { + private int ct; + public CfInputStream(byte[] input) { + super(input); + } + + byte u1() { return (byte)read(); } + short u2() { + int b0 = read() << 8; + int b1 = read(); + return (short)(b0 | b1); + } + int u4() { + int b0 = read() << 24; + int b1 = read() << 16; + int b2 = read() << 8; + int b3 = read(); + return b0 | b1 | b2 | b3; + } + byte[] array(int count) { + byte[] ret = new byte[count]; + read(ret, 0, count); + return ret; + } +}; + +class CfOutputStream extends ByteArrayOutputStream { + void u1(byte b) { write((int)b); } + void u2(short s) { + write((s >> 8) & 0xff); + write(s & 0xff); + } + void u4(int i) { + write((i >> 24) & 0xff); + write((i >> 16) & 0xff); + write((i >> 8) & 0xff); + write(i & 0xff); + } + void array(byte[] a) { + write(a, 0, a.length); + } + + public byte[] toByteArray() { return super.toByteArray(); } +}; + +// A quick and dirty class file parser and representation +public class ClassFile { + + int magic; + short minor_version; + short major_version; + ArrayList constant_pool; + short access_flags; + short this_class; + short super_class; + ArrayList interfaces; + ArrayList fields; + ArrayList methods; + ArrayList attributes; + + ClassFile(byte[] cf) { + CfInputStream in = new CfInputStream(cf); + + magic = in.u4(); + minor_version = in.u2(); + major_version = in.u2(); + + short cpCount = in.u2(); + constant_pool = new ArrayList<>(); + constant_pool.add(new CpNull()); + for (int i = 1; i < cpCount; ++i) { + constant_pool.add(CpEntry.newCpEntry(in)); + } + + access_flags = in.u2(); + this_class = in.u2(); + super_class = in.u2(); + + short ifaceCount = in.u2(); + interfaces = new ArrayList<>(); + for (int i = 0; i < ifaceCount; ++i) { + interfaces.add(new Interface(in)); + } + + short fieldCount = in.u2(); + fields = new ArrayList<>(); + for (int i = 0; i < fieldCount; ++i) { + fields.add(new Field(in)); + } + + short methodCount = in.u2(); + methods = new ArrayList<>(); + for (int i = 0; i < methodCount; ++i) { + methods.add(new Method(in)); + } + + short attributeCount = in.u2(); + attributes = new ArrayList<>(); + for (int i = 0; i < attributeCount; ++i) { + attributes.add(new Attribute(in)); + } + } + + byte[] toByteArray() { + CfOutputStream out = new CfOutputStream(); + + out.u4(magic); + out.u2(minor_version); + out.u2(major_version); + + out.u2((short)(constant_pool.size())); + for (CpEntry cp : constant_pool) { + cp.write(out); + } + + out.u2(access_flags); + out.u2(this_class); + out.u2(super_class); + + out.u2((short)interfaces.size()); + for (Interface iface : interfaces) { + iface.write(out); + } + + out.u2((short)fields.size()); + for (Field field : fields) { + field.write(out); + } + + out.u2((short)methods.size()); + for (Method method : methods) { + method.write(out); + } + + out.u2((short)attributes.size()); + for (Attribute attribute : attributes) { + attribute.write(out); + } + + return out.toByteArray(); + } + + static abstract class CpEntry { + byte tag; + + CpEntry(byte t) { tag = t; } + void write(CfOutputStream out) { + out.u1(tag); + } + + static CpEntry newCpEntry(CfInputStream in) { + byte tag = in.u1(); + switch (tag) { + case CpUtf8.TAG: return new CpUtf8(in); + case CpInteger.TAG: return new CpInteger(in); + case CpFloat.TAG: return new CpFloat(in); + case CpLong.TAG: return new CpLong(in); + case CpDouble.TAG: return new CpDouble(in); + case CpClass.TAG: return new CpClass(in); + case CpString.TAG: return new CpString(in); + case CpFieldRef.TAG: return new CpFieldRef(in); + case CpMethodRef.TAG: return new CpMethodRef(in); + case CpInterfaceMethodRef.TAG: + return new CpInterfaceMethodRef(in); + case CpNameAndType.TAG: return new CpNameAndType(in); + case CpMethodHandle.TAG: return new CpMethodHandle(in); + case CpMethodType.TAG: return new CpMethodType(in); + case CpInvokeDynamic.TAG: return new CpInvokeDynamic(in); + default: throw new RuntimeException("Bad cp entry tag: " + tag); + } + } + } + + static class CpNull extends CpEntry { + CpNull() { super((byte)0); } + CpNull(CfInputStream in) { super((byte)0); } + void write(CfOutputStream out) {} + } + + static class CpUtf8 extends CpEntry { + static final byte TAG = 1; + byte[] bytes; + + CpUtf8() { super(TAG); } + CpUtf8(CfInputStream in) { + this(); + short length = in.u2(); + bytes = in.array(length); + } + void write(CfOutputStream out) { + super.write(out); + out.u2((short)bytes.length); + out.array(bytes); + } + } + + static class CpU4Constant extends CpEntry { + byte[] bytes; + + CpU4Constant(byte tag) { super(tag); } + CpU4Constant(byte tag, CfInputStream in) { + this(tag); + bytes = in.array(4); + } + void write(CfOutputStream out) { super.write(out); out.array(bytes); } + } + static class CpInteger extends CpU4Constant { + static final byte TAG = 3; + CpInteger() { super(TAG); } + CpInteger(CfInputStream in) { super(TAG, in); } + } + static class CpFloat extends CpU4Constant { + static final byte TAG = 4; + CpFloat() { super(TAG); } + CpFloat(CfInputStream in) { super(TAG, in); } + } + + static class CpU8Constant extends CpEntry { + byte[] bytes; + + CpU8Constant(byte tag) { super(tag); } + CpU8Constant(byte tag, CfInputStream in) { + this(tag); + bytes = in.array(8); + } + void write(CfOutputStream out) { super.write(out); out.array(bytes); } + } + static class CpLong extends CpU8Constant { + static final byte TAG = 5; + CpLong() { super(TAG); } + CpLong(CfInputStream in) { super(TAG, in); } + } + static class CpDouble extends CpU8Constant { + static final byte TAG = 6; + CpDouble() { super(TAG); } + CpDouble(CfInputStream in) { super(TAG, in); } + } + + static class CpClass extends CpEntry { + static final byte TAG = 7; + short name_index; + + CpClass() { super(TAG); } + CpClass(CfInputStream in) { super(TAG); name_index = in.u2(); } + void write(CfOutputStream out) { + super.write(out); + out.u2(name_index); + } + } + + static class CpString extends CpEntry { + static final byte TAG = 8; + short string_index; + + CpString() { super(TAG); } + CpString(CfInputStream in) { super(TAG); string_index = in.u2(); } + void write(CfOutputStream out) { + super.write(out); + out.u2(string_index); + } + } + + static class CpRef extends CpEntry { + short class_index; + short name_and_type_index; + + CpRef(byte tag) { super(tag); } + CpRef(byte tag, CfInputStream in) { + this(tag); + class_index = in.u2(); + name_and_type_index = in.u2(); + } + void write(CfOutputStream out) { + super.write(out); + out.u2(class_index); + out.u2(name_and_type_index); + } + } + static class CpFieldRef extends CpRef { + static final byte TAG = 9; + CpFieldRef() { super(TAG); } + CpFieldRef(CfInputStream in) { super(TAG, in); } + } + static class CpMethodRef extends CpRef { + static final byte TAG = 10; + CpMethodRef() { super(TAG); } + CpMethodRef(CfInputStream in) { super(TAG, in); } + } + static class CpInterfaceMethodRef extends CpRef { + static final byte TAG = 11; + CpInterfaceMethodRef() { super(TAG); } + CpInterfaceMethodRef(CfInputStream in) { super(TAG, in); } + } + + static class CpNameAndType extends CpEntry { + static final byte TAG = 12; + short name_index; + short descriptor_index; + + CpNameAndType() { super(TAG); } + CpNameAndType(CfInputStream in) { + this(); + name_index = in.u2(); + descriptor_index = in.u2(); + } + void write(CfOutputStream out) { + super.write(out); + out.u2(name_index); + out.u2(descriptor_index); + } + } + + static class CpMethodHandle extends CpEntry { + static final byte TAG = 15; + byte reference_kind; + short reference_index; + + CpMethodHandle() { super(TAG); } + CpMethodHandle(CfInputStream in) { + this(); + reference_kind = in.u1(); + reference_index = in.u2(); + } + void write(CfOutputStream out) { + super.write(out); + out.u1(reference_kind); + out.u2(reference_index); + } + } + + static class CpMethodType extends CpEntry { + static final byte TAG = 16; + short descriptor_index; + + CpMethodType() { super(TAG); } + CpMethodType(CfInputStream in) { + this(); + descriptor_index = in.u2(); + } + void write(CfOutputStream out) { + super.write(out); + out.u2(descriptor_index); + } + } + + static class CpInvokeDynamic extends CpEntry { + static final byte TAG = 18; + short bootstrap_index; + short name_and_type_index; + + CpInvokeDynamic() { super(TAG); } + CpInvokeDynamic(CfInputStream in) { + this(); + bootstrap_index = in.u2(); + name_and_type_index = in.u2(); + } + void write(CfOutputStream out) { + super.write(out); + out.u2(bootstrap_index); + out.u2(name_and_type_index); + } + } + + static class Interface { + short index; + + Interface() {} + Interface(CfInputStream in) { index = in.u2(); } + void write(CfOutputStream out) { out.u2(index); } + } + + static class FieldOrMethod { + short access_flags; + short name_index; + short descriptor_index; + ArrayList attributes; + + FieldOrMethod() { attributes = new ArrayList<>(); } + FieldOrMethod(CfInputStream in) { + access_flags = in.u2(); + name_index = in.u2(); + descriptor_index = in.u2(); + + short attrCount = in.u2(); + attributes = new ArrayList<>(); + for (int i = 0; i < attrCount; ++i) { + attributes.add(new Attribute(in)); + } + } + void write(CfOutputStream out) { + out.u2(access_flags); + out.u2(name_index); + out.u2(descriptor_index); + out.u2((short)attributes.size()); + for (Attribute attribute : attributes) { attribute.write(out); } + } + } + + static class Field extends FieldOrMethod { + Field() {} + Field(CfInputStream in) { super(in); } + } + static class Method extends FieldOrMethod { + Method() {} + Method(CfInputStream in) { super(in); } + } + + static class Attribute { + short attribute_name_index; + byte[] info; + + Attribute() { info = new byte[0]; } + Attribute(CfInputStream in) { + attribute_name_index = in.u2(); + int length = in.u4(); + info = in.array(length); + } + void write(CfOutputStream out) { + out.u2(attribute_name_index); + out.u4(info.length); + out.array(info); + } + } +} diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFilePreprocessor.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFilePreprocessor.java new file mode 100644 index 00000000000..bd863088e2d --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFilePreprocessor.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.separate; + +public interface ClassFilePreprocessor { + public byte[] preprocess(String name, byte[] classfile); +}; diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassToInterfaceConverter.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassToInterfaceConverter.java new file mode 100644 index 00000000000..afc15c2e519 --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassToInterfaceConverter.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.separate; + +import java.io.*; +import java.util.*; + +public class ClassToInterfaceConverter implements ClassFilePreprocessor { + + private String whichClass; + + public ClassToInterfaceConverter(String className) { + this.whichClass = className; + } + + private boolean utf8Matches(ClassFile.CpEntry entry, String v) { + if (!(entry instanceof ClassFile.CpUtf8)) { + return false; + } + ClassFile.CpUtf8 utf8 = (ClassFile.CpUtf8)entry; + if (v.length() != utf8.bytes.length) { + return false; + } + for (int i = 0; i < v.length(); ++i) { + if (v.charAt(i) != utf8.bytes[i]) { + return false; + } + } + return true; + } + + private void convertToInterface(ClassFile cf) { + cf.access_flags = 0x0601; // ACC_INTERFACE | ACC_ABSTRACT | ACC_PUBLIC + ArrayList new_methods = new ArrayList<>(); + // Find method and delete it + for (int i = 0; i < cf.methods.size(); ++i) { + ClassFile.Method method = cf.methods.get(i); + ClassFile.CpEntry name = cf.constant_pool.get(method.name_index); + if (!utf8Matches(name, "")) { + new_methods.add(method); + } + } + cf.methods = new_methods; + } + + public byte[] preprocess(String classname, byte[] bytes) { + ClassFile cf = new ClassFile(bytes); + + ClassFile.CpEntry entry = cf.constant_pool.get(cf.this_class); + ClassFile.CpEntry name = cf.constant_pool.get( + ((ClassFile.CpClass)entry).name_index); + if (utf8Matches(name, whichClass)) { + convertToInterface(cf); + return cf.toByteArray(); + } else { + return bytes; // unmodified + } + } + +/* + public static void main(String argv[]) throws Exception { + File input = new File(argv[0]); + byte[] buffer = new byte[(int)input.length()]; + new FileInputStream(input).read(buffer); + + ClassFilePreprocessor cfp = new ClassToInterfaceConverter("Hello"); + byte[] cf = cfp.preprocess(argv[0], buffer); + new FileOutputStream(argv[0] + ".mod").write(cf); + } +*/ +} diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java new file mode 100644 index 00000000000..50c2398cfc1 --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.separate; + +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentHashMap; +import java.io.*; +import java.net.URI; +import javax.tools.*; + +import com.sun.source.util.JavacTask; + +import static org.openjdk.tests.separate.SourceModel.Type; +import static org.openjdk.tests.separate.SourceModel.Class; +import static org.openjdk.tests.separate.SourceModel.Extends; +import static org.openjdk.tests.separate.SourceModel.SourceProcessor; + +public class Compiler { + + public enum Flags { + VERBOSE, // Prints out files as they are compiled + USECACHE // Keeps results around for reuse. Only use this is + // you're sure that each compilation name maps to the + // same source code + }; + + private static final AtomicInteger counter = new AtomicInteger(); + private static final String targetDir = "gen-separate"; + private static final File root = new File(targetDir); + private static ConcurrentHashMap cache = + new ConcurrentHashMap<>(); + + Set flags; + + private JavaCompiler systemJavaCompiler; + private StandardJavaFileManager fm; + private List tempDirs; + private List postprocessors; + + private static class SourceFile extends SimpleJavaFileObject { + private final String content; + + public SourceFile(String name, String content) { + super(URI.create("myfo:/" + name + ".java"), Kind.SOURCE); + this.content = content; + } + + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return toString(); + } + + public String toString() { return this.content; } + } + + public Compiler(Flags ... flags) { + setFlags(flags); + this.tempDirs = new ArrayList<>(); + this.postprocessors = new ArrayList<>(); + this.systemJavaCompiler = ToolProvider.getSystemJavaCompiler(); + this.fm = systemJavaCompiler.getStandardFileManager(null, null, null); + } + + public void setFlags(Flags ... flags) { + this.flags = new HashSet(Arrays.asList(flags)); + } + + public void addPostprocessor(ClassFilePreprocessor cfp) { + this.postprocessors.add(cfp); + } + + /** + * Compile hierarchies starting with each of the 'types' and return + * a ClassLoader that can be used to load the compiled classes. + */ + public ClassLoader compile(Type ... types) { + ClassFilePreprocessor[] cfps = this.postprocessors.toArray( + new ClassFilePreprocessor[0]); + + DirectedClassLoader dcl = new DirectedClassLoader(cfps); + + for (Type t : types) { + for (Map.Entry each : compileHierarchy(t).entrySet()) { + dcl.setLocationFor(each.getKey(), each.getValue()); + } + } + return dcl; + } + + /** + * Compiles and loads a hierarchy, starting at 'type' + */ + public java.lang.Class compileAndLoad(Type type) + throws ClassNotFoundException { + + ClassLoader loader = compile(type); + return java.lang.Class.forName(type.getName(), false, loader); + } + + /** + * Compiles a hierarchy, starting at 'type' and return a mapping of the + * name to the location where the classfile for that type resides. + */ + private Map compileHierarchy(Type type) { + HashMap outputDirs = new HashMap<>(); + + File outDir = compileOne(type); + outputDirs.put(type.getName(), outDir); + + Class superClass = type.getSuperclass(); + if (superClass != null) { + for( Map.Entry each : compileHierarchy(superClass).entrySet()) { + outputDirs.put(each.getKey(), each.getValue()); + } + } + for (Extends ext : type.getSupertypes()) { + Type iface = ext.getType(); + for( Map.Entry each : compileHierarchy(iface).entrySet()) { + outputDirs.put(each.getKey(), each.getValue()); + } + } + + return outputDirs; + } + + private File compileOne(Type type) { + if (this.flags.contains(Flags.USECACHE)) { + File dir = cache.get(type.getName()); + if (dir != null) { + return dir; + } + } + List files = new ArrayList<>(); + SourceProcessor accum = + (name, src) -> { files.add(new SourceFile(name, src)); }; + + for (Type dep : type.typeDependencies()) { + dep.generateAsDependency(accum, type.methodDependencies()); + } + + type.generate(accum); + + JavacTask ct = (JavacTask)this.systemJavaCompiler.getTask( + null, this.fm, null, null, null, files); + File destDir = null; + do { + int value = counter.incrementAndGet(); + destDir = new File(root, Integer.toString(value)); + } while (destDir.exists()); + + if (this.flags.contains(Flags.VERBOSE)) { + System.out.println("Compilation unit for " + type.getName() + + " : compiled into " + destDir); + for (JavaFileObject jfo : files) { + System.out.println(jfo.toString()); + } + } + + try { + destDir.mkdirs(); + this.fm.setLocation( + StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir)); + } catch (IOException e) { + throw new RuntimeException( + "IOException encountered during compilation"); + } + Boolean result = ct.call(); + if (result == Boolean.FALSE) { + throw new RuntimeException( + "Compilation failure in " + type.getName() + " unit"); + } + if (this.flags.contains(Flags.USECACHE)) { + File existing = cache.putIfAbsent(type.getName(), destDir); + if (existing != null) { + deleteDir(destDir); + return existing; + } + } else { + this.tempDirs.add(destDir); + } + return destDir; + } + + private static void deleteDir(File dir) { + for (File f : dir.listFiles()) { + f.delete(); + }; + dir.delete(); + } + + public void cleanup() { + if (!this.flags.contains(Flags.USECACHE)) { + for (File d : tempDirs) { + deleteDir(d); + }; + tempDirs = new ArrayList<>(); + } + } + + // Removes all of the elements in the cache and deletes the associated + // output directories. This may not actually empty the cache if there + // are concurrent users of it. + public static void purgeCache() { + for (Map.Entry entry : cache.entrySet()) { + cache.remove(entry.getKey()); + deleteDir(entry.getValue()); + } + } +} diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/DirectedClassLoader.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/DirectedClassLoader.java new file mode 100644 index 00000000000..6f6ee747238 --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/DirectedClassLoader.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.separate; + +import java.util.HashMap; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +class DirectedClassLoader extends ClassLoader { + + private HashMap loadLocations; + private File defaultLocation; + private ClassFilePreprocessor[] preprocessors; + + public DirectedClassLoader( + HashMap locations, File fallback, + ClassFilePreprocessor ... preprocessors) { + loadLocations = new HashMap<>(locations); + defaultLocation = fallback; + this.preprocessors = preprocessors; + } + + public DirectedClassLoader( + File fallback, ClassFilePreprocessor ... preprocessors) { + loadLocations = new HashMap<>(); + defaultLocation = fallback; + this.preprocessors = preprocessors; + } + + public DirectedClassLoader(ClassFilePreprocessor ... preprocessors) { + this((File)null, preprocessors); + } + + public void setDefaultLocation(File dir) { this.defaultLocation = dir; } + public void setLocationFor(String name, File dir) { + loadLocations.put(name, dir); + } + + @Override + protected Class findClass(String name) { + String path = name.replace(".", File.separator) + ".class"; + + File location = loadLocations.get(name); + if (location == null || !(new File(location, path)).exists()) { + File def = new File(defaultLocation, path); + if (def.exists()) { + return defineFrom(name, new File(location, path)); + } + } else { + return defineFrom(name, new File(location, path)); + } + return null; + } + + private Class defineFrom(String name, File file) { + FileInputStream fis = null; + try { + try { + fis = new FileInputStream(file); + byte[] bytes = new byte[fis.available()]; + int read = fis.read(bytes); + if (read != bytes.length) { + return null; + } + if (preprocessors != null) { + for (ClassFilePreprocessor cfp : preprocessors) { + bytes = cfp.preprocess(name, bytes); + } + } + return defineClass(name, bytes, 0, bytes.length); + } finally { + fis.close(); + } + } catch (IOException e) {} + return null; + } +} diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java new file mode 100644 index 00000000000..0d1d1a06de0 --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java @@ -0,0 +1,582 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.separate; + +import java.util.*; +import java.io.StringWriter; +import java.io.PrintWriter; + +public class SourceModel { + + public static final String stdMethodName = "m"; + + public static interface SourceProcessor { + // Called with a generated source file + void process(String name, String content); + } + + public static abstract class Element { + + protected abstract void generate(PrintWriter pw); + + public String toString() { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + generate(pw); + return sw.toString(); + } + }; + + public static class AccessFlag extends Element { + private String flag; + + public AccessFlag(String name) { flag = name; } + + protected void generate(PrintWriter pw) { + pw.print(flag); + } + + public String toString() { return flag; } + + public static final AccessFlag PUBLIC = new AccessFlag("public"); + public static final AccessFlag PRIVATE = new AccessFlag("private"); + public static final AccessFlag PROTECTED = new AccessFlag("protected"); + public static final AccessFlag STATIC = new AccessFlag("static"); + public static final AccessFlag FINAL = new AccessFlag("final"); + public static final AccessFlag SYNCHRONIZED = new AccessFlag("synchronized"); + public static final AccessFlag VOLATILE = new AccessFlag("volatile"); + public static final AccessFlag NATIVE = new AccessFlag("native"); + public static final AccessFlag ABSTRACT = new AccessFlag("abstract"); + public static final AccessFlag STRICTFP = new AccessFlag("strictfp"); + public static final AccessFlag DEFAULT = new AccessFlag("default"); + } + + public static class TypeParameter extends Element { + private String parameter; + + public TypeParameter(String str) { + this.parameter = str; + } + + protected void generate(PrintWriter pw) { + pw.print(parameter); + } + } + + public static class TypeArgument extends Element { + private String argument; + + public TypeArgument(String str) { + this.argument = str; + } + + protected void generate(PrintWriter pw) { + pw.print(argument); + } + } + + public static class MethodParameter extends Element { + private String type; + private String name; + + public MethodParameter(String type, String name) { + this.type = type; + this.name = name; + } + + protected void generate(PrintWriter pw) { + pw.printf("%s %s", this.type, this.name); + } + + public String toString() { return type + " " + name; } + } + + public static abstract class Type extends Element { + private String name; + private List accessFlags; + private List parameters; + private List supertypes; + private List methods; + + // methods from superclasses that are required for compilation + // (and thus will be present in stubs) + private Set methodDependencies; + private List typeDependencies; + + protected Type(String name, + List flags, List params, + List ifaces, List methods) { + this.name = name; + this.accessFlags = flags == null ? new ArrayList<>() : flags; + this.parameters = params == null ? new ArrayList<>() : params; + this.supertypes = ifaces == null ? new ArrayList<>() : ifaces; + this.methods = methods == null ? new ArrayList<>() : methods; + this.methodDependencies = new HashSet<>(); + this.typeDependencies = new ArrayList<>(); + } + + public String getName() { return this.name; } + public List getAccessFlags() { return this.accessFlags; } + public List getParameters() { return this.parameters; } + public List getSupertypes() { return this.supertypes; } + public List getMethods() { return this.methods; } + public Set methodDependencies() { + return this.methodDependencies; + } + + public Class getSuperclass() { return null; } + protected abstract void setSuperClass(Extends supertype); + + public void addSuperType(Extends sup) { + assert sup.getType() instanceof Interface : "Must be an interface"; + this.supertypes.add(sup); + } + public void addSuperType(Interface iface) { + this.supertypes.add(new Extends(iface)); + } + + public void addMethod(Method m) { + this.methods.add(m); + } + + public void addAccessFlag(AccessFlag f) { + this.accessFlags.add(f); + } + + // Convenience method for creation. Parameters are interpreted + // according to their type. Class (or Extends with a Class type) is + // considered a superclass (only one allowed). TypeParameters are + // generic parameter names. Interface (or Extends with an Interface + // type) is an implemented supertype. Methods are methods (duh!). + protected void addComponent(Element p) { + if (p instanceof Class) { + setSuperClass(new Extends((Class)p)); + } else if (p instanceof Extends) { + Extends ext = (Extends)p; + if (ext.supertype instanceof Class) { + setSuperClass(ext); + } else if (ext.supertype instanceof Interface) { + addSuperType(ext); + } else { + assert false : "What is this thing?"; + } + } else if (p instanceof Interface) { + addSuperType((Interface)p); + } else if (p instanceof TypeParameter) { + this.parameters.add((TypeParameter)p); + } else if (p instanceof Method) { + addMethod((Method)p); + } else if (p instanceof AccessFlag) { + addAccessFlag((AccessFlag)p); + } else { + assert false : "What is this thing?"; + } + } + + // Find and return the first method that has name 'name' + public Method findMethod(String name) { + for (Method m : methods) { + if (m.name.equals(name)) { + return m; + } + } + return null; + } + + public void addCompilationDependency(Type t) { + typeDependencies.add(t); + } + + public void addCompilationDependency(Method m) { + methodDependencies.add(m); + } + + // Convenience method for creating an Extends object using this + // class and specified type arguments. + public Extends with(String ... args) { + return new Extends(this, args); + } + + public abstract void generate(SourceProcessor sp); + public abstract void generateAsDependency( + SourceProcessor sp, Set neededMethods); + + protected void generateName(PrintWriter pw) { + pw.print(this.name); + toJoinedString(this.parameters, ",", "<", ">", ""); + pw.print(toJoinedString(this.parameters, ",", "<", ">", "")); + pw.print(" "); + } + + protected void generateBody(PrintWriter pw, String superSpec) { + pw.print(toJoinedString(this.supertypes, ",", superSpec + " ", " ", "")); + pw.println("{ "); + pw.print(toJoinedString(this.methods, "\n ", "\n ", "\n", "")); + pw.println("}"); + } + + protected void generateAccessFlags(PrintWriter pw) { + pw.print(toJoinedString(this.accessFlags, " ", "", " ")); + } + + protected void generateBodyAsDependency( + PrintWriter pw, Set neededMethods) { + pw.println(" {"); + for (Method m : this.methods) { + if (neededMethods.contains(m)) { + pw.print(" "); + m.generate(pw); + pw.println(); + } + } + pw.println("}"); + } + + public Collection typeDependencies() { + HashMap dependencies = new HashMap<>(); + Type superclass = getSuperclass(); + if (superclass != null) { + dependencies.put(superclass.getName(), superclass); + } + for (Extends e : getSupertypes()) + dependencies.put(e.getType().getName(), e.getType()); + // Do these last so that they override + for (Type t : this.typeDependencies) + dependencies.put(t.getName(), t); + return dependencies.values(); + } + } + + public static class Class extends Type { + private Extends superClass; + + public Class(String name, List flags, + List params, Extends sprClass, + List interfaces, List methods) { + super(name, flags, params, interfaces, methods); + this.superClass = sprClass; + addAccessFlag(AccessFlag.PUBLIC); // should remove this + } + + public Class(String name, Element ... components) { + super(name, null, null, null, null); + this.superClass = null; + + for (Element p : components) { + addComponent(p); + } + addAccessFlag(AccessFlag.PUBLIC); // should remove this + } + + public boolean isAbstract() { + for (AccessFlag flag : getAccessFlags()) { + if (flag == AccessFlag.ABSTRACT) { + return true; + } + } + return false; + } + + @Override + public void setSuperClass(Extends ext) { + assert this.superClass == null : "Multiple superclasses defined"; + assert ext.getType() instanceof Class : "Must be a class"; + this.superClass = ext; + } + + public void setSuperClass(Class c) { + setSuperClass(new Extends(c)); + } + + @Override + public Class getSuperclass() { + return superClass == null ? null : (Class)superClass.supertype; + } + + public void generate(SourceProcessor processor) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + generate(pw); + processor.process(getName(), sw.toString()); + } + + public void generate(PrintWriter pw) { + generateAccessFlags(pw); + pw.print("class "); + generateName(pw); + if (superClass != null) { + pw.print("extends "); + superClass.generate(pw); + pw.print(" "); + } + generateBody(pw, "implements"); + } + + public void generateAsDependency( + SourceProcessor processor, Set neededMethods) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + generateAccessFlags(pw); + pw.print("class "); + generateName(pw); + pw.print(" "); + generateBodyAsDependency(pw, neededMethods); + + processor.process(getName(), sw.toString()); + } + } + + public static class Interface extends Type { + + public Interface(String name, + List flags, List params, + List interfaces, List methods) { + super(name, flags, params, interfaces, methods); + } + + public Interface(String name, Element ... components) { + super(name, null, null, null, null); + for (Element c : components) { + addComponent(c); + } + } + + protected void setSuperClass(Extends ext) { + assert false : "Interfaces cannot have Class supertypes"; + } + + public void generate(SourceProcessor processor) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + generate(pw); + processor.process(getName(), sw.toString()); + } + + public void generate(PrintWriter pw) { + generateAccessFlags(pw); + pw.print("interface "); + generateName(pw); + pw.print(" "); + generateBody(pw, "extends"); + } + + public void generateAsDependency( + SourceProcessor processor, Set neededMethods) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + + generateAccessFlags(pw); + pw.print("interface "); + generateName(pw); + pw.print(" "); + generateBodyAsDependency(pw, neededMethods); + + processor.process(getName(), sw.toString()); + } + } + + /** + * Represents a type extension that might contain type arguments + */ + public static class Extends extends Element { + private final Type supertype; + private final List arguments; + + public Type getType() { return supertype; } + public List getArguments() { + return arguments; + } + + public Extends(Type supertype, String ... args) { + assert supertype != null : "Null supertype"; + this.supertype = supertype; + this.arguments = new ArrayList<>(); + for (String arg : args) { + this.arguments.add(new TypeArgument(arg)); + } + } + + public void generate(PrintWriter pw) { + pw.print(supertype.getName()); + pw.print(toJoinedString(getArguments(), ",", "<", ">", "")); + } + } + + public static abstract class Method extends Element { + private String name; + private String returnType; + private List accessFlags; + private List parameters; + private boolean emitSuppressWarnings; + + protected Method(String ret, String name, Element ... params) { + this.name = name; + this.returnType = ret; + this.accessFlags = new ArrayList<>(); + this.parameters = new ArrayList<>(); + this.emitSuppressWarnings = false; + + for (Element e : params) { + if (e instanceof MethodParameter) { + this.parameters.add((MethodParameter) e); + } else if (e instanceof AccessFlag) { + this.accessFlags.add((AccessFlag) e); + } + } + assert accessFlags.size() + parameters.size() == params.length : + "Non method parameters or access flags in constructor"; + } + + public String getName() { return this.name; } + public String getReturnType() { return this.returnType; } + public List getParameters() { + return this.parameters; + } + public List getAccessFlags() { + return this.accessFlags; + } + public Element[] getElements() { + ArrayList elements = new ArrayList<>(); + elements.addAll(getParameters()); + elements.addAll(getAccessFlags()); + return elements.toArray(new Element[0]); + } + + public void suppressWarnings() { this.emitSuppressWarnings = true; } + + public void generateWarningSuppression(PrintWriter pw) { + if (this.emitSuppressWarnings) { + pw.printf("@SuppressWarnings(\"unchecked\")\n "); + } + } + + protected void generateDecl(PrintWriter pw) { + generateWarningSuppression(pw); + pw.print(toJoinedString(this.accessFlags, " ", "", " ")); + pw.printf("%s %s(", returnType, name); + pw.print(toJoinedString(parameters, ",")); + pw.print(")"); + } + } + + public static class AbstractMethod extends Method { + public AbstractMethod( + String ret, String name, Element ... params) { + super(ret, name, params); + this.getAccessFlags().add(AccessFlag.ABSTRACT); + } + + public void generate(PrintWriter pw) { + generateDecl(pw); + pw.print(";"); + } + + public static AbstractMethod std() { + return new AbstractMethod( + "int", SourceModel.stdMethodName, AccessFlag.PUBLIC); + } + } + + public static class ConcreteMethod extends Method { + protected String body; + + public ConcreteMethod(String ret, String name, + String body, Element ... params) { + super(ret, name, params); + this.body = body; + } + + public void generate(PrintWriter pw) { + generateDecl(pw); + pw.printf(" { %s }", this.body); + } + + public static ConcreteMethod std(String value) { + return new ConcreteMethod( + "int", SourceModel.stdMethodName, "return " + value + ";", + AccessFlag.PUBLIC); + } + } + + // When the default method flag gets moved into the traditional + // access flags location, we can remove this class completely and + // use a ConcreteMethod with an AccessFlag("default") in the constructor + public static class DefaultMethod extends Method { + protected String body; + + public DefaultMethod(String ret, String name, String body, + Element ... params) { + super(ret, name, params); + this.body = body; + this.getAccessFlags().add(AccessFlag.DEFAULT); + } + + public void generate(PrintWriter pw) { + generateDecl(pw); + pw.printf(" { %s }", this.body); + } + + public static DefaultMethod std(String value) { + return new DefaultMethod( + "int", SourceModel.stdMethodName, "return " + value + ";"); + } + } + + private static String toJoinedString(List list, String... p) { + StringBuilder sb = new StringBuilder(); + String sep = ""; + String init = ""; + String end = ""; + String empty = null; + switch (p.length) { + case 4: + empty = p[3]; + /*fall-through*/ + case 3: + end = p[2]; + /*fall-through*/ + case 2: + init = p[1]; + /*fall-through*/ + case 1: + sep = p[0]; + break; + } + if (empty != null && list.isEmpty()) { + return empty; + } else { + sb.append(init); + for (T x : list) { + if (sb.length() != init.length()) { + sb.append(sep); + } + sb.append(x.toString()); + } + sb.append(end); + return sb.toString(); + } + } +} diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java new file mode 100644 index 00000000000..142ea0de2ac --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java @@ -0,0 +1,354 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.separate; + +import org.testng.ITestResult; +import org.testng.annotations.AfterMethod; + +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import static org.openjdk.tests.separate.SourceModel.Class; +import static org.openjdk.tests.separate.SourceModel.*; +import static org.testng.Assert.*; + +public class TestHarness { + + /** + * Creates a per-thread persistent compiler object to allow as much + * sharing as possible, but still allows for parallel execution of tests. + */ + protected ThreadLocal compilerLocal = new ThreadLocal(){ + protected synchronized Compiler initialValue() { + return new Compiler(); + } + }; + + protected ThreadLocal verboseLocal = new ThreadLocal() { + protected synchronized Boolean initialValue() { + return Boolean.FALSE; + } + }; + + protected boolean verbose; + protected boolean canUseCompilerCache; + public static final String stdMethodName = SourceModel.stdMethodName; + + private TestHarness() { + } + + protected TestHarness(boolean verbose, boolean canUseCompilerCache) { + this.verbose = verbose; + this.canUseCompilerCache = canUseCompilerCache; + } + + public void setTestVerbose() { + verboseLocal.set(Boolean.TRUE); + } + + @AfterMethod + public void reset() { + if (!this.verbose) { + verboseLocal.set(Boolean.FALSE); + } + } + + public Compiler.Flags[] compilerFlags() { + HashSet flags = new HashSet<>(); + if (verboseLocal.get() == Boolean.TRUE) { + flags.add(Compiler.Flags.VERBOSE); + } + if (this.canUseCompilerCache) { + flags.add(Compiler.Flags.USECACHE); + } + return flags.toArray(new Compiler.Flags[0]); + } + + @AfterMethod + public void printError(ITestResult result) { + if (result.getStatus() == ITestResult.FAILURE) { + String clsName = result.getTestClass().getName(); + clsName = clsName.substring(clsName.lastIndexOf(".") + 1); + System.out.println("Test " + clsName + "." + + result.getName() + " FAILED"); + } + } + + private static final ConcreteMethod stdCM = ConcreteMethod.std("-1"); + private static final AbstractMethod stdAM = + new AbstractMethod("int", stdMethodName); + + /** + * Returns a class which has a static method with the same name as + * 'method', whose body creates an new instance of 'specimen' and invokes + * 'method' upon it via an invokevirtual instruction with 'args' as + * function call parameters. + * + * 'returns' is a dummy return value that need only match 'methods' + * return type (it is only used in the dummy class when compiling IV). + */ + private Class invokeVirtualHarness( + Class specimen, ConcreteMethod method, + String returns, String ... args) { + Method cm = new ConcreteMethod( + method.getReturnType(), method.getName(), + "return " + returns + ";", method.getElements()); + Class stub = new Class(specimen.getName(), cm); + + String params = toJoinedString(args, ", "); + + ConcreteMethod sm = new ConcreteMethod( + method.getReturnType(), method.getName(), + String.format("return (new %s()).%s(%s);", + specimen.getName(), method.getName(), params), + new AccessFlag("public"), new AccessFlag("static")); + + Class iv = new Class("IV_" + specimen.getName(), sm); + + iv.addCompilationDependency(stub); + iv.addCompilationDependency(cm); + + return iv; + } + + /** + * Returns a class which has a static method with the same name as + * 'method', whose body creates an new instance of 'specimen', casts it + * to 'iface' (including the type parameters) and invokes + * 'method' upon it via an invokeinterface instruction with 'args' as + * function call parameters. + */ + private Class invokeInterfaceHarness(Class specimen, Extends iface, + AbstractMethod method, String ... args) { + Interface istub = new Interface( + iface.getType().getName(), iface.getType().getAccessFlags(), + iface.getType().getParameters(), + null, Arrays.asList((Method)method)); + Class cstub = new Class(specimen.getName()); + + String params = toJoinedString(args, ", "); + + ConcreteMethod sm = new ConcreteMethod( + "int", SourceModel.stdMethodName, + String.format("return ((%s)(new %s())).%s(%s);", iface.toString(), + specimen.getName(), method.getName(), params), + new AccessFlag("public"), new AccessFlag("static")); + sm.suppressWarnings(); + + Class ii = new Class("II_" + specimen.getName() + "_" + + iface.getType().getName(), sm); + ii.addCompilationDependency(istub); + ii.addCompilationDependency(cstub); + ii.addCompilationDependency(method); + return ii; + } + + + /** + * Uses 'loader' to load class 'clzz', and calls the static method + * 'method'. If the return value does not equal 'value' (or if an + * exception is thrown), then a test failure is indicated. + * + * If 'value' is null, then no equality check is performed -- the assertion + * fails only if an exception is thrown. + */ + protected void assertStaticCallEquals( + ClassLoader loader, Class clzz, String method, Object value) { + java.lang.Class cls = null; + try { + cls = java.lang.Class.forName(clzz.getName(), true, loader); + } catch (ClassNotFoundException e) {} + assertNotNull(cls); + + java.lang.reflect.Method m = null; + try { + m = cls.getMethod(method); + } catch (NoSuchMethodException e) {} + assertNotNull(m); + + try { + Object res = m.invoke(null); + assertNotNull(res); + if (value != null) { + assertEquals(res, value); + } + } catch (InvocationTargetException | IllegalAccessException e) { + fail("Unexpected exception thrown: " + e.getCause()); + } + } + + /** + * Creates a class which calls target::method(args) via invokevirtual, + * compiles and loads both the new class and 'target', and then invokes + * the method. If the returned value does not match 'value' then a + * test failure is indicated. + */ + public void assertInvokeVirtualEquals( + Object value, Class target, ConcreteMethod method, + String returns, String ... args) { + + Compiler compiler = compilerLocal.get(); + compiler.setFlags(compilerFlags()); + + Class iv = invokeVirtualHarness(target, method, returns, args); + ClassLoader loader = compiler.compile(iv, target); + + assertStaticCallEquals(loader, iv, method.getName(), value); + compiler.cleanup(); + } + + /** + * Convenience method for above, which assumes stdMethodName, + * a return type of 'int', and no arguments. + */ + public void assertInvokeVirtualEquals(int value, Class target) { + assertInvokeVirtualEquals( + new Integer(value), target, stdCM, "-1"); + } + + /** + * Creates a class which calls target::method(args) via invokeinterface + * through 'iface', compiles and loads both it and 'target', and + * then invokes the method. If the returned value does not match + * 'value' then a test failure is indicated. + */ + public void assertInvokeInterfaceEquals(Object value, Class target, + Extends iface, AbstractMethod method, String ... args) { + + Compiler compiler = compilerLocal.get(); + compiler.setFlags(compilerFlags()); + + Class ii = invokeInterfaceHarness(target, iface, method, args); + ClassLoader loader = compiler.compile(ii, target); + + assertStaticCallEquals(loader, ii, method.getName(), value); + compiler.cleanup(); + } + + /** + * Convenience method for above, which assumes stdMethodName, + * a return type of 'int', and no arguments. + */ + public void assertInvokeInterfaceEquals( + int value, Class target, Interface iface) { + + Compiler compiler = compilerLocal.get(); + compiler.setFlags(compilerFlags()); + + assertInvokeInterfaceEquals( + new Integer(value), target, new Extends(iface), stdAM); + + compiler.cleanup(); + } + + /** + * Creates a class which calls target::method(args) via invokevirtual, + * compiles and loads both the new class and 'target', and then invokes + * the method. If an exception of type 'exceptionType' is not thrown, + * then a test failure is indicated. + */ + public void assertThrows(java.lang.Class exceptionType, Class target, + ConcreteMethod method, String returns, String ... args) { + + Compiler compiler = compilerLocal.get(); + compiler.setFlags(compilerFlags()); + + Class iv = invokeVirtualHarness(target, method, returns, args); + ClassLoader loader = compiler.compile(iv, target); + + java.lang.Class cls = null; + try { + cls = java.lang.Class.forName(iv.getName(), true, loader); + } catch (ClassNotFoundException e) {} + assertNotNull(cls); + + java.lang.reflect.Method m = null; + try { + m = cls.getMethod(method.getName()); + } catch (NoSuchMethodException e) {} + assertNotNull(m); + + try { + m.invoke(null); + fail("Exception should have been thrown"); + } catch (InvocationTargetException | IllegalAccessException e) { + if (verboseLocal.get() == Boolean.TRUE) { + System.out.println(e.getCause()); + } + assertEquals(e.getCause().getClass(), exceptionType); + } + compiler.cleanup(); + } + + /** + * Convenience method for above, which assumes stdMethodName, + * a return type of 'int', and no arguments. + */ + public void assertThrows(java.lang.Class exceptionType, Class target) { + assertThrows(exceptionType, target, stdCM, "-1"); + } + + private static String toJoinedString(T[] a, String... p) { + return toJoinedString(Arrays.asList(a), p); + } + + private static String toJoinedString(List list, String... p) { + StringBuilder sb = new StringBuilder(); + String sep = ""; + String init = ""; + String end = ""; + String empty = null; + switch (p.length) { + case 4: + empty = p[3]; + /*fall-through*/ + case 3: + end = p[2]; + /*fall-through*/ + case 2: + init = p[1]; + /*fall-through*/ + case 1: + sep = p[0]; + break; + } + if (empty != null && list.isEmpty()) { + return empty; + } else { + sb.append(init); + for (T x : list) { + if (sb.length() != init.length()) { + sb.append(sep); + } + sb.append(x.toString()); + } + sb.append(end); + return sb.toString(); + } + } +} diff --git a/langtools/test/tools/javac/defaultMethods/fd/shapegen/ClassCase.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/ClassCase.java similarity index 98% rename from langtools/test/tools/javac/defaultMethods/fd/shapegen/ClassCase.java rename to langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/ClassCase.java index 9c4b8bfd806..d3578ee2afa 100644 --- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/ClassCase.java +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/ClassCase.java @@ -23,7 +23,7 @@ * questions. */ -package shapegen; +package org.openjdk.tests.shapegen; import java.util.ArrayList; import java.util.HashSet; @@ -52,6 +52,8 @@ public class ClassCase { this.isInterface = isInterface; this.prefix = prefix; } + + public String getPrefix() { return prefix; } } public final Kind kind; @@ -67,7 +69,7 @@ public class ClassCase { private ClassCase _mres; private ClassCase _mdefend; - private Set executed = new HashSet() {}; + private Set executed = new HashSet(); public ClassCase(Kind kind, ClassCase superclass, List interfaces) { this.kind = kind; diff --git a/langtools/test/tools/javac/defaultMethods/fd/shapegen/Hierarchy.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Hierarchy.java similarity index 59% rename from langtools/test/tools/javac/defaultMethods/fd/shapegen/Hierarchy.java rename to langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Hierarchy.java index 97ba817e43e..b594eecbdfd 100644 --- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/Hierarchy.java +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Hierarchy.java @@ -23,14 +23,16 @@ * questions. */ -package shapegen; +package org.openjdk.tests.shapegen; +import java.util.ArrayList; import java.util.List; import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; -import static shapegen.ClassCase.Kind.*; +import static org.openjdk.tests.shapegen.ClassCase.Kind.*; /** * @@ -67,15 +69,15 @@ public class Hierarchy { } private static void genInterfaceList(StringBuilder buf, String prefix, List interfaces) { - if (!interfaces.isEmpty()) { - buf.append(" "); - buf.append(prefix); - buf.append(" "); - buf.append(interfaces.get(0)); - for (int i = 1; i < interfaces.size(); ++i) { - buf.append(", " + interfaces.get(i)); + if (!interfaces.isEmpty()) { + buf.append(" "); + buf.append(prefix); + buf.append(" "); + buf.append(interfaces.get(0)); + for (int i = 1; i < interfaces.size(); ++i) { + buf.append(", " + interfaces.get(i)); + } } - } } public static void genClassDef(StringBuilder buf, ClassCase cc, String implClass, List defaultRef) { @@ -140,4 +142,68 @@ public class Hierarchy { return root.getName(); } + private static String classNames[] = { + "C", "D", "E", "F", "G", "H", "S", "T", "U", "V" + }; + + private static String interfaceNames[] = { + "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R" + }; + + private static int CLASS_INDEX = 0; + private static int INTERFACE_INDEX = 1; + private static int NUM_INDICIES = 2; + + public List getDescription() { + Map nameMap = new HashMap<>(); + assignNames(root, new int[NUM_INDICIES], nameMap); + + ArrayList res = new ArrayList<>(); + if (root.getSupertypes().size() == 0) { + res.add(nameMap.get(root) + root.kind.getPrefix() + "()"); + } else { + genCaseDescription(root, res, new HashSet(), nameMap); + } + return res; + } + + private static void assignNames( + ClassCase cc, int indices[], Map names) { + String name = names.get(cc); + if (name == null) { + if (cc.isInterface()) { + names.put(cc, interfaceNames[indices[INTERFACE_INDEX]++]); + } else { + names.put(cc, classNames[indices[CLASS_INDEX]++]); + } + for (int i = 0; i < cc.getSupertypes().size(); ++i) { + assignNames(cc.getSupertypes().get(i), indices, names); + } + } + } + + private static void genCaseDescription( + ClassCase cc, List res, Set alreadyDone, + Map nameMap) { + if (!alreadyDone.contains(cc)) { + if (cc.getSupertypes().size() > 0) { + StringBuilder sb = new StringBuilder(); + sb.append(nameMap.get(cc)); + sb.append(cc.kind.getPrefix()); + sb.append("("); + for (int i = 0; i < cc.getSupertypes().size(); ++i) { + ClassCase supertype = cc.getSupertypes().get(i); + if (i != 0) { + sb.append(","); + } + genCaseDescription(supertype, res, alreadyDone, nameMap); + sb.append(nameMap.get(supertype)); + sb.append(supertype.kind.getPrefix()); + } + sb.append(")"); + res.add(sb.toString()); + } + } + alreadyDone.add(cc); + } } diff --git a/langtools/test/tools/javac/defaultMethods/fd/shapegen/HierarchyGenerator.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/HierarchyGenerator.java similarity index 92% rename from langtools/test/tools/javac/defaultMethods/fd/shapegen/HierarchyGenerator.java rename to langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/HierarchyGenerator.java index 4c51ad38c77..828b3131a76 100644 --- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/HierarchyGenerator.java +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/HierarchyGenerator.java @@ -23,9 +23,9 @@ * questions. */ -package shapegen; +package org.openjdk.tests.shapegen; -import shapegen.ClassCase.Kind; +import org.openjdk.tests.shapegen.ClassCase.Kind; import java.util.Collection; import java.util.Set; @@ -34,7 +34,7 @@ import java.util.Collections; import java.util.ArrayList; import java.util.List; -import static shapegen.ClassCase.Kind.*; +import static org.openjdk.tests.shapegen.ClassCase.Kind.*; import static java.lang.Math.pow; @@ -44,10 +44,10 @@ import static java.lang.Math.pow; */ public final class HierarchyGenerator { - private static int okcnt = 0; - private static int errcnt = 0; - private static Set uniqueOK = new HashSet<>(); - private static Set uniqueErr = new HashSet<>(); + private int okcnt = 0; + private int errcnt = 0; + private Set uniqueOK = new HashSet<>(); + private Set uniqueErr = new HashSet<>(); /** * @param args the command line arguments @@ -71,7 +71,7 @@ public final class HierarchyGenerator { } private void organize(String tname, List totest) { - System.out.printf("\nTesting %s....\n", tname); + System.out.printf("\nGenerating %s....\n", tname); int nodefault = 0; List ok = new ArrayList<>(); List err = new ArrayList<>(); @@ -152,12 +152,14 @@ public final class HierarchyGenerator { return totest; } + public static final List EMPTY_LIST = new ArrayList<>(); + private List iList(Kind kind) { if (kind == null) { - return Collections.EMPTY_LIST; + return EMPTY_LIST; } else { List itfs = new ArrayList<>(); - itfs.add(new ClassCase(kind, null, Collections.EMPTY_LIST)); + itfs.add(new ClassCase(kind, null, EMPTY_LIST)); return itfs; } } diff --git a/langtools/test/tools/javac/defaultMethods/fd/shapegen/Rule.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Rule.java similarity index 97% rename from langtools/test/tools/javac/defaultMethods/fd/shapegen/Rule.java rename to langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Rule.java index 76b6a16ee87..a02eea97675 100644 --- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/Rule.java +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Rule.java @@ -23,7 +23,7 @@ * questions. */ -package shapegen; +package org.openjdk.tests.shapegen; /** * diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/RuleGroup.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/RuleGroup.java new file mode 100644 index 00000000000..0ff573bb664 --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/RuleGroup.java @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.shapegen; + +import java.util.HashSet; +import java.util.Set; + +import static org.openjdk.tests.shapegen.ClassCase.Kind.*; + +/** + * + * @author Robert Field + */ +public class RuleGroup { + + final String name; + private final Rule[] rules; + + public RuleGroup(String name, Rule[] rules) { + this.name = name; + this.rules = rules; + } + + public boolean exec(ClassCase cc) { + boolean found = false; + for (Rule rule : rules) { + if (rule.guard(cc)) { + if (found) { + throw new RuntimeException("Bad rules -- multiple matches " + toString() + " for " + cc); + } else { + rule.eval(cc); + found = true; + } + } + } + return found; + } + + @Override + public String toString() { + return name; + } + + public static RuleGroup PROVENENCE = new RuleGroup("Provenence", new Rule[] { + new Rule("P-CDeclare") { + boolean guard(ClassCase cc) { + return cc.isa(CCONCRETE, CABSTRACT); + } + + void eval(ClassCase cc) { + cc.set_mprov(cc); + cc.set_HasClassMethod(true); + } + }, + + new Rule("P-IDeclare") { + boolean guard(ClassCase cc) { + return cc.isa(IDEFAULT, IPRESENT); + } + + void eval(ClassCase cc) { + cc.set_mprov(cc); + } + }, + + new Rule("P-IntfInh") { + boolean guard(ClassCase cc) { + return cc.isa(IVAC, CNONE) && !(cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod()); + } + + void eval(ClassCase cc) { + Set _S = new HashSet<>(); + for (ClassCase t : cc.getSupertypes()) { + _S.addAll(t.get_mprov()); + } + Set tops = new HashSet<>(); + for (ClassCase _W : _S) { + for (ClassCase _V : _S) { + if (_V.equals(_W) || !(_V.isSubtypeOf(_W))) { + tops.add(_W); + } + } + } + cc.set_mprov(tops); + } + }, + + new Rule("P-ClassInh") { + boolean guard(ClassCase cc) { + return cc.isa(CNONE) && (cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod()); + } + + void eval(ClassCase cc) { + cc.set_mprov(cc.getSuperclass()); + cc.set_HasClassMethod(true); + } + }, + + }); + + public static RuleGroup MARKER = new RuleGroup("Marker", new Rule[] { + new Rule("M-Default") { + boolean guard(ClassCase cc) { + return cc.isa(IDEFAULT); + } + + void eval(ClassCase cc) { + cc.set_HasDefault(true); + } + }, + + new Rule("M-Conc") { + boolean guard(ClassCase cc) { + return cc.isa(CCONCRETE); + } + + void eval(ClassCase cc) { + cc.set_IsConcrete(true); + } + }, + + }); + + public static RuleGroup RESOLUTION = new RuleGroup("Resolution", new Rule[] { + new Rule("R-Resolve") { + boolean guard(ClassCase cc) { + if (!(cc.isClass() && cc.get_mprov().size() == 1)) { + return false; + } + ClassCase _V = cc.get_mprov().iterator().next(); + return _V.get_IsConcrete() || _V.get_HasDefault(); + } + + void eval(ClassCase cc) { + ClassCase _V = cc.get_mprov().iterator().next(); + cc.set_mres(_V); + } + }, + + }); + + public static RuleGroup DEFENDER = new RuleGroup("Defender", new Rule[] { + new Rule("D-Defend") { + boolean guard(ClassCase cc) { + ClassCase mresSuper = cc.hasSuperclass() ? cc.getSuperclass().get_mres() : null; + boolean eq = cc.get_mres() == null ? mresSuper == null : cc.get_mres().equals(mresSuper); + return cc.isa(CNONE) && !eq; + } + + void eval(ClassCase cc) { + cc.set_mdefend(cc.get_mres()); + } + }, + + }); + + public static RuleGroup CHECKING = new RuleGroup("Checking", new Rule[] { + new Rule("C-Check") { + boolean guard(ClassCase cc) { + for (ClassCase t : cc.getSupertypes()) { + if (! t.get_OK()) { + return false; + } + } + int defenderCount = 0; + int provCount = 0; + for (ClassCase prov : cc.get_mprov()) { + if (prov.get_HasDefault()) { + defenderCount++; + } + provCount++; + } + return provCount <= 1 || defenderCount == 0; + } + + void eval(ClassCase cc) { + cc.set_OK(true); + } + }, + + }); + +} diff --git a/langtools/test/tools/javac/defaultMethods/fd/shapegen/TTNode.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTNode.java similarity index 96% rename from langtools/test/tools/javac/defaultMethods/fd/shapegen/TTNode.java rename to langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTNode.java index 7e3830b1063..db0e8353641 100644 --- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/TTNode.java +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTNode.java @@ -23,15 +23,15 @@ * questions. */ -package shapegen; +package org.openjdk.tests.shapegen; -import shapegen.ClassCase.Kind; +import org.openjdk.tests.shapegen.ClassCase.Kind; import java.util.ArrayList; import java.util.List; import java.util.Set; -import static shapegen.ClassCase.Kind.*; +import static org.openjdk.tests.shapegen.ClassCase.Kind.*; /** * Type Template Node diff --git a/langtools/test/tools/javac/defaultMethods/fd/shapegen/TTParser.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTParser.java similarity index 98% rename from langtools/test/tools/javac/defaultMethods/fd/shapegen/TTParser.java rename to langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTParser.java index 213338d28d7..f54eb374654 100644 --- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/TTParser.java +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTParser.java @@ -23,7 +23,7 @@ * questions. */ -package shapegen; +package org.openjdk.tests.shapegen; import java.util.ArrayList; import java.util.HashMap; diff --git a/langtools/test/tools/javac/defaultMethods/fd/shapegen/TTShape.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTShape.java similarity index 98% rename from langtools/test/tools/javac/defaultMethods/fd/shapegen/TTShape.java rename to langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTShape.java index 8781484845f..07a23da47fa 100644 --- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/TTShape.java +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTShape.java @@ -23,7 +23,7 @@ * questions. */ -package shapegen; +package org.openjdk.tests.shapegen; import java.util.ArrayList; import java.util.HashSet; diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java new file mode 100644 index 00000000000..46b66e1fd86 --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java @@ -0,0 +1,826 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.vm; + +import java.lang.reflect.*; +import java.util.*; +import java.io.File; +import java.io.IOException; + +import org.testng.annotations.Test; +import org.openjdk.tests.separate.*; +import org.openjdk.tests.separate.Compiler; + +import static org.testng.Assert.*; +import static org.openjdk.tests.separate.SourceModel.*; +import static org.openjdk.tests.separate.SourceModel.Class; + +@Test(groups = "vm") +public class DefaultMethodsTest extends TestHarness { + public DefaultMethodsTest() { + super(false, false); + } + + /** + * class C { public int m() { return 22; } } + * + * TEST: C c = new C(); c.m() == 22 + */ + public void testHarnessInvokeVirtual() { + Class C = new Class("C", ConcreteMethod.std("22")); + assertInvokeVirtualEquals(22, C); + } + + /** + * interface I { int m(); } + * class C implements I { public int m() { return 33; } } + * + * TEST: I i = new C(); i.m() == 33; + */ + public void testHarnessInvokeInterface() { + Interface I = new Interface("I", AbstractMethod.std()); + Class C = new Class("C", I, ConcreteMethod.std("33")); + assertInvokeInterfaceEquals(33, C, I); + } + + /** + * class C {} + * + * TEST: C c = new C(); c.m() throws NoSuchMethod + */ + public void testHarnessThrows() { + Class C = new Class("C"); + assertThrows(NoSuchMethodError.class, C); + } + + /** + * interface I { int m() default { return 44; } } + * class C implements I {} + * + * TEST: C c = new C(); c.m() == 44; + * TEST: I i = new C(); i.m() == 44; + */ + public void testBasicDefault() { + Interface I = new Interface("I", DefaultMethod.std("44")); + Class C = new Class("C", I); + + assertInvokeVirtualEquals(44, C); + assertInvokeInterfaceEquals(44, C, I); + } + + /** + * interface I { default int m() { return 44; } } + * interface J extends I {} + * interface K extends J {} + * class C implements K {} + * + * TEST: C c = new C(); c.m() == 44; + * TEST: I i = new C(); i.m() == 44; + */ + public void testFarDefault() { + Interface I = new Interface("I", DefaultMethod.std("44")); + Interface J = new Interface("J", I); + Interface K = new Interface("K", J); + Class C = new Class("C", K); + + assertInvokeVirtualEquals(44, C); + assertInvokeInterfaceEquals(44, C, K); + } + + /** + * interface I { int m(); } + * interface J extends I { default int m() { return 44; } } + * interface K extends J {} + * class C implements K {} + * + * TEST: C c = new C(); c.m() == 44; + * TEST: K k = new C(); k.m() == 44; + */ + public void testOverrideAbstract() { + Interface I = new Interface("I", AbstractMethod.std()); + Interface J = new Interface("J", I, DefaultMethod.std("44")); + Interface K = new Interface("K", J); + Class C = new Class("C", K); + + assertInvokeVirtualEquals(44, C); + assertInvokeInterfaceEquals(44, C, K); + } + + /** + * interface I { int m() default { return 44; } } + * class C implements I { public int m() { return 55; } } + * + * TEST: C c = new C(); c.m() == 55; + * TEST: I i = new C(); i.m() == 55; + */ + public void testExisting() { + Interface I = new Interface("I", DefaultMethod.std("44")); + Class C = new Class("C", I, ConcreteMethod.std("55")); + + assertInvokeVirtualEquals(55, C); + assertInvokeInterfaceEquals(55, C, I); + } + + /** + * interface I { default int m() { return 99; } } + * class B implements I {} + * class C extends B {} + * + * TEST: C c = new C(); c.m() == 99; + * TEST: I i = new C(); i.m() == 99; + */ + public void testInherited() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Class B = new Class("B", I); + Class C = new Class("C", B); + + assertInvokeVirtualEquals(99, C); + assertInvokeInterfaceEquals(99, C, I); + } + + /** + * interface I { default int m() { return 99; } } + * class C { public int m() { return 11; } } + * class D extends C implements I {} + * + * TEST: D d = new D(); d.m() == 11; + * TEST: I i = new D(); i.m() == 11; + */ + public void testExistingInherited() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Class C = new Class("C", ConcreteMethod.std("11")); + Class D = new Class("D", C, I); + + assertInvokeVirtualEquals(11, D); + assertInvokeInterfaceEquals(11, D, I); + } + + /** + * interface I { default int m() { return 44; } } + * class C implements I { public int m() { return 11; } } + * class D extends C { public int m() { return 22; } } + * + * TEST: D d = new D(); d.m() == 22; + * TEST: I i = new D(); i.m() == 22; + */ + void testExistingInheritedOverride() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Class C = new Class("C", I, ConcreteMethod.std("11")); + Class D = new Class("D", C, ConcreteMethod.std("22")); + + assertInvokeVirtualEquals(22, D); + assertInvokeInterfaceEquals(22, D, I); + } + + /** + * interface I { default int m() { return 99; } } + * interface J { defaultint m() { return 88; } } + * class C implements I { public int m() { return 11; } } + * class D extends C { public int m() { return 22; } } + * class E extends D implements J {} + * + * TEST: E e = new E(); e.m() == 22; + * TEST: J j = new E(); j.m() == 22; + */ + public void testExistingInheritedPlusDefault() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Interface J = new Interface("J", DefaultMethod.std("88")); + Class C = new Class("C", I, ConcreteMethod.std("11")); + Class D = new Class("D", C, ConcreteMethod.std("22")); + Class E = new Class("E", D, J); + + assertInvokeVirtualEquals(22, E); + assertInvokeInterfaceEquals(22, E, J); + } + + /** + * interface I { default int m() { return 99; } } + * class B implements I {} + * class C extends B { public int m() { return 77; } } + * + * TEST: C c = new C(); c.m() == 77; + * TEST: I i = new C(); i.m() == 77; + */ + public void testInheritedWithConcrete() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Class B = new Class("B", I); + Class C = new Class("C", B, ConcreteMethod.std("77")); + + assertInvokeVirtualEquals(77, C); + assertInvokeInterfaceEquals(77, C, I); + } + + /** + * interface I { default int m() { return 99; } } + * class B implements I {} + * class C extends B implements I { public int m() { return 66; } } + * + * TEST: C c = new C(); c.m() == 66; + * TEST: I i = new C(); i.m() == 66; + */ + public void testInheritedWithConcreteAndImpl() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Class B = new Class("B", I); + Class C = new Class("C", B, I, ConcreteMethod.std("66")); + + assertInvokeVirtualEquals(66, C); + assertInvokeInterfaceEquals(66, C, I); + } + + /** + * interface I { default int m() { return 99; } } + * interface J { default int m() { return 88; } } + * class C implements I, J {} + * + * TEST: C c = new C(); c.m() throws AME + */ + public void testConflict() { + // debugTest(); + Interface I = new Interface("I", DefaultMethod.std("99")); + Interface J = new Interface("J", DefaultMethod.std("88")); + Class C = new Class("C", I, J); + + assertThrows(AbstractMethodError.class, C); + } + + /** + * interface I { int m(); } + * interface J { default int m() { return 88; } } + * class C implements I, J {} + * + * TEST: C c = new C(); c.m() throws AME + */ + public void testAmbiguousReabstract() { + Interface I = new Interface("I", AbstractMethod.std()); + Interface J = new Interface("J", DefaultMethod.std("88")); + Class C = new Class("C", I, J); + + assertThrows(AbstractMethodError.class, C); + } + + /** + * interface I { default int m() { return 99; } } + * interface J extends I { } + * interface K extends I { } + * class C implements J, K {} + * + * TEST: C c = new C(); c.m() == 99 + * TEST: J j = new C(); j.m() == 99 + * TEST: K k = new C(); k.m() == 99 + * TEST: I i = new C(); i.m() == 99 + */ + public void testDiamond() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Interface J = new Interface("J", I); + Interface K = new Interface("K", I); + Class C = new Class("C", J, K); + + assertInvokeVirtualEquals(99, C); + assertInvokeInterfaceEquals(99, C, J); + assertInvokeInterfaceEquals(99, C, K); + assertInvokeInterfaceEquals(99, C, I); + } + + /** + * interface I { default int m() { return 99; } } + * interface J extends I { } + * interface K extends I { } + * interface L extends I { } + * interface M extends I { } + * class C implements I, J, K, L, M {} + * + * TEST: C c = new C(); c.m() == 99 + * TEST: J j = new C(); j.m() == 99 + * TEST: K k = new C(); k.m() == 99 + * TEST: I i = new C(); i.m() == 99 + * TEST: L l = new C(); l.m() == 99 + * TEST: M m = new C(); m.m() == 99 + */ + public void testExpandedDiamond() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Interface J = new Interface("J", I); + Interface K = new Interface("K", I); + Interface L = new Interface("L", I); + Interface M = new Interface("M", L); + Class C = new Class("C", I, J, K, L, M); + + assertInvokeVirtualEquals(99, C); + assertInvokeInterfaceEquals(99, C, J); + assertInvokeInterfaceEquals(99, C, K); + assertInvokeInterfaceEquals(99, C, I); + assertInvokeInterfaceEquals(99, C, L); + assertInvokeInterfaceEquals(99, C, M); + } + + /** + * interface I { int m() default { return 99; } } + * interface J extends I { int m(); } + * class C implements J {} + * + * TEST: C c = new C(); c.m() throws AME + */ + public void testReabstract() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Interface J = new Interface("J", I, AbstractMethod.std()); + Class C = new Class("C", J); + + assertThrows(AbstractMethodError.class, C); + } + + /** + * interface I { default int m() { return 88; } } + * interface J extends I { default int m() { return 99; } } + * class C implements J {} + * + * TEST: C c = new C(); c.m() == 99; + * TEST: J j = new C(); j.m() == 99; + * TEST: I i = new C(); i.m() == 99; + */ + public void testShadow() { + Interface I = new Interface("I", DefaultMethod.std("88")); + Interface J = new Interface("J", I, DefaultMethod.std("99")); + Class C = new Class("C", J); + + assertInvokeVirtualEquals(99, C); + assertInvokeInterfaceEquals(99, C, J); + assertInvokeInterfaceEquals(99, C, I); + } + + /** + * interface I { default int m() { return 88; } } + * interface J extends I { default int m() { return 99; } } + * class C implements I, J {} + * + * TEST: C c = new C(); c.m() == 99; + * TEST: J j = new C(); j.m() == 99; + * TEST: I i = new C(); i.m() == 99; + */ + public void testDisqualified() { + Interface I = new Interface("I", DefaultMethod.std("88")); + Interface J = new Interface("J", I, DefaultMethod.std("99")); + Class C = new Class("C", I, J); + + assertInvokeVirtualEquals(99, C); + assertInvokeInterfaceEquals(99, C, J); + assertInvokeInterfaceEquals(99, C, I); + } + + /** + * interface I { default int m(T t) { return 99; } } + * Class C implements I { public int m() { return 88; } } + * + * TEST: C c = new C(); c.m() == 88; + * TEST: I i = new C(); i.m() == 88; + */ + public void testSelfFill() { + // This test ensures that a concrete method overrides a default method + // that matches at the language-level, but has a different method + // signature due to erasure. + + // debugTest(); + + DefaultMethod dm = new DefaultMethod( + "int", "m", "return 99;", new MethodParameter("T", "t")); + ConcreteMethod cm = new ConcreteMethod( + "int", "m", "return 88;", AccessFlag.PUBLIC, + new MethodParameter("String", "s")); + + Interface I = new Interface("I", new TypeParameter("T"), dm); + Class C = new Class("C", I.with("String"), cm); + + AbstractMethod pm = new AbstractMethod( + "int", "m", new MethodParameter("T", "t")); + + assertInvokeVirtualEquals(new Integer(88), C, cm, "-1", "\"string\""); + assertInvokeInterfaceEquals( + new Integer(88), C, I.with("String"), pm, "\"string\""); + } + + /** + * interface I { default int m() { return 99; } } + * class C implements I {} + * + * TEST: C.class.getMethod("m").invoke(new C()) == 99 + */ + public void testReflectCall() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Class C = new Class("C", I); + + Compiler.Flags[] flags = this.verbose ? + new Compiler.Flags[] { Compiler.Flags.VERBOSE } : + new Compiler.Flags[] {}; + Compiler compiler = new Compiler(flags); + java.lang.Class cls = null; + try { + cls = compiler.compileAndLoad(C); + } catch (ClassNotFoundException e) { + fail("Could not load class"); + } + + java.lang.reflect.Method method = null; + try { + method = cls.getMethod(stdMethodName); + } catch (NoSuchMethodException e) { + fail("Could not find method in class"); + } + assertNotNull(method); + + Object c = null; + try { + c = cls.newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + fail("Could not create instance of class"); + } + assertNotNull(c); + + Integer res = null; + try { + res = (Integer)method.invoke(c); + } catch (IllegalAccessException | + java.lang.reflect.InvocationTargetException e) { + fail("Could not invoke default instance method"); + } + assertNotNull(res); + + assertEquals(res.intValue(), 99); + + compiler.cleanup(); + } + + /** + * interface I { default int m(T t, V v, W w) { return 99; } } + * interface J extends I { int m(T t, V v, String w); } } + * interface K extends J { int m(T t, String v, String w); } } + * class C implements K { + * public int m(String t, String v, String w) { return 88; } + * } + * + * TEST: I i = new C(); i.m("A","B","C") == 88; + * TEST: J j = new C(); j.m("A","B","C") == 88; + * TEST: K k = new C(); k.m("A","B","C") == 88; + */ + public void testBridges() { + DefaultMethod dm = new DefaultMethod("int", stdMethodName, "return 99;", + new MethodParameter("T", "t"), new MethodParameter("V", "v"), + new MethodParameter("W", "w")); + + AbstractMethod pm0 = new AbstractMethod("int", stdMethodName, + new MethodParameter("T", "t"), new MethodParameter("V", "v"), + new MethodParameter("W", "w")); + + AbstractMethod pm1 = new AbstractMethod("int", stdMethodName, + new MethodParameter("T", "t"), new MethodParameter("V", "v"), + new MethodParameter("String", "w")); + + AbstractMethod pm2 = new AbstractMethod("int", stdMethodName, + new MethodParameter("T", "t"), new MethodParameter("String", "v"), + new MethodParameter("String", "w")); + + ConcreteMethod cm = new ConcreteMethod("int",stdMethodName,"return 88;", + AccessFlag.PUBLIC, + new MethodParameter("String", "t"), + new MethodParameter("String", "v"), + new MethodParameter("String", "w")); + + Interface I = new Interface("I", new TypeParameter("T"), + new TypeParameter("V"), new TypeParameter("W"), dm); + Interface J = new Interface("J", + new TypeParameter("T"), new TypeParameter("V"), + I.with("String", "T", "V"), pm1); + Interface K = new Interface("K", new TypeParameter("T"), + J.with("String", "T"), pm2); + Class C = new Class("C", K.with("String"), cm); + + String[] args = new String[] { "\"A\"", "\"B\"", "\"C\"" }; + assertInvokeInterfaceEquals(new Integer(88), C, + I.with("String", "String", "String"), pm0, args); + assertInvokeInterfaceEquals(new Integer(88), C, + J.with("String", "String"), pm1, args); + assertInvokeInterfaceEquals(new Integer(88), C, + K.with("String"), pm2, args); + } + + /** + * interface J { default int m() { return 88; } } + * interface I extends J { default int m() { return J.super.m(); } } + * class C implements I {} + * + * TEST: C c = new C(); c.m() == 88; + * TEST: I i = new C(); i.m() == 88; + */ + public void testSuperBasic() { + // debugTest(); + + Interface J = new Interface("J", DefaultMethod.std("88")); + Interface I = new Interface("I", J, new DefaultMethod( + "int", stdMethodName, "return J.super.m();")); + I.addCompilationDependency(J.findMethod(stdMethodName)); + Class C = new Class("C", I); + + assertInvokeVirtualEquals(88, C); + assertInvokeInterfaceEquals(88, C, I); + } + + /** + * interface K { int m() default { return 99; } } + * interface L { int m() default { return 101; } } + * interface J extends K, L {} + * interface I extends J, K { int m() default { J.super.m(); } } + * class C implements I {} + * + * TEST: C c = new C(); c.m() throws AME + * TODO: add case for K k = new C(); k.m() throws AME + */ + public void testSuperConflict() { + // debugTest(); + + Interface K = new Interface("K", DefaultMethod.std("99")); + Interface L = new Interface("L", DefaultMethod.std("101")); + Interface J = new Interface("J", K, L); + Interface I = new Interface("I", J, K, new DefaultMethod( + "int", stdMethodName, "return J.super.m();")); + Interface Jstub = new Interface("J", DefaultMethod.std("-1")); + I.addCompilationDependency(Jstub); + I.addCompilationDependency(Jstub.findMethod(stdMethodName)); + Class C = new Class("C", I); + + assertThrows(AbstractMethodError.class, C); + } + + /** + * interface I { default int m() { return 99; } } + * interface J extends I { default int m() { return 55; } } + * class C implements I, J { public int m() { return I.super.m(); } } + * + * TEST: C c = new C(); c.m() throws AME + * TODO: add case for J j = new C(); j.m() throws AME + */ + public void testSuperDisqual() { + Interface I = new Interface("I", DefaultMethod.std("99")); + Interface J = new Interface("J", I, DefaultMethod.std("55")); + Class C = new Class("C", I, J, + new ConcreteMethod("int", stdMethodName, "return I.super.m();", + AccessFlag.PUBLIC)); + C.addCompilationDependency(I.findMethod(stdMethodName)); + + assertThrows(AbstractMethodError.class, C); + } + + /** + * interface J { int m(); } + * interface I extends J { default int m() { return J.super.m(); } } + * class C implements I {} + * + * TEST: C c = new C(); c.m() throws AME + * TODO: add case for I i = new C(); i.m() throws AME + */ + public void testSuperNull() { + Interface J = new Interface("J", AbstractMethod.std()); + Interface I = new Interface("I", J, new DefaultMethod( + "int", stdMethodName, "return J.super.m();")); + Interface Jstub = new Interface("J", DefaultMethod.std("99")); + I.addCompilationDependency(Jstub); + I.addCompilationDependency(Jstub.findMethod(stdMethodName)); + Class C = new Class("C", I); + + assertThrows(AbstractMethodError.class, C); + } + + /** + * interface J { default int m(T t) { return 88; } } + * interface I extends J { + * int m(String s) default { return J.super.m(); } + * } + * class C implements I {} + * + * TEST: I i = new C(); i.m("") == 88; + */ + public void testSuperGeneric() { + Interface J = new Interface("J", new TypeParameter("T"), + new DefaultMethod("int", stdMethodName, "return 88;", + new MethodParameter("T", "t"))); + Interface I = new Interface("I", J.with("String"), + new DefaultMethod("int", stdMethodName, "return J.super.m(s);", + new MethodParameter("String", "s"))); + I.addCompilationDependency(J.findMethod(stdMethodName)); + Class C = new Class("C", I); + + AbstractMethod pm = new AbstractMethod("int", stdMethodName, + new MethodParameter("String", "s")); + + assertInvokeInterfaceEquals( + new Integer(88), C, new Extends(I), pm, "\"\""); + } + + /** + * interface I { int m(T t) default { return 44; } } + * interface J extends I { int m(String s) default { return 55; } } + * class C implements I, J { + * public int m(String s) { return I.super.m(s); } + * } + * + * TEST: C c = new C(); c.m("string") throws AME + */ + public void testSuperGenericDisqual() { + MethodParameter t = new MethodParameter("T", "t"); + MethodParameter s = new MethodParameter("String", "s"); + + Interface I = new Interface("I", new TypeParameter("T"), + new DefaultMethod("int", stdMethodName, "return 44;", t)); + Interface J = new Interface("J", I.with("String"), + new DefaultMethod("int", stdMethodName, "return 55;", s)); + Class C = new Class("C", I.with("String"), J, + new ConcreteMethod("int", stdMethodName, + "return I.super.m(s);", AccessFlag.PUBLIC, s)); + C.addCompilationDependency(I.findMethod(stdMethodName)); + + assertThrows(AbstractMethodError.class, C, + new ConcreteMethod( + "int", stdMethodName, "return -1;", AccessFlag.PUBLIC, s), + "-1", "\"string\""); + } + + /** + * interface I { default Integer m() { return new Integer(88); } } + * class C { Number m() { return new Integer(99); } } + * class D extends C implements I {} + * class S { Object foo() { return (new D()).m(); } // link sig: ()LInteger; + * TEST: S s = new S(); s.foo() == new Integer(99) + */ + public void testCovarBridge() { + Interface I = new Interface("I", new DefaultMethod( + "Integer", "m", "return new Integer(88);")); + Class C = new Class("C", new ConcreteMethod( + "Number", "m", "return new Integer(99);", AccessFlag.PUBLIC)); + Class D = new Class("D", I, C); + + ConcreteMethod DstubMethod = new ConcreteMethod( + "Integer", "m", "return null;", AccessFlag.PUBLIC); + Class Dstub = new Class("D", DstubMethod); + + ConcreteMethod toCall = new ConcreteMethod( + "Object", "foo", "return (new D()).m();", AccessFlag.PUBLIC); + Class S = new Class("S", D, toCall); + S.addCompilationDependency(Dstub); + S.addCompilationDependency(DstubMethod); + + assertInvokeVirtualEquals(new Integer(99), S, toCall, "null"); + } + + /** + * interface I { default Integer m() { return new Integer(88); } } + * class C { int m() { return 99; } } + * class D extends C implements I {} + * class S { Object foo() { return (new D()).m(); } // link sig: ()LInteger; + * TEST: S s = new S(); s.foo() == new Integer(88) + */ + public void testNoCovarNoBridge() { + Interface I = new Interface("I", new DefaultMethod( + "Integer", "m", "return new Integer(88);")); + Class C = new Class("C", new ConcreteMethod( + "int", "m", "return 99;", AccessFlag.PUBLIC)); + Class D = new Class("D", I, C); + + ConcreteMethod DstubMethod = new ConcreteMethod( + "Integer", "m", "return null;", AccessFlag.PUBLIC); + Class Dstub = new Class("D", DstubMethod); + + ConcreteMethod toCall = new ConcreteMethod( + "Object", "foo", "return (new D()).m();", AccessFlag.PUBLIC); + Class S = new Class("S", D, toCall); + S.addCompilationDependency(Dstub); + S.addCompilationDependency(DstubMethod); + + assertInvokeVirtualEquals(new Integer(88), S, toCall, "null"); + } + + /** + * interface J { int m(); } + * interface I extends J { default int m() { return 99; } } + * class B implements J {} + * class C extends B implements I {} + * TEST: C c = new C(); c.m() == 99 + * + * The point of this test is that B does not get default method analysis, + * and C does not generate any new miranda methods in the vtable. + * It verifies that default method analysis occurs when mirandas have been + * inherited and the supertypes don't have any overpass methods. + */ + public void testNoNewMiranda() { + Interface J = new Interface("J", AbstractMethod.std()); + Interface I = new Interface("I", J, DefaultMethod.std("99")); + Class B = new Class("B", J); + Class C = new Class("C", B, I); + assertInvokeVirtualEquals(99, C); + } + + /** + * interface I { int m(T t, V v, W w); } + * interface J implements I { int m(T t, V v, String w); } + * interface K implements J { + * int m(T t, String v, String w); { return 99; } } + * class C implements K { + * public int m(Object t, Object v, String w) { return 77; } + * } + * TEST C = new C(); ((I)c).m(Object,Object,Object) == 99 + * TEST C = new C(); ((J)c).m(Object,Object,String) == 77 + * TEST C = new C(); ((K)c).m(Object,String,String) == 99 + * + * Test that a erased-signature-matching method does not implement + * non-language-level matching methods + */ + public void testNonConcreteFill() { + AbstractMethod ipm = new AbstractMethod("int", "m", + new MethodParameter("T", "t"), + new MethodParameter("V", "s"), + new MethodParameter("W", "w")); + Interface I = new Interface("I", + new TypeParameter("T"), + new TypeParameter("V"), + new TypeParameter("W"), ipm); + + AbstractMethod jpm = new AbstractMethod("int", "m", + new MethodParameter("T", "t"), + new MethodParameter("V", "s"), + new MethodParameter("String", "w")); + Interface J = new Interface("J", + new TypeParameter("T"), + new TypeParameter("V"), + I.with("T", "V", "String"), jpm); + + AbstractMethod kpm = new AbstractMethod("int", "m", + new MethodParameter("T", "t"), + new MethodParameter("String", "s"), + new MethodParameter("String", "w")); + Interface K = new Interface("K", + new TypeParameter("T"), + J.with("T", "String"), + new DefaultMethod("int", "m", "return 99;", + new MethodParameter("T", "t"), + new MethodParameter("String", "v"), + new MethodParameter("String", "w"))); + + Class C = new Class("C", + K.with("String"), + new ConcreteMethod("int", "m", "return 77;", + AccessFlag.PUBLIC, + new MethodParameter("Object", "t"), + new MethodParameter("Object", "v"), + new MethodParameter("String", "w"))); + + String a = "\"\""; + assertInvokeInterfaceEquals(99, C, + K.with("String"), kpm, a, a, a); + assertInvokeInterfaceEquals(77, C, + J.with("String", "String"), jpm, a, a, a); + assertInvokeInterfaceEquals(99, C, + I.with("String", "String", "String"), ipm, a, a, a); + } + + public void testStrictfpDefault() { + try { + java.lang.Class.forName("org.openjdk.tests.vm.StrictfpDefault"); + } catch (Exception e) { + fail("Could not load class", e); + } + } + + public void testSynchronizedDefault() { + try { + java.lang.Class.forName("org.openjdk.tests.vm.SynchronizedDefault"); + } catch (Exception e) { + fail("Could not load class", e); + } + } +} + +interface StrictfpDefault { + default strictfp void m() {} +} + +interface SynchronizedDefault { + default synchronized void m() {} +} diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/FDSeparateCompilationTest.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/FDSeparateCompilationTest.java new file mode 100644 index 00000000000..c0c2dc79d22 --- /dev/null +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/FDSeparateCompilationTest.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2012 Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.tests.vm; + +import java.util.*; + +import org.testng.ITestResult; +import org.testng.annotations.Test; +import org.testng.annotations.DataProvider; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; + +import org.openjdk.tests.separate.*; +import org.openjdk.tests.separate.Compiler; + +import org.openjdk.tests.shapegen.Hierarchy; +import org.openjdk.tests.shapegen.HierarchyGenerator; +import org.openjdk.tests.shapegen.ClassCase; + +import static org.testng.Assert.*; +import static org.openjdk.tests.separate.SourceModel.*; +import static org.openjdk.tests.separate.SourceModel.Class; +import static org.openjdk.tests.separate.SourceModel.Method; +import static org.openjdk.tests.separate.SourceModel.Type; + +public class FDSeparateCompilationTest extends TestHarness { + + private static String EMPTY = "\"\""; + + public FDSeparateCompilationTest() { + super(false, true); + } + + @DataProvider(name = "allShapes", parallel = true) + public Object[][] hierarchyGenerator() { + ArrayList allCases = new ArrayList<>(); + + HierarchyGenerator hg = new HierarchyGenerator(); + for (Object x : hg.getOK()) { + allCases.add(new Object[]{x}); + } + for (Object x : hg.getErr()) { + allCases.add(new Object[]{x}); + } + return allCases.toArray(new Object[0][]); + } + + // The expected value obtained when invoking the method from the specified + // class. If returns null, then an AbstractMethodError is expected. + private static String getExpectedResult(ClassCase cc) { + Set provs = cc.get_mprov(); + if (cc.get_mres() != null) { + return cc.get_mres().getName(); + } else if (provs != null && provs.size() == 1) { + ClassCase cand = provs.iterator().next(); + switch (cand.kind) { + case CCONCRETE: + case IDEFAULT: + return cand.getName(); + case CNONE: + case IVAC: + return getExpectedResult(cand); + } + } + return null; + } + + private static final ConcreteMethod canonicalMethod = new ConcreteMethod( + "String", "m", "returns " + EMPTY + ";", AccessFlag.PUBLIC); + + @Test(groups = "vm", dataProvider = "allShapes") + public void separateCompilationTest(Hierarchy hs) { + ClassCase cc = hs.root; + Type type = sourceTypeFrom(hs.root); + + Class specimen = null; + if (type instanceof Class) { + Class ctype = (Class)type; + if (ctype.isAbstract()) { + specimen = new Class("Test" + ctype.getName(), ctype); + } else { + specimen = ctype; + } + } else { + specimen = new Class("Test" + type.getName(), (Interface)type); + } + + String value = getExpectedResult(cc); + if (value != null) { + assertInvokeVirtualEquals(value, specimen, canonicalMethod, EMPTY); + } else { + assertThrows(AbstractMethodError.class, specimen, + canonicalMethod, EMPTY); + } + } + + @AfterMethod + public void printCaseError(ITestResult result) { + if (result.getStatus() == ITestResult.FAILURE) { + Hierarchy hs = (Hierarchy)result.getParameters()[0]; + System.out.println("Separate compilation case " + hs); + printCaseDetails(hs); + } + } + + @AfterSuite + public void cleanupCompilerCache() { + Compiler.purgeCache(); + } + + private void printCaseDetails(Hierarchy hs) { + String exp = getExpectedResult(hs.root); + for (String s : hs.getDescription()) { + System.out.println(" " + s); + } + if (exp != null) { + System.out.println(" Expected \"" + exp + "\""); + } else { + System.out.println(" Expected AbstractMethodError"); + } + } + + private Type sourceTypeFrom(ClassCase cc) { + Type type = null; + + if (cc.isInterface()) { + Interface iface = new Interface(cc.getName()); + for (ClassCase scc : cc.getInterfaces()) { + Interface supertype = (Interface)sourceTypeFrom(scc); + iface.addSuperType(supertype); + } + type = iface; + } else { + Class cls = new Class(cc.getName()); + if (cc.hasSuperclass()) { + Class superc = (Class)sourceTypeFrom(cc.getSuperclass()); + cls.setSuperClass(superc); + } + for (ClassCase scc : cc.getInterfaces()) { + Interface supertype = (Interface)sourceTypeFrom(scc); + cls.addSuperType(supertype); + } + if (cc.isAbstract()) { + cls.getAccessFlags().add(AccessFlag.ABSTRACT); + } + type = cls; + } + Method method = methodFrom(cc); + if (method != null) { + type.addMethod(method); + } + return type; + } + + private Method methodFrom(ClassCase cc) { + switch (cc.kind) { + case IVAC: + case CNONE: return null; + case IPRESENT: + case CABSTRACT: + return new AbstractMethod("String", "m", AccessFlag.PUBLIC); + case IDEFAULT: + return new DefaultMethod( + "String", "m", "return \"" + cc.getName() + "\";"); + case CCONCRETE: + return new ConcreteMethod( + "String", "m", "return \"" + cc.getName() + "\";", + AccessFlag.PUBLIC); + default: + fail("Unknown method type in class"); + return null; + } + } +} From b197a6ca68898cbc3e9ddfbdeede195640aaf10c Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 28 Nov 2012 09:47:25 +0100 Subject: [PATCH 48/94] 8003960: build-infra: Jarsigner launcher has wrong classname Fixed package name in launcher Reviewed-by: alanb, ohair, ohrstrom --- jdk/makefiles/CompileLaunchers.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/makefiles/CompileLaunchers.gmk b/jdk/makefiles/CompileLaunchers.gmk index 586ecd473dc..102a2e7831f 100644 --- a/jdk/makefiles/CompileLaunchers.gmk +++ b/jdk/makefiles/CompileLaunchers.gmk @@ -238,7 +238,7 @@ $(eval $(call SetupLauncher,jar,\ -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jar.Main"$(COMMA) }')) $(eval $(call SetupLauncher,jarsigner,\ - -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.jarSigner.Main"$(COMMA) }')) + -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.jarsigner.Main"$(COMMA) }')) $(eval $(call SetupLauncher,javac,\ -DEXPAND_CLASSPATH_WILDCARDS \ From fb43b09f46d8747f4dbecc3e910f1934df5f9b71 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 28 Nov 2012 13:15:56 +0100 Subject: [PATCH 49/94] 8001460: build-infra: Linker warnings on macosx Only linking against jvm variant specific dirs if they are expected to exist. Reviewed-by: ohair --- common/autoconf/generated-configure.sh | 11186 +++++++++-------------- common/autoconf/toolchain.m4 | 11 +- 2 files changed, 4165 insertions(+), 7032 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index dced36f3f3a..47151032873 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -1,20 +1,24 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63 for OpenJDK jdk8. +# Generated by GNU Autoconf 2.67 for OpenJDK jdk8. # # Report bugs to . # +# # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. +# +# # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -22,23 +26,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; esac - fi - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - as_nl=' ' export as_nl @@ -46,7 +42,13 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -57,7 +59,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in + case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -80,13 +82,6 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -96,15 +91,15 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in +case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done IFS=$as_save_IFS ;; @@ -116,12 +111,16 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } + exit 1 fi -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' @@ -133,7 +132,249 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# Required to use basename. +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and +$0: build-dev@openjdk.java.net about your system, including +$0: any error possibly output before this message. Then +$0: install a modern shell, or manually run the script +$0: under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -147,8 +388,12 @@ else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -168,295 +413,19 @@ $as_echo X/"$0" | } s/.*/./; q'` -# CDPATH. -$as_unset CDPATH +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi - - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - case $as_dir in - /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell bug-autoconf@gnu.org about your system, - echo including any error possibly output before this message. - echo This can help us improve future autoconf versions. - echo Configuration will now proceed without shell functions. -} - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= @@ -473,8 +442,7 @@ test \$exitcode = 0") || { s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the @@ -484,29 +452,18 @@ test \$exitcode = 0") || { exit } - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in +case `echo -n x` in #((((( -n*) - case `echo 'x\c'` in + case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -536,7 +493,7 @@ rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false @@ -555,10 +512,10 @@ else if test -d "$1"; then test -d "$1/."; else - case $1 in + case $1 in #( -*)set "./$1";; esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' @@ -572,11 +529,11 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - -exec 7<&0 &1 +test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -591,7 +548,6 @@ cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='OpenJDK' @@ -599,6 +555,7 @@ PACKAGE_TARNAME='openjdk' PACKAGE_VERSION='jdk8' PACKAGE_STRING='OpenJDK jdk8' PACKAGE_BUGREPORT='build-dev@openjdk.java.net' +PACKAGE_URL='http://openjdk.java.net' # Factoring default headers for most tests. ac_includes_default="\ @@ -979,6 +936,7 @@ bindir program_transform_name prefix exec_prefix +PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION @@ -1035,7 +993,7 @@ with_alsa with_alsa_include with_alsa_lib with_zlib -with_stdc++lib +with_stdc__lib with_num_cores with_memory_size with_sjavac_server_java @@ -1128,8 +1086,9 @@ do fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -1174,8 +1133,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1201,8 +1159,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1406,8 +1363,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1423,8 +1379,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1454,17 +1409,17 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) { $as_echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1481,15 +1436,13 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { $as_echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 - { (exit 1); exit 1; }; } ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1512,8 +1465,7 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1527,8 +1479,8 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1543,11 +1495,9 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { $as_echo "$as_me: error: working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1586,13 +1536,11 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 - { (exit 1); exit 1; }; } + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1632,7 +1580,7 @@ Configuration: --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1816,7 +1764,7 @@ Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags @@ -1836,6 +1784,7 @@ Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . +OpenJDK home page: . _ACEOF ac_status=$? fi @@ -1899,21 +1848,698 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF OpenJDK configure jdk8 -generated by GNU Autoconf 2.63 +generated by GNU Autoconf 2.67 -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_compile + +# ac_fn_objc_try_compile LINENO +# ----------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_objc_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_objc_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_objc_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_cxx_try_cpp LINENO +# ------------------------ +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_cpp + +# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES +# --------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_cxx_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval "test \"\${$3+set}\"" = set; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ----------------------------------------- ## +## Report this to build-dev@openjdk.java.net ## +## ----------------------------------------- ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_cxx_check_header_mongrel + +# ac_fn_cxx_try_run LINENO +# ------------------------ +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_cxx_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_run + +# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES +# --------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_cxx_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_cxx_check_header_compile + +# ac_fn_cxx_compute_int LINENO EXPR VAR INCLUDES +# ---------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_cxx_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + echo >>conftest.val; read $3 &5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_link + +# ac_fn_cxx_check_func LINENO FUNC VAR +# ------------------------------------ +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_cxx_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_cxx_check_func + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_compile cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -1949,8 +2575,8 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" -done + $as_echo "PATH: $as_dir" + done IFS=$as_save_IFS } >&5 @@ -1987,9 +2613,9 @@ do ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" + as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else @@ -2005,13 +2631,13 @@ do -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args '$ac_arg'" + as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there @@ -2023,11 +2649,9 @@ trap 'exit_status=$? { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -2036,13 +2660,13 @@ _ASBOX case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; + *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done @@ -2061,11 +2685,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -2078,11 +2700,9 @@ _ASBOX echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -2096,11 +2716,9 @@ _ASBOX fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -2114,46 +2732,53 @@ _ASBOX exit $exit_status ' 0 for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h +$as_echo "/* confdefs.h */" > confdefs.h + # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -2164,19 +2789,23 @@ fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue - if test -r "$ac_site_file"; then - { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5 ; } fi done if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; @@ -2184,7 +2813,7 @@ $as_echo "$as_me: loading cache $cache_file" >&6;} esac fi else - { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -2199,11 +2828,11 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; @@ -2213,17 +2842,17 @@ $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else - { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi - { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac @@ -2235,43 +2864,20 @@ $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then - { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi - - - - - - - - - - - - - - - - - - - - - - - - +## -------------------- ## +## Main body of script. ## +## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -2298,9 +2904,7 @@ for ac_dir in build-aux "$srcdir"/build-aux; do fi done if test -z "$ac_aux_dir"; then - { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in build-aux \"$srcdir\"/build-aux" >&5 -$as_echo "$as_me: error: cannot find install-sh or install.sh in build-aux \"$srcdir\"/build-aux" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "cannot find install-sh, install.sh, or shtool in build-aux \"$srcdir\"/build-aux" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -2831,7 +3435,7 @@ pkgadd_help() { # to create them # Check whether --with-custom-make-dir was given. -if test "${with_custom_make_dir+set}" = set; then +if test "${with_custom_make_dir+set}" = set; then : withval=$with_custom_make_dir; CUSTOM_MAKE_DIR=$with_custom_make_dir fi @@ -3068,7 +3672,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1353361797 +DATE_WHEN_GENERATED=1354104798 ############################################################################### # @@ -3085,9 +3689,9 @@ DATE_WHEN_GENERATED=1353361797 DATE_WHEN_CONFIGURED=`LANG=C date` -{ $as_echo "$as_me:$LINENO: Configuration created at $DATE_WHEN_CONFIGURED." >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: Configuration created at $DATE_WHEN_CONFIGURED." >&5 $as_echo "$as_me: Configuration created at $DATE_WHEN_CONFIGURED." >&6;} -{ $as_echo "$as_me:$LINENO: configure script generated at timestamp $DATE_WHEN_GENERATED." >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: configure script generated at timestamp $DATE_WHEN_GENERATED." >&5 $as_echo "$as_me: configure script generated at timestamp $DATE_WHEN_GENERATED." >&6;} @@ -3104,9 +3708,9 @@ $as_echo "$as_me: configure script generated at timestamp $DATE_WHEN_GENERATED." do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BASENAME+set}" = set; then +if test "${ac_cv_path_BASENAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BASENAME in @@ -3119,14 +3723,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_BASENAME="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3134,10 +3738,10 @@ esac fi BASENAME=$ac_cv_path_BASENAME if test -n "$BASENAME"; then - { $as_echo "$as_me:$LINENO: result: $BASENAME" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BASENAME" >&5 $as_echo "$BASENAME" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3152,11 +3756,9 @@ done else PROG_NAME=basename fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3165,9 +3767,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BASH+set}" = set; then +if test "${ac_cv_path_BASH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BASH in @@ -3180,14 +3782,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_BASH="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3195,10 +3797,10 @@ esac fi BASH=$ac_cv_path_BASH if test -n "$BASH"; then - { $as_echo "$as_me:$LINENO: result: $BASH" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BASH" >&5 $as_echo "$BASH" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3213,11 +3815,9 @@ done else PROG_NAME=bash fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3226,9 +3826,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CAT+set}" = set; then +if test "${ac_cv_path_CAT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CAT in @@ -3241,14 +3841,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CAT="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3256,10 +3856,10 @@ esac fi CAT=$ac_cv_path_CAT if test -n "$CAT"; then - { $as_echo "$as_me:$LINENO: result: $CAT" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CAT" >&5 $as_echo "$CAT" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3274,11 +3874,9 @@ done else PROG_NAME=cat fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3287,9 +3885,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHMOD+set}" = set; then +if test "${ac_cv_path_CHMOD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHMOD in @@ -3302,14 +3900,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CHMOD="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3317,10 +3915,10 @@ esac fi CHMOD=$ac_cv_path_CHMOD if test -n "$CHMOD"; then - { $as_echo "$as_me:$LINENO: result: $CHMOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHMOD" >&5 $as_echo "$CHMOD" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3335,11 +3933,9 @@ done else PROG_NAME=chmod fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3348,9 +3944,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CMP+set}" = set; then +if test "${ac_cv_path_CMP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CMP in @@ -3363,14 +3959,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CMP="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3378,10 +3974,10 @@ esac fi CMP=$ac_cv_path_CMP if test -n "$CMP"; then - { $as_echo "$as_me:$LINENO: result: $CMP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CMP" >&5 $as_echo "$CMP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3396,11 +3992,9 @@ done else PROG_NAME=cmp fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3409,9 +4003,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CP+set}" = set; then +if test "${ac_cv_path_CP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CP in @@ -3424,14 +4018,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CP="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3439,10 +4033,10 @@ esac fi CP=$ac_cv_path_CP if test -n "$CP"; then - { $as_echo "$as_me:$LINENO: result: $CP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CP" >&5 $as_echo "$CP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3457,11 +4051,9 @@ done else PROG_NAME=cp fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3470,9 +4062,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CUT+set}" = set; then +if test "${ac_cv_path_CUT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CUT in @@ -3485,14 +4077,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CUT="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3500,10 +4092,10 @@ esac fi CUT=$ac_cv_path_CUT if test -n "$CUT"; then - { $as_echo "$as_me:$LINENO: result: $CUT" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUT" >&5 $as_echo "$CUT" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3518,11 +4110,9 @@ done else PROG_NAME=cut fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3531,9 +4121,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DATE+set}" = set; then +if test "${ac_cv_path_DATE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DATE in @@ -3546,14 +4136,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DATE="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3561,10 +4151,10 @@ esac fi DATE=$ac_cv_path_DATE if test -n "$DATE"; then - { $as_echo "$as_me:$LINENO: result: $DATE" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DATE" >&5 $as_echo "$DATE" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3579,11 +4169,9 @@ done else PROG_NAME=date fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3592,9 +4180,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DIFF+set}" = set; then +if test "${ac_cv_path_DIFF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DIFF in @@ -3607,14 +4195,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DIFF="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3622,10 +4210,10 @@ esac fi DIFF=$ac_cv_path_DIFF if test -n "$DIFF"; then - { $as_echo "$as_me:$LINENO: result: $DIFF" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DIFF" >&5 $as_echo "$DIFF" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3640,11 +4228,9 @@ done else PROG_NAME=gdiff diff fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3653,9 +4239,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DIRNAME+set}" = set; then +if test "${ac_cv_path_DIRNAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DIRNAME in @@ -3668,14 +4254,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DIRNAME="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3683,10 +4269,10 @@ esac fi DIRNAME=$ac_cv_path_DIRNAME if test -n "$DIRNAME"; then - { $as_echo "$as_me:$LINENO: result: $DIRNAME" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DIRNAME" >&5 $as_echo "$DIRNAME" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3701,11 +4287,9 @@ done else PROG_NAME=dirname fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3714,9 +4298,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ECHO+set}" = set; then +if test "${ac_cv_path_ECHO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ECHO in @@ -3729,14 +4313,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ECHO="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3744,10 +4328,10 @@ esac fi ECHO=$ac_cv_path_ECHO if test -n "$ECHO"; then - { $as_echo "$as_me:$LINENO: result: $ECHO" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ECHO" >&5 $as_echo "$ECHO" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3762,11 +4346,9 @@ done else PROG_NAME=echo fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3775,9 +4357,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_EXPR+set}" = set; then +if test "${ac_cv_path_EXPR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $EXPR in @@ -3790,14 +4372,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_EXPR="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3805,10 +4387,10 @@ esac fi EXPR=$ac_cv_path_EXPR if test -n "$EXPR"; then - { $as_echo "$as_me:$LINENO: result: $EXPR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $EXPR" >&5 $as_echo "$EXPR" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3823,11 +4405,9 @@ done else PROG_NAME=expr fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3836,9 +4416,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_FILE+set}" = set; then +if test "${ac_cv_path_FILE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $FILE in @@ -3851,14 +4431,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_FILE="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3866,10 +4446,10 @@ esac fi FILE=$ac_cv_path_FILE if test -n "$FILE"; then - { $as_echo "$as_me:$LINENO: result: $FILE" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FILE" >&5 $as_echo "$FILE" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3884,11 +4464,9 @@ done else PROG_NAME=file fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3897,9 +4475,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_FIND+set}" = set; then +if test "${ac_cv_path_FIND+set}" = set; then : $as_echo_n "(cached) " >&6 else case $FIND in @@ -3912,14 +4490,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_FIND="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3927,10 +4505,10 @@ esac fi FIND=$ac_cv_path_FIND if test -n "$FIND"; then - { $as_echo "$as_me:$LINENO: result: $FIND" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FIND" >&5 $as_echo "$FIND" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3945,11 +4523,9 @@ done else PROG_NAME=find fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -3958,9 +4534,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_HEAD+set}" = set; then +if test "${ac_cv_path_HEAD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $HEAD in @@ -3973,14 +4549,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_HEAD="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -3988,10 +4564,10 @@ esac fi HEAD=$ac_cv_path_HEAD if test -n "$HEAD"; then - { $as_echo "$as_me:$LINENO: result: $HEAD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HEAD" >&5 $as_echo "$HEAD" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4006,11 +4582,9 @@ done else PROG_NAME=head fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4019,9 +4593,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LN+set}" = set; then +if test "${ac_cv_path_LN+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LN in @@ -4034,14 +4608,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_LN="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4049,10 +4623,10 @@ esac fi LN=$ac_cv_path_LN if test -n "$LN"; then - { $as_echo "$as_me:$LINENO: result: $LN" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LN" >&5 $as_echo "$LN" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4067,11 +4641,9 @@ done else PROG_NAME=ln fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4080,9 +4652,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LS+set}" = set; then +if test "${ac_cv_path_LS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LS in @@ -4095,14 +4667,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_LS="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4110,10 +4682,10 @@ esac fi LS=$ac_cv_path_LS if test -n "$LS"; then - { $as_echo "$as_me:$LINENO: result: $LS" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LS" >&5 $as_echo "$LS" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4128,11 +4700,9 @@ done else PROG_NAME=ls fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4141,9 +4711,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MKDIR+set}" = set; then +if test "${ac_cv_path_MKDIR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MKDIR in @@ -4156,14 +4726,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MKDIR="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4171,10 +4741,10 @@ esac fi MKDIR=$ac_cv_path_MKDIR if test -n "$MKDIR"; then - { $as_echo "$as_me:$LINENO: result: $MKDIR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR" >&5 $as_echo "$MKDIR" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4189,11 +4759,9 @@ done else PROG_NAME=mkdir fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4202,9 +4770,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MKTEMP+set}" = set; then +if test "${ac_cv_path_MKTEMP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MKTEMP in @@ -4217,14 +4785,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MKTEMP="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4232,10 +4800,10 @@ esac fi MKTEMP=$ac_cv_path_MKTEMP if test -n "$MKTEMP"; then - { $as_echo "$as_me:$LINENO: result: $MKTEMP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKTEMP" >&5 $as_echo "$MKTEMP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4250,11 +4818,9 @@ done else PROG_NAME=mktemp fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4263,9 +4829,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MV+set}" = set; then +if test "${ac_cv_path_MV+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MV in @@ -4278,14 +4844,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MV="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4293,10 +4859,10 @@ esac fi MV=$ac_cv_path_MV if test -n "$MV"; then - { $as_echo "$as_me:$LINENO: result: $MV" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MV" >&5 $as_echo "$MV" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4311,11 +4877,9 @@ done else PROG_NAME=mv fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4324,9 +4888,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PRINTF+set}" = set; then +if test "${ac_cv_path_PRINTF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PRINTF in @@ -4339,14 +4903,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PRINTF="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4354,10 +4918,10 @@ esac fi PRINTF=$ac_cv_path_PRINTF if test -n "$PRINTF"; then - { $as_echo "$as_me:$LINENO: result: $PRINTF" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PRINTF" >&5 $as_echo "$PRINTF" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4372,11 +4936,9 @@ done else PROG_NAME=printf fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4385,9 +4947,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_THEPWDCMD+set}" = set; then +if test "${ac_cv_path_THEPWDCMD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $THEPWDCMD in @@ -4400,14 +4962,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_THEPWDCMD="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4415,10 +4977,10 @@ esac fi THEPWDCMD=$ac_cv_path_THEPWDCMD if test -n "$THEPWDCMD"; then - { $as_echo "$as_me:$LINENO: result: $THEPWDCMD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THEPWDCMD" >&5 $as_echo "$THEPWDCMD" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4433,11 +4995,9 @@ done else PROG_NAME=pwd fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4446,9 +5006,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_RM+set}" = set; then +if test "${ac_cv_path_RM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $RM in @@ -4461,14 +5021,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_RM="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4476,10 +5036,10 @@ esac fi RM=$ac_cv_path_RM if test -n "$RM"; then - { $as_echo "$as_me:$LINENO: result: $RM" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RM" >&5 $as_echo "$RM" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4494,11 +5054,9 @@ done else PROG_NAME=rm fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4507,9 +5065,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_SH+set}" = set; then +if test "${ac_cv_path_SH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SH in @@ -4522,14 +5080,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_SH="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4537,10 +5095,10 @@ esac fi SH=$ac_cv_path_SH if test -n "$SH"; then - { $as_echo "$as_me:$LINENO: result: $SH" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SH" >&5 $as_echo "$SH" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4555,11 +5113,9 @@ done else PROG_NAME=sh fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4568,9 +5124,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_SORT+set}" = set; then +if test "${ac_cv_path_SORT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SORT in @@ -4583,14 +5139,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_SORT="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4598,10 +5154,10 @@ esac fi SORT=$ac_cv_path_SORT if test -n "$SORT"; then - { $as_echo "$as_me:$LINENO: result: $SORT" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SORT" >&5 $as_echo "$SORT" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4616,11 +5172,9 @@ done else PROG_NAME=sort fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4629,9 +5183,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TAIL+set}" = set; then +if test "${ac_cv_path_TAIL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TAIL in @@ -4644,14 +5198,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_TAIL="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4659,10 +5213,10 @@ esac fi TAIL=$ac_cv_path_TAIL if test -n "$TAIL"; then - { $as_echo "$as_me:$LINENO: result: $TAIL" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAIL" >&5 $as_echo "$TAIL" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4677,11 +5231,9 @@ done else PROG_NAME=tail fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4690,9 +5242,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TAR+set}" = set; then +if test "${ac_cv_path_TAR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TAR in @@ -4705,14 +5257,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_TAR="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4720,10 +5272,10 @@ esac fi TAR=$ac_cv_path_TAR if test -n "$TAR"; then - { $as_echo "$as_me:$LINENO: result: $TAR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR" >&5 $as_echo "$TAR" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4738,11 +5290,9 @@ done else PROG_NAME=tar fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4751,9 +5301,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TEE+set}" = set; then +if test "${ac_cv_path_TEE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TEE in @@ -4766,14 +5316,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_TEE="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4781,10 +5331,10 @@ esac fi TEE=$ac_cv_path_TEE if test -n "$TEE"; then - { $as_echo "$as_me:$LINENO: result: $TEE" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TEE" >&5 $as_echo "$TEE" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4799,11 +5349,9 @@ done else PROG_NAME=tee fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4812,9 +5360,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TOUCH+set}" = set; then +if test "${ac_cv_path_TOUCH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOUCH in @@ -4827,14 +5375,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_TOUCH="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4842,10 +5390,10 @@ esac fi TOUCH=$ac_cv_path_TOUCH if test -n "$TOUCH"; then - { $as_echo "$as_me:$LINENO: result: $TOUCH" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TOUCH" >&5 $as_echo "$TOUCH" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4860,11 +5408,9 @@ done else PROG_NAME=touch fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4873,9 +5419,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TR+set}" = set; then +if test "${ac_cv_path_TR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TR in @@ -4888,14 +5434,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_TR="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4903,10 +5449,10 @@ esac fi TR=$ac_cv_path_TR if test -n "$TR"; then - { $as_echo "$as_me:$LINENO: result: $TR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TR" >&5 $as_echo "$TR" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4921,11 +5467,9 @@ done else PROG_NAME=tr fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4934,9 +5478,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_UNAME+set}" = set; then +if test "${ac_cv_path_UNAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNAME in @@ -4949,14 +5493,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_UNAME="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4964,10 +5508,10 @@ esac fi UNAME=$ac_cv_path_UNAME if test -n "$UNAME"; then - { $as_echo "$as_me:$LINENO: result: $UNAME" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNAME" >&5 $as_echo "$UNAME" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4982,11 +5526,9 @@ done else PROG_NAME=uname fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -4995,9 +5537,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_UNIQ+set}" = set; then +if test "${ac_cv_path_UNIQ+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNIQ in @@ -5010,14 +5552,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_UNIQ="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -5025,10 +5567,10 @@ esac fi UNIQ=$ac_cv_path_UNIQ if test -n "$UNIQ"; then - { $as_echo "$as_me:$LINENO: result: $UNIQ" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNIQ" >&5 $as_echo "$UNIQ" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -5043,11 +5585,9 @@ done else PROG_NAME=uniq fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -5056,9 +5596,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_WC+set}" = set; then +if test "${ac_cv_path_WC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $WC in @@ -5071,14 +5611,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_WC="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -5086,10 +5626,10 @@ esac fi WC=$ac_cv_path_WC if test -n "$WC"; then - { $as_echo "$as_me:$LINENO: result: $WC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WC" >&5 $as_echo "$WC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -5104,11 +5644,9 @@ done else PROG_NAME=wc fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -5117,9 +5655,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_WHICH+set}" = set; then +if test "${ac_cv_path_WHICH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $WHICH in @@ -5132,14 +5670,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_WHICH="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -5147,10 +5685,10 @@ esac fi WHICH=$ac_cv_path_WHICH if test -n "$WHICH"; then - { $as_echo "$as_me:$LINENO: result: $WHICH" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WHICH" >&5 $as_echo "$WHICH" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -5165,11 +5703,9 @@ done else PROG_NAME=which fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -5178,9 +5714,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_XARGS+set}" = set; then +if test "${ac_cv_path_XARGS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $XARGS in @@ -5193,14 +5729,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_XARGS="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -5208,10 +5744,10 @@ esac fi XARGS=$ac_cv_path_XARGS if test -n "$XARGS"; then - { $as_echo "$as_me:$LINENO: result: $XARGS" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XARGS" >&5 $as_echo "$XARGS" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -5226,11 +5762,9 @@ done else PROG_NAME=xargs fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -5240,9 +5774,9 @@ for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then +if test "${ac_cv_prog_AWK+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -5253,24 +5787,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - { $as_echo "$as_me:$LINENO: result: $AWK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -5285,16 +5819,14 @@ done else PROG_NAME= fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi -{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -5305,7 +5837,7 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do + for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue @@ -5325,7 +5857,7 @@ case `"$ac_path_GREP" --version 2>&1` in $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" @@ -5340,19 +5872,17 @@ esac $ac_path_GREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" @@ -5364,16 +5894,14 @@ $as_echo "$ac_cv_path_GREP" >&6; } else PROG_NAME= fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi -{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then +if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -5387,7 +5915,7 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do + for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue @@ -5407,7 +5935,7 @@ case `"$ac_path_EGREP" --version 2>&1` in $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" @@ -5422,12 +5950,10 @@ esac $ac_path_EGREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -5435,7 +5961,7 @@ fi fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" @@ -5447,16 +5973,14 @@ $as_echo "$ac_cv_path_EGREP" >&6; } else PROG_NAME= fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi -{ $as_echo "$as_me:$LINENO: checking for fgrep" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } -if test "${ac_cv_path_FGREP+set}" = set; then +if test "${ac_cv_path_FGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 @@ -5470,7 +5994,7 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in fgrep; do + for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue @@ -5490,7 +6014,7 @@ case `"$ac_path_FGREP" --version 2>&1` in $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" @@ -5505,12 +6029,10 @@ esac $ac_path_FGREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP @@ -5518,7 +6040,7 @@ fi fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_FGREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" @@ -5530,16 +6052,14 @@ $as_echo "$ac_cv_path_FGREP" >&6; } else PROG_NAME= fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi -{ $as_echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } -if test "${ac_cv_path_SED+set}" = set; then +if test "${ac_cv_path_SED+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ @@ -5547,7 +6067,7 @@ else ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - $as_unset ac_script || ac_script= + { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST @@ -5556,7 +6076,7 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do + for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue @@ -5576,7 +6096,7 @@ case `"$ac_path_SED" --version 2>&1` in $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" @@ -5591,19 +6111,17 @@ esac $ac_path_SED_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable sed could be found in \$PATH" >&5 -$as_echo "$as_me: error: no acceptable sed could be found in \$PATH" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_SED" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed @@ -5615,11 +6133,9 @@ $as_echo "$ac_cv_path_SED" >&6; } else PROG_NAME= fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -5627,9 +6143,9 @@ for ac_prog in nawk gawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_NAWK+set}" = set; then +if test "${ac_cv_path_NAWK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $NAWK in @@ -5642,14 +6158,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_NAWK="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -5657,10 +6173,10 @@ esac fi NAWK=$ac_cv_path_NAWK if test -n "$NAWK"; then - { $as_echo "$as_me:$LINENO: result: $NAWK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NAWK" >&5 $as_echo "$NAWK" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -5675,11 +6191,9 @@ done else PROG_NAME= fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -5689,9 +6203,9 @@ RM="$RM -f" # These are not required on all platforms # Extract the first word of "cygpath", so it can be a program name with args. set dummy cygpath; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CYGPATH+set}" = set; then +if test "${ac_cv_path_CYGPATH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CYGPATH in @@ -5704,14 +6218,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CYGPATH="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -5719,19 +6233,19 @@ esac fi CYGPATH=$ac_cv_path_CYGPATH if test -n "$CYGPATH"; then - { $as_echo "$as_me:$LINENO: result: $CYGPATH" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGPATH" >&5 $as_echo "$CYGPATH" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "readlink", so it can be a program name with args. set dummy readlink; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_READLINK+set}" = set; then +if test "${ac_cv_path_READLINK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $READLINK in @@ -5744,14 +6258,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_READLINK="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -5759,19 +6273,19 @@ esac fi READLINK=$ac_cv_path_READLINK if test -n "$READLINK"; then - { $as_echo "$as_me:$LINENO: result: $READLINK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READLINK" >&5 $as_echo "$READLINK" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "df", so it can be a program name with args. set dummy df; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DF+set}" = set; then +if test "${ac_cv_path_DF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DF in @@ -5784,14 +6298,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DF="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -5799,19 +6313,19 @@ esac fi DF=$ac_cv_path_DF if test -n "$DF"; then - { $as_echo "$as_me:$LINENO: result: $DF" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DF" >&5 $as_echo "$DF" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "SetFile", so it can be a program name with args. set dummy SetFile; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_SETFILE+set}" = set; then +if test "${ac_cv_path_SETFILE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SETFILE in @@ -5824,14 +6338,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_SETFILE="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -5839,10 +6353,10 @@ esac fi SETFILE=$ac_cv_path_SETFILE if test -n "$SETFILE"; then - { $as_echo "$as_me:$LINENO: result: $SETFILE" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SETFILE" >&5 $as_echo "$SETFILE" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -5851,43 +6365,29 @@ fi # Now we can determine OpenJDK build and target platforms. This is required to # have early on. - -# Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target" -# is confusing; it assumes you are cross-compiling a cross-compiler (!) and "target" is thus the target of the -# product you're building. The target of this build is called "host". Since this is confusing to most people, we -# have not adopted that system, but use "target" as the platform we are building for. In some places though we need -# to use the configure naming style. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 -$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 -{ $as_echo "$as_me:$LINENO: checking build system type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then +if test "${ac_cv_build+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && - { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 -$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 -$as_echo "$as_me: error: invalid value of canonical build" >&2;} - { (exit 1); exit 1; }; };; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -5903,28 +6403,24 @@ IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac -{ $as_echo "$as_me:$LINENO: checking host system type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then +if test "${ac_cv_host+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 -$as_echo "$as_me: error: invalid value of canonical host" >&2;} - { (exit 1); exit 1; }; };; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -5940,28 +6436,24 @@ IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac -{ $as_echo "$as_me:$LINENO: checking target system type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } -if test "${ac_cv_target+set}" = set; then +if test "${ac_cv_target+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 -$as_echo "$as_me: error: invalid value of canonical target" >&2;} - { (exit 1); exit 1; }; };; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' @@ -5984,6 +6476,15 @@ test -n "$target_alias" && NONENONEs,x,x, && program_prefix=${target_alias}- +# Figure out the build and target systems. # Note that in autoconf terminology, "build" is obvious, but "target" +# is confusing; it assumes you are cross-compiling a cross-compiler (!) and "target" is thus the target of the +# product you're building. The target of this build is called "host". Since this is confusing to most people, we +# have not adopted that system, but use "target" as the platform we are building for. In some places though we need +# to use the configure naming style. + + + + # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME @@ -6028,9 +6529,7 @@ test -n "$target_alias" && VAR_OS_ENV=windows.msys ;; *) - { { $as_echo "$as_me:$LINENO: error: unsupported operating system $build_os" >&5 -$as_echo "$as_me: error: unsupported operating system $build_os" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "unsupported operating system $build_os" "$LINENO" 5 ;; esac @@ -6080,9 +6579,7 @@ $as_echo "$as_me: error: unsupported operating system $build_os" >&2;} VAR_CPU_ENDIAN=big ;; *) - { { $as_echo "$as_me:$LINENO: error: unsupported cpu $build_cpu" >&5 -$as_echo "$as_me: error: unsupported cpu $build_cpu" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "unsupported cpu $build_cpu" "$LINENO" 5 ;; esac @@ -6101,9 +6598,9 @@ $as_echo "$as_me: error: unsupported cpu $build_cpu" >&2;} - { $as_echo "$as_me:$LINENO: checking openjdk-build os-cpu" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking openjdk-build os-cpu" >&5 $as_echo_n "checking openjdk-build os-cpu... " >&6; } - { $as_echo "$as_me:$LINENO: result: $OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&5 $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; } # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables. @@ -6140,9 +6637,7 @@ $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; } VAR_OS_ENV=windows.msys ;; *) - { { $as_echo "$as_me:$LINENO: error: unsupported operating system $host_os" >&5 -$as_echo "$as_me: error: unsupported operating system $host_os" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "unsupported operating system $host_os" "$LINENO" 5 ;; esac @@ -6192,9 +6687,7 @@ $as_echo "$as_me: error: unsupported operating system $host_os" >&2;} VAR_CPU_ENDIAN=big ;; *) - { { $as_echo "$as_me:$LINENO: error: unsupported cpu $host_cpu" >&5 -$as_echo "$as_me: error: unsupported cpu $host_cpu" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "unsupported cpu $host_cpu" "$LINENO" 5 ;; esac @@ -6213,15 +6706,15 @@ $as_echo "$as_me: error: unsupported cpu $host_cpu" >&2;} - { $as_echo "$as_me:$LINENO: checking openjdk-target os-cpu" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking openjdk-target os-cpu" >&5 $as_echo_n "checking openjdk-target os-cpu... " >&6; } - { $as_echo "$as_me:$LINENO: result: $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" >&5 $as_echo "$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" >&6; } # Check whether --with-target-bits was given. -if test "${with_target_bits+set}" = set; then +if test "${with_target_bits+set}" = set; then : withval=$with_target_bits; fi @@ -6240,9 +6733,7 @@ fi if test "x$with_target_bits" != x; then if test "x$COMPILE_TYPE" = "xcross"; then - { { $as_echo "$as_me:$LINENO: error: It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either." >&5 -$as_echo "$as_me: error: It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either." "$LINENO" 5 fi if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then @@ -6254,28 +6745,22 @@ $as_echo "$as_me: error: It is not possible to combine --with-target-bits=X and elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then OPENJDK_TARGET_CPU=sparc else - { { $as_echo "$as_me:$LINENO: error: Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9" >&5 -$as_echo "$as_me: error: Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9" "$LINENO" 5 fi elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - { { $as_echo "$as_me:$LINENO: error: It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead." >&5 -$as_echo "$as_me: error: It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead." "$LINENO" 5 elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then - { $as_echo "$as_me:$LINENO: --with-target-bits are set to build platform address size; argument has no meaning" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: --with-target-bits are set to build platform address size; argument has no meaning" >&5 $as_echo "$as_me: --with-target-bits are set to build platform address size; argument has no meaning" >&6;} else - { { $as_echo "$as_me:$LINENO: error: --with-target-bits can only be 32 or 64, you specified $with_target_bits!" >&5 -$as_echo "$as_me: error: --with-target-bits can only be 32 or 64, you specified $with_target_bits!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "--with-target-bits can only be 32 or 64, you specified $with_target_bits!" "$LINENO" 5 fi fi -{ $as_echo "$as_me:$LINENO: checking compilation type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking compilation type" >&5 $as_echo_n "checking compilation type... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $COMPILE_TYPE" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $COMPILE_TYPE" >&5 $as_echo "$COMPILE_TYPE" >&6; } @@ -6466,59 +6951,51 @@ if test "x$OPENJDK_TARGET_OS" = "xwindows"; then SRC_ROOT_LENGTH=`$THEPWDCMD|$WC -m` if test $SRC_ROOT_LENGTH -gt 100; then - { { $as_echo "$as_me:$LINENO: error: Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported" >&5 -$as_echo "$as_me: error: Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported" "$LINENO" 5 fi if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - { $as_echo "$as_me:$LINENO: checking cygwin release" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking cygwin release" >&5 $as_echo_n "checking cygwin release... " >&6; } CYGWIN_VERSION=`$UNAME -r` - { $as_echo "$as_me:$LINENO: result: $CYGWIN_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGWIN_VERSION" >&5 $as_echo "$CYGWIN_VERSION" >&6; } WINDOWS_ENV_VENDOR='cygwin' WINDOWS_ENV_VERSION="$CYGWIN_VERSION" CYGWIN_VERSION_OK=`$ECHO $CYGWIN_VERSION | $GREP ^1.7.` if test "x$CYGWIN_VERSION_OK" = x; then - { $as_echo "$as_me:$LINENO: Your cygwin is too old. You are running $CYGWIN_VERSION, but at least cygwin 1.7 is required. Please upgrade." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your cygwin is too old. You are running $CYGWIN_VERSION, but at least cygwin 1.7 is required. Please upgrade." >&5 $as_echo "$as_me: Your cygwin is too old. You are running $CYGWIN_VERSION, but at least cygwin 1.7 is required. Please upgrade." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi if test "x$CYGPATH" = x; then - { { $as_echo "$as_me:$LINENO: error: Something is wrong with your cygwin installation since I cannot find cygpath.exe in your path" >&5 -$as_echo "$as_me: error: Something is wrong with your cygwin installation since I cannot find cygpath.exe in your path" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Something is wrong with your cygwin installation since I cannot find cygpath.exe in your path" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: checking cygwin root directory as unix-style path" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking cygwin root directory as unix-style path" >&5 $as_echo_n "checking cygwin root directory as unix-style path... " >&6; } # The cmd output ends with Windows line endings (CR/LF), the grep command will strip that away cygwin_winpath_root=`cd / ; cmd /c cd | grep ".*"` # Force cygpath to report the proper root by including a trailing space, and then stripping it off again. CYGWIN_ROOT_PATH=`$CYGPATH -u "$cygwin_winpath_root " | $CUT -f 1 -d " "` - { $as_echo "$as_me:$LINENO: result: $CYGWIN_ROOT_PATH" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGWIN_ROOT_PATH" >&5 $as_echo "$CYGWIN_ROOT_PATH" >&6; } WINDOWS_ENV_ROOT_PATH="$CYGWIN_ROOT_PATH" test_cygdrive_prefix=`$ECHO $CYGWIN_ROOT_PATH | $GREP ^/cygdrive/` if test "x$test_cygdrive_prefix" = x; then - { { $as_echo "$as_me:$LINENO: error: Your cygdrive prefix is not /cygdrive. This is currently not supported. Change with mount -c." >&5 -$as_echo "$as_me: error: Your cygdrive prefix is not /cygdrive. This is currently not supported. Change with mount -c." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your cygdrive prefix is not /cygdrive. This is currently not supported. Change with mount -c." "$LINENO" 5 fi elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - { $as_echo "$as_me:$LINENO: checking msys release" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking msys release" >&5 $as_echo_n "checking msys release... " >&6; } MSYS_VERSION=`$UNAME -r` - { $as_echo "$as_me:$LINENO: result: $MSYS_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSYS_VERSION" >&5 $as_echo "$MSYS_VERSION" >&6; } WINDOWS_ENV_VENDOR='msys' WINDOWS_ENV_VERSION="$MSYS_VERSION" - { $as_echo "$as_me:$LINENO: checking msys root directory as unix-style path" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking msys root directory as unix-style path" >&5 $as_echo_n "checking msys root directory as unix-style path... " >&6; } # The cmd output ends with Windows line endings (CR/LF), the grep command will strip that away MSYS_ROOT_PATH=`cd / ; cmd /c cd | grep ".*"` @@ -6532,36 +7009,32 @@ $as_echo_n "checking msys root directory as unix-style path... " >&6; } MSYS_ROOT_PATH="$unix_path" fi - { $as_echo "$as_me:$LINENO: result: $MSYS_ROOT_PATH" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSYS_ROOT_PATH" >&5 $as_echo "$MSYS_ROOT_PATH" >&6; } WINDOWS_ENV_ROOT_PATH="$MSYS_ROOT_PATH" else - { { $as_echo "$as_me:$LINENO: error: Unknown Windows environment. Neither cygwin nor msys was detected." >&5 -$as_echo "$as_me: error: Unknown Windows environment. Neither cygwin nor msys was detected." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Unknown Windows environment. Neither cygwin nor msys was detected." "$LINENO" 5 fi # Test if windows or unix (cygwin/msys) find is first in path. - { $as_echo "$as_me:$LINENO: checking what kind of 'find' is first on the PATH" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking what kind of 'find' is first on the PATH" >&5 $as_echo_n "checking what kind of 'find' is first on the PATH... " >&6; } FIND_BINARY_OUTPUT=`find --version 2>&1` if test "x`echo $FIND_BINARY_OUTPUT | $GREP GNU`" != x; then - { $as_echo "$as_me:$LINENO: result: unix style" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unix style" >&5 $as_echo "unix style" >&6; } elif test "x`echo $FIND_BINARY_OUTPUT | $GREP FIND`" != x; then - { $as_echo "$as_me:$LINENO: result: Windows" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Windows" >&5 $as_echo "Windows" >&6; } - { $as_echo "$as_me:$LINENO: Your path contains Windows tools (C:\Windows\system32) before your unix (cygwin or msys) tools." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your path contains Windows tools (C:\Windows\system32) before your unix (cygwin or msys) tools." >&5 $as_echo "$as_me: Your path contains Windows tools (C:\Windows\system32) before your unix (cygwin or msys) tools." >&6;} - { $as_echo "$as_me:$LINENO: This will not work. Please correct and make sure /usr/bin (or similar) is first in path." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This will not work. Please correct and make sure /usr/bin (or similar) is first in path." >&5 $as_echo "$as_me: This will not work. Please correct and make sure /usr/bin (or similar) is first in path." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 else - { $as_echo "$as_me:$LINENO: result: unknown" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown" >&5 $as_echo "unknown" >&6; } - { $as_echo "$as_me:$LINENO: WARNING: It seems that your find utility is non-standard." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: It seems that your find utility is non-standard." >&5 $as_echo "$as_me: WARNING: It seems that your find utility is non-standard." >&2;} fi @@ -6590,11 +7063,9 @@ cd "$CURDIR" # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of SRC_ROOT, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of SRC_ROOT, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of SRC_ROOT, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of SRC_ROOT" >&5 -$as_echo "$as_me: error: Cannot locate the the path of SRC_ROOT" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of SRC_ROOT" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -6633,7 +7104,7 @@ $as_echo "$as_me: error: Cannot locate the the path of SRC_ROOT" >&2;} if test "x$path" != "x$new_path"; then SRC_ROOT="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting SRC_ROOT to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting SRC_ROOT to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting SRC_ROOT to \"$new_path\"" >&6;} fi @@ -6671,7 +7142,7 @@ $as_echo "$as_me: Rewriting SRC_ROOT to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then SRC_ROOT="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting SRC_ROOT to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting SRC_ROOT to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting SRC_ROOT to \"$new_path\"" >&6;} fi @@ -6683,18 +7154,14 @@ $as_echo "$as_me: Rewriting SRC_ROOT to \"$new_path\"" >&6;} path="$SRC_ROOT" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of SRC_ROOT, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of SRC_ROOT, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of SRC_ROOT, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of SRC_ROOT, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of SRC_ROOT, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of SRC_ROOT, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi @@ -6715,11 +7182,9 @@ $as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of CURDIR, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CURDIR, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of CURDIR, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CURDIR" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CURDIR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CURDIR" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -6758,7 +7223,7 @@ $as_echo "$as_me: error: Cannot locate the the path of CURDIR" >&2;} if test "x$path" != "x$new_path"; then CURDIR="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting CURDIR to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting CURDIR to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting CURDIR to \"$new_path\"" >&6;} fi @@ -6796,7 +7261,7 @@ $as_echo "$as_me: Rewriting CURDIR to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then CURDIR="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting CURDIR to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting CURDIR to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting CURDIR to \"$new_path\"" >&6;} fi @@ -6808,18 +7273,14 @@ $as_echo "$as_me: Rewriting CURDIR to \"$new_path\"" >&6;} path="$CURDIR" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of CURDIR, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of CURDIR, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of CURDIR, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of CURDIR, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CURDIR, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of CURDIR, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi @@ -6833,7 +7294,7 @@ fi # is not correct. # Check whether --with-sys-root was given. -if test "${with_sys_root+set}" = set; then +if test "${with_sys_root+set}" = set; then : withval=$with_sys_root; fi @@ -6847,24 +7308,20 @@ fi # Check whether --with-tools-dir was given. -if test "${with_tools_dir+set}" = set; then +if test "${with_tools_dir+set}" = set; then : withval=$with_tools_dir; TOOLS_DIR=$with_tools_dir fi # Check whether --with-devkit was given. -if test "${with_devkit+set}" = set; then +if test "${with_devkit+set}" = set; then : withval=$with_devkit; if test "x$with_sys_root" != x; then - { { $as_echo "$as_me:$LINENO: error: Cannot specify both --with-devkit and --with-sys-root at the same time" >&5 -$as_echo "$as_me: error: Cannot specify both --with-devkit and --with-sys-root at the same time" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot specify both --with-devkit and --with-sys-root at the same time" "$LINENO" 5 fi if test "x$with_tools_dir" != x; then - { { $as_echo "$as_me:$LINENO: error: Cannot specify both --with-devkit and --with-tools-dir at the same time" >&5 -$as_echo "$as_me: error: Cannot specify both --with-devkit and --with-tools-dir at the same time" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot specify both --with-devkit and --with-tools-dir at the same time" "$LINENO" 5 fi TOOLS_DIR=$with_devkit/bin SYS_ROOT=$with_devkit/$host_alias/libc @@ -6896,11 +7353,11 @@ BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)' # modules to compile into the JDK. In the future, these modules # might even be Jigsaw modules. # -{ $as_echo "$as_me:$LINENO: checking which variant of the JDK to build" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of the JDK to build" >&5 $as_echo_n "checking which variant of the JDK to build... " >&6; } # Check whether --with-jdk-variant was given. -if test "${with_jdk_variant+set}" = set; then +if test "${with_jdk_variant+set}" = set; then : withval=$with_jdk_variant; fi @@ -6908,14 +7365,12 @@ fi if test "x$with_jdk_variant" = xnormal || test "x$with_jdk_variant" = x; then JDK_VARIANT="normal" else - { { $as_echo "$as_me:$LINENO: error: The available JDK variants are: normal" >&5 -$as_echo "$as_me: error: The available JDK variants are: normal" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The available JDK variants are: normal" "$LINENO" 5 fi -{ $as_echo "$as_me:$LINENO: result: $JDK_VARIANT" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $JDK_VARIANT" >&5 $as_echo "$JDK_VARIANT" >&6; } @@ -6930,11 +7385,11 @@ $as_echo "$JDK_VARIANT" >&6; } # ie normal interpreter and C1, only the serial GC, kernel jvmti etc # zero: no machine code interpreter, no compiler # zeroshark: zero interpreter and shark/llvm compiler backend -{ $as_echo "$as_me:$LINENO: checking which variants of the JVM to build" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which variants of the JVM to build" >&5 $as_echo_n "checking which variants of the JVM to build... " >&6; } # Check whether --with-jvm-variants was given. -if test "${with_jvm_variants+set}" = set; then +if test "${with_jvm_variants+set}" = set; then : withval=$with_jvm_variants; fi @@ -6947,11 +7402,9 @@ JVM_VARIANTS=",$with_jvm_variants," TEST_VARIANTS=`$ECHO "$JVM_VARIANTS" | $SED -e 's/server,//' -e 's/client,//' -e 's/kernel,//' -e 's/zero,//' -e 's/zeroshark,//'` if test "x$TEST_VARIANTS" != "x,"; then - { { $as_echo "$as_me:$LINENO: error: The available JVM variants are: server, client, kernel, zero, zeroshark" >&5 -$as_echo "$as_me: error: The available JVM variants are: server, client, kernel, zero, zeroshark" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The available JVM variants are: server, client, kernel, zero, zeroshark" "$LINENO" 5 fi -{ $as_echo "$as_me:$LINENO: result: $with_jvm_variants" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_jvm_variants" >&5 $as_echo "$with_jvm_variants" >&6; } JVM_VARIANT_SERVER=`$ECHO "$JVM_VARIANTS" | $SED -e '/,server,/!s/.*/false/g' -e '/,server,/s/.*/true/g'` @@ -6962,16 +7415,12 @@ JVM_VARIANT_ZEROSHARK=`$ECHO "$JVM_VARIANTS" | $SED -e '/,zeroshark,/!s/.*/false if test "x$JVM_VARIANT_CLIENT" = xtrue; then if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - { { $as_echo "$as_me:$LINENO: error: You cannot build a client JVM for a 64-bit machine." >&5 -$as_echo "$as_me: error: You cannot build a client JVM for a 64-bit machine." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You cannot build a client JVM for a 64-bit machine." "$LINENO" 5 fi fi if test "x$JVM_VARIANT_KERNEL" = xtrue; then if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - { { $as_echo "$as_me:$LINENO: error: You cannot build a kernel JVM for a 64-bit machine." >&5 -$as_echo "$as_me: error: You cannot build a kernel JVM for a 64-bit machine." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You cannot build a kernel JVM for a 64-bit machine." "$LINENO" 5 fi fi @@ -7007,10 +7456,10 @@ fi # slowdebug: debug information (-g), no optimizations, all asserts # DEBUG_LEVEL="release" -{ $as_echo "$as_me:$LINENO: checking which debug level to use" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which debug level to use" >&5 $as_echo_n "checking which debug level to use... " >&6; } # Check whether --enable-debug was given. -if test "${enable_debug+set}" = set; then +if test "${enable_debug+set}" = set; then : enableval=$enable_debug; ENABLE_DEBUG="${enableval}" DEBUG_LEVEL="fastdebug" @@ -7022,26 +7471,22 @@ fi # Check whether --with-debug-level was given. -if test "${with_debug_level+set}" = set; then +if test "${with_debug_level+set}" = set; then : withval=$with_debug_level; DEBUG_LEVEL="${withval}" if test "x$ENABLE_DEBUG" = xyes; then - { { $as_echo "$as_me:$LINENO: error: You cannot use both --enable-debug and --with-debug-level at the same time." >&5 -$as_echo "$as_me: error: You cannot use both --enable-debug and --with-debug-level at the same time." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You cannot use both --enable-debug and --with-debug-level at the same time." "$LINENO" 5 fi fi -{ $as_echo "$as_me:$LINENO: result: $DEBUG_LEVEL" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEBUG_LEVEL" >&5 $as_echo "$DEBUG_LEVEL" >&6; } if test "x$DEBUG_LEVEL" != xrelease && \ test "x$DEBUG_LEVEL" != xfastdebug && \ test "x$DEBUG_LEVEL" != xslowdebug; then - { { $as_echo "$as_me:$LINENO: error: Allowed debug levels are: release, fastdebug and slowdebug" >&5 -$as_echo "$as_me: error: Allowed debug levels are: release, fastdebug and slowdebug" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Allowed debug levels are: release, fastdebug and slowdebug" "$LINENO" 5 fi @@ -7131,7 +7576,7 @@ fi # Check whether --with-conf-name was given. -if test "${with_conf_name+set}" = set; then +if test "${with_conf_name+set}" = set; then : withval=$with_conf_name; CONF_NAME=${with_conf_name} fi @@ -7195,9 +7640,7 @@ if test "x$NOSYM_CURDIR" = "x$SRC_ROOT" || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/c OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}" $MKDIR -p "$OUTPUT_ROOT" if test ! -d "$OUTPUT_ROOT"; then - { { $as_echo "$as_me:$LINENO: error: Could not create build directory $OUTPUT_ROOT" >&5 -$as_echo "$as_me: error: Could not create build directory $OUTPUT_ROOT" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create build directory $OUTPUT_ROOT" "$LINENO" 5 fi else # We are running configure from outside of the src dir. @@ -7221,29 +7664,27 @@ else filtered_files=`$ECHO "$files_present" | $SED -e 's/config.log//g' -e 's/confdefs.h//g' -e 's/ //g' \ | $TR -d '\n'` if test "x$filtered_files" != x; then - { $as_echo "$as_me:$LINENO: Current directory is $CURDIR." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Current directory is $CURDIR." >&5 $as_echo "$as_me: Current directory is $CURDIR." >&6;} - { $as_echo "$as_me:$LINENO: Since this is not the source root, configure will output the configuration here" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Since this is not the source root, configure will output the configuration here" >&5 $as_echo "$as_me: Since this is not the source root, configure will output the configuration here" >&6;} - { $as_echo "$as_me:$LINENO: (as opposed to creating a configuration in /build/)." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (as opposed to creating a configuration in /build/)." >&5 $as_echo "$as_me: (as opposed to creating a configuration in /build/)." >&6;} - { $as_echo "$as_me:$LINENO: However, this directory is not empty. This is not allowed, since it could" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: However, this directory is not empty. This is not allowed, since it could" >&5 $as_echo "$as_me: However, this directory is not empty. This is not allowed, since it could" >&6;} - { $as_echo "$as_me:$LINENO: seriously mess up just about everything." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: seriously mess up just about everything." >&5 $as_echo "$as_me: seriously mess up just about everything." >&6;} - { $as_echo "$as_me:$LINENO: Try 'cd $SRC_ROOT' and restart configure" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Try 'cd $SRC_ROOT' and restart configure" >&5 $as_echo "$as_me: Try 'cd $SRC_ROOT' and restart configure" >&6;} - { $as_echo "$as_me:$LINENO: (or create a new empty directory and cd to it)." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (or create a new empty directory and cd to it)." >&5 $as_echo "$as_me: (or create a new empty directory and cd to it)." >&6;} - { { $as_echo "$as_me:$LINENO: error: Will not continue creating configuration in $CURDIR" >&5 -$as_echo "$as_me: error: Will not continue creating configuration in $CURDIR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Will not continue creating configuration in $CURDIR" "$LINENO" 5 fi fi fi -{ $as_echo "$as_me:$LINENO: checking what configuration name to use" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking what configuration name to use" >&5 $as_echo_n "checking what configuration name to use... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $CONF_NAME" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CONF_NAME" >&5 $as_echo "$CONF_NAME" >&6; } @@ -7263,11 +7704,9 @@ $as_echo "$CONF_NAME" >&6; } # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of OUTPUT_ROOT, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OUTPUT_ROOT, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of OUTPUT_ROOT, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OUTPUT_ROOT" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OUTPUT_ROOT" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OUTPUT_ROOT" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -7306,7 +7745,7 @@ $as_echo "$as_me: error: Cannot locate the the path of OUTPUT_ROOT" >&2;} if test "x$path" != "x$new_path"; then OUTPUT_ROOT="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting OUTPUT_ROOT to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting OUTPUT_ROOT to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting OUTPUT_ROOT to \"$new_path\"" >&6;} fi @@ -7344,7 +7783,7 @@ $as_echo "$as_me: Rewriting OUTPUT_ROOT to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then OUTPUT_ROOT="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting OUTPUT_ROOT to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting OUTPUT_ROOT to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting OUTPUT_ROOT to \"$new_path\"" >&6;} fi @@ -7356,18 +7795,14 @@ $as_echo "$as_me: Rewriting OUTPUT_ROOT to \"$new_path\"" >&6;} path="$OUTPUT_ROOT" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of OUTPUT_ROOT, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of OUTPUT_ROOT, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of OUTPUT_ROOT, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of OUTPUT_ROOT, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OUTPUT_ROOT, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of OUTPUT_ROOT, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi @@ -7413,9 +7848,9 @@ echo "$CONFIGURE_COMMAND_LINE" > $OUTPUT_ROOT/configure-arguments do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PKGHANDLER+set}" = set; then +if test "${ac_cv_prog_PKGHANDLER+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PKGHANDLER"; then @@ -7426,24 +7861,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PKGHANDLER="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi PKGHANDLER=$ac_cv_prog_PKGHANDLER if test -n "$PKGHANDLER"; then - { $as_echo "$as_me:$LINENO: result: $PKGHANDLER" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKGHANDLER" >&5 $as_echo "$PKGHANDLER" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -7460,25 +7895,23 @@ done if test "x$MAKE" != x; then # User has supplied a make, test it. if test ! -f "$MAKE"; then - { { $as_echo "$as_me:$LINENO: error: The specified make (by MAKE=$MAKE) is not found." >&5 -$as_echo "$as_me: error: The specified make (by MAKE=$MAKE) is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The specified make (by MAKE=$MAKE) is not found." "$LINENO" 5 fi MAKE_CANDIDATE=""$MAKE"" DESCRIPTION="user supplied MAKE=$MAKE" if test "x$MAKE_CANDIDATE" != x; then - { $as_echo "$as_me:$LINENO: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5 $as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&6;} MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1` IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'` if test "x$IS_GNU_MAKE" = x; then - { $as_echo "$as_me:$LINENO: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 $as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;} else IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[12346789]'` if test "x$IS_MODERN_MAKE" = x; then - { $as_echo "$as_me:$LINENO: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;} else if test "x$OPENJDK_BUILD_OS" = "xwindows"; then @@ -7487,9 +7920,7 @@ $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then MAKE_EXPECTED_ENV='msys' else - { { $as_echo "$as_me:$LINENO: error: Unknown Windows environment" >&5 -$as_echo "$as_me: error: Unknown Windows environment" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Unknown Windows environment" "$LINENO" 5 fi MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'` IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV` @@ -7498,7 +7929,7 @@ $as_echo "$as_me: error: Unknown Windows environment" >&2;} IS_MAKE_CORRECT_ENV=true fi if test "x$IS_MAKE_CORRECT_ENV" = x; then - { $as_echo "$as_me:$LINENO: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&5 $as_echo "$as_me: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&6;} else FOUND_MAKE=$MAKE_CANDIDATE @@ -7543,16 +7974,14 @@ $as_echo "$as_me: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi @@ -7572,13 +8001,11 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -7670,16 +8097,14 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi @@ -7734,20 +8159,18 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi fi @@ -7761,7 +8184,7 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$complete" != "x$new_complete"; then FOUND_MAKE="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting FOUND_MAKE to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FOUND_MAKE to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting FOUND_MAKE to \"$new_complete\"" >&6;} fi @@ -7771,9 +8194,7 @@ $as_echo "$as_me: Rewriting FOUND_MAKE to \"$new_complete\"" >&6;} fi if test "x$FOUND_MAKE" = x; then - { { $as_echo "$as_me:$LINENO: error: The specified make (by MAKE=$MAKE) is not GNU make 3.81 or newer." >&5 -$as_echo "$as_me: error: The specified make (by MAKE=$MAKE) is not GNU make 3.81 or newer." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The specified make (by MAKE=$MAKE) is not GNU make 3.81 or newer." "$LINENO" 5 fi else # Try our hardest to locate a correct version of GNU make @@ -7781,9 +8202,9 @@ $as_echo "$as_me: error: The specified make (by MAKE=$MAKE) is not GNU make 3.81 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_GMAKE+set}" = set; then +if test "${ac_cv_path_CHECK_GMAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_GMAKE in @@ -7796,14 +8217,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CHECK_GMAKE="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -7811,10 +8232,10 @@ esac fi CHECK_GMAKE=$ac_cv_path_CHECK_GMAKE if test -n "$CHECK_GMAKE"; then - { $as_echo "$as_me:$LINENO: result: $CHECK_GMAKE" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHECK_GMAKE" >&5 $as_echo "$CHECK_GMAKE" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -7826,17 +8247,17 @@ done MAKE_CANDIDATE=""$CHECK_GMAKE"" DESCRIPTION="gmake in PATH" if test "x$MAKE_CANDIDATE" != x; then - { $as_echo "$as_me:$LINENO: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5 $as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&6;} MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1` IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'` if test "x$IS_GNU_MAKE" = x; then - { $as_echo "$as_me:$LINENO: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 $as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;} else IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[12346789]'` if test "x$IS_MODERN_MAKE" = x; then - { $as_echo "$as_me:$LINENO: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;} else if test "x$OPENJDK_BUILD_OS" = "xwindows"; then @@ -7845,9 +8266,7 @@ $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then MAKE_EXPECTED_ENV='msys' else - { { $as_echo "$as_me:$LINENO: error: Unknown Windows environment" >&5 -$as_echo "$as_me: error: Unknown Windows environment" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Unknown Windows environment" "$LINENO" 5 fi MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'` IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV` @@ -7856,7 +8275,7 @@ $as_echo "$as_me: error: Unknown Windows environment" >&2;} IS_MAKE_CORRECT_ENV=true fi if test "x$IS_MAKE_CORRECT_ENV" = x; then - { $as_echo "$as_me:$LINENO: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&5 $as_echo "$as_me: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&6;} else FOUND_MAKE=$MAKE_CANDIDATE @@ -7901,16 +8320,14 @@ $as_echo "$as_me: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi @@ -7930,13 +8347,11 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -8028,16 +8443,14 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi @@ -8092,20 +8505,18 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi fi @@ -8119,7 +8530,7 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$complete" != "x$new_complete"; then FOUND_MAKE="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting FOUND_MAKE to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FOUND_MAKE to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting FOUND_MAKE to \"$new_complete\"" >&6;} fi @@ -8134,9 +8545,9 @@ $as_echo "$as_me: Rewriting FOUND_MAKE to \"$new_complete\"" >&6;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_MAKE+set}" = set; then +if test "${ac_cv_path_CHECK_MAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_MAKE in @@ -8149,14 +8560,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CHECK_MAKE="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -8164,10 +8575,10 @@ esac fi CHECK_MAKE=$ac_cv_path_CHECK_MAKE if test -n "$CHECK_MAKE"; then - { $as_echo "$as_me:$LINENO: result: $CHECK_MAKE" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHECK_MAKE" >&5 $as_echo "$CHECK_MAKE" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -8179,17 +8590,17 @@ done MAKE_CANDIDATE=""$CHECK_MAKE"" DESCRIPTION="make in PATH" if test "x$MAKE_CANDIDATE" != x; then - { $as_echo "$as_me:$LINENO: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5 $as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&6;} MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1` IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'` if test "x$IS_GNU_MAKE" = x; then - { $as_echo "$as_me:$LINENO: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 $as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;} else IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[12346789]'` if test "x$IS_MODERN_MAKE" = x; then - { $as_echo "$as_me:$LINENO: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;} else if test "x$OPENJDK_BUILD_OS" = "xwindows"; then @@ -8198,9 +8609,7 @@ $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then MAKE_EXPECTED_ENV='msys' else - { { $as_echo "$as_me:$LINENO: error: Unknown Windows environment" >&5 -$as_echo "$as_me: error: Unknown Windows environment" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Unknown Windows environment" "$LINENO" 5 fi MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'` IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV` @@ -8209,7 +8618,7 @@ $as_echo "$as_me: error: Unknown Windows environment" >&2;} IS_MAKE_CORRECT_ENV=true fi if test "x$IS_MAKE_CORRECT_ENV" = x; then - { $as_echo "$as_me:$LINENO: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&5 $as_echo "$as_me: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&6;} else FOUND_MAKE=$MAKE_CANDIDATE @@ -8254,16 +8663,14 @@ $as_echo "$as_me: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi @@ -8283,13 +8690,11 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -8381,16 +8786,14 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi @@ -8445,20 +8848,18 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi fi @@ -8472,7 +8873,7 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$complete" != "x$new_complete"; then FOUND_MAKE="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting FOUND_MAKE to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FOUND_MAKE to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting FOUND_MAKE to \"$new_complete\"" >&6;} fi @@ -8492,9 +8893,9 @@ $as_echo "$as_me: Rewriting FOUND_MAKE to \"$new_complete\"" >&6;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_TOOLSDIR_GMAKE+set}" = set; then +if test "${ac_cv_path_CHECK_TOOLSDIR_GMAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_GMAKE in @@ -8507,14 +8908,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CHECK_TOOLSDIR_GMAKE="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -8522,10 +8923,10 @@ esac fi CHECK_TOOLSDIR_GMAKE=$ac_cv_path_CHECK_TOOLSDIR_GMAKE if test -n "$CHECK_TOOLSDIR_GMAKE"; then - { $as_echo "$as_me:$LINENO: result: $CHECK_TOOLSDIR_GMAKE" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHECK_TOOLSDIR_GMAKE" >&5 $as_echo "$CHECK_TOOLSDIR_GMAKE" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -8537,17 +8938,17 @@ done MAKE_CANDIDATE=""$CHECK_TOOLSDIR_GMAKE"" DESCRIPTION="gmake in tools-dir" if test "x$MAKE_CANDIDATE" != x; then - { $as_echo "$as_me:$LINENO: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5 $as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&6;} MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1` IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'` if test "x$IS_GNU_MAKE" = x; then - { $as_echo "$as_me:$LINENO: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 $as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;} else IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[12346789]'` if test "x$IS_MODERN_MAKE" = x; then - { $as_echo "$as_me:$LINENO: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;} else if test "x$OPENJDK_BUILD_OS" = "xwindows"; then @@ -8556,9 +8957,7 @@ $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then MAKE_EXPECTED_ENV='msys' else - { { $as_echo "$as_me:$LINENO: error: Unknown Windows environment" >&5 -$as_echo "$as_me: error: Unknown Windows environment" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Unknown Windows environment" "$LINENO" 5 fi MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'` IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV` @@ -8567,7 +8966,7 @@ $as_echo "$as_me: error: Unknown Windows environment" >&2;} IS_MAKE_CORRECT_ENV=true fi if test "x$IS_MAKE_CORRECT_ENV" = x; then - { $as_echo "$as_me:$LINENO: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&5 $as_echo "$as_me: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&6;} else FOUND_MAKE=$MAKE_CANDIDATE @@ -8612,16 +9011,14 @@ $as_echo "$as_me: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi @@ -8641,13 +9038,11 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -8739,16 +9134,14 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi @@ -8803,20 +9196,18 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi fi @@ -8830,7 +9221,7 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$complete" != "x$new_complete"; then FOUND_MAKE="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting FOUND_MAKE to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FOUND_MAKE to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting FOUND_MAKE to \"$new_complete\"" >&6;} fi @@ -8844,9 +9235,9 @@ $as_echo "$as_me: Rewriting FOUND_MAKE to \"$new_complete\"" >&6;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_TOOLSDIR_MAKE+set}" = set; then +if test "${ac_cv_path_CHECK_TOOLSDIR_MAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_MAKE in @@ -8859,14 +9250,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CHECK_TOOLSDIR_MAKE="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -8874,10 +9265,10 @@ esac fi CHECK_TOOLSDIR_MAKE=$ac_cv_path_CHECK_TOOLSDIR_MAKE if test -n "$CHECK_TOOLSDIR_MAKE"; then - { $as_echo "$as_me:$LINENO: result: $CHECK_TOOLSDIR_MAKE" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHECK_TOOLSDIR_MAKE" >&5 $as_echo "$CHECK_TOOLSDIR_MAKE" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -8889,17 +9280,17 @@ done MAKE_CANDIDATE=""$CHECK_TOOLSDIR_MAKE"" DESCRIPTION="make in tools-dir" if test "x$MAKE_CANDIDATE" != x; then - { $as_echo "$as_me:$LINENO: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&5 $as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION" >&6;} MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1` IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'` if test "x$IS_GNU_MAKE" = x; then - { $as_echo "$as_me:$LINENO: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 $as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;} else IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[12346789]'` if test "x$IS_MODERN_MAKE" = x; then - { $as_echo "$as_me:$LINENO: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;} else if test "x$OPENJDK_BUILD_OS" = "xwindows"; then @@ -8908,9 +9299,7 @@ $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then MAKE_EXPECTED_ENV='msys' else - { { $as_echo "$as_me:$LINENO: error: Unknown Windows environment" >&5 -$as_echo "$as_me: error: Unknown Windows environment" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Unknown Windows environment" "$LINENO" 5 fi MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'` IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV` @@ -8919,7 +9308,7 @@ $as_echo "$as_me: error: Unknown Windows environment" >&2;} IS_MAKE_CORRECT_ENV=true fi if test "x$IS_MAKE_CORRECT_ENV" = x; then - { $as_echo "$as_me:$LINENO: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&5 $as_echo "$as_me: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring." >&6;} else FOUND_MAKE=$MAKE_CANDIDATE @@ -8964,16 +9353,14 @@ $as_echo "$as_me: Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi @@ -8993,13 +9380,11 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -9091,16 +9476,14 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi @@ -9155,20 +9538,18 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving FOUND_MAKE (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of FOUND_MAKE, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FOUND_MAKE" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FOUND_MAKE" "$LINENO" 5 fi fi fi @@ -9182,7 +9563,7 @@ $as_echo "$as_me: error: Cannot locate the the path of FOUND_MAKE" >&2;} if test "x$complete" != "x$new_complete"; then FOUND_MAKE="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting FOUND_MAKE to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FOUND_MAKE to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting FOUND_MAKE to \"$new_complete\"" >&6;} fi @@ -9197,21 +9578,19 @@ $as_echo "$as_me: Rewriting FOUND_MAKE to \"$new_complete\"" >&6;} fi if test "x$FOUND_MAKE" = x; then - { { $as_echo "$as_me:$LINENO: error: Cannot find GNU make 3.81 or newer! Please put it in the path, or add e.g. MAKE=/opt/gmake3.81/make as argument to configure." >&5 -$as_echo "$as_me: error: Cannot find GNU make 3.81 or newer! Please put it in the path, or add e.g. MAKE=/opt/gmake3.81/make as argument to configure." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot find GNU make 3.81 or newer! Please put it in the path, or add e.g. MAKE=/opt/gmake3.81/make as argument to configure." "$LINENO" 5 fi fi MAKE=$FOUND_MAKE - { $as_echo "$as_me:$LINENO: Using GNU make 3.81 (or later) at $FOUND_MAKE (version: $MAKE_VERSION_STRING)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Using GNU make 3.81 (or later) at $FOUND_MAKE (version: $MAKE_VERSION_STRING)" >&5 $as_echo "$as_me: Using GNU make 3.81 (or later) at $FOUND_MAKE (version: $MAKE_VERSION_STRING)" >&6;} # Test if find supports -delete - { $as_echo "$as_me:$LINENO: checking if find supports -delete" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if find supports -delete" >&5 $as_echo_n "checking if find supports -delete... " >&6; } FIND_DELETE="-delete" @@ -9224,10 +9603,10 @@ $as_echo_n "checking if find supports -delete... " >&6; } # No, it does not. rm $DELETEDIR/TestIfFindSupportsDelete FIND_DELETE="-exec rm \{\} \+" - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } else - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi rmdir $DELETEDIR @@ -9241,9 +9620,9 @@ $as_echo "yes" >&6; } do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_UNZIP+set}" = set; then +if test "${ac_cv_path_UNZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNZIP in @@ -9256,14 +9635,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_UNZIP="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9271,10 +9650,10 @@ esac fi UNZIP=$ac_cv_path_UNZIP if test -n "$UNZIP"; then - { $as_echo "$as_me:$LINENO: result: $UNZIP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNZIP" >&5 $as_echo "$UNZIP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -9289,11 +9668,9 @@ done else PROG_NAME=unzip fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -9302,9 +9679,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ZIP+set}" = set; then +if test "${ac_cv_path_ZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ZIP in @@ -9317,14 +9694,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ZIP="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9332,10 +9709,10 @@ esac fi ZIP=$ac_cv_path_ZIP if test -n "$ZIP"; then - { $as_echo "$as_me:$LINENO: result: $ZIP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5 $as_echo "$ZIP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -9350,11 +9727,9 @@ done else PROG_NAME=zip fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -9363,9 +9738,9 @@ $as_echo "$as_me: error: Cannot continue" >&2;} # Extract the first word of "ldd", so it can be a program name with args. set dummy ldd; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LDD+set}" = set; then +if test "${ac_cv_path_LDD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LDD in @@ -9378,14 +9753,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_LDD="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9393,10 +9768,10 @@ esac fi LDD=$ac_cv_path_LDD if test -n "$LDD"; then - { $as_echo "$as_me:$LINENO: result: $LDD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDD" >&5 $as_echo "$LDD" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -9409,9 +9784,9 @@ if test "x$LDD" = "x"; then fi # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_OTOOL+set}" = set; then +if test "${ac_cv_path_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $OTOOL in @@ -9424,14 +9799,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_OTOOL="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9439,10 +9814,10 @@ esac fi OTOOL=$ac_cv_path_OTOOL if test -n "$OTOOL"; then - { $as_echo "$as_me:$LINENO: result: $OTOOL" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -9454,9 +9829,9 @@ for ac_prog in readelf greadelf do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_READELF+set}" = set; then +if test "${ac_cv_path_READELF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $READELF in @@ -9469,14 +9844,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_READELF="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9484,10 +9859,10 @@ esac fi READELF=$ac_cv_path_READELF if test -n "$READELF"; then - { $as_echo "$as_me:$LINENO: result: $READELF" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READELF" >&5 $as_echo "$READELF" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -9497,9 +9872,9 @@ done # Extract the first word of "hg", so it can be a program name with args. set dummy hg; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_HG+set}" = set; then +if test "${ac_cv_path_HG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $HG in @@ -9512,14 +9887,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_HG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9527,19 +9902,19 @@ esac fi HG=$ac_cv_path_HG if test -n "$HG"; then - { $as_echo "$as_me:$LINENO: result: $HG" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HG" >&5 $as_echo "$HG" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "stat", so it can be a program name with args. set dummy stat; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_STAT+set}" = set; then +if test "${ac_cv_path_STAT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STAT in @@ -9552,14 +9927,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_STAT="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9567,19 +9942,19 @@ esac fi STAT=$ac_cv_path_STAT if test -n "$STAT"; then - { $as_echo "$as_me:$LINENO: result: $STAT" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STAT" >&5 $as_echo "$STAT" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "time", so it can be a program name with args. set dummy time; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TIME+set}" = set; then +if test "${ac_cv_path_TIME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TIME in @@ -9592,14 +9967,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_TIME="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9607,10 +9982,10 @@ esac fi TIME=$ac_cv_path_TIME if test -n "$TIME"; then - { $as_echo "$as_me:$LINENO: result: $TIME" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TIME" >&5 $as_echo "$TIME" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -9622,9 +9997,9 @@ if test "x$OPENJDK_TARGET_OS" = "xwindows"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_COMM+set}" = set; then +if test "${ac_cv_path_COMM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -9637,14 +10012,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_COMM="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9652,10 +10027,10 @@ esac fi COMM=$ac_cv_path_COMM if test -n "$COMM"; then - { $as_echo "$as_me:$LINENO: result: $COMM" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $COMM" >&5 $as_echo "$COMM" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -9670,11 +10045,9 @@ done else PROG_NAME=comm fi - { $as_echo "$as_me:$LINENO: Could not find $PROG_NAME!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -9688,9 +10061,9 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -9703,14 +10076,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9718,10 +10091,10 @@ esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -9731,9 +10104,9 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in @@ -9746,14 +10119,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -9761,10 +10134,10 @@ esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:$LINENO: result: $ac_pt_PKG_CONFIG" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -9773,7 +10146,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -9786,13 +10159,13 @@ fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 - { $as_echo "$as_me:$LINENO: checking pkg-config is at least version $_pkg_min_version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi @@ -9820,21 +10193,21 @@ OS_VERSION_MICRO="`${ECHO} ${OS_VERSION} | ${CUT} -f 3 -d ' '`" # Check whether --with-builddeps-conf was given. -if test "${with_builddeps_conf+set}" = set; then +if test "${with_builddeps_conf+set}" = set; then : withval=$with_builddeps_conf; fi # Check whether --with-builddeps-server was given. -if test "${with_builddeps_server+set}" = set; then +if test "${with_builddeps_server+set}" = set; then : withval=$with_builddeps_server; fi # Check whether --with-builddeps-dir was given. -if test "${with_builddeps_dir+set}" = set; then +if test "${with_builddeps_dir+set}" = set; then : withval=$with_builddeps_dir; else with_builddeps_dir=/localhome/builddeps @@ -9843,7 +10216,7 @@ fi # Check whether --with-builddeps-group was given. -if test "${with_builddeps_group+set}" = set; then +if test "${with_builddeps_group+set}" = set; then : withval=$with_builddeps_group; fi @@ -9852,20 +10225,18 @@ fi if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then if test "x$with_builddeps_conf" != x; then - { $as_echo "$as_me:$LINENO: checking for supplied builddeps configuration file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for supplied builddeps configuration file" >&5 $as_echo_n "checking for supplied builddeps configuration file... " >&6; } builddepsfile=$with_builddeps_conf if test -s $builddepsfile; then . $builddepsfile - { $as_echo "$as_me:$LINENO: result: loaded!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: loaded!" >&5 $as_echo "loaded!" >&6; } else - { { $as_echo "$as_me:$LINENO: error: The given builddeps conf file $with_builddeps_conf could not be loaded!" >&5 -$as_echo "$as_me: error: The given builddeps conf file $with_builddeps_conf could not be loaded!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The given builddeps conf file $with_builddeps_conf could not be loaded!" "$LINENO" 5 fi else - { $as_echo "$as_me:$LINENO: checking for builddeps.conf files in sources..." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for builddeps.conf files in sources..." >&5 $as_echo_n "checking for builddeps.conf files in sources...... " >&6; } builddepsfile=`mktemp` touch $builddepsfile @@ -9874,12 +10245,10 @@ $as_echo_n "checking for builddeps.conf files in sources...... " >&6; } # Source the file to acquire the variables if test -s $builddepsfile; then . $builddepsfile - { $as_echo "$as_me:$LINENO: result: found at least one!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found at least one!" >&5 $as_echo "found at least one!" >&6; } else - { { $as_echo "$as_me:$LINENO: error: Could not find any builddeps.conf at all!" >&5 -$as_echo "$as_me: error: Could not find any builddeps.conf at all!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find any builddeps.conf at all!" "$LINENO" 5 fi fi # Create build and target names that use _ instead of "-" and ".". @@ -9908,9 +10277,9 @@ $as_echo "$as_me: error: Could not find any builddeps.conf at all!" >&2;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_BDEPS_UNZIP+set}" = set; then +if test "${ac_cv_prog_BDEPS_UNZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_UNZIP"; then @@ -9921,24 +10290,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_BDEPS_UNZIP="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi BDEPS_UNZIP=$ac_cv_prog_BDEPS_UNZIP if test -n "$BDEPS_UNZIP"; then - { $as_echo "$as_me:$LINENO: result: $BDEPS_UNZIP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BDEPS_UNZIP" >&5 $as_echo "$BDEPS_UNZIP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -9954,9 +10323,9 @@ done do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_BDEPS_FTP+set}" = set; then +if test "${ac_cv_prog_BDEPS_FTP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_FTP"; then @@ -9967,24 +10336,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_BDEPS_FTP="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi BDEPS_FTP=$ac_cv_prog_BDEPS_FTP if test -n "$BDEPS_FTP"; then - { $as_echo "$as_me:$LINENO: result: $BDEPS_FTP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BDEPS_FTP" >&5 $as_echo "$BDEPS_FTP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -10008,33 +10377,33 @@ done # Should we build only OpenJDK even if closed sources are present? # # Check whether --enable-openjdk-only was given. -if test "${enable_openjdk_only+set}" = set; then +if test "${enable_openjdk_only+set}" = set; then : enableval=$enable_openjdk_only; else enable_openjdk_only="no" fi -{ $as_echo "$as_me:$LINENO: checking for presence of closed sources" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for presence of closed sources" >&5 $as_echo_n "checking for presence of closed sources... " >&6; } if test -d "$SRC_ROOT/jdk/src/closed"; then CLOSED_SOURCE_PRESENT=yes else CLOSED_SOURCE_PRESENT=no fi -{ $as_echo "$as_me:$LINENO: result: $CLOSED_SOURCE_PRESENT" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CLOSED_SOURCE_PRESENT" >&5 $as_echo "$CLOSED_SOURCE_PRESENT" >&6; } -{ $as_echo "$as_me:$LINENO: checking if closed source is supressed (openjdk-only)" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if closed source is supressed (openjdk-only)" >&5 $as_echo_n "checking if closed source is supressed (openjdk-only)... " >&6; } SUPRESS_CLOSED_SOURCE="$enable_openjdk_only" -{ $as_echo "$as_me:$LINENO: result: $SUPRESS_CLOSED_SOURCE" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SUPRESS_CLOSED_SOURCE" >&5 $as_echo "$SUPRESS_CLOSED_SOURCE" >&6; } if test "x$CLOSED_SOURCE_PRESENT" = xno; then OPENJDK=true if test "x$SUPRESS_CLOSED_SOURCE" = "xyes"; then - { $as_echo "$as_me:$LINENO: WARNING: No closed source present, --enable-openjdk-only makes no sense" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: No closed source present, --enable-openjdk-only makes no sense" >&5 $as_echo "$as_me: WARNING: No closed source present, --enable-openjdk-only makes no sense" >&2;} fi else @@ -10056,10 +10425,10 @@ fi # Should we build a JDK/JVM with headful support (ie a graphical ui)? # We always build headless support. # -{ $as_echo "$as_me:$LINENO: checking headful support" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking headful support" >&5 $as_echo_n "checking headful support... " >&6; } # Check whether --enable-headful was given. -if test "${enable_headful+set}" = set; then +if test "${enable_headful+set}" = set; then : enableval=$enable_headful; SUPPORT_HEADFUL=${enable_headful} else SUPPORT_HEADFUL=yes @@ -10080,7 +10449,7 @@ if test "x$SUPPORT_HEADFUL" = xno; then headful_msg="headless only" fi -{ $as_echo "$as_me:$LINENO: result: $headful_msg" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $headful_msg" >&5 $as_echo "$headful_msg" >&6; } @@ -10089,7 +10458,7 @@ $as_echo "$headful_msg" >&6; } # Control wether Hotspot runs Queens test after build. # Check whether --enable-hotspot-test-in-build was given. -if test "${enable_hotspot_test_in_build+set}" = set; then +if test "${enable_hotspot_test_in_build+set}" = set; then : enableval=$enable_hotspot_test_in_build; else enable_hotspot_test_in_build=no @@ -10108,7 +10477,7 @@ fi # # Check whether --with-cacerts-file was given. -if test "${with_cacerts_file+set}" = set; then +if test "${with_cacerts_file+set}" = set; then : withval=$with_cacerts_file; fi @@ -10128,7 +10497,7 @@ fi # Enable or disable unlimited crypto # # Check whether --enable-unlimited-crypto was given. -if test "${enable_unlimited_crypto+set}" = set; then +if test "${enable_unlimited_crypto+set}" = set; then : enableval=$enable_unlimited_crypto; else enable_unlimited_crypto=no @@ -10215,7 +10584,7 @@ COOKED_BUILD_NUMBER=`$ECHO $JDK_BUILD_NUMBER | $SED -e 's/^b//' -e 's/^0//'` BOOT_JDK_FOUND=no # Check whether --with-boot-jdk was given. -if test "${with_boot_jdk+set}" = set; then +if test "${with_boot_jdk+set}" = set; then : withval=$with_boot_jdk; fi @@ -10233,7 +10602,7 @@ fi if test "x$with_boot_jdk" != x; then BOOT_JDK=$with_boot_jdk BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using configure arguments" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using configure arguments" >&5 $as_echo "$as_me: Found potential Boot JDK using configure arguments" >&6;} fi @@ -10242,21 +10611,21 @@ fi if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -10266,9 +10635,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -10291,11 +10660,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -10334,7 +10701,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -10372,7 +10739,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -10384,29 +10751,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -10418,9 +10781,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then # Having specified an argument which is incorrect will produce an instant failure; # we should not go on looking - { { $as_echo "$as_me:$LINENO: error: The path given by --with-boot-jdk does not contain a valid Boot JDK" >&5 -$as_echo "$as_me: error: The path given by --with-boot-jdk does not contain a valid Boot JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path given by --with-boot-jdk does not contain a valid Boot JDK" "$LINENO" 5 fi # Test: Is bootjdk available from builddeps? @@ -10449,7 +10810,7 @@ fi resource=${builddep_bootjdk} fi if test "x$resource" != x; then - { $as_echo "$as_me:$LINENO: Using builddeps $resource for bootjdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Using builddeps $resource for bootjdk" >&5 $as_echo "$as_me: Using builddeps $resource for bootjdk" >&6;} # If the resource in the builddeps.conf file is an existing directory, # for example /java/linux/cups @@ -10470,22 +10831,18 @@ $as_echo "$as_me: Using builddeps $resource for bootjdk" >&6;} extension=${filename#*.} installdir=$with_builddeps_dir/$filebase if test ! -f $installdir/$filename.unpacked; then - { $as_echo "$as_me:$LINENO: Downloading build dependency bootjdk from $with_builddeps_server/$resource and installing into $installdir" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Downloading build dependency bootjdk from $with_builddeps_server/$resource and installing into $installdir" >&5 $as_echo "$as_me: Downloading build dependency bootjdk from $with_builddeps_server/$resource and installing into $installdir" >&6;} if test ! -d $installdir; then mkdir -p $installdir fi if test ! -d $installdir; then - { { $as_echo "$as_me:$LINENO: error: Could not create directory $installdir" >&5 -$as_echo "$as_me: error: Could not create directory $installdir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create directory $installdir" "$LINENO" 5 fi tmpfile=`mktemp $installdir/bootjdk.XXXXXXXXX` touch $tmpfile if test ! -f $tmpfile; then - { { $as_echo "$as_me:$LINENO: error: Could not create files in directory $installdir" >&5 -$as_echo "$as_me: error: Could not create files in directory $installdir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create files in directory $installdir" "$LINENO" 5 fi # $with_builddeps_server/$resource is the ftp://abuilddeps.server.com/libs/cups.zip @@ -10523,16 +10880,12 @@ $as_echo "$as_me: error: Could not create files in directory $installdir" >&2;} ) | ftp -in $FTPSERVER fi if test "x$VALID_TOOL" != xyes; then - { { $as_echo "$as_me:$LINENO: error: I do not know how to use the tool: $BDEPS_FTP" >&5 -$as_echo "$as_me: error: I do not know how to use the tool: $BDEPS_FTP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "I do not know how to use the tool: $BDEPS_FTP" "$LINENO" 5 fi mv $tmpfile $installdir/$filename if test ! -s $installdir/$filename; then - { { $as_echo "$as_me:$LINENO: error: Could not download $with_builddeps_server/$resource" >&5 -$as_echo "$as_me: error: Could not download $with_builddeps_server/$resource" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not download $with_builddeps_server/$resource" "$LINENO" 5 fi case "$extension" in zip) echo "Unzipping $installdir/$filename..." @@ -10544,9 +10897,7 @@ $as_echo "$as_me: error: Could not download $with_builddeps_server/$resource" >& tgz) echo "Untaring $installdir/$filename..." (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked) ;; - *) { { $as_echo "$as_me:$LINENO: error: Cannot handle build depency archive with extension $extension" >&5 -$as_echo "$as_me: error: Cannot handle build depency archive with extension $extension" >&2;} - { (exit 1); exit 1; }; } + *) as_fn_error $? "Cannot handle build depency archive with extension $extension" "$LINENO" 5 ;; esac fi @@ -10563,9 +10914,7 @@ $as_echo "$as_me: error: Cannot handle build depency archive with extension $ext thecflags=${builddep_bootjdk_CFLAGS} thelibs=${builddep_bootjdk_LIBS} if test "x$depdir" = x; then - { { $as_echo "$as_me:$LINENO: error: Could not download build dependency bootjdk" >&5 -$as_echo "$as_me: error: Could not download build dependency bootjdk" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not download build dependency bootjdk" "$LINENO" 5 fi BOOT_JDK=$depdir if test "x$theroot" != x; then @@ -10591,21 +10940,21 @@ $as_echo "$as_me: error: Could not download build dependency bootjdk" >&2;} if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -10615,9 +10964,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -10640,11 +10989,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -10683,7 +11030,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -10721,7 +11068,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -10733,29 +11080,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -10789,11 +11132,9 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of JAVA_HOME_PROCESSED" >&5 -$as_echo "$as_me: error: Cannot locate the the path of JAVA_HOME_PROCESSED" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of JAVA_HOME_PROCESSED" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -10832,7 +11173,7 @@ $as_echo "$as_me: error: Cannot locate the the path of JAVA_HOME_PROCESSED" >&2; if test "x$path" != "x$new_path"; then JAVA_HOME_PROCESSED="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting JAVA_HOME_PROCESSED to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting JAVA_HOME_PROCESSED to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting JAVA_HOME_PROCESSED to \"$new_path\"" >&6;} fi @@ -10870,7 +11211,7 @@ $as_echo "$as_me: Rewriting JAVA_HOME_PROCESSED to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then JAVA_HOME_PROCESSED="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting JAVA_HOME_PROCESSED to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting JAVA_HOME_PROCESSED to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting JAVA_HOME_PROCESSED to \"$new_path\"" >&6;} fi @@ -10882,30 +11223,26 @@ $as_echo "$as_me: Rewriting JAVA_HOME_PROCESSED to \"$new_path\"" >&6;} path="$JAVA_HOME_PROCESSED" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi if test ! -d "$JAVA_HOME_PROCESSED"; then - { $as_echo "$as_me:$LINENO: Your JAVA_HOME points to a non-existing directory!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your JAVA_HOME points to a non-existing directory!" >&5 $as_echo "$as_me: Your JAVA_HOME points to a non-existing directory!" >&6;} else # Aha, the user has set a JAVA_HOME # let us use that as the Boot JDK. BOOT_JDK="$JAVA_HOME_PROCESSED" BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using JAVA_HOME" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using JAVA_HOME" >&5 $as_echo "$as_me: Found potential Boot JDK using JAVA_HOME" >&6;} fi fi @@ -10915,21 +11252,21 @@ $as_echo "$as_me: Found potential Boot JDK using JAVA_HOME" >&6;} if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -10939,9 +11276,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -10964,11 +11301,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -11007,7 +11342,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -11045,7 +11380,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -11057,29 +11392,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -11097,7 +11428,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test -x /usr/libexec/java_home; then BOOT_JDK=`/usr/libexec/java_home` BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using /usr/libexec/java_home" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using /usr/libexec/java_home" >&5 $as_echo "$as_me: Found potential Boot JDK using /usr/libexec/java_home" >&6;} fi @@ -11106,21 +11437,21 @@ $as_echo "$as_me: Found potential Boot JDK using /usr/libexec/java_home" >&6;} if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -11130,9 +11461,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -11155,11 +11486,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -11198,7 +11527,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -11236,7 +11565,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -11248,29 +11577,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -11287,9 +11612,9 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } # Extract the first word of "javac", so it can be a program name with args. set dummy javac; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_JAVAC_CHECK+set}" = set; then +if test "${ac_cv_path_JAVAC_CHECK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JAVAC_CHECK in @@ -11302,14 +11627,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_JAVAC_CHECK="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -11317,19 +11642,19 @@ esac fi JAVAC_CHECK=$ac_cv_path_JAVAC_CHECK if test -n "$JAVAC_CHECK"; then - { $as_echo "$as_me:$LINENO: result: $JAVAC_CHECK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVAC_CHECK" >&5 $as_echo "$JAVAC_CHECK" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "java", so it can be a program name with args. set dummy java; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_JAVA_CHECK+set}" = set; then +if test "${ac_cv_path_JAVA_CHECK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JAVA_CHECK in @@ -11342,14 +11667,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_JAVA_CHECK="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -11357,10 +11682,10 @@ esac fi JAVA_CHECK=$ac_cv_path_JAVA_CHECK if test -n "$JAVA_CHECK"; then - { $as_echo "$as_me:$LINENO: result: $JAVA_CHECK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVA_CHECK" >&5 $as_echo "$JAVA_CHECK" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -11423,7 +11748,7 @@ fi if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then # Looks like we found ourselves an JDK BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using java(c) in PATH" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using java(c) in PATH" >&5 $as_echo "$as_me: Found potential Boot JDK using java(c) in PATH" >&6;} fi fi @@ -11433,21 +11758,21 @@ $as_echo "$as_me: Found potential Boot JDK using java(c) in PATH" >&6;} if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -11457,9 +11782,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -11482,11 +11807,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -11525,7 +11848,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -11563,7 +11886,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -11575,29 +11898,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -11642,7 +11961,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" if test -d "$BOOT_JDK"; then BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&6;} fi @@ -11651,21 +11970,21 @@ $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_ if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -11675,9 +11994,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -11700,11 +12019,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -11743,7 +12060,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -11781,7 +12098,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -11793,29 +12110,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -11834,21 +12147,21 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -11858,9 +12171,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -11883,11 +12196,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -11926,7 +12237,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -11964,7 +12275,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -11976,29 +12287,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -12036,7 +12343,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" if test -d "$BOOT_JDK"; then BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&6;} fi @@ -12045,21 +12352,21 @@ $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_ if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -12069,9 +12376,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -12094,11 +12401,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -12137,7 +12442,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -12175,7 +12480,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -12187,29 +12492,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -12228,21 +12529,21 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -12252,9 +12553,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -12277,11 +12578,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -12320,7 +12619,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -12358,7 +12657,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -12370,29 +12669,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -12430,7 +12725,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" if test -d "$BOOT_JDK"; then BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&6;} fi @@ -12439,21 +12734,21 @@ $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_ if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -12463,9 +12758,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -12488,11 +12783,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -12531,7 +12824,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -12569,7 +12862,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -12581,29 +12874,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -12622,21 +12911,21 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -12646,9 +12935,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -12671,11 +12960,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -12714,7 +13001,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -12752,7 +13039,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -12764,29 +13051,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -12824,7 +13107,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" if test -d "$BOOT_JDK"; then BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&6;} fi @@ -12833,21 +13116,21 @@ $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_ if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -12857,9 +13140,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -12882,11 +13165,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -12925,7 +13206,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -12963,7 +13244,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -12975,29 +13256,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -13016,21 +13293,21 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -13040,9 +13317,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -13065,11 +13342,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -13108,7 +13383,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -13146,7 +13421,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -13158,29 +13433,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -13205,7 +13476,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" if test -d "$BOOT_JDK"; then BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&6;} fi @@ -13214,21 +13485,21 @@ $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_ if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -13238,9 +13509,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -13263,11 +13534,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -13306,7 +13575,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -13344,7 +13613,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -13356,29 +13625,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -13395,21 +13660,21 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -13419,9 +13684,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -13444,11 +13709,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -13487,7 +13750,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -13525,7 +13788,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -13537,29 +13800,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -13585,7 +13844,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" if test -d "$BOOT_JDK"; then BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&6;} fi @@ -13594,21 +13853,21 @@ $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_ if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -13618,9 +13877,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -13643,11 +13902,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -13686,7 +13943,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -13724,7 +13981,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -13736,29 +13993,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -13775,21 +14028,21 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -13799,9 +14052,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -13824,11 +14077,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -13867,7 +14118,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -13905,7 +14156,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -13917,29 +14168,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -13964,7 +14211,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" if test -d "$BOOT_JDK"; then BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&6;} fi @@ -13973,21 +14220,21 @@ $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_ if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -13997,9 +14244,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -14022,11 +14269,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -14065,7 +14310,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -14103,7 +14348,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -14115,29 +14360,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -14154,21 +14395,21 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -14178,9 +14419,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -14203,11 +14444,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -14246,7 +14485,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -14284,7 +14523,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -14296,29 +14535,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -14344,7 +14579,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" if test -d "$BOOT_JDK"; then BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:$LINENO: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&5 $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)" >&6;} fi @@ -14353,21 +14588,21 @@ $as_echo "$as_me: Found potential Boot JDK using well-known locations (in $BOOT_ if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -14377,9 +14612,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -14402,11 +14637,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -14445,7 +14678,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -14483,7 +14716,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -14495,29 +14728,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -14534,21 +14763,21 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -14558,9 +14787,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -14583,11 +14812,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -14626,7 +14853,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -14664,7 +14891,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -14676,29 +14903,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -14714,21 +14937,21 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } if test "x$BOOT_JDK_FOUND" = xmaybe; then # Do we have a bin/java? if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} BOOT_JDK_FOUND=no else # Do we have a bin/javac? if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (This might be an JRE instead of an JDK)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 $as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} BOOT_JDK_FOUND=no else # Do we have an rt.jar? (On MacOSX it is called classes.jar) if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} BOOT_JDK_FOUND=no else @@ -14738,9 +14961,9 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja # Extra M4 quote needed to protect [] in grep expression. FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:$LINENO: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:$LINENO: (Your Boot JDK must be version 7 or 8)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} BOOT_JDK_FOUND=no else @@ -14763,11 +14986,9 @@ $as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BOOT_JDK" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -14806,7 +15027,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BOOT_JDK" >&2;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -14844,7 +15065,7 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then BOOT_JDK="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting BOOT_JDK to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} fi @@ -14856,29 +15077,25 @@ $as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} path="$BOOT_JDK" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of BOOT_JDK, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 $as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 $as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:$LINENO: checking Boot JDK version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 $as_echo_n "checking Boot JDK version... " >&6; } BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:$LINENO: result: $BOOT_JDK_VERSION" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 $as_echo "$BOOT_JDK_VERSION" >&6; } fi # end check jdk version fi # end check rt.jar @@ -14915,13 +15132,11 @@ if test "x$BOOT_JDK_FOUND" = xno; then HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." fi - { $as_echo "$as_me:$LINENO: Could not find a valid Boot JDK. $HELP_MSG" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find a valid Boot JDK. $HELP_MSG" >&5 $as_echo "$as_me: Could not find a valid Boot JDK. $HELP_MSG" >&6;} - { $as_echo "$as_me:$LINENO: This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi # Setup proper paths for what we found @@ -14942,115 +15157,101 @@ BOOT_JDK="$BOOT_JDK" # Setup tools from the Boot JDK. - { $as_echo "$as_me:$LINENO: checking for java in Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for java in Boot JDK" >&5 $as_echo_n "checking for java in Boot JDK... " >&6; } JAVA=$BOOT_JDK/bin/java if test ! -x $JAVA; then - { $as_echo "$as_me:$LINENO: result: not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:$LINENO: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - { { $as_echo "$as_me:$LINENO: error: Could not find java in the Boot JDK" >&5 -$as_echo "$as_me: error: Could not find java in the Boot JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find java in the Boot JDK" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: result: ok" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:$LINENO: checking for javac in Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javac in Boot JDK" >&5 $as_echo_n "checking for javac in Boot JDK... " >&6; } JAVAC=$BOOT_JDK/bin/javac if test ! -x $JAVAC; then - { $as_echo "$as_me:$LINENO: result: not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:$LINENO: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - { { $as_echo "$as_me:$LINENO: error: Could not find javac in the Boot JDK" >&5 -$as_echo "$as_me: error: Could not find javac in the Boot JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find javac in the Boot JDK" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: result: ok" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:$LINENO: checking for javah in Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javah in Boot JDK" >&5 $as_echo_n "checking for javah in Boot JDK... " >&6; } JAVAH=$BOOT_JDK/bin/javah if test ! -x $JAVAH; then - { $as_echo "$as_me:$LINENO: result: not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:$LINENO: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - { { $as_echo "$as_me:$LINENO: error: Could not find javah in the Boot JDK" >&5 -$as_echo "$as_me: error: Could not find javah in the Boot JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find javah in the Boot JDK" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: result: ok" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:$LINENO: checking for javap in Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javap in Boot JDK" >&5 $as_echo_n "checking for javap in Boot JDK... " >&6; } JAVAP=$BOOT_JDK/bin/javap if test ! -x $JAVAP; then - { $as_echo "$as_me:$LINENO: result: not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:$LINENO: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - { { $as_echo "$as_me:$LINENO: error: Could not find javap in the Boot JDK" >&5 -$as_echo "$as_me: error: Could not find javap in the Boot JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find javap in the Boot JDK" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: result: ok" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:$LINENO: checking for jar in Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jar in Boot JDK" >&5 $as_echo_n "checking for jar in Boot JDK... " >&6; } JAR=$BOOT_JDK/bin/jar if test ! -x $JAR; then - { $as_echo "$as_me:$LINENO: result: not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:$LINENO: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - { { $as_echo "$as_me:$LINENO: error: Could not find jar in the Boot JDK" >&5 -$as_echo "$as_me: error: Could not find jar in the Boot JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find jar in the Boot JDK" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: result: ok" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:$LINENO: checking for rmic in Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rmic in Boot JDK" >&5 $as_echo_n "checking for rmic in Boot JDK... " >&6; } RMIC=$BOOT_JDK/bin/rmic if test ! -x $RMIC; then - { $as_echo "$as_me:$LINENO: result: not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:$LINENO: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - { { $as_echo "$as_me:$LINENO: error: Could not find rmic in the Boot JDK" >&5 -$as_echo "$as_me: error: Could not find rmic in the Boot JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find rmic in the Boot JDK" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: result: ok" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:$LINENO: checking for native2ascii in Boot JDK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for native2ascii in Boot JDK" >&5 $as_echo_n "checking for native2ascii in Boot JDK... " >&6; } NATIVE2ASCII=$BOOT_JDK/bin/native2ascii if test ! -x $NATIVE2ASCII; then - { $as_echo "$as_me:$LINENO: result: not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:$LINENO: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - { { $as_echo "$as_me:$LINENO: error: Could not find native2ascii in the Boot JDK" >&5 -$as_echo "$as_me: error: Could not find native2ascii in the Boot JDK" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find native2ascii in the Boot JDK" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: result: ok" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } @@ -15068,7 +15269,7 @@ BOOT_JDK_SOURCETARGET="-source 7 -target 7" # # Check whether --with-boot-jdk-jvmargs was given. -if test "${with_boot_jdk_jvmargs+set}" = set; then +if test "${with_boot_jdk_jvmargs+set}" = set; then : withval=$with_boot_jdk_jvmargs; fi @@ -15195,21 +15396,21 @@ JDK_TOPDIR="$SRC_ROOT/jdk" # # Check whether --with-add-source-root was given. -if test "${with_add_source_root+set}" = set; then +if test "${with_add_source_root+set}" = set; then : withval=$with_add_source_root; fi # Check whether --with-override-source-root was given. -if test "${with_override_source_root+set}" = set; then +if test "${with_override_source_root+set}" = set; then : withval=$with_override_source_root; fi # Check whether --with-adds-and-overrides was given. -if test "${with_adds_and_overrides+set}" = set; then +if test "${with_adds_and_overrides+set}" = set; then : withval=$with_adds_and_overrides; fi @@ -15221,9 +15422,7 @@ fi if test "x$with_add_source_root" != x; then if ! test -d $with_add_source_root; then - { { $as_echo "$as_me:$LINENO: error: Trying to use a non-existant add-source-root $with_add_source_root" >&5 -$as_echo "$as_me: error: Trying to use a non-existant add-source-root $with_add_source_root" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Trying to use a non-existant add-source-root $with_add_source_root" "$LINENO" 5 fi CURDIR="$PWD" cd "$with_add_source_root" @@ -15233,48 +15432,34 @@ $as_echo "$as_me: error: Trying to use a non-existant add-source-root $with_add_ # If it does, then it is usually an error, prevent this. if test -f $with_add_source_root/langtools/makefiles/Makefile || \ test -f $with_add_source_root/langtools/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your add source root seems to contain a full langtools repo! An add source root should only contain additional sources." >&5 -$as_echo "$as_me: error: Your add source root seems to contain a full langtools repo! An add source root should only contain additional sources." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your add source root seems to contain a full langtools repo! An add source root should only contain additional sources." "$LINENO" 5 fi if test -f $with_add_source_root/corba/makefiles/Makefile || \ test -f $with_add_source_root/corba/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your add source root seems to contain a full corba repo! An add source root should only contain additional sources." >&5 -$as_echo "$as_me: error: Your add source root seems to contain a full corba repo! An add source root should only contain additional sources." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your add source root seems to contain a full corba repo! An add source root should only contain additional sources." "$LINENO" 5 fi if test -f $with_add_source_root/jaxp/makefiles/Makefile || \ test -f $with_add_source_root/jaxp/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your add source root seems to contain a full jaxp repo! An add source root should only contain additional sources." >&5 -$as_echo "$as_me: error: Your add source root seems to contain a full jaxp repo! An add source root should only contain additional sources." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your add source root seems to contain a full jaxp repo! An add source root should only contain additional sources." "$LINENO" 5 fi if test -f $with_add_source_root/jaxws/makefiles/Makefile || \ test -f $with_add_source_root/jaxws/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your add source root seems to contain a full jaxws repo! An add source root should only contain additional sources." >&5 -$as_echo "$as_me: error: Your add source root seems to contain a full jaxws repo! An add source root should only contain additional sources." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your add source root seems to contain a full jaxws repo! An add source root should only contain additional sources." "$LINENO" 5 fi if test -f $with_add_source_root/hotspot/makefiles/Makefile || \ test -f $with_add_source_root/hotspot/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your add source root seems to contain a full hotspot repo! An add source root should only contain additional sources." >&5 -$as_echo "$as_me: error: Your add source root seems to contain a full hotspot repo! An add source root should only contain additional sources." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your add source root seems to contain a full hotspot repo! An add source root should only contain additional sources." "$LINENO" 5 fi if test -f $with_add_source_root/jdk/makefiles/Makefile || \ test -f $with_add_source_root/jdk/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your add source root seems to contain a full JDK repo! An add source root should only contain additional sources." >&5 -$as_echo "$as_me: error: Your add source root seems to contain a full JDK repo! An add source root should only contain additional sources." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your add source root seems to contain a full JDK repo! An add source root should only contain additional sources." "$LINENO" 5 fi fi if test "x$with_override_source_root" != x; then if ! test -d $with_override_source_root; then - { { $as_echo "$as_me:$LINENO: error: Trying to use a non-existant override-source-root $with_override_source_root" >&5 -$as_echo "$as_me: error: Trying to use a non-existant override-source-root $with_override_source_root" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Trying to use a non-existant override-source-root $with_override_source_root" "$LINENO" 5 fi CURDIR="$PWD" cd "$with_override_source_root" @@ -15282,39 +15467,27 @@ $as_echo "$as_me: error: Trying to use a non-existant override-source-root $with cd "$CURDIR" if test -f $with_override_source_root/langtools/makefiles/Makefile || \ test -f $with_override_source_root/langtools/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your override source root seems to contain a full langtools repo! An override source root should only contain sources that override." >&5 -$as_echo "$as_me: error: Your override source root seems to contain a full langtools repo! An override source root should only contain sources that override." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your override source root seems to contain a full langtools repo! An override source root should only contain sources that override." "$LINENO" 5 fi if test -f $with_override_source_root/corba/makefiles/Makefile || \ test -f $with_override_source_root/corba/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your override source root seems to contain a full corba repo! An override source root should only contain sources that override." >&5 -$as_echo "$as_me: error: Your override source root seems to contain a full corba repo! An override source root should only contain sources that override." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your override source root seems to contain a full corba repo! An override source root should only contain sources that override." "$LINENO" 5 fi if test -f $with_override_source_root/jaxp/makefiles/Makefile || \ test -f $with_override_source_root/jaxp/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your override source root seems to contain a full jaxp repo! An override source root should only contain sources that override." >&5 -$as_echo "$as_me: error: Your override source root seems to contain a full jaxp repo! An override source root should only contain sources that override." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your override source root seems to contain a full jaxp repo! An override source root should only contain sources that override." "$LINENO" 5 fi if test -f $with_override_source_root/jaxws/makefiles/Makefile || \ test -f $with_override_source_root/jaxws/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your override source root seems to contain a full jaxws repo! An override source root should only contain sources that override." >&5 -$as_echo "$as_me: error: Your override source root seems to contain a full jaxws repo! An override source root should only contain sources that override." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your override source root seems to contain a full jaxws repo! An override source root should only contain sources that override." "$LINENO" 5 fi if test -f $with_override_source_root/hotspot/makefiles/Makefile || \ test -f $with_override_source_root/hotspot/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your override source root seems to contain a full hotspot repo! An override source root should only contain sources that override." >&5 -$as_echo "$as_me: error: Your override source root seems to contain a full hotspot repo! An override source root should only contain sources that override." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your override source root seems to contain a full hotspot repo! An override source root should only contain sources that override." "$LINENO" 5 fi if test -f $with_override_source_root/jdk/makefiles/Makefile || \ test -f $with_override_source_root/jdk/make/Makefile; then - { { $as_echo "$as_me:$LINENO: error: Your override source root seems to contain a full JDK repo! An override source root should only contain sources that override." >&5 -$as_echo "$as_me: error: Your override source root seems to contain a full JDK repo! An override source root should only contain sources that override." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your override source root seems to contain a full JDK repo! An override source root should only contain sources that override." "$LINENO" 5 fi fi @@ -15340,42 +15513,42 @@ fi # Check whether --with-override-langtools was given. -if test "${with_override_langtools+set}" = set; then +if test "${with_override_langtools+set}" = set; then : withval=$with_override_langtools; fi # Check whether --with-override-corba was given. -if test "${with_override_corba+set}" = set; then +if test "${with_override_corba+set}" = set; then : withval=$with_override_corba; fi # Check whether --with-override-jaxp was given. -if test "${with_override_jaxp+set}" = set; then +if test "${with_override_jaxp+set}" = set; then : withval=$with_override_jaxp; fi # Check whether --with-override-jaxws was given. -if test "${with_override_jaxws+set}" = set; then +if test "${with_override_jaxws+set}" = set; then : withval=$with_override_jaxws; fi # Check whether --with-override-hotspot was given. -if test "${with_override_hotspot+set}" = set; then +if test "${with_override_hotspot+set}" = set; then : withval=$with_override_hotspot; fi # Check whether --with-override-jdk was given. -if test "${with_override_jdk+set}" = set; then +if test "${with_override_jdk+set}" = set; then : withval=$with_override_jdk; fi @@ -15386,13 +15559,11 @@ if test "x$with_override_langtools" != x; then LANGTOOLS_TOPDIR="`pwd`" cd "$CURDIR" if ! test -f $LANGTOOLS_TOPDIR/makefiles/Makefile; then - { { $as_echo "$as_me:$LINENO: error: You have to override langtools with a full langtools repo!" >&5 -$as_echo "$as_me: error: You have to override langtools with a full langtools repo!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You have to override langtools with a full langtools repo!" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: checking if langtools should be overridden" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if langtools should be overridden" >&5 $as_echo_n "checking if langtools should be overridden... " >&6; } - { $as_echo "$as_me:$LINENO: result: yes with $LANGTOOLS_TOPDIR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes with $LANGTOOLS_TOPDIR" >&5 $as_echo "yes with $LANGTOOLS_TOPDIR" >&6; } fi if test "x$with_override_corba" != x; then @@ -15401,13 +15572,11 @@ if test "x$with_override_corba" != x; then CORBA_TOPDIR="`pwd`" cd "$CURDIR" if ! test -f $CORBA_TOPDIR/makefiles/Makefile; then - { { $as_echo "$as_me:$LINENO: error: You have to override corba with a full corba repo!" >&5 -$as_echo "$as_me: error: You have to override corba with a full corba repo!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You have to override corba with a full corba repo!" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: checking if corba should be overridden" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if corba should be overridden" >&5 $as_echo_n "checking if corba should be overridden... " >&6; } - { $as_echo "$as_me:$LINENO: result: yes with $CORBA_TOPDIR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes with $CORBA_TOPDIR" >&5 $as_echo "yes with $CORBA_TOPDIR" >&6; } fi if test "x$with_override_jaxp" != x; then @@ -15416,13 +15585,11 @@ if test "x$with_override_jaxp" != x; then JAXP_TOPDIR="`pwd`" cd "$CURDIR" if ! test -f $JAXP_TOPDIR/makefiles/Makefile; then - { { $as_echo "$as_me:$LINENO: error: You have to override jaxp with a full jaxp repo!" >&5 -$as_echo "$as_me: error: You have to override jaxp with a full jaxp repo!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You have to override jaxp with a full jaxp repo!" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: checking if jaxp should be overridden" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if jaxp should be overridden" >&5 $as_echo_n "checking if jaxp should be overridden... " >&6; } - { $as_echo "$as_me:$LINENO: result: yes with $JAXP_TOPDIR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes with $JAXP_TOPDIR" >&5 $as_echo "yes with $JAXP_TOPDIR" >&6; } fi if test "x$with_override_jaxws" != x; then @@ -15431,13 +15598,11 @@ if test "x$with_override_jaxws" != x; then JAXWS_TOPDIR="`pwd`" cd "$CURDIR" if ! test -f $JAXWS_TOPDIR/makefiles/Makefile; then - { { $as_echo "$as_me:$LINENO: error: You have to override jaxws with a full jaxws repo!" >&5 -$as_echo "$as_me: error: You have to override jaxws with a full jaxws repo!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You have to override jaxws with a full jaxws repo!" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: checking if jaxws should be overridden" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if jaxws should be overridden" >&5 $as_echo_n "checking if jaxws should be overridden... " >&6; } - { $as_echo "$as_me:$LINENO: result: yes with $JAXWS_TOPDIR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes with $JAXWS_TOPDIR" >&5 $as_echo "yes with $JAXWS_TOPDIR" >&6; } fi if test "x$with_override_hotspot" != x; then @@ -15447,13 +15612,11 @@ if test "x$with_override_hotspot" != x; then cd "$CURDIR" if ! test -f $HOTSPOT_TOPDIR/make/Makefile && \ ! test -f $HOTSPOT_TOPDIR/makefiles/Makefile; then - { { $as_echo "$as_me:$LINENO: error: You have to override hotspot with a full hotspot repo!" >&5 -$as_echo "$as_me: error: You have to override hotspot with a full hotspot repo!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You have to override hotspot with a full hotspot repo!" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: checking if hotspot should be overridden" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if hotspot should be overridden" >&5 $as_echo_n "checking if hotspot should be overridden... " >&6; } - { $as_echo "$as_me:$LINENO: result: yes with $HOTSPOT_TOPDIR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes with $HOTSPOT_TOPDIR" >&5 $as_echo "yes with $HOTSPOT_TOPDIR" >&6; } fi if test "x$with_override_jdk" != x; then @@ -15462,13 +15625,11 @@ if test "x$with_override_jdk" != x; then JDK_TOPDIR="`pwd`" cd "$CURDIR" if ! test -f $JDK_TOPDIR/makefiles/Makefile; then - { { $as_echo "$as_me:$LINENO: error: You have to override JDK with a full JDK repo!" >&5 -$as_echo "$as_me: error: You have to override JDK with a full JDK repo!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You have to override JDK with a full JDK repo!" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: checking if JDK should be overridden" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if JDK should be overridden" >&5 $as_echo_n "checking if JDK should be overridden... " >&6; } - { $as_echo "$as_me:$LINENO: result: yes with $JDK_TOPDIR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes with $JDK_TOPDIR" >&5 $as_echo "yes with $JDK_TOPDIR" >&6; } fi @@ -15483,7 +15644,7 @@ BUILD_HOTSPOT=true # Check whether --with-import-hotspot was given. -if test "${with_import_hotspot+set}" = set; then +if test "${with_import_hotspot+set}" = set; then : withval=$with_import_hotspot; fi @@ -15493,13 +15654,11 @@ if test "x$with_import_hotspot" != x; then HOTSPOT_DIST="`pwd`" cd "$CURDIR" if ! (test -d $HOTSPOT_DIST/lib && test -d $HOTSPOT_DIST/jre/lib); then - { { $as_echo "$as_me:$LINENO: error: You have to import hotspot from a full jdk image or hotspot build dist dir!" >&5 -$as_echo "$as_me: error: You have to import hotspot from a full jdk image or hotspot build dist dir!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "You have to import hotspot from a full jdk image or hotspot build dist dir!" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: checking if hotspot should be imported" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if hotspot should be imported" >&5 $as_echo_n "checking if hotspot should be imported... " >&6; } - { $as_echo "$as_me:$LINENO: result: yes from $HOTSPOT_DIST" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes from $HOTSPOT_DIST" >&5 $as_echo "yes from $HOTSPOT_DIST" >&6; } BUILD_HOTSPOT=false fi @@ -15548,9 +15707,9 @@ if test "x$OPENJDK_TARGET_OS" = "xwindows"; then # VS linker. This must be done before changing the PATH when looking for VS. # Extract the first word of "link", so it can be a program name with args. set dummy link; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CYGWIN_LINK+set}" = set; then +if test "${ac_cv_path_CYGWIN_LINK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CYGWIN_LINK in @@ -15563,14 +15722,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CYGWIN_LINK="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -15578,23 +15737,23 @@ esac fi CYGWIN_LINK=$ac_cv_path_CYGWIN_LINK if test -n "$CYGWIN_LINK"; then - { $as_echo "$as_me:$LINENO: result: $CYGWIN_LINK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGWIN_LINK" >&5 $as_echo "$CYGWIN_LINK" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$CYGWIN_LINK" != x; then - { $as_echo "$as_me:$LINENO: checking if the first found link.exe is actually the Cygwin link tool" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the first found link.exe is actually the Cygwin link tool" >&5 $as_echo_n "checking if the first found link.exe is actually the Cygwin link tool... " >&6; } "$CYGWIN_LINK" --version > /dev/null if test $? -eq 0 ; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # This might be the VS linker. Don't exclude it later on. CYGWIN_LINK="" @@ -15628,13 +15787,13 @@ $as_echo "no" >&6; } if test -d "$VS100BASE"; then if test -f "$VS100BASE/$VCVARSFILE"; then - { $as_echo "$as_me:$LINENO: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} VS_ENV_CMD="$VS100BASE/$VCVARSFILE" else - { $as_echo "$as_me:$LINENO: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - { $as_echo "$as_me:$LINENO: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} fi fi @@ -15645,13 +15804,11 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi if test "x$with_toolsdir" != x && test "x$VS_ENV_CMD" = x; then # Having specified an argument which is incorrect will produce an instant failure; # we should not go on looking - { $as_echo "$as_me:$LINENO: The path given by --with-tools-dir does not contain a valid Visual Studio installation" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path given by --with-tools-dir does not contain a valid Visual Studio installation" >&5 $as_echo "$as_me: The path given by --with-tools-dir does not contain a valid Visual Studio installation" >&6;} - { $as_echo "$as_me:$LINENO: Please point to the VC/bin directory within the Visual Studio installation" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Please point to the VC/bin directory within the Visual Studio installation" >&5 $as_echo "$as_me: Please point to the VC/bin directory within the Visual Studio installation" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate a valid Visual Studio installation" >&5 -$as_echo "$as_me: error: Cannot locate a valid Visual Studio installation" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate a valid Visual Studio installation" "$LINENO" 5 fi if test "x$ProgramW6432" != x; then @@ -15671,7 +15828,7 @@ $as_echo "$as_me: error: Cannot locate a valid Visual Studio installation" >&2;} if test -d "$WIN_SDK_BASE"; then if test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then - { $as_echo "$as_me:$LINENO: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;} VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd" if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then @@ -15680,9 +15837,9 @@ $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" VS_ENV_ARGS="/x64" fi else - { $as_echo "$as_me:$LINENO: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;} - { $as_echo "$as_me:$LINENO: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&5 $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&6;} fi fi @@ -15706,7 +15863,7 @@ $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignori if test -d "$WIN_SDK_BASE"; then if test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then - { $as_echo "$as_me:$LINENO: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;} VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd" if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then @@ -15715,9 +15872,9 @@ $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" VS_ENV_ARGS="/x64" fi else - { $as_echo "$as_me:$LINENO: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;} - { $as_echo "$as_me:$LINENO: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&5 $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&6;} fi fi @@ -15741,7 +15898,7 @@ $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignori if test -d "$WIN_SDK_BASE"; then if test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then - { $as_echo "$as_me:$LINENO: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;} VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd" if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then @@ -15750,9 +15907,9 @@ $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" VS_ENV_ARGS="/x64" fi else - { $as_echo "$as_me:$LINENO: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;} - { $as_echo "$as_me:$LINENO: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&5 $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&6;} fi fi @@ -15775,7 +15932,7 @@ $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignori if test -d "$WIN_SDK_BASE"; then if test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then - { $as_echo "$as_me:$LINENO: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;} VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd" if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then @@ -15784,9 +15941,9 @@ $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" VS_ENV_ARGS="/x64" fi else - { $as_echo "$as_me:$LINENO: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;} - { $as_echo "$as_me:$LINENO: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&5 $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&6;} fi fi @@ -15808,7 +15965,7 @@ $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignori if test -d "$WIN_SDK_BASE"; then if test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then - { $as_echo "$as_me:$LINENO: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;} VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd" if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then @@ -15817,9 +15974,9 @@ $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" VS_ENV_ARGS="/x64" fi else - { $as_echo "$as_me:$LINENO: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;} - { $as_echo "$as_me:$LINENO: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&5 $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring" >&6;} fi fi @@ -15843,13 +16000,13 @@ $as_echo "$as_me: Warning: Installation is broken, SetEnv.Cmd is missing. Ignori if test -d "$VS100BASE"; then if test -f "$VS100BASE/$VCVARSFILE"; then - { $as_echo "$as_me:$LINENO: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} VS_ENV_CMD="$VS100BASE/$VCVARSFILE" else - { $as_echo "$as_me:$LINENO: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - { $as_echo "$as_me:$LINENO: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} fi fi @@ -15873,13 +16030,13 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi if test -d "$VS100BASE"; then if test -f "$VS100BASE/$VCVARSFILE"; then - { $as_echo "$as_me:$LINENO: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} VS_ENV_CMD="$VS100BASE/$VCVARSFILE" else - { $as_echo "$as_me:$LINENO: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - { $as_echo "$as_me:$LINENO: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} fi fi @@ -15902,13 +16059,13 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi if test -d "$VS100BASE"; then if test -f "$VS100BASE/$VCVARSFILE"; then - { $as_echo "$as_me:$LINENO: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} VS_ENV_CMD="$VS100BASE/$VCVARSFILE" else - { $as_echo "$as_me:$LINENO: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - { $as_echo "$as_me:$LINENO: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} fi fi @@ -15930,13 +16087,13 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi if test -d "$VS100BASE"; then if test -f "$VS100BASE/$VCVARSFILE"; then - { $as_echo "$as_me:$LINENO: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} VS_ENV_CMD="$VS100BASE/$VCVARSFILE" else - { $as_echo "$as_me:$LINENO: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;} - { $as_echo "$as_me:$LINENO: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} fi fi @@ -15986,16 +16143,14 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of VS_ENV_CMD, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of VS_ENV_CMD, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of VS_ENV_CMD, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of VS_ENV_CMD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of VS_ENV_CMD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of VS_ENV_CMD" "$LINENO" 5 fi fi @@ -16015,13 +16170,11 @@ $as_echo "$as_me: error: Cannot locate the the path of VS_ENV_CMD" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of VS_ENV_CMD, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of VS_ENV_CMD, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of VS_ENV_CMD, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of VS_ENV_CMD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of VS_ENV_CMD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of VS_ENV_CMD" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -16113,16 +16266,14 @@ $as_echo "$as_me: error: Cannot locate the the path of VS_ENV_CMD" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of VS_ENV_CMD, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of VS_ENV_CMD, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of VS_ENV_CMD, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of VS_ENV_CMD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of VS_ENV_CMD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of VS_ENV_CMD" "$LINENO" 5 fi fi @@ -16177,20 +16328,18 @@ $as_echo "$as_me: error: Cannot locate the the path of VS_ENV_CMD" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving VS_ENV_CMD (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving VS_ENV_CMD (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving VS_ENV_CMD (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of VS_ENV_CMD, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of VS_ENV_CMD, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of VS_ENV_CMD, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of VS_ENV_CMD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of VS_ENV_CMD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of VS_ENV_CMD" "$LINENO" 5 fi fi fi @@ -16204,13 +16353,13 @@ $as_echo "$as_me: error: Cannot locate the the path of VS_ENV_CMD" >&2;} if test "x$complete" != "x$new_complete"; then VS_ENV_CMD="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting VS_ENV_CMD to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting VS_ENV_CMD to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting VS_ENV_CMD to \"$new_complete\"" >&6;} fi # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat - { $as_echo "$as_me:$LINENO: Trying to extract Visual Studio environment variables" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Trying to extract Visual Studio environment variables" >&5 $as_echo "$as_me: Trying to extract Visual Studio environment variables" >&6;} cd $OUTPUT_ROOT # FIXME: The code betweeen ---- was inlined from a separate script and is not properly adapted @@ -16251,43 +16400,39 @@ $as_echo "$as_me: Trying to extract Visual Studio environment variables" >&6;} #---- cd $CURDIR if test ! -s $OUTPUT_ROOT/localdevenv.sh; then - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - { $as_echo "$as_me:$LINENO: Could not succesfully extract the envionment variables needed for the VS setup." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not succesfully extract the envionment variables needed for the VS setup." >&5 $as_echo "$as_me: Could not succesfully extract the envionment variables needed for the VS setup." >&6;} - { $as_echo "$as_me:$LINENO: Try setting --with-tools-dir to the VC/bin directory within the VS installation" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Try setting --with-tools-dir to the VC/bin directory within the VS installation" >&5 $as_echo "$as_me: Try setting --with-tools-dir to the VC/bin directory within the VS installation" >&6;} - { $as_echo "$as_me:$LINENO: or run \"bash.exe -l\" from a VS command prompt and then run configure from there." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: or run \"bash.exe -l\" from a VS command prompt and then run configure from there." >&5 $as_echo "$as_me: or run \"bash.exe -l\" from a VS command prompt and then run configure from there." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi # Now set all paths and other env variables. This will allow the rest of # the configure script to find and run the compiler in the proper way. - { $as_echo "$as_me:$LINENO: Setting extracted environment variables" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Setting extracted environment variables" >&5 $as_echo "$as_me: Setting extracted environment variables" >&6;} . $OUTPUT_ROOT/localdevenv.sh else # We did not find a vsvars bat file, let's hope we are run from a VS command prompt. - { $as_echo "$as_me:$LINENO: Cannot locate a valid Visual Studio installation, checking current environment" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Cannot locate a valid Visual Studio installation, checking current environment" >&5 $as_echo "$as_me: Cannot locate a valid Visual Studio installation, checking current environment" >&6;} fi # At this point, we should have corrent variables in the environment, or we can't continue. - { $as_echo "$as_me:$LINENO: checking for Visual Studio variables" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Visual Studio variables" >&5 $as_echo_n "checking for Visual Studio variables... " >&6; } if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then if test "x$INCLUDE" = x || test "x$LIB" = x; then - { $as_echo "$as_me:$LINENO: result: present but broken" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: present but broken" >&5 $as_echo "present but broken" >&6; } - { { $as_echo "$as_me:$LINENO: error: Your VC command prompt seems broken, INCLUDE and/or LIB is missing." >&5 -$as_echo "$as_me: error: Your VC command prompt seems broken, INCLUDE and/or LIB is missing." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Your VC command prompt seems broken, INCLUDE and/or LIB is missing." "$LINENO" 5 else - { $as_echo "$as_me:$LINENO: result: ok" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } VS_INCLUDE="$INCLUDE" VS_LIB="$LIB" @@ -16297,32 +16442,30 @@ $as_echo "ok" >&6; } fi else - { $as_echo "$as_me:$LINENO: result: not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } if test "x$VS_ENV_CMD" = x; then - { $as_echo "$as_me:$LINENO: Cannot locate a valid Visual Studio or Windows SDK installation on disk," >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Cannot locate a valid Visual Studio or Windows SDK installation on disk," >&5 $as_echo "$as_me: Cannot locate a valid Visual Studio or Windows SDK installation on disk," >&6;} - { $as_echo "$as_me:$LINENO: nor is this script run from a Visual Studio command prompt." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: nor is this script run from a Visual Studio command prompt." >&5 $as_echo "$as_me: nor is this script run from a Visual Studio command prompt." >&6;} else - { $as_echo "$as_me:$LINENO: Running the extraction script failed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Running the extraction script failed." >&5 $as_echo "$as_me: Running the extraction script failed." >&6;} fi - { $as_echo "$as_me:$LINENO: Try setting --with-tools-dir to the VC/bin directory within the VS installation" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Try setting --with-tools-dir to the VC/bin directory within the VS installation" >&5 $as_echo "$as_me: Try setting --with-tools-dir to the VC/bin directory within the VS installation" >&6;} - { $as_echo "$as_me:$LINENO: or run \"bash.exe -l\" from a VS command prompt and then run configure from there." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: or run \"bash.exe -l\" from a VS command prompt and then run configure from there." >&5 $as_echo "$as_me: or run \"bash.exe -l\" from a VS command prompt and then run configure from there." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot continue" >&5 -$as_echo "$as_me: error: Cannot continue" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: checking for msvcr100.dll" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for msvcr100.dll" >&5 $as_echo_n "checking for msvcr100.dll... " >&6; } # Check whether --with-msvcr-dll was given. -if test "${with_msvcr_dll+set}" = set; then +if test "${with_msvcr_dll+set}" = set; then : withval=$with_msvcr_dll; fi @@ -16339,29 +16482,27 @@ fi fi fi if test "x$MSVCR_DLL" != x; then - { $as_echo "$as_me:$LINENO: msvcr100.dll found in VCINSTALLDIR: $VCINSTALLDIR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: msvcr100.dll found in VCINSTALLDIR: $VCINSTALLDIR" >&5 $as_echo "$as_me: msvcr100.dll found in VCINSTALLDIR: $VCINSTALLDIR" >&6;} else - { $as_echo "$as_me:$LINENO: Warning: msvcr100.dll not found in VCINSTALLDIR: $VCINSTALLDIR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: msvcr100.dll not found in VCINSTALLDIR: $VCINSTALLDIR" >&5 $as_echo "$as_me: Warning: msvcr100.dll not found in VCINSTALLDIR: $VCINSTALLDIR" >&6;} fi fi if test "x$MSVCR_DLL" = x; then if test -f "$SYSTEMROOT/system32/msvcr100.dll"; then - { $as_echo "$as_me:$LINENO: msvcr100.dll found in $SYSTEMROOT/system32" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: msvcr100.dll found in $SYSTEMROOT/system32" >&5 $as_echo "$as_me: msvcr100.dll found in $SYSTEMROOT/system32" >&6;} MSVCR_DLL="$SYSTEMROOT/system32/msvcr100.dll" fi fi fi if test "x$MSVCR_DLL" = x; then - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - { { $as_echo "$as_me:$LINENO: error: Could not find msvcr100.dll !" >&5 -$as_echo "$as_me: error: Could not find msvcr100.dll !" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find msvcr100.dll !" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: result: $MSVCR_DLL" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVCR_DLL" >&5 $as_echo "$MSVCR_DLL" >&6; } if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -16380,11 +16521,9 @@ $as_echo "$MSVCR_DLL" >&6; } # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of MSVCR_DLL, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MSVCR_DLL, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of MSVCR_DLL, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of MSVCR_DLL" >&5 -$as_echo "$as_me: error: Cannot locate the the path of MSVCR_DLL" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of MSVCR_DLL" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -16423,7 +16562,7 @@ $as_echo "$as_me: error: Cannot locate the the path of MSVCR_DLL" >&2;} if test "x$path" != "x$new_path"; then MSVCR_DLL="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting MSVCR_DLL to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting MSVCR_DLL to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting MSVCR_DLL to \"$new_path\"" >&6;} fi @@ -16461,7 +16600,7 @@ $as_echo "$as_me: Rewriting MSVCR_DLL to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then MSVCR_DLL="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting MSVCR_DLL to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting MSVCR_DLL to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting MSVCR_DLL to \"$new_path\"" >&6;} fi @@ -16473,18 +16612,14 @@ $as_echo "$as_me: Rewriting MSVCR_DLL to \"$new_path\"" >&6;} path="$MSVCR_DLL" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of MSVCR_DLL, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of MSVCR_DLL, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of MSVCR_DLL, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of MSVCR_DLL, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MSVCR_DLL, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of MSVCR_DLL, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi @@ -16514,9 +16649,9 @@ if test "x$COMPILE_TYPE" = "xcross"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BUILD_CC+set}" = set; then +if test "${ac_cv_path_BUILD_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_CC in @@ -16529,14 +16664,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_BUILD_CC="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -16544,10 +16679,10 @@ esac fi BUILD_CC=$ac_cv_path_BUILD_CC if test -n "$BUILD_CC"; then - { $as_echo "$as_me:$LINENO: result: $BUILD_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_CC" >&5 $as_echo "$BUILD_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -16596,16 +16731,14 @@ done fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of BUILD_CC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_CC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of BUILD_CC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_CC" "$LINENO" 5 fi fi @@ -16625,13 +16758,11 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_CC" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of BUILD_CC, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_CC, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of BUILD_CC, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_CC" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -16723,16 +16854,14 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_CC" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of BUILD_CC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_CC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of BUILD_CC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_CC" "$LINENO" 5 fi fi @@ -16787,20 +16916,18 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_CC" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving BUILD_CC (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving BUILD_CC (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving BUILD_CC (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of BUILD_CC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_CC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of BUILD_CC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_CC" "$LINENO" 5 fi fi fi @@ -16814,7 +16941,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_CC" >&2;} if test "x$complete" != "x$new_complete"; then BUILD_CC="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting BUILD_CC to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BUILD_CC to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting BUILD_CC to \"$new_complete\"" >&6;} fi @@ -16822,9 +16949,9 @@ $as_echo "$as_me: Rewriting BUILD_CC to \"$new_complete\"" >&6;} do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BUILD_CXX+set}" = set; then +if test "${ac_cv_path_BUILD_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_CXX in @@ -16837,14 +16964,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_BUILD_CXX="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -16852,10 +16979,10 @@ esac fi BUILD_CXX=$ac_cv_path_BUILD_CXX if test -n "$BUILD_CXX"; then - { $as_echo "$as_me:$LINENO: result: $BUILD_CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_CXX" >&5 $as_echo "$BUILD_CXX" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -16904,16 +17031,14 @@ done fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of BUILD_CXX, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_CXX, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of BUILD_CXX, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_CXX" "$LINENO" 5 fi fi @@ -16933,13 +17058,11 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_CXX" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of BUILD_CXX, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_CXX, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of BUILD_CXX, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_CXX" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -17031,16 +17154,14 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_CXX" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of BUILD_CXX, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_CXX, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of BUILD_CXX, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_CXX" "$LINENO" 5 fi fi @@ -17095,20 +17216,18 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_CXX" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving BUILD_CXX (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving BUILD_CXX (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving BUILD_CXX (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of BUILD_CXX, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_CXX, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of BUILD_CXX, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_CXX" "$LINENO" 5 fi fi fi @@ -17122,15 +17241,15 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_CXX" >&2;} if test "x$complete" != "x$new_complete"; then BUILD_CXX="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting BUILD_CXX to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BUILD_CXX to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting BUILD_CXX to \"$new_complete\"" >&6;} fi # Extract the first word of "ld", so it can be a program name with args. set dummy ld; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BUILD_LD+set}" = set; then +if test "${ac_cv_path_BUILD_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_LD in @@ -17143,14 +17262,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_BUILD_LD="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -17158,10 +17277,10 @@ esac fi BUILD_LD=$ac_cv_path_BUILD_LD if test -n "$BUILD_LD"; then - { $as_echo "$as_me:$LINENO: result: $BUILD_LD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_LD" >&5 $as_echo "$BUILD_LD" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -17207,16 +17326,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of BUILD_LD, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_LD, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of BUILD_LD, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_LD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_LD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_LD" "$LINENO" 5 fi fi @@ -17236,13 +17353,11 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_LD" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of BUILD_LD, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_LD, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of BUILD_LD, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_LD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_LD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_LD" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -17334,16 +17449,14 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_LD" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of BUILD_LD, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_LD, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of BUILD_LD, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_LD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_LD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_LD" "$LINENO" 5 fi fi @@ -17398,20 +17511,18 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_LD" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving BUILD_LD (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving BUILD_LD (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving BUILD_LD (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of BUILD_LD, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BUILD_LD, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of BUILD_LD, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of BUILD_LD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of BUILD_LD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of BUILD_LD" "$LINENO" 5 fi fi fi @@ -17425,7 +17536,7 @@ $as_echo "$as_me: error: Cannot locate the the path of BUILD_LD" >&2;} if test "x$complete" != "x$new_complete"; then BUILD_LD="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting BUILD_LD to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BUILD_LD to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting BUILD_LD to \"$new_complete\"" >&6;} fi @@ -17459,7 +17570,7 @@ DEVKIT= resource=${builddep_devkit} fi if test "x$resource" != x; then - { $as_echo "$as_me:$LINENO: Using builddeps $resource for devkit" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Using builddeps $resource for devkit" >&5 $as_echo "$as_me: Using builddeps $resource for devkit" >&6;} # If the resource in the builddeps.conf file is an existing directory, # for example /java/linux/cups @@ -17480,22 +17591,18 @@ $as_echo "$as_me: Using builddeps $resource for devkit" >&6;} extension=${filename#*.} installdir=$with_builddeps_dir/$filebase if test ! -f $installdir/$filename.unpacked; then - { $as_echo "$as_me:$LINENO: Downloading build dependency devkit from $with_builddeps_server/$resource and installing into $installdir" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Downloading build dependency devkit from $with_builddeps_server/$resource and installing into $installdir" >&5 $as_echo "$as_me: Downloading build dependency devkit from $with_builddeps_server/$resource and installing into $installdir" >&6;} if test ! -d $installdir; then mkdir -p $installdir fi if test ! -d $installdir; then - { { $as_echo "$as_me:$LINENO: error: Could not create directory $installdir" >&5 -$as_echo "$as_me: error: Could not create directory $installdir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create directory $installdir" "$LINENO" 5 fi tmpfile=`mktemp $installdir/devkit.XXXXXXXXX` touch $tmpfile if test ! -f $tmpfile; then - { { $as_echo "$as_me:$LINENO: error: Could not create files in directory $installdir" >&5 -$as_echo "$as_me: error: Could not create files in directory $installdir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create files in directory $installdir" "$LINENO" 5 fi # $with_builddeps_server/$resource is the ftp://abuilddeps.server.com/libs/cups.zip @@ -17533,16 +17640,12 @@ $as_echo "$as_me: error: Could not create files in directory $installdir" >&2;} ) | ftp -in $FTPSERVER fi if test "x$VALID_TOOL" != xyes; then - { { $as_echo "$as_me:$LINENO: error: I do not know how to use the tool: $BDEPS_FTP" >&5 -$as_echo "$as_me: error: I do not know how to use the tool: $BDEPS_FTP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "I do not know how to use the tool: $BDEPS_FTP" "$LINENO" 5 fi mv $tmpfile $installdir/$filename if test ! -s $installdir/$filename; then - { { $as_echo "$as_me:$LINENO: error: Could not download $with_builddeps_server/$resource" >&5 -$as_echo "$as_me: error: Could not download $with_builddeps_server/$resource" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not download $with_builddeps_server/$resource" "$LINENO" 5 fi case "$extension" in zip) echo "Unzipping $installdir/$filename..." @@ -17554,9 +17657,7 @@ $as_echo "$as_me: error: Could not download $with_builddeps_server/$resource" >& tgz) echo "Untaring $installdir/$filename..." (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked) ;; - *) { { $as_echo "$as_me:$LINENO: error: Cannot handle build depency archive with extension $extension" >&5 -$as_echo "$as_me: error: Cannot handle build depency archive with extension $extension" >&2;} - { (exit 1); exit 1; }; } + *) as_fn_error $? "Cannot handle build depency archive with extension $extension" "$LINENO" 5 ;; esac fi @@ -17573,9 +17674,7 @@ $as_echo "$as_me: error: Cannot handle build depency archive with extension $ext thecflags=${builddep_devkit_CFLAGS} thelibs=${builddep_devkit_LIBS} if test "x$depdir" = x; then - { { $as_echo "$as_me:$LINENO: error: Could not download build dependency devkit" >&5 -$as_echo "$as_me: error: Could not download build dependency devkit" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not download build dependency devkit" "$LINENO" 5 fi DEVKIT=$depdir if test "x$theroot" != x; then @@ -17646,9 +17745,9 @@ fi do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_POTENTIAL_CC+set}" = set; then +if test "${ac_cv_path_POTENTIAL_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CC in @@ -17661,14 +17760,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_POTENTIAL_CC="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -17676,10 +17775,10 @@ esac fi POTENTIAL_CC=$ac_cv_path_POTENTIAL_CC if test -n "$POTENTIAL_CC"; then - { $as_echo "$as_me:$LINENO: result: $POTENTIAL_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $POTENTIAL_CC" >&5 $as_echo "$POTENTIAL_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -17715,9 +17814,7 @@ done HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." fi - { { $as_echo "$as_me:$LINENO: error: Could not find a $COMPILER_NAME compiler. $HELP_MSG" >&5 -$as_echo "$as_me: error: Could not find a $COMPILER_NAME compiler. $HELP_MSG" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find a $COMPILER_NAME compiler. $HELP_MSG" "$LINENO" 5 fi if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -17760,16 +17857,14 @@ $as_echo "$as_me: error: Could not find a $COMPILER_NAME compiler. $HELP_MSG" >& fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of CC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CC" "$LINENO" 5 fi fi @@ -17789,13 +17884,11 @@ $as_echo "$as_me: error: Cannot locate the the path of CC" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of CC, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CC, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of CC, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CC" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -17887,16 +17980,14 @@ $as_echo "$as_me: error: Cannot locate the the path of CC" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of CC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CC" "$LINENO" 5 fi fi @@ -17951,20 +18042,18 @@ $as_echo "$as_me: error: Cannot locate the the path of CC" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving CC (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving CC (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving CC (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of CC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CC" "$LINENO" 5 fi fi fi @@ -17978,11 +18067,11 @@ $as_echo "$as_me: error: Cannot locate the the path of CC" >&2;} if test "x$complete" != "x$new_complete"; then CC="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting CC to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting CC to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting CC to \"$new_complete\"" >&6;} fi - { $as_echo "$as_me:$LINENO: checking resolved symbolic links for CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking resolved symbolic links for CC" >&5 $as_echo_n "checking resolved symbolic links for CC... " >&6; } TEST_COMPILER="$CC" @@ -18029,14 +18118,14 @@ $as_echo_n "checking resolved symbolic links for CC... " >&6; } fi fi - { $as_echo "$as_me:$LINENO: result: $TEST_COMPILER" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TEST_COMPILER" >&5 $as_echo "$TEST_COMPILER" >&6; } - { $as_echo "$as_me:$LINENO: checking if CC is disguised ccache" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CC is disguised ccache" >&5 $as_echo_n "checking if CC is disguised ccache... " >&6; } COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"` if test "x$COMPILER_BASENAME" = "xccache"; then - { $as_echo "$as_me:$LINENO: result: yes, trying to find proper $COMPILER_NAME compiler" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, trying to find proper $COMPILER_NAME compiler" >&5 $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache. # We want to control ccache invocation ourselves, so ignore this cc and try @@ -18053,9 +18142,9 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PROPER_COMPILER_CC+set}" = set; then +if test "${ac_cv_prog_PROPER_COMPILER_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CC"; then @@ -18066,24 +18155,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PROPER_COMPILER_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi PROPER_COMPILER_CC=$ac_cv_prog_PROPER_COMPILER_CC if test -n "$PROPER_COMPILER_CC"; then - { $as_echo "$as_me:$LINENO: result: $PROPER_COMPILER_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PROPER_COMPILER_CC" >&5 $as_echo "$PROPER_COMPILER_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -18097,9 +18186,9 @@ if test -z "$PROPER_COMPILER_CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CC"; then @@ -18110,24 +18199,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_PROPER_COMPILER_CC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_PROPER_COMPILER_CC=$ac_cv_prog_ac_ct_PROPER_COMPILER_CC if test -n "$ac_ct_PROPER_COMPILER_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_PROPER_COMPILER_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_PROPER_COMPILER_CC" >&5 $as_echo "$ac_ct_PROPER_COMPILER_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -18140,7 +18229,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -18189,16 +18278,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of PROPER_COMPILER_CC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of PROPER_COMPILER_CC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of PROPER_COMPILER_CC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of PROPER_COMPILER_CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of PROPER_COMPILER_CC" "$LINENO" 5 fi fi @@ -18218,13 +18305,11 @@ $as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CC" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of PROPER_COMPILER_CC, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of PROPER_COMPILER_CC, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of PROPER_COMPILER_CC, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of PROPER_COMPILER_CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of PROPER_COMPILER_CC" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -18316,16 +18401,14 @@ $as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CC" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of PROPER_COMPILER_CC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of PROPER_COMPILER_CC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of PROPER_COMPILER_CC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of PROPER_COMPILER_CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of PROPER_COMPILER_CC" "$LINENO" 5 fi fi @@ -18380,20 +18463,18 @@ $as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CC" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving PROPER_COMPILER_CC (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving PROPER_COMPILER_CC (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving PROPER_COMPILER_CC (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of PROPER_COMPILER_CC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of PROPER_COMPILER_CC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of PROPER_COMPILER_CC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of PROPER_COMPILER_CC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of PROPER_COMPILER_CC" "$LINENO" 5 fi fi fi @@ -18407,13 +18488,13 @@ $as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CC" >&2;} if test "x$complete" != "x$new_complete"; then PROPER_COMPILER_CC="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting PROPER_COMPILER_CC to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting PROPER_COMPILER_CC to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting PROPER_COMPILER_CC to \"$new_complete\"" >&6;} fi PATH="$RETRY_COMPILER_SAVED_PATH" - { $as_echo "$as_me:$LINENO: checking for resolved symbolic links for CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for resolved symbolic links for CC" >&5 $as_echo_n "checking for resolved symbolic links for CC... " >&6; } if test "x$OPENJDK_BUILD_OS" != xwindows; then @@ -18459,11 +18540,11 @@ $as_echo_n "checking for resolved symbolic links for CC... " >&6; } fi fi - { $as_echo "$as_me:$LINENO: result: $PROPER_COMPILER_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PROPER_COMPILER_CC" >&5 $as_echo "$PROPER_COMPILER_CC" >&6; } CC="$PROPER_COMPILER_CC" else - { $as_echo "$as_me:$LINENO: result: no, keeping CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, keeping CC" >&5 $as_echo "no, keeping CC" >&6; } CC="$TEST_COMPILER" fi @@ -18478,13 +18559,11 @@ $as_echo "no, keeping CC" >&6; } if test $? -ne 0; then GCC_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1` - { $as_echo "$as_me:$LINENO: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler." >&5 $as_echo "$as_me: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler." >&6;} - { $as_echo "$as_me:$LINENO: The result from running with -V was: \"$COMPILER_VERSION_TEST\" and with --version: \"$GCC_VERSION_TEST\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The result from running with -V was: \"$COMPILER_VERSION_TEST\" and with --version: \"$GCC_VERSION_TEST\"" >&5 $as_echo "$as_me: The result from running with -V was: \"$COMPILER_VERSION_TEST\" and with --version: \"$GCC_VERSION_TEST\"" >&6;} - { { $as_echo "$as_me:$LINENO: error: Sun Studio compiler is required. Try setting --with-tools-dir." >&5 -$as_echo "$as_me: error: Sun Studio compiler is required. Try setting --with-tools-dir." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Sun Studio compiler is required. Try setting --with-tools-dir." "$LINENO" 5 else COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*[ ,\t]$COMPILER_NAME[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p"` COMPILER_VENDOR="Sun Studio" @@ -18498,15 +18577,11 @@ $as_echo "$as_me: error: Sun Studio compiler is required. Try setting --with-too COMPILER_CPU_TEST=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* for \(.*\)$/\1/p"` if test "x$OPENJDK_TARGET_CPU" = "xx86"; then if test "x$COMPILER_CPU_TEST" != "x80x86"; then - { { $as_echo "$as_me:$LINENO: error: Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"80x86\"." >&5 -$as_echo "$as_me: error: Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"80x86\"." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"80x86\"." "$LINENO" 5 fi elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then if test "x$COMPILER_CPU_TEST" != "xx64"; then - { { $as_echo "$as_me:$LINENO: error: Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"x64\"." >&5 -$as_echo "$as_me: error: Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"x64\"." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"x64\"." "$LINENO" 5 fi fi else @@ -18514,13 +18589,11 @@ $as_echo "$as_me: error: Target CPU mismatch. We are building for $OPENJDK_TARGE # Check that this is likely to be GCC. $COMPILER --version 2>&1 | $GREP "Free Software Foundation" > /dev/null if test $? -ne 0; then - { $as_echo "$as_me:$LINENO: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler." >&5 $as_echo "$as_me: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler." >&6;} - { $as_echo "$as_me:$LINENO: The result from running with --version was: \"$COMPILER_VERSION_TEST\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The result from running with --version was: \"$COMPILER_VERSION_TEST\"" >&5 $as_echo "$as_me: The result from running with --version was: \"$COMPILER_VERSION_TEST\"" >&6;} - { { $as_echo "$as_me:$LINENO: error: GCC compiler is required. Try setting --with-tools-dir." >&5 -$as_echo "$as_me: error: GCC compiler is required. Try setting --with-tools-dir." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "GCC compiler is required. Try setting --with-tools-dir." "$LINENO" 5 fi # First line typically looks something like: @@ -18533,7 +18606,7 @@ $as_echo "$as_me: error: GCC compiler is required. Try setting --with-tools-dir. # This sets CC_VENDOR or CXX_VENDOR. (This comment is a grep marker) CC_VENDOR="$COMPILER_VENDOR" - { $as_echo "$as_me:$LINENO: Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)" >&5 $as_echo "$as_me: Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)" >&6;} @@ -18548,9 +18621,9 @@ if test -n "$ac_tool_prefix"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -18561,24 +18634,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -18592,9 +18665,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -18605,24 +18678,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -18635,7 +18708,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -18644,57 +18717,37 @@ esac fi -test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -18710,8 +18763,8 @@ ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: @@ -18727,17 +18780,17 @@ do done rm -f $ac_rmfiles -if { (ac_try="$ac_link_default" +if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, @@ -18754,7 +18807,7 @@ do # certainly right. break;; *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi @@ -18773,84 +18826,41 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi - -{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -if test -z "$ac_file"; then - $as_echo "$as_me: failed program was:" >&5 +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; }; } -fi - -ac_exeext=$ac_cv_exeext - -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } - fi - fi -fi -{ $as_echo "$as_me:$LINENO: result: yes" >&5 +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5 ; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } -if { (ac_try="$ac_link" +if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with @@ -18865,32 +18875,83 @@ for ac_file in conftest.exe conftest conftest.*; do esac done else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5 ; } fi - -rm -f conftest$ac_cv_exeext -{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5 ; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -18902,17 +18963,17 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (ac_try="$ac_compile" +if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in @@ -18925,31 +18986,23 @@ else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5 ; } fi - rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -18963,37 +19016,16 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no + ac_compiler_gnu=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes @@ -19002,20 +19034,16 @@ else fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -19026,35 +19054,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -19065,36 +19069,12 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_compile "$LINENO"; then : - ac_c_werror_flag=$ac_save_c_werror_flag +else + ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -19105,42 +19085,17 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS @@ -19157,18 +19112,14 @@ else CFLAGS= fi fi -{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -19225,32 +19176,9 @@ for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done @@ -19261,17 +19189,19 @@ fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) - { $as_echo "$as_me:$LINENO: result: none needed" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) - { $as_echo "$as_me:$LINENO: result: unsupported" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac +if test "x$ac_cv_prog_cc_c89" != xno; then : +fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -19298,9 +19228,9 @@ fi do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_POTENTIAL_CXX+set}" = set; then +if test "${ac_cv_path_POTENTIAL_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CXX in @@ -19313,14 +19243,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_POTENTIAL_CXX="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -19328,10 +19258,10 @@ esac fi POTENTIAL_CXX=$ac_cv_path_POTENTIAL_CXX if test -n "$POTENTIAL_CXX"; then - { $as_echo "$as_me:$LINENO: result: $POTENTIAL_CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $POTENTIAL_CXX" >&5 $as_echo "$POTENTIAL_CXX" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -19367,9 +19297,7 @@ done HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." fi - { { $as_echo "$as_me:$LINENO: error: Could not find a $COMPILER_NAME compiler. $HELP_MSG" >&5 -$as_echo "$as_me: error: Could not find a $COMPILER_NAME compiler. $HELP_MSG" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find a $COMPILER_NAME compiler. $HELP_MSG" "$LINENO" 5 fi if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -19412,16 +19340,14 @@ $as_echo "$as_me: error: Could not find a $COMPILER_NAME compiler. $HELP_MSG" >& fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of CXX, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CXX, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CXX, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CXX" "$LINENO" 5 fi fi @@ -19441,13 +19367,11 @@ $as_echo "$as_me: error: Cannot locate the the path of CXX" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of CXX, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CXX, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of CXX, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CXX" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -19539,16 +19463,14 @@ $as_echo "$as_me: error: Cannot locate the the path of CXX" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of CXX, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CXX, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CXX, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CXX" "$LINENO" 5 fi fi @@ -19603,20 +19525,18 @@ $as_echo "$as_me: error: Cannot locate the the path of CXX" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving CXX (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving CXX (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving CXX (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of CXX, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CXX, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CXX, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CXX" "$LINENO" 5 fi fi fi @@ -19630,11 +19550,11 @@ $as_echo "$as_me: error: Cannot locate the the path of CXX" >&2;} if test "x$complete" != "x$new_complete"; then CXX="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting CXX to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting CXX to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting CXX to \"$new_complete\"" >&6;} fi - { $as_echo "$as_me:$LINENO: checking resolved symbolic links for CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking resolved symbolic links for CXX" >&5 $as_echo_n "checking resolved symbolic links for CXX... " >&6; } TEST_COMPILER="$CXX" @@ -19681,14 +19601,14 @@ $as_echo_n "checking resolved symbolic links for CXX... " >&6; } fi fi - { $as_echo "$as_me:$LINENO: result: $TEST_COMPILER" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TEST_COMPILER" >&5 $as_echo "$TEST_COMPILER" >&6; } - { $as_echo "$as_me:$LINENO: checking if CXX is disguised ccache" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CXX is disguised ccache" >&5 $as_echo_n "checking if CXX is disguised ccache... " >&6; } COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"` if test "x$COMPILER_BASENAME" = "xccache"; then - { $as_echo "$as_me:$LINENO: result: yes, trying to find proper $COMPILER_NAME compiler" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, trying to find proper $COMPILER_NAME compiler" >&5 $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache. # We want to control ccache invocation ourselves, so ignore this cc and try @@ -19705,9 +19625,9 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PROPER_COMPILER_CXX+set}" = set; then +if test "${ac_cv_prog_PROPER_COMPILER_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CXX"; then @@ -19718,24 +19638,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PROPER_COMPILER_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi PROPER_COMPILER_CXX=$ac_cv_prog_PROPER_COMPILER_CXX if test -n "$PROPER_COMPILER_CXX"; then - { $as_echo "$as_me:$LINENO: result: $PROPER_COMPILER_CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PROPER_COMPILER_CXX" >&5 $as_echo "$PROPER_COMPILER_CXX" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -19749,9 +19669,9 @@ if test -z "$PROPER_COMPILER_CXX"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+set}" = set; then +if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CXX"; then @@ -19762,24 +19682,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_PROPER_COMPILER_CXX="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_PROPER_COMPILER_CXX=$ac_cv_prog_ac_ct_PROPER_COMPILER_CXX if test -n "$ac_ct_PROPER_COMPILER_CXX"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_PROPER_COMPILER_CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_PROPER_COMPILER_CXX" >&5 $as_echo "$ac_ct_PROPER_COMPILER_CXX" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -19792,7 +19712,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -19841,16 +19761,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of PROPER_COMPILER_CXX, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of PROPER_COMPILER_CXX, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of PROPER_COMPILER_CXX, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of PROPER_COMPILER_CXX" "$LINENO" 5 fi fi @@ -19870,13 +19788,11 @@ $as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&2; elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of PROPER_COMPILER_CXX, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of PROPER_COMPILER_CXX, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of PROPER_COMPILER_CXX, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of PROPER_COMPILER_CXX" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -19968,16 +19884,14 @@ $as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&2; if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of PROPER_COMPILER_CXX, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of PROPER_COMPILER_CXX, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of PROPER_COMPILER_CXX, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of PROPER_COMPILER_CXX" "$LINENO" 5 fi fi @@ -20032,20 +19946,18 @@ $as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&2; if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving PROPER_COMPILER_CXX (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving PROPER_COMPILER_CXX (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving PROPER_COMPILER_CXX (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of PROPER_COMPILER_CXX, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of PROPER_COMPILER_CXX, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of PROPER_COMPILER_CXX, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&5 -$as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of PROPER_COMPILER_CXX" "$LINENO" 5 fi fi fi @@ -20059,13 +19971,13 @@ $as_echo "$as_me: error: Cannot locate the the path of PROPER_COMPILER_CXX" >&2; if test "x$complete" != "x$new_complete"; then PROPER_COMPILER_CXX="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting PROPER_COMPILER_CXX to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting PROPER_COMPILER_CXX to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting PROPER_COMPILER_CXX to \"$new_complete\"" >&6;} fi PATH="$RETRY_COMPILER_SAVED_PATH" - { $as_echo "$as_me:$LINENO: checking for resolved symbolic links for CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for resolved symbolic links for CXX" >&5 $as_echo_n "checking for resolved symbolic links for CXX... " >&6; } if test "x$OPENJDK_BUILD_OS" != xwindows; then @@ -20111,11 +20023,11 @@ $as_echo_n "checking for resolved symbolic links for CXX... " >&6; } fi fi - { $as_echo "$as_me:$LINENO: result: $PROPER_COMPILER_CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PROPER_COMPILER_CXX" >&5 $as_echo "$PROPER_COMPILER_CXX" >&6; } CXX="$PROPER_COMPILER_CXX" else - { $as_echo "$as_me:$LINENO: result: no, keeping CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, keeping CXX" >&5 $as_echo "no, keeping CXX" >&6; } CXX="$TEST_COMPILER" fi @@ -20130,13 +20042,11 @@ $as_echo "no, keeping CXX" >&6; } if test $? -ne 0; then GCC_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1` - { $as_echo "$as_me:$LINENO: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler." >&5 $as_echo "$as_me: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler." >&6;} - { $as_echo "$as_me:$LINENO: The result from running with -V was: \"$COMPILER_VERSION_TEST\" and with --version: \"$GCC_VERSION_TEST\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The result from running with -V was: \"$COMPILER_VERSION_TEST\" and with --version: \"$GCC_VERSION_TEST\"" >&5 $as_echo "$as_me: The result from running with -V was: \"$COMPILER_VERSION_TEST\" and with --version: \"$GCC_VERSION_TEST\"" >&6;} - { { $as_echo "$as_me:$LINENO: error: Sun Studio compiler is required. Try setting --with-tools-dir." >&5 -$as_echo "$as_me: error: Sun Studio compiler is required. Try setting --with-tools-dir." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Sun Studio compiler is required. Try setting --with-tools-dir." "$LINENO" 5 else COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*[ ,\t]$COMPILER_NAME[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p"` COMPILER_VENDOR="Sun Studio" @@ -20150,15 +20060,11 @@ $as_echo "$as_me: error: Sun Studio compiler is required. Try setting --with-too COMPILER_CPU_TEST=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* for \(.*\)$/\1/p"` if test "x$OPENJDK_TARGET_CPU" = "xx86"; then if test "x$COMPILER_CPU_TEST" != "x80x86"; then - { { $as_echo "$as_me:$LINENO: error: Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"80x86\"." >&5 -$as_echo "$as_me: error: Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"80x86\"." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"80x86\"." "$LINENO" 5 fi elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then if test "x$COMPILER_CPU_TEST" != "xx64"; then - { { $as_echo "$as_me:$LINENO: error: Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"x64\"." >&5 -$as_echo "$as_me: error: Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"x64\"." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"x64\"." "$LINENO" 5 fi fi else @@ -20166,13 +20072,11 @@ $as_echo "$as_me: error: Target CPU mismatch. We are building for $OPENJDK_TARGE # Check that this is likely to be GCC. $COMPILER --version 2>&1 | $GREP "Free Software Foundation" > /dev/null if test $? -ne 0; then - { $as_echo "$as_me:$LINENO: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler." >&5 $as_echo "$as_me: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler." >&6;} - { $as_echo "$as_me:$LINENO: The result from running with --version was: \"$COMPILER_VERSION_TEST\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The result from running with --version was: \"$COMPILER_VERSION_TEST\"" >&5 $as_echo "$as_me: The result from running with --version was: \"$COMPILER_VERSION_TEST\"" >&6;} - { { $as_echo "$as_me:$LINENO: error: GCC compiler is required. Try setting --with-tools-dir." >&5 -$as_echo "$as_me: error: GCC compiler is required. Try setting --with-tools-dir." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "GCC compiler is required. Try setting --with-tools-dir." "$LINENO" 5 fi # First line typically looks something like: @@ -20185,7 +20089,7 @@ $as_echo "$as_me: error: GCC compiler is required. Try setting --with-tools-dir. # This sets CC_VENDOR or CXX_VENDOR. (This comment is a grep marker) CXX_VENDOR="$COMPILER_VENDOR" - { $as_echo "$as_me:$LINENO: Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)" >&5 $as_echo "$as_me: Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)" >&6;} @@ -20204,9 +20108,9 @@ if test -z "$CXX"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then +if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -20217,24 +20121,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then - { $as_echo "$as_me:$LINENO: result: $CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -20248,9 +20152,9 @@ if test -z "$CXX"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then @@ -20261,24 +20165,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -20291,7 +20195,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -20302,53 +20206,36 @@ fi fi fi # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C++ compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -20362,37 +20249,16 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no + ac_compiler_gnu=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes @@ -20401,20 +20267,16 @@ else fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } -if test "${ac_cv_prog_cxx_g+set}" = set; then +if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -20425,35 +20287,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CXXFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -20464,36 +20302,12 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cxx_werror_flag=$ac_save_cxx_werror_flag +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -20504,42 +20318,17 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS @@ -20576,9 +20365,9 @@ if test -n "$ac_tool_prefix"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJC+set}" = set; then +if test "${ac_cv_prog_OBJC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJC"; then @@ -20589,24 +20378,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi OBJC=$ac_cv_prog_OBJC if test -n "$OBJC"; then - { $as_echo "$as_me:$LINENO: result: $OBJC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJC" >&5 $as_echo "$OBJC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -20620,9 +20409,9 @@ if test -z "$OBJC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJC+set}" = set; then +if test "${ac_cv_prog_ac_ct_OBJC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJC"; then @@ -20633,24 +20422,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_OBJC=$ac_cv_prog_ac_ct_OBJC if test -n "$ac_ct_OBJC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_OBJC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJC" >&5 $as_echo "$ac_ct_OBJC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -20663,7 +20452,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -20672,53 +20461,36 @@ esac fi # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for Objective C compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for Objective C compiler version" >&5 set X $ac_compile ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU Objective C compiler" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Objective C compiler" >&5 $as_echo_n "checking whether we are using the GNU Objective C compiler... " >&6; } -if test "${ac_cv_objc_compiler_gnu+set}" = set; then +if test "${ac_cv_objc_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -20732,37 +20504,16 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_objc_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_objc_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no + ac_compiler_gnu=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_objc_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_objc_compiler_gnu" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objc_compiler_gnu" >&5 $as_echo "$ac_cv_objc_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GOBJC=yes @@ -20771,20 +20522,16 @@ else fi ac_test_OBJCFLAGS=${OBJCFLAGS+set} ac_save_OBJCFLAGS=$OBJCFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $OBJC accepts -g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $OBJC accepts -g" >&5 $as_echo_n "checking whether $OBJC accepts -g... " >&6; } -if test "${ac_cv_prog_objc_g+set}" = set; then +if test "${ac_cv_prog_objc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_objc_werror_flag=$ac_objc_werror_flag ac_objc_werror_flag=yes ac_cv_prog_objc_g=no OBJCFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -20795,35 +20542,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_objc_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_objc_try_compile "$LINENO"; then : ac_cv_prog_objc_g=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - OBJCFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + OBJCFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -20834,36 +20557,12 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_objc_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_objc_try_compile "$LINENO"; then : - ac_objc_werror_flag=$ac_save_objc_werror_flag +else + ac_objc_werror_flag=$ac_save_objc_werror_flag OBJCFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -20874,42 +20573,17 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_objc_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_objc_try_compile "$LINENO"; then : ac_cv_prog_objc_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_objc_werror_flag=$ac_save_objc_werror_flag fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_objc_g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_objc_g" >&5 $as_echo "$ac_cv_prog_objc_g" >&6; } if test "$ac_test_OBJCFLAGS" = set; then OBJCFLAGS=$ac_save_OBJCFLAGS @@ -20973,16 +20647,14 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of OBJC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of OBJC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJC" "$LINENO" 5 fi fi @@ -21002,13 +20674,11 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJC" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of OBJC, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJC, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of OBJC, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJC" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -21100,16 +20770,14 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJC" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of OBJC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of OBJC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJC" "$LINENO" 5 fi fi @@ -21164,20 +20832,18 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJC" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving OBJC (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving OBJC (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving OBJC (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of OBJC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of OBJC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJC" "$LINENO" 5 fi fi fi @@ -21191,7 +20857,7 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJC" >&2;} if test "x$complete" != "x$new_complete"; then OBJC="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting OBJC to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting OBJC to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting OBJC to \"$new_complete\"" >&6;} fi @@ -21221,9 +20887,9 @@ if test "x$OPENJDK_TARGET_OS" != xwindows; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AR+set}" = set; then +if test "${ac_cv_prog_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -21234,24 +20900,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="${ac_tool_prefix}ar" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then - { $as_echo "$as_me:$LINENO: result: $AR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -21261,9 +20927,9 @@ if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_AR+set}" = set; then +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then @@ -21274,24 +20940,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="ar" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -21300,7 +20966,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -21351,16 +21017,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of AR, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of AR, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of AR, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of AR" >&5 -$as_echo "$as_me: error: Cannot locate the the path of AR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of AR" "$LINENO" 5 fi fi @@ -21380,13 +21044,11 @@ $as_echo "$as_me: error: Cannot locate the the path of AR" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of AR, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of AR, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of AR, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of AR" >&5 -$as_echo "$as_me: error: Cannot locate the the path of AR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of AR" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -21478,16 +21140,14 @@ $as_echo "$as_me: error: Cannot locate the the path of AR" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of AR, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of AR, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of AR, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of AR" >&5 -$as_echo "$as_me: error: Cannot locate the the path of AR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of AR" "$LINENO" 5 fi fi @@ -21542,20 +21202,18 @@ $as_echo "$as_me: error: Cannot locate the the path of AR" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving AR (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving AR (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving AR (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of AR, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of AR, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of AR, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of AR" >&5 -$as_echo "$as_me: error: Cannot locate the the path of AR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of AR" "$LINENO" 5 fi fi fi @@ -21569,7 +21227,7 @@ $as_echo "$as_me: error: Cannot locate the the path of AR" >&2;} if test "x$complete" != "x$new_complete"; then AR="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting AR to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting AR to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting AR to \"$new_complete\"" >&6;} fi @@ -21589,7 +21247,7 @@ HOTSPOT_LD="$LD" COMPILER_NAME=gcc COMPILER_TYPE=CC -if test "x$OPENJDK_TARGET_OS" = xwindows; then +if test "x$OPENJDK_TARGET_OS" = xwindows; then : # For now, assume that we are always compiling using cl.exe. CC_OUT_OPTION=-Fo @@ -21600,9 +21258,9 @@ if test "x$OPENJDK_TARGET_OS" = xwindows; then # program for something completely different. # Extract the first word of "link", so it can be a program name with args. set dummy link; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_WINLD+set}" = set; then +if test "${ac_cv_prog_WINLD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$WINLD"; then @@ -21614,18 +21272,18 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "$CYGWIN_LINK"; then ac_prog_rejected=yes continue fi ac_cv_prog_WINLD="link" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then @@ -21644,10 +21302,10 @@ fi fi WINLD=$ac_cv_prog_WINLD if test -n "$WINLD"; then - { $as_echo "$as_me:$LINENO: result: $WINLD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WINLD" >&5 $as_echo "$WINLD" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -21695,16 +21353,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of WINLD, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of WINLD, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of WINLD, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of WINLD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of WINLD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of WINLD" "$LINENO" 5 fi fi @@ -21724,13 +21380,11 @@ $as_echo "$as_me: error: Cannot locate the the path of WINLD" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of WINLD, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of WINLD, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of WINLD, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of WINLD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of WINLD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of WINLD" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -21822,16 +21476,14 @@ $as_echo "$as_me: error: Cannot locate the the path of WINLD" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of WINLD, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of WINLD, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of WINLD, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of WINLD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of WINLD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of WINLD" "$LINENO" 5 fi fi @@ -21886,20 +21538,18 @@ $as_echo "$as_me: error: Cannot locate the the path of WINLD" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving WINLD (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving WINLD (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving WINLD (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of WINLD, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of WINLD, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of WINLD, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of WINLD" >&5 -$as_echo "$as_me: error: Cannot locate the the path of WINLD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of WINLD" "$LINENO" 5 fi fi fi @@ -21913,22 +21563,20 @@ $as_echo "$as_me: error: Cannot locate the the path of WINLD" >&2;} if test "x$complete" != "x$new_complete"; then WINLD="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting WINLD to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting WINLD to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting WINLD to \"$new_complete\"" >&6;} fi printf "Windows linker was found at $WINLD\n" - { $as_echo "$as_me:$LINENO: checking if the found link.exe is actually the Visual Studio linker" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the found link.exe is actually the Visual Studio linker" >&5 $as_echo_n "checking if the found link.exe is actually the Visual Studio linker... " >&6; } "$WINLD" --version > /dev/null if test $? -eq 0 ; then - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - { { $as_echo "$as_me:$LINENO: error: This is the Cygwin link tool. Please check your PATH and rerun configure." >&5 -$as_echo "$as_me: error: This is the Cygwin link tool. Please check your PATH and rerun configure." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "This is the Cygwin link tool. Please check your PATH and rerun configure." "$LINENO" 5 else - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi LD="$WINLD" @@ -21938,9 +21586,9 @@ $as_echo "yes" >&6; } # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_MT+set}" = set; then +if test "${ac_cv_prog_MT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$MT"; then @@ -21952,18 +21600,18 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/bin/mt"; then ac_prog_rejected=yes continue fi ac_cv_prog_MT="mt" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then @@ -21982,10 +21630,10 @@ fi fi MT=$ac_cv_prog_MT if test -n "$MT"; then - { $as_echo "$as_me:$LINENO: result: $MT" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MT" >&5 $as_echo "$MT" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -22031,16 +21679,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of MT, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MT, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of MT, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of MT" >&5 -$as_echo "$as_me: error: Cannot locate the the path of MT" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of MT" "$LINENO" 5 fi fi @@ -22060,13 +21706,11 @@ $as_echo "$as_me: error: Cannot locate the the path of MT" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of MT, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MT, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of MT, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of MT" >&5 -$as_echo "$as_me: error: Cannot locate the the path of MT" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of MT" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -22158,16 +21802,14 @@ $as_echo "$as_me: error: Cannot locate the the path of MT" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of MT, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MT, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of MT, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of MT" >&5 -$as_echo "$as_me: error: Cannot locate the the path of MT" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of MT" "$LINENO" 5 fi fi @@ -22222,20 +21864,18 @@ $as_echo "$as_me: error: Cannot locate the the path of MT" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving MT (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving MT (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving MT (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of MT, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MT, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of MT, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of MT" >&5 -$as_echo "$as_me: error: Cannot locate the the path of MT" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of MT" "$LINENO" 5 fi fi fi @@ -22249,16 +21889,16 @@ $as_echo "$as_me: error: Cannot locate the the path of MT" >&2;} if test "x$complete" != "x$new_complete"; then MT="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting MT to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting MT to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting MT to \"$new_complete\"" >&6;} fi # The resource compiler # Extract the first word of "rc", so it can be a program name with args. set dummy rc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RC+set}" = set; then +if test "${ac_cv_prog_RC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$RC"; then @@ -22270,18 +21910,18 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/bin/rc"; then ac_prog_rejected=yes continue fi ac_cv_prog_RC="rc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then @@ -22300,10 +21940,10 @@ fi fi RC=$ac_cv_prog_RC if test -n "$RC"; then - { $as_echo "$as_me:$LINENO: result: $RC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RC" >&5 $as_echo "$RC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -22349,16 +21989,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of RC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of RC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of RC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of RC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of RC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of RC" "$LINENO" 5 fi fi @@ -22378,13 +22016,11 @@ $as_echo "$as_me: error: Cannot locate the the path of RC" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of RC, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of RC, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of RC, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of RC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of RC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of RC" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -22476,16 +22112,14 @@ $as_echo "$as_me: error: Cannot locate the the path of RC" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of RC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of RC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of RC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of RC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of RC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of RC" "$LINENO" 5 fi fi @@ -22540,20 +22174,18 @@ $as_echo "$as_me: error: Cannot locate the the path of RC" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving RC (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving RC (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving RC (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of RC, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of RC, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of RC, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of RC" >&5 -$as_echo "$as_me: error: Cannot locate the the path of RC" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of RC" "$LINENO" 5 fi fi fi @@ -22567,7 +22199,7 @@ $as_echo "$as_me: error: Cannot locate the the path of RC" >&2;} if test "x$complete" != "x$new_complete"; then RC="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting RC to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting RC to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting RC to \"$new_complete\"" >&6;} fi @@ -22622,19 +22254,17 @@ $as_echo "$as_me: Rewriting RC to \"$new_complete\"" >&6;} RC_FLAGS="-nologo -l 0x409 -r" - if test "x$VARIANT" = xOPT; then + if test "x$VARIANT" = xOPT; then : RC_FLAGS="$RC_FLAGS -d NDEBUG" fi - JDK_UPDATE_VERSION_NOTNULL=$JDK_UPDATE_VERSION - if test "x$JDK_UPDATE_VERSION" = x; then + if test "x$JDK_UPDATE_VERSION" = x; then : JDK_UPDATE_VERSION_NOTNULL=0 fi - RC_FLAGS="$RC_FLAGS -d \"JDK_BUILD_ID=$FULL_VERSION\"" RC_FLAGS="$RC_FLAGS -d \"JDK_COMPANY=$COMPANY_NAME\"" RC_FLAGS="$RC_FLAGS -d \"JDK_COMPONENT=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME binary\"" @@ -22646,9 +22276,9 @@ fi # lib.exe is used to create static libraries. # Extract the first word of "lib", so it can be a program name with args. set dummy lib; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_WINAR+set}" = set; then +if test "${ac_cv_prog_WINAR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$WINAR"; then @@ -22659,24 +22289,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_WINAR="lib" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi WINAR=$ac_cv_prog_WINAR if test -n "$WINAR"; then - { $as_echo "$as_me:$LINENO: result: $WINAR" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WINAR" >&5 $as_echo "$WINAR" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -22722,16 +22352,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of WINAR, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of WINAR, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of WINAR, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of WINAR" >&5 -$as_echo "$as_me: error: Cannot locate the the path of WINAR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of WINAR" "$LINENO" 5 fi fi @@ -22751,13 +22379,11 @@ $as_echo "$as_me: error: Cannot locate the the path of WINAR" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of WINAR, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of WINAR, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of WINAR, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of WINAR" >&5 -$as_echo "$as_me: error: Cannot locate the the path of WINAR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of WINAR" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -22849,16 +22475,14 @@ $as_echo "$as_me: error: Cannot locate the the path of WINAR" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of WINAR, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of WINAR, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of WINAR, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of WINAR" >&5 -$as_echo "$as_me: error: Cannot locate the the path of WINAR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of WINAR" "$LINENO" 5 fi fi @@ -22913,20 +22537,18 @@ $as_echo "$as_me: error: Cannot locate the the path of WINAR" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving WINAR (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving WINAR (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving WINAR (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of WINAR, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of WINAR, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of WINAR, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of WINAR" >&5 -$as_echo "$as_me: error: Cannot locate the the path of WINAR" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of WINAR" "$LINENO" 5 fi fi fi @@ -22940,7 +22562,7 @@ $as_echo "$as_me: error: Cannot locate the the path of WINAR" >&2;} if test "x$complete" != "x$new_complete"; then WINAR="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting WINAR to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting WINAR to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting WINAR to \"$new_complete\"" >&6;} fi @@ -22949,9 +22571,9 @@ $as_echo "$as_me: Rewriting WINAR to \"$new_complete\"" >&6;} # Extract the first word of "dumpbin", so it can be a program name with args. set dummy dumpbin; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DUMPBIN+set}" = set; then +if test "${ac_cv_prog_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then @@ -22962,24 +22584,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DUMPBIN="dumpbin" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then - { $as_echo "$as_me:$LINENO: result: $DUMPBIN" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -23025,16 +22647,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of DUMPBIN, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of DUMPBIN, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of DUMPBIN, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of DUMPBIN" >&5 -$as_echo "$as_me: error: Cannot locate the the path of DUMPBIN" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of DUMPBIN" "$LINENO" 5 fi fi @@ -23054,13 +22674,11 @@ $as_echo "$as_me: error: Cannot locate the the path of DUMPBIN" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of DUMPBIN, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of DUMPBIN, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of DUMPBIN, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of DUMPBIN" >&5 -$as_echo "$as_me: error: Cannot locate the the path of DUMPBIN" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of DUMPBIN" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -23152,16 +22770,14 @@ $as_echo "$as_me: error: Cannot locate the the path of DUMPBIN" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of DUMPBIN, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of DUMPBIN, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of DUMPBIN, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of DUMPBIN" >&5 -$as_echo "$as_me: error: Cannot locate the the path of DUMPBIN" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of DUMPBIN" "$LINENO" 5 fi fi @@ -23216,20 +22832,18 @@ $as_echo "$as_me: error: Cannot locate the the path of DUMPBIN" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving DUMPBIN (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving DUMPBIN (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving DUMPBIN (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of DUMPBIN, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of DUMPBIN, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of DUMPBIN, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of DUMPBIN" >&5 -$as_echo "$as_me: error: Cannot locate the the path of DUMPBIN" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of DUMPBIN" "$LINENO" 5 fi fi fi @@ -23243,7 +22857,7 @@ $as_echo "$as_me: error: Cannot locate the the path of DUMPBIN" >&2;} if test "x$complete" != "x$new_complete"; then DUMPBIN="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting DUMPBIN to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting DUMPBIN to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting DUMPBIN to \"$new_complete\"" >&6;} fi @@ -23255,20 +22869,19 @@ fi - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -23283,11 +22896,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -23296,78 +22905,34 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : break fi @@ -23379,7 +22944,7 @@ fi else ac_cv_prog_CPP=$CPP fi -{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -23390,11 +22955,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -23403,87 +22964,40 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=cpp @@ -23533,16 +23047,14 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of CPP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CPP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CPP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CPP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CPP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CPP" "$LINENO" 5 fi fi @@ -23562,13 +23074,11 @@ $as_echo "$as_me: error: Cannot locate the the path of CPP" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of CPP, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CPP, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of CPP, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CPP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CPP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CPP" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -23660,16 +23170,14 @@ $as_echo "$as_me: error: Cannot locate the the path of CPP" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of CPP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CPP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CPP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CPP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CPP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CPP" "$LINENO" 5 fi fi @@ -23724,20 +23232,18 @@ $as_echo "$as_me: error: Cannot locate the the path of CPP" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving CPP (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving CPP (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving CPP (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of CPP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CPP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CPP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CPP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CPP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CPP" "$LINENO" 5 fi fi fi @@ -23751,7 +23257,7 @@ $as_echo "$as_me: error: Cannot locate the the path of CPP" >&2;} if test "x$complete" != "x$new_complete"; then CPP="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting CPP to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting CPP to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting CPP to \"$new_complete\"" >&6;} fi @@ -23761,10 +23267,10 @@ ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then - if test "${ac_cv_prog_CXXCPP+set}" = set; then + if test "${ac_cv_prog_CXXCPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded @@ -23779,11 +23285,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -23792,78 +23294,34 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_cxx_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : break fi @@ -23875,7 +23333,7 @@ fi else ac_cv_prog_CXXCPP=$CXXCPP fi -{ $as_echo "$as_me:$LINENO: result: $CXXCPP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes @@ -23886,11 +23344,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -23899,87 +23353,40 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_cxx_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=cpp @@ -24029,16 +23436,14 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of CXXCPP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CXXCPP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CXXCPP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CXXCPP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CXXCPP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CXXCPP" "$LINENO" 5 fi fi @@ -24058,13 +23463,11 @@ $as_echo "$as_me: error: Cannot locate the the path of CXXCPP" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of CXXCPP, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CXXCPP, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of CXXCPP, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CXXCPP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CXXCPP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CXXCPP" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -24156,16 +23559,14 @@ $as_echo "$as_me: error: Cannot locate the the path of CXXCPP" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of CXXCPP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CXXCPP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CXXCPP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CXXCPP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CXXCPP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CXXCPP" "$LINENO" 5 fi fi @@ -24220,20 +23621,18 @@ $as_echo "$as_me: error: Cannot locate the the path of CXXCPP" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving CXXCPP (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving CXXCPP (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving CXXCPP (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of CXXCPP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CXXCPP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of CXXCPP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of CXXCPP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of CXXCPP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of CXXCPP" "$LINENO" 5 fi fi fi @@ -24247,7 +23646,7 @@ $as_echo "$as_me: error: Cannot locate the the path of CXXCPP" >&2;} if test "x$complete" != "x$new_complete"; then CXXCPP="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting CXXCPP to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting CXXCPP to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting CXXCPP to \"$new_complete\"" >&6;} fi @@ -24276,9 +23675,9 @@ fi if test "x$OPENJDK_TARGET_OS" = xsolaris; then # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_AS+set}" = set; then +if test "${ac_cv_path_AS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $AS in @@ -24291,14 +23690,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_AS="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -24306,10 +23705,10 @@ esac fi AS=$ac_cv_path_AS if test -n "$AS"; then - { $as_echo "$as_me:$LINENO: result: $AS" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 $as_echo "$AS" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -24355,16 +23754,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of AS, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of AS, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of AS, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of AS" >&5 -$as_echo "$as_me: error: Cannot locate the the path of AS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of AS" "$LINENO" 5 fi fi @@ -24384,13 +23781,11 @@ $as_echo "$as_me: error: Cannot locate the the path of AS" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of AS, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of AS, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of AS, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of AS" >&5 -$as_echo "$as_me: error: Cannot locate the the path of AS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of AS" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -24482,16 +23877,14 @@ $as_echo "$as_me: error: Cannot locate the the path of AS" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of AS, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of AS, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of AS, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of AS" >&5 -$as_echo "$as_me: error: Cannot locate the the path of AS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of AS" "$LINENO" 5 fi fi @@ -24546,20 +23939,18 @@ $as_echo "$as_me: error: Cannot locate the the path of AS" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving AS (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving AS (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving AS (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of AS, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of AS, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of AS, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of AS" >&5 -$as_echo "$as_me: error: Cannot locate the the path of AS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of AS" "$LINENO" 5 fi fi fi @@ -24573,7 +23964,7 @@ $as_echo "$as_me: error: Cannot locate the the path of AS" >&2;} if test "x$complete" != "x$new_complete"; then AS="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting AS to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting AS to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting AS to \"$new_complete\"" >&6;} fi @@ -24587,9 +23978,9 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_NM+set}" = set; then +if test "${ac_cv_path_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $NM in @@ -24602,14 +23993,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_NM="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -24617,10 +24008,10 @@ esac fi NM=$ac_cv_path_NM if test -n "$NM"; then - { $as_echo "$as_me:$LINENO: result: $NM" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NM" >&5 $as_echo "$NM" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -24669,16 +24060,14 @@ done fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of NM, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of NM, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of NM, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of NM" >&5 -$as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of NM" "$LINENO" 5 fi fi @@ -24698,13 +24087,11 @@ $as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of NM, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of NM, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of NM, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of NM" >&5 -$as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of NM" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -24796,16 +24183,14 @@ $as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of NM, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of NM, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of NM, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of NM" >&5 -$as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of NM" "$LINENO" 5 fi fi @@ -24860,20 +24245,18 @@ $as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving NM (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving NM (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving NM (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of NM, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of NM, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of NM, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of NM" >&5 -$as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of NM" "$LINENO" 5 fi fi fi @@ -24887,15 +24270,15 @@ $as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} if test "x$complete" != "x$new_complete"; then NM="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting NM to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting NM to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} fi # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_STRIP+set}" = set; then +if test "${ac_cv_path_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STRIP in @@ -24908,14 +24291,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_STRIP="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -24923,10 +24306,10 @@ esac fi STRIP=$ac_cv_path_STRIP if test -n "$STRIP"; then - { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -24972,16 +24355,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of STRIP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STRIP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of STRIP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of STRIP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of STRIP" "$LINENO" 5 fi fi @@ -25001,13 +24382,11 @@ $as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of STRIP, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STRIP, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of STRIP, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of STRIP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of STRIP" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -25099,16 +24478,14 @@ $as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of STRIP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STRIP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of STRIP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of STRIP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of STRIP" "$LINENO" 5 fi fi @@ -25163,20 +24540,18 @@ $as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving STRIP (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving STRIP (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving STRIP (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of STRIP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STRIP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of STRIP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of STRIP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of STRIP" "$LINENO" 5 fi fi fi @@ -25190,15 +24565,15 @@ $as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} if test "x$complete" != "x$new_complete"; then STRIP="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting STRIP to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting STRIP to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting STRIP to \"$new_complete\"" >&6;} fi # Extract the first word of "mcs", so it can be a program name with args. set dummy mcs; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MCS+set}" = set; then +if test "${ac_cv_path_MCS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MCS in @@ -25211,14 +24586,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MCS="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -25226,10 +24601,10 @@ esac fi MCS=$ac_cv_path_MCS if test -n "$MCS"; then - { $as_echo "$as_me:$LINENO: result: $MCS" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MCS" >&5 $as_echo "$MCS" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -25275,16 +24650,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of MCS, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MCS, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of MCS, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of MCS" >&5 -$as_echo "$as_me: error: Cannot locate the the path of MCS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of MCS" "$LINENO" 5 fi fi @@ -25304,13 +24677,11 @@ $as_echo "$as_me: error: Cannot locate the the path of MCS" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of MCS, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MCS, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of MCS, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of MCS" >&5 -$as_echo "$as_me: error: Cannot locate the the path of MCS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of MCS" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -25402,16 +24773,14 @@ $as_echo "$as_me: error: Cannot locate the the path of MCS" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of MCS, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MCS, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of MCS, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of MCS" >&5 -$as_echo "$as_me: error: Cannot locate the the path of MCS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of MCS" "$LINENO" 5 fi fi @@ -25466,20 +24835,18 @@ $as_echo "$as_me: error: Cannot locate the the path of MCS" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving MCS (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving MCS (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving MCS (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of MCS, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MCS, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of MCS, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of MCS" >&5 -$as_echo "$as_me: error: Cannot locate the the path of MCS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of MCS" "$LINENO" 5 fi fi fi @@ -25493,7 +24860,7 @@ $as_echo "$as_me: error: Cannot locate the the path of MCS" >&2;} if test "x$complete" != "x$new_complete"; then MCS="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting MCS to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting MCS to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting MCS to \"$new_complete\"" >&6;} fi @@ -25501,9 +24868,9 @@ elif test "x$OPENJDK_TARGET_OS" != xwindows; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args. set dummy ${ac_tool_prefix}nm; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_NM+set}" = set; then +if test "${ac_cv_prog_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then @@ -25514,24 +24881,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NM="${ac_tool_prefix}nm" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi NM=$ac_cv_prog_NM if test -n "$NM"; then - { $as_echo "$as_me:$LINENO: result: $NM" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NM" >&5 $as_echo "$NM" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -25541,9 +24908,9 @@ if test -z "$ac_cv_prog_NM"; then ac_ct_NM=$NM # Extract the first word of "nm", so it can be a program name with args. set dummy nm; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_NM+set}" = set; then +if test "${ac_cv_prog_ac_ct_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NM"; then @@ -25554,24 +24921,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_NM="nm" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_NM=$ac_cv_prog_ac_ct_NM if test -n "$ac_ct_NM"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_NM" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NM" >&5 $as_echo "$ac_ct_NM" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -25580,7 +24947,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -25631,16 +24998,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of NM, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of NM, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of NM, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of NM" >&5 -$as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of NM" "$LINENO" 5 fi fi @@ -25660,13 +25025,11 @@ $as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of NM, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of NM, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of NM, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of NM" >&5 -$as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of NM" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -25758,16 +25121,14 @@ $as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of NM, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of NM, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of NM, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of NM" >&5 -$as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of NM" "$LINENO" 5 fi fi @@ -25822,20 +25183,18 @@ $as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving NM (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving NM (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving NM (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of NM, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of NM, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of NM, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of NM" >&5 -$as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of NM" "$LINENO" 5 fi fi fi @@ -25849,16 +25208,16 @@ $as_echo "$as_me: error: Cannot locate the the path of NM" >&2;} if test "x$complete" != "x$new_complete"; then NM="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting NM to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting NM to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then +if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -25869,24 +25228,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then - { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -25896,9 +25255,9 @@ if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -25909,24 +25268,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -25935,7 +25294,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -25986,16 +25345,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of STRIP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STRIP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of STRIP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of STRIP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of STRIP" "$LINENO" 5 fi fi @@ -26015,13 +25372,11 @@ $as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of STRIP, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STRIP, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of STRIP, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of STRIP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of STRIP" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -26113,16 +25468,14 @@ $as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of STRIP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STRIP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of STRIP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of STRIP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of STRIP" "$LINENO" 5 fi fi @@ -26177,20 +25530,18 @@ $as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving STRIP (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving STRIP (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving STRIP (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of STRIP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STRIP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of STRIP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of STRIP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of STRIP" "$LINENO" 5 fi fi fi @@ -26204,7 +25555,7 @@ $as_echo "$as_me: error: Cannot locate the the path of STRIP" >&2;} if test "x$complete" != "x$new_complete"; then STRIP="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting STRIP to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting STRIP to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting STRIP to \"$new_complete\"" >&6;} fi @@ -26218,9 +25569,9 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJCOPY+set}" = set; then +if test "${ac_cv_prog_OBJCOPY+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJCOPY"; then @@ -26231,24 +25582,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJCOPY="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi OBJCOPY=$ac_cv_prog_OBJCOPY if test -n "$OBJCOPY"; then - { $as_echo "$as_me:$LINENO: result: $OBJCOPY" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJCOPY" >&5 $as_echo "$OBJCOPY" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -26262,9 +25613,9 @@ if test -z "$OBJCOPY"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then +if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJCOPY"; then @@ -26275,24 +25626,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJCOPY="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_OBJCOPY=$ac_cv_prog_ac_ct_OBJCOPY if test -n "$ac_ct_OBJCOPY"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_OBJCOPY" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJCOPY" >&5 $as_echo "$ac_ct_OBJCOPY" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -26305,7 +25656,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -26356,16 +25707,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of OBJCOPY, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJCOPY, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of OBJCOPY, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJCOPY" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJCOPY" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJCOPY" "$LINENO" 5 fi fi @@ -26385,13 +25734,11 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJCOPY" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of OBJCOPY, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJCOPY, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of OBJCOPY, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJCOPY" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJCOPY" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJCOPY" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -26483,16 +25830,14 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJCOPY" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of OBJCOPY, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJCOPY, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of OBJCOPY, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJCOPY" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJCOPY" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJCOPY" "$LINENO" 5 fi fi @@ -26547,20 +25892,18 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJCOPY" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving OBJCOPY (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving OBJCOPY (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving OBJCOPY (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of OBJCOPY, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJCOPY, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of OBJCOPY, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJCOPY" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJCOPY" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJCOPY" "$LINENO" 5 fi fi fi @@ -26574,7 +25917,7 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJCOPY" >&2;} if test "x$complete" != "x$new_complete"; then OBJCOPY="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting OBJCOPY to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting OBJCOPY to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting OBJCOPY to \"$new_complete\"" >&6;} fi @@ -26586,9 +25929,9 @@ if test -n "$ac_tool_prefix"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJDUMP+set}" = set; then +if test "${ac_cv_prog_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then @@ -26599,24 +25942,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then - { $as_echo "$as_me:$LINENO: result: $OBJDUMP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -26630,9 +25973,9 @@ if test -z "$OBJDUMP"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then +if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then @@ -26643,24 +25986,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_OBJDUMP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -26673,7 +26016,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -26724,16 +26067,14 @@ if test "x$OBJDUMP" != x; then fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of OBJDUMP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJDUMP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of OBJDUMP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJDUMP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJDUMP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJDUMP" "$LINENO" 5 fi fi @@ -26753,13 +26094,11 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJDUMP" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of OBJDUMP, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJDUMP, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of OBJDUMP, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJDUMP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJDUMP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJDUMP" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -26851,16 +26190,14 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJDUMP" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of OBJDUMP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJDUMP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of OBJDUMP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJDUMP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJDUMP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJDUMP" "$LINENO" 5 fi fi @@ -26915,20 +26252,18 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJDUMP" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving OBJDUMP (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving OBJDUMP (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving OBJDUMP (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of OBJDUMP, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OBJDUMP, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of OBJDUMP, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of OBJDUMP" >&5 -$as_echo "$as_me: error: Cannot locate the the path of OBJDUMP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of OBJDUMP" "$LINENO" 5 fi fi fi @@ -26942,7 +26277,7 @@ $as_echo "$as_me: error: Cannot locate the the path of OBJDUMP" >&2;} if test "x$complete" != "x$new_complete"; then OBJDUMP="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting OBJDUMP to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting OBJDUMP to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting OBJDUMP to \"$new_complete\"" >&6;} fi @@ -26951,9 +26286,9 @@ fi if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LIPO+set}" = set; then +if test "${ac_cv_path_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LIPO in @@ -26966,14 +26301,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_LIPO="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -26981,10 +26316,10 @@ esac fi LIPO=$ac_cv_path_LIPO if test -n "$LIPO"; then - { $as_echo "$as_me:$LINENO: result: $LIPO" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -27030,16 +26365,14 @@ fi fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of LIPO, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of LIPO, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of LIPO, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of LIPO" >&5 -$as_echo "$as_me: error: Cannot locate the the path of LIPO" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of LIPO" "$LINENO" 5 fi fi @@ -27059,13 +26392,11 @@ $as_echo "$as_me: error: Cannot locate the the path of LIPO" >&2;} elif test -f "${new_path}.cmd"; then input_to_shortpath="${new_path}.cmd" else - { $as_echo "$as_me:$LINENO: The path of LIPO, which resolves as \"$new_path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of LIPO, which resolves as \"$new_path\", is invalid." >&5 $as_echo "$as_me: The path of LIPO, which resolves as \"$new_path\", is invalid." >&6;} - { $as_echo "$as_me:$LINENO: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of LIPO" >&5 -$as_echo "$as_me: error: Cannot locate the the path of LIPO" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of LIPO" "$LINENO" 5 fi else input_to_shortpath="$new_path" @@ -27157,16 +26488,14 @@ $as_echo "$as_me: error: Cannot locate the the path of LIPO" >&2;} if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. - { $as_echo "$as_me:$LINENO: The path of LIPO, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of LIPO, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of LIPO, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 $as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of LIPO" >&5 -$as_echo "$as_me: error: Cannot locate the the path of LIPO" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of LIPO" "$LINENO" 5 fi fi @@ -27221,20 +26550,18 @@ $as_echo "$as_me: error: Cannot locate the the path of LIPO" >&2;} if test "x$new_path" = x; then is_absolute_path=`$ECHO "$path" | $GREP ^/` if test "x$is_absolute_path" != x; then - { $as_echo "$as_me:$LINENO: Resolving LIPO (as $path) with 'which' failed, using $path directly." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving LIPO (as $path) with 'which' failed, using $path directly." >&5 $as_echo "$as_me: Resolving LIPO (as $path) with 'which' failed, using $path directly." >&6;} new_path="$path" else - { $as_echo "$as_me:$LINENO: The path of LIPO, which resolves as \"$complete\", is not found." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of LIPO, which resolves as \"$complete\", is not found." >&5 $as_echo "$as_me: The path of LIPO, which resolves as \"$complete\", is not found." >&6;} has_space=`$ECHO "$complete" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: This might be caused by spaces in the path, which is not allowed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 $as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of LIPO" >&5 -$as_echo "$as_me: error: Cannot locate the the path of LIPO" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of LIPO" "$LINENO" 5 fi fi fi @@ -27248,7 +26575,7 @@ $as_echo "$as_me: error: Cannot locate the the path of LIPO" >&2;} if test "x$complete" != "x$new_complete"; then LIPO="$new_complete" - { $as_echo "$as_me:$LINENO: Rewriting LIPO to \"$new_complete\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting LIPO to \"$new_complete\"" >&5 $as_echo "$as_me: Rewriting LIPO to \"$new_complete\"" >&6;} fi @@ -27263,16 +26590,12 @@ PATH="$OLD_PATH" # And we can test some aspects on the target using configure macros. -{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -27287,48 +26610,23 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdc=no + ac_cv_header_stdc=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : + $EGREP "memchr" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -27338,18 +26636,14 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : + $EGREP "free" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -27359,14 +26653,10 @@ fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : : else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -27393,118 +26683,33 @@ main () return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : +if ac_fn_cxx_try_run "$LINENO"; then : + else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no + ac_cv_header_stdc=no fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF +$as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -27560,167 +26765,26 @@ elif test "x$COMPILE_TYPE" = xreduced; then fi # Make compilation sanity check - for ac_header in stdio.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## ----------------------------------------- ## -## Report this to build-dev@openjdk.java.net ## -## ----------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "stdio.h" "ac_cv_header_stdio_h" "$ac_includes_default" +if test "x$ac_cv_header_stdio_h" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_STDIO_H 1 _ACEOF else - { $as_echo "$as_me:$LINENO: Failed to compile stdio.h. This likely implies missing compile dependencies." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Failed to compile stdio.h. This likely implies missing compile dependencies." >&5 $as_echo "$as_me: Failed to compile stdio.h. This likely implies missing compile dependencies." >&6;} if test "x$COMPILE_TYPE" = xreduced; then - { $as_echo "$as_me:$LINENO: You are doing a reduced build. Check that you have 32-bit libraries installed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You are doing a reduced build. Check that you have 32-bit libraries installed." >&5 $as_echo "$as_me: You are doing a reduced build. Check that you have 32-bit libraries installed." >&6;} elif test "x$COMPILE_TYPE" = xcross; then - { $as_echo "$as_me:$LINENO: You are doing a cross-compilation. Check that you have all target platform libraries installed." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: You are doing a cross-compilation. Check that you have all target platform libraries installed." >&5 $as_echo "$as_me: You are doing a cross-compilation. Check that you have all target platform libraries installed." >&6;} fi - { { $as_echo "$as_me:$LINENO: error: Cannot continue." >&5 -$as_echo "$as_me: error: Cannot continue." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot continue." "$LINENO" 5 fi @@ -27731,352 +26795,26 @@ done # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:$LINENO: checking size of int *" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 $as_echo_n "checking size of int *... " >&6; } -if test "${ac_cv_sizeof_int_p+set}" = set; then +if test "${ac_cv_sizeof_int_p+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (int *))) >= 0)]; -test_array [0] = 0 + if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (int *))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (int *))) < 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (int *))) >= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_lo=$ac_mid; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo= ac_hi= -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (int *))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=$ac_mid -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo=`expr '(' $ac_mid ')' + 1` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_sizeof_int_p=$ac_lo;; -'') if test "$ac_cv_type_int_p" = yes; then - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + if test "$ac_cv_type_int_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int *) -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (int *) -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; }; } - else - ac_cv_sizeof_int_p=0 - fi ;; -esac -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -static long int longval () { return (long int) (sizeof (int *)); } -static unsigned long int ulongval () { return (long int) (sizeof (int *)); } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (((long int) (sizeof (int *))) < 0) - { - long int i = longval (); - if (i != ((long int) (sizeof (int *)))) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ((long int) (sizeof (int *)))) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sizeof_int_p=`cat conftest.val` -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -if test "$ac_cv_type_int_p" = yes; then - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int *) -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (int *) -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; }; } +as_fn_error 77 "cannot compute sizeof (int *) +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_int_p=0 fi fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext + fi -rm -f conftest.val -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_int_p" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int_p" >&5 $as_echo "$ac_cv_sizeof_int_p" >&6; } @@ -28094,21 +26832,19 @@ fi if test "x$SIZEOF_INT_P" = x; then # The test failed, lets stick to the assumed value. - { $as_echo "$as_me:$LINENO: WARNING: The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS." >&5 $as_echo "$as_me: WARNING: The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS." >&2;} else TESTED_TARGET_CPU_BITS=`expr 8 \* $SIZEOF_INT_P` if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then - { { $as_echo "$as_me:$LINENO: error: The tested number of bits in the target ($TESTED_TARGET_CPU_BITS) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)" >&5 -$as_echo "$as_me: error: The tested number of bits in the target ($TESTED_TARGET_CPU_BITS) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The tested number of bits in the target ($TESTED_TARGET_CPU_BITS) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)" "$LINENO" 5 fi fi -{ $as_echo "$as_me:$LINENO: checking for target address size" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for target address size" >&5 $as_echo_n "checking for target address size... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $OPENJDK_TARGET_CPU_BITS bits" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENJDK_TARGET_CPU_BITS bits" >&5 $as_echo "$OPENJDK_TARGET_CPU_BITS bits" >&6; } @@ -28116,19 +26852,14 @@ $as_echo "$OPENJDK_TARGET_CPU_BITS bits" >&6; } # # Is the target little of big endian? # - - { $as_echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if test "${ac_cv_c_bigendian+set}" = set; then +if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler @@ -28136,46 +26867,34 @@ cat >>conftest.$ac_ext <<_ACEOF typedef int dummy; _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless - # there are some -arch flags. Note that *ppc* also matches - # ppc64. This check is also rather less than ideal. - case "${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}" in #( - *-arch*ppc*|*-arch*i386*|*-arch*x86_64*) ac_cv_c_bigendian=universal;; - esac -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -28193,30 +26912,9 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -28232,49 +26930,18 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_c_bigendian=no + ac_cv_c_bigendian=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -28289,30 +26956,9 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -28327,51 +26973,20 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_c_bigendian=no + ac_cv_c_bigendian=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; @@ -28397,24 +27012,7 @@ return use_ascii (foo) == use_ebcdic (foo); return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi @@ -28426,20 +27024,10 @@ $as_echo "$ac_try_echo") >&5 ac_cv_c_bigendian=unknown fi fi -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int @@ -28459,45 +27047,18 @@ main () return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_c_bigendian=no else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_c_bigendian=yes + ac_cv_c_bigendian=yes fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) @@ -28513,14 +27074,10 @@ $as_echo "$ac_cv_c_bigendian" >&6; } if test "x$ENDIAN" = xuniversal_endianness; then - { { $as_echo "$as_me:$LINENO: error: Building with both big and little endianness is not supported" >&5 -$as_echo "$as_me: error: Building with both big and little endianness is not supported" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Building with both big and little endianness is not supported" "$LINENO" 5 fi if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then - { { $as_echo "$as_me:$LINENO: error: The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)" >&5 -$as_echo "$as_me: error: The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)" "$LINENO" 5 fi @@ -28648,57 +27205,26 @@ if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacos # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned. # While waiting for a better solution, the current workaround is to use -mstackrealign. CFLAGS="$CFLAGS -mstackrealign" - { $as_echo "$as_me:$LINENO: checking if 32-bit compiler supports -mstackrealign" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 32-bit compiler supports -mstackrealign" >&5 $as_echo_n "checking if 32-bit compiler supports -mstackrealign... " >&6; } - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main() { return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - { { $as_echo "$as_me:$LINENO: error: The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path." >&5 -$as_echo "$as_me: error: The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path." "$LINENO" 5 fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi C_FLAG_DEPS="-MMD -MF" @@ -28846,37 +27372,37 @@ fi if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then - { $as_echo "$as_me:$LINENO: WARNING: Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags" >&5 $as_echo "$as_me: WARNING: Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags" >&2;} fi if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then - { $as_echo "$as_me:$LINENO: WARNING: Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags" >&5 $as_echo "$as_me: WARNING: Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags" >&2;} fi if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then - { $as_echo "$as_me:$LINENO: WARNING: Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags" >&5 $as_echo "$as_me: WARNING: Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags" >&2;} fi # Check whether --with-extra-cflags was given. -if test "${with_extra_cflags+set}" = set; then +if test "${with_extra_cflags+set}" = set; then : withval=$with_extra_cflags; fi # Check whether --with-extra-cxxflags was given. -if test "${with_extra_cxxflags+set}" = set; then +if test "${with_extra_cxxflags+set}" = set; then : withval=$with_extra_cxxflags; fi # Check whether --with-extra-ldflags was given. -if test "${with_extra_ldflags+set}" = set; then +if test "${with_extra_ldflags+set}" = set; then : withval=$with_extra_ldflags; fi @@ -29056,10 +27582,17 @@ else fi fi LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \ - -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server \ - -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client \ -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}" + # On some platforms (mac) the linker warns about non existing -L dirs. + # Only add client dir if client is being built. Otherwise server should + # be enough + if test "x$JVM_VARIANT_CLIENT" = xtrue; then + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client" + else + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server" + fi + LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm" if test "x$COMPILER_NAME" = xossc; then LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc" @@ -29115,20 +27648,18 @@ if test "x$OPENJDK_TARGET_OS" = xmacosx; then fi # Check whether --enable-debug-symbols was given. -if test "${enable_debug_symbols+set}" = set; then +if test "${enable_debug_symbols+set}" = set; then : enableval=$enable_debug_symbols; ENABLE_DEBUG_SYMBOLS=${enable_debug_symbols} fi -{ $as_echo "$as_me:$LINENO: checking if we should generate debug symbols" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should generate debug symbols" >&5 $as_echo_n "checking if we should generate debug symbols... " >&6; } if test "x$ENABLE_DEBUG_SYMBOLS" = "xyes" && test "x$OBJCOPY" = x; then # explicit enabling of enable-debug-symbols and can't find objcopy # this is an error - { { $as_echo "$as_me:$LINENO: error: Unable to find objcopy, cannot enable debug-symbols" >&5 -$as_echo "$as_me: error: Unable to find objcopy, cannot enable debug-symbols" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Unable to find objcopy, cannot enable debug-symbols" "$LINENO" 5 fi if test "x$ENABLE_DEBUG_SYMBOLS" = "xdefault"; then @@ -29140,7 +27671,7 @@ if test "x$ENABLE_DEBUG_SYMBOLS" = "xdefault"; then fi fi -{ $as_echo "$as_me:$LINENO: result: $ENABLE_DEBUG_SYMBOLS" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ENABLE_DEBUG_SYMBOLS" >&5 $as_echo "$ENABLE_DEBUG_SYMBOLS" >&6; } # @@ -29149,14 +27680,14 @@ $as_echo "$ENABLE_DEBUG_SYMBOLS" >&6; } ZIP_DEBUGINFO_FILES=yes # Check whether --enable-zip-debug-info was given. -if test "${enable_zip_debug_info+set}" = set; then +if test "${enable_zip_debug_info+set}" = set; then : enableval=$enable_zip_debug_info; ZIP_DEBUGINFO_FILES=${enable_zip_debug_info} fi -{ $as_echo "$as_me:$LINENO: checking if we should zip debug-info files" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should zip debug-info files" >&5 $as_echo_n "checking if we should zip debug-info files... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $ZIP_DEBUGINFO_FILES" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP_DEBUGINFO_FILES" >&5 $as_echo "$ZIP_DEBUGINFO_FILES" >&6; } # Hotspot wants ZIP_DEBUGINFO_FILES to be 1 for yes @@ -29186,35 +27717,35 @@ fi # OS specific settings that we never will need to probe. # if test "x$OPENJDK_TARGET_OS" = xlinux; then - { $as_echo "$as_me:$LINENO: checking what is not needed on Linux?" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking what is not needed on Linux?" >&5 $as_echo_n "checking what is not needed on Linux?... " >&6; } PULSE_NOT_NEEDED=yes - { $as_echo "$as_me:$LINENO: result: pulse" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pulse" >&5 $as_echo "pulse" >&6; } fi if test "x$OPENJDK_TARGET_OS" = xsolaris; then - { $as_echo "$as_me:$LINENO: checking what is not needed on Solaris?" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking what is not needed on Solaris?" >&5 $as_echo_n "checking what is not needed on Solaris?... " >&6; } ALSA_NOT_NEEDED=yes PULSE_NOT_NEEDED=yes - { $as_echo "$as_me:$LINENO: result: alsa pulse" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: alsa pulse" >&5 $as_echo "alsa pulse" >&6; } fi if test "x$OPENJDK_TARGET_OS" = xwindows; then - { $as_echo "$as_me:$LINENO: checking what is not needed on Windows?" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking what is not needed on Windows?" >&5 $as_echo_n "checking what is not needed on Windows?... " >&6; } CUPS_NOT_NEEDED=yes ALSA_NOT_NEEDED=yes PULSE_NOT_NEEDED=yes X11_NOT_NEEDED=yes - { $as_echo "$as_me:$LINENO: result: alsa cups pulse x11" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: alsa cups pulse x11" >&5 $as_echo "alsa cups pulse x11" >&6; } fi if test "x$OPENJDK_TARGET_OS" = xmacosx; then - { $as_echo "$as_me:$LINENO: checking what is not needed on MacOSX?" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking what is not needed on MacOSX?" >&5 $as_echo_n "checking what is not needed on MacOSX?... " >&6; } ALSA_NOT_NEEDED=yes PULSE_NOT_NEEDED=yes @@ -29222,15 +27753,15 @@ $as_echo_n "checking what is not needed on MacOSX?... " >&6; } FREETYPE2_NOT_NEEDED=yes # If the java runtime framework is disabled, then we need X11. # This will be adjusted below. - { $as_echo "$as_me:$LINENO: result: alsa pulse x11" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: alsa pulse x11" >&5 $as_echo "alsa pulse x11" >&6; } fi if test "x$OPENJDK_TARGET_OS" = xbsd; then - { $as_echo "$as_me:$LINENO: checking what is not needed on bsd?" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking what is not needed on bsd?" >&5 $as_echo_n "checking what is not needed on bsd?... " >&6; } ALSA_NOT_NEEDED=yes - { $as_echo "$as_me:$LINENO: result: alsa" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: alsa" >&5 $as_echo "alsa" >&6; } fi @@ -29248,7 +27779,7 @@ fi # that uses this API. # # Check whether --enable-macosx-runtime-support was given. -if test "${enable_macosx_runtime_support+set}" = set; then +if test "${enable_macosx_runtime_support+set}" = set; then : enableval=$enable_macosx_runtime_support; MACOSX_RUNTIME_SUPPORT="${enableval}" else MACOSX_RUNTIME_SUPPORT="no" @@ -29256,29 +27787,29 @@ fi USE_MACOSX_RUNTIME_SUPPORT=no -{ $as_echo "$as_me:$LINENO: checking for explicit Java runtime support in the OS" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for explicit Java runtime support in the OS" >&5 $as_echo_n "checking for explicit Java runtime support in the OS... " >&6; } if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then if test "x$MACOSX_RUNTIME_SUPPORT" != xno; then MACOSX_RUNTIME_SUPPORT=yes USE_MACOSX_RUNTIME_SUPPORT=yes - { $as_echo "$as_me:$LINENO: result: yes, does not need alsa freetype2 pulse and X11" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, does not need alsa freetype2 pulse and X11" >&5 $as_echo "yes, does not need alsa freetype2 pulse and X11" >&6; } else - { $as_echo "$as_me:$LINENO: result: yes, but explicitly disabled." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, but explicitly disabled." >&5 $as_echo "yes, but explicitly disabled." >&6; } fi else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$USE_MACOSX_RUNTIME_SUPPORT" = xno; then - { $as_echo "$as_me:$LINENO: checking what is not needed on an X11 build on MacOSX?" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking what is not needed on an X11 build on MacOSX?" >&5 $as_echo_n "checking what is not needed on an X11 build on MacOSX?... " >&6; } X11_NOT_NEEDED= FREETYPE2_NOT_NEEDED= - { $as_echo "$as_me:$LINENO: result: alsa pulse" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: alsa pulse" >&5 $as_echo "alsa pulse" >&6; } fi @@ -29307,12 +27838,12 @@ if test "x$SYS_ROOT" != "x/"; then fi # Now let autoconf do it's magic -{ $as_echo "$as_me:$LINENO: checking for X" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for X" >&5 $as_echo_n "checking for X... " >&6; } # Check whether --with-x was given. -if test "${with_x+set}" = set; then +if test "${with_x+set}" = set; then : withval=$with_x; fi @@ -29322,10 +27853,8 @@ if test "x$with_x" = xno; then have_x=disabled else case $x_includes,$x_libraries in #( - *\'*) { { $as_echo "$as_me:$LINENO: error: cannot use X directory names containing '" >&5 -$as_echo "$as_me: error: cannot use X directory names containing '" >&2;} - { (exit 1); exit 1; }; };; #( - *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then + *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5 ;; #( + *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then : $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. @@ -29342,7 +27871,7 @@ libdir: @echo libdir='${LIBDIR}' _ACEOF if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then - # GNU make sometimes prints "make[1]: Entering...", which would confuse us. + # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. for ac_var in incroot usrlibdir libdir; do eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`" done @@ -29373,21 +27902,25 @@ fi # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include +/usr/X11R7/include /usr/X11R6/include /usr/X11R5/include /usr/X11R4/include /usr/include/X11 +/usr/include/X11R7 /usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 /usr/local/X11/include +/usr/local/X11R7/include /usr/local/X11R6/include /usr/local/X11R5/include /usr/local/X11R4/include /usr/local/include/X11 +/usr/local/include/X11R7 /usr/local/include/X11R6 /usr/local/include/X11R5 /usr/local/include/X11R4 @@ -29409,37 +27942,14 @@ ac_x_header_dirs=' if test "$ac_x_includes" = no; then # Guess where to find include files, by looking for Xlib.h. # First, try using that file with no special directory specified. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_cxx_try_cpp "$LINENO"; then : # We can compile using X headers with no special include directory. ac_x_includes= else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - for ac_dir in $ac_x_header_dirs; do if test -r "$ac_dir/X11/Xlib.h"; then ac_x_includes=$ac_dir @@ -29447,8 +27957,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi done fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext fi # $ac_x_includes = no if test "$ac_x_libraries" = no; then @@ -29457,11 +27966,7 @@ if test "$ac_x_libraries" = no; then # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS LIBS="-lX11 $LIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -29472,35 +27977,12 @@ XrmInitialize () return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : LIBS=$ac_save_LIBS # We can link X programs with no special library path. ac_x_libraries= else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - LIBS=$ac_save_LIBS + LIBS=$ac_save_LIBS for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` do # Don't even attempt the hair of trying to link an X program! @@ -29512,10 +27994,8 @@ do done done fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no case $ac_x_includes,$ac_x_libraries in #( @@ -29536,7 +28016,7 @@ fi fi # $with_x != no if test "$have_x" != yes; then - { $as_echo "$as_me:$LINENO: result: $have_x" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5 $as_echo "$have_x" >&6; } no_x=yes else @@ -29547,16 +28027,14 @@ else ac_cv_have_x="have_x=yes\ ac_x_includes='$x_includes'\ ac_x_libraries='$x_libraries'" - { $as_echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5 $as_echo "libraries $x_libraries, headers $x_includes" >&6; } fi if test "$no_x" = yes; then # Not all programs may use this symbol, but it does not hurt to define it. -cat >>confdefs.h <<\_ACEOF -#define X_DISPLAY_MISSING 1 -_ACEOF +$as_echo "#define X_DISPLAY_MISSING 1" >>confdefs.h X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= else @@ -29569,16 +28047,12 @@ else X_LIBS="$X_LIBS -L$x_libraries" # For Solaris; some versions of Sun CC require a space after -R and # others require no space. Words are not sufficient . . . . - { $as_echo "$as_me:$LINENO: checking whether -R must be followed by a space" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -R must be followed by a space" >&5 $as_echo_n "checking whether -R must be followed by a space... " >&6; } ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries" ac_xsave_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -29589,40 +28063,13 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: no" >&5 +if ac_fn_cxx_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } X_LIBS="$X_LIBS -R$x_libraries" else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - LIBS="$ac_xsave_LIBS -R $x_libraries" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + LIBS="$ac_xsave_LIBS -R $x_libraries" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -29633,46 +28080,19 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 +if ac_fn_cxx_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } X_LIBS="$X_LIBS -R $x_libraries" else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: neither works" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: neither works" >&5 $as_echo "neither works" >&6; } fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext ac_cxx_werror_flag=$ac_xsave_cxx_werror_flag LIBS=$ac_xsave_LIBS fi @@ -29688,11 +28108,7 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ # libraries were built with DECnet support. And Karl Berry says # the Alpha needs dnet_stub (dnet does not exist). ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -29710,44 +28126,17 @@ return XOpenDisplay (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_cxx_try_link "$LINENO"; then : - { $as_echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; } -if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then +if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -29765,59 +28154,30 @@ return dnet_ntoa (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_dnet_dnet_ntoa=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_dnet_dnet_ntoa=no + ac_cv_lib_dnet_dnet_ntoa=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then +if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then - { $as_echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; } -if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then +if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet_stub $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -29835,52 +28195,25 @@ return dnet_ntoa (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_dnet_stub_dnet_ntoa=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_dnet_stub_dnet_ntoa=no + ac_cv_lib_dnet_stub_dnet_ntoa=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = x""yes; then +if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi fi fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS="$ac_xsave_LIBS" # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, @@ -29891,105 +28224,20 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ # on Irix 5.2, according to T.E. Dickey. # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. - { $as_echo "$as_me:$LINENO: checking for gethostbyname" >&5 -$as_echo_n "checking for gethostbyname... " >&6; } -if test "${ac_cv_func_gethostbyname+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define gethostbyname to an innocuous variant, in case declares gethostbyname. - For example, HP-UX 11i declares gettimeofday. */ -#define gethostbyname innocuous_gethostbyname + ac_fn_cxx_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" +if test "x$ac_cv_func_gethostbyname" = x""yes; then : -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char gethostbyname (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef gethostbyname - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gethostbyname (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_gethostbyname || defined __stub___gethostbyname -choke me -#endif - -int -main () -{ -return gethostbyname (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_gethostbyname=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_gethostbyname=no fi -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5 -$as_echo "$ac_cv_func_gethostbyname" >&6; } - if test $ac_cv_func_gethostbyname = no; then - { $as_echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 $as_echo_n "checking for gethostbyname in -lnsl... " >&6; } -if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then +if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -30007,59 +28255,30 @@ return gethostbyname (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_nsl_gethostbyname=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_nsl_gethostbyname=no + ac_cv_lib_nsl_gethostbyname=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } -if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then +if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then - { $as_echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5 $as_echo_n "checking for gethostbyname in -lbsd... " >&6; } -if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then +if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbsd $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -30077,43 +28296,18 @@ return gethostbyname (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_bsd_gethostbyname=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_bsd_gethostbyname=no + ac_cv_lib_bsd_gethostbyname=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5 $as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; } -if test "x$ac_cv_lib_bsd_gethostbyname" = x""yes; then +if test "x$ac_cv_lib_bsd_gethostbyname" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi @@ -30127,105 +28321,20 @@ fi # variants that don't use the name server (or something). -lsocket # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. - { $as_echo "$as_me:$LINENO: checking for connect" >&5 -$as_echo_n "checking for connect... " >&6; } -if test "${ac_cv_func_connect+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define connect to an innocuous variant, in case declares connect. - For example, HP-UX 11i declares gettimeofday. */ -#define connect innocuous_connect + ac_fn_cxx_check_func "$LINENO" "connect" "ac_cv_func_connect" +if test "x$ac_cv_func_connect" = x""yes; then : -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char connect (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef connect - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char connect (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_connect || defined __stub___connect -choke me -#endif - -int -main () -{ -return connect (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_connect=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_connect=no fi -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5 -$as_echo "$ac_cv_func_connect" >&6; } - if test $ac_cv_func_connect = no; then - { $as_echo "$as_me:$LINENO: checking for connect in -lsocket" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 $as_echo_n "checking for connect in -lsocket... " >&6; } -if test "${ac_cv_lib_socket_connect+set}" = set; then +if test "${ac_cv_lib_socket_connect+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $X_EXTRA_LIBS $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -30243,148 +28352,38 @@ return connect (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_socket_connect=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_socket_connect=no + ac_cv_lib_socket_connect=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 $as_echo "$ac_cv_lib_socket_connect" >&6; } -if test "x$ac_cv_lib_socket_connect" = x""yes; then +if test "x$ac_cv_lib_socket_connect" = x""yes; then : X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi fi # Guillermo Gomez says -lposix is necessary on A/UX. - { $as_echo "$as_me:$LINENO: checking for remove" >&5 -$as_echo_n "checking for remove... " >&6; } -if test "${ac_cv_func_remove+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define remove to an innocuous variant, in case declares remove. - For example, HP-UX 11i declares gettimeofday. */ -#define remove innocuous_remove + ac_fn_cxx_check_func "$LINENO" "remove" "ac_cv_func_remove" +if test "x$ac_cv_func_remove" = x""yes; then : -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char remove (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef remove - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char remove (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_remove || defined __stub___remove -choke me -#endif - -int -main () -{ -return remove (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_remove=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_remove=no fi -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5 -$as_echo "$ac_cv_func_remove" >&6; } - if test $ac_cv_func_remove = no; then - { $as_echo "$as_me:$LINENO: checking for remove in -lposix" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5 $as_echo_n "checking for remove in -lposix... " >&6; } -if test "${ac_cv_lib_posix_remove+set}" = set; then +if test "${ac_cv_lib_posix_remove+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lposix $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -30402,148 +28401,38 @@ return remove (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_posix_remove=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_posix_remove=no + ac_cv_lib_posix_remove=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5 $as_echo "$ac_cv_lib_posix_remove" >&6; } -if test "x$ac_cv_lib_posix_remove" = x""yes; then +if test "x$ac_cv_lib_posix_remove" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. - { $as_echo "$as_me:$LINENO: checking for shmat" >&5 -$as_echo_n "checking for shmat... " >&6; } -if test "${ac_cv_func_shmat+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define shmat to an innocuous variant, in case declares shmat. - For example, HP-UX 11i declares gettimeofday. */ -#define shmat innocuous_shmat + ac_fn_cxx_check_func "$LINENO" "shmat" "ac_cv_func_shmat" +if test "x$ac_cv_func_shmat" = x""yes; then : -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char shmat (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef shmat - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char shmat (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_shmat || defined __stub___shmat -choke me -#endif - -int -main () -{ -return shmat (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_shmat=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_shmat=no fi -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5 -$as_echo "$ac_cv_func_shmat" >&6; } - if test $ac_cv_func_shmat = no; then - { $as_echo "$as_me:$LINENO: checking for shmat in -lipc" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5 $as_echo_n "checking for shmat in -lipc... " >&6; } -if test "${ac_cv_lib_ipc_shmat+set}" = set; then +if test "${ac_cv_lib_ipc_shmat+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lipc $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -30561,43 +28450,18 @@ return shmat (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_ipc_shmat=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_ipc_shmat=no + ac_cv_lib_ipc_shmat=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5 $as_echo "$ac_cv_lib_ipc_shmat" >&6; } -if test "x$ac_cv_lib_ipc_shmat" = x""yes; then +if test "x$ac_cv_lib_ipc_shmat" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi @@ -30613,18 +28477,14 @@ fi # These have to be linked with before -lX11, unlike the other # libraries we check for below, so use a different variable. # John Interrante, Karl Berry - { $as_echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5 $as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; } -if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then +if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lICE $X_EXTRA_LIBS $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -30642,43 +28502,18 @@ return IceConnectionNumber (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_ICE_IceConnectionNumber=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_ICE_IceConnectionNumber=no + ac_cv_lib_ICE_IceConnectionNumber=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 $as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; } -if test "x$ac_cv_lib_ICE_IceConnectionNumber" = x""yes; then +if test "x$ac_cv_lib_ICE_IceConnectionNumber" = x""yes; then : X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi @@ -30713,9 +28548,7 @@ if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." fi - { { $as_echo "$as_me:$LINENO: error: Could not find X11 libraries. $HELP_MSG" >&5 -$as_echo "$as_me: error: Could not find X11 libraries. $HELP_MSG" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find X11 libraries. $HELP_MSG" "$LINENO" 5 fi # Some of the old makefiles require a setting of OPENWIN_HOME @@ -30756,64 +28589,14 @@ OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $X_CFLAGS" # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10 - - - for ac_header in X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - # include +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " # include # include - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -30859,9 +28642,7 @@ if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." fi - { { $as_echo "$as_me:$LINENO: error: Could not find all X11 headers (shape.h Xrender.h XTest.h). $HELP_MSG" >&5 -$as_echo "$as_me: error: Could not find all X11 headers (shape.h Xrender.h XTest.h). $HELP_MSG" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find all X11 headers (shape.h Xrender.h XTest.h). $HELP_MSG" "$LINENO" 5 fi @@ -30875,20 +28656,20 @@ fi # # Check whether --with-cups was given. -if test "${with_cups+set}" = set; then +if test "${with_cups+set}" = set; then : withval=$with_cups; fi # Check whether --with-cups-include was given. -if test "${with_cups_include+set}" = set; then +if test "${with_cups_include+set}" = set; then : withval=$with_cups_include; fi if test "x$CUPS_NOT_NEEDED" = xyes; then if test "x${with_cups}" != x || test "x${with_cups_include}" != x; then - { $as_echo "$as_me:$LINENO: WARNING: cups not used, so --with-cups is ignored" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cups not used, so --with-cups is ignored" >&5 $as_echo "$as_me: WARNING: cups not used, so --with-cups is ignored" >&2;} fi CUPS_CFLAGS= @@ -30896,9 +28677,7 @@ else CUPS_FOUND=no if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno; then - { { $as_echo "$as_me:$LINENO: error: It is not possible to disable the use of cups. Remove the --without-cups option." >&5 -$as_echo "$as_me: error: It is not possible to disable the use of cups. Remove the --without-cups option." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "It is not possible to disable the use of cups. Remove the --without-cups option." "$LINENO" 5 fi if test "x${with_cups}" != x; then @@ -30931,7 +28710,7 @@ $as_echo "$as_me: error: It is not possible to disable the use of cups. Remove t resource=${builddep_cups} fi if test "x$resource" != x; then - { $as_echo "$as_me:$LINENO: Using builddeps $resource for cups" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Using builddeps $resource for cups" >&5 $as_echo "$as_me: Using builddeps $resource for cups" >&6;} # If the resource in the builddeps.conf file is an existing directory, # for example /java/linux/cups @@ -30952,22 +28731,18 @@ $as_echo "$as_me: Using builddeps $resource for cups" >&6;} extension=${filename#*.} installdir=$with_builddeps_dir/$filebase if test ! -f $installdir/$filename.unpacked; then - { $as_echo "$as_me:$LINENO: Downloading build dependency cups from $with_builddeps_server/$resource and installing into $installdir" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Downloading build dependency cups from $with_builddeps_server/$resource and installing into $installdir" >&5 $as_echo "$as_me: Downloading build dependency cups from $with_builddeps_server/$resource and installing into $installdir" >&6;} if test ! -d $installdir; then mkdir -p $installdir fi if test ! -d $installdir; then - { { $as_echo "$as_me:$LINENO: error: Could not create directory $installdir" >&5 -$as_echo "$as_me: error: Could not create directory $installdir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create directory $installdir" "$LINENO" 5 fi tmpfile=`mktemp $installdir/cups.XXXXXXXXX` touch $tmpfile if test ! -f $tmpfile; then - { { $as_echo "$as_me:$LINENO: error: Could not create files in directory $installdir" >&5 -$as_echo "$as_me: error: Could not create files in directory $installdir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create files in directory $installdir" "$LINENO" 5 fi # $with_builddeps_server/$resource is the ftp://abuilddeps.server.com/libs/cups.zip @@ -31005,16 +28780,12 @@ $as_echo "$as_me: error: Could not create files in directory $installdir" >&2;} ) | ftp -in $FTPSERVER fi if test "x$VALID_TOOL" != xyes; then - { { $as_echo "$as_me:$LINENO: error: I do not know how to use the tool: $BDEPS_FTP" >&5 -$as_echo "$as_me: error: I do not know how to use the tool: $BDEPS_FTP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "I do not know how to use the tool: $BDEPS_FTP" "$LINENO" 5 fi mv $tmpfile $installdir/$filename if test ! -s $installdir/$filename; then - { { $as_echo "$as_me:$LINENO: error: Could not download $with_builddeps_server/$resource" >&5 -$as_echo "$as_me: error: Could not download $with_builddeps_server/$resource" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not download $with_builddeps_server/$resource" "$LINENO" 5 fi case "$extension" in zip) echo "Unzipping $installdir/$filename..." @@ -31026,9 +28797,7 @@ $as_echo "$as_me: error: Could not download $with_builddeps_server/$resource" >& tgz) echo "Untaring $installdir/$filename..." (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked) ;; - *) { { $as_echo "$as_me:$LINENO: error: Cannot handle build depency archive with extension $extension" >&5 -$as_echo "$as_me: error: Cannot handle build depency archive with extension $extension" >&2;} - { (exit 1); exit 1; }; } + *) as_fn_error $? "Cannot handle build depency archive with extension $extension" "$LINENO" 5 ;; esac fi @@ -31045,9 +28814,7 @@ $as_echo "$as_me: error: Cannot handle build depency archive with extension $ext thecflags=${builddep_cups_CFLAGS} thelibs=${builddep_cups_LIBS} if test "x$depdir" = x; then - { { $as_echo "$as_me:$LINENO: error: Could not download build dependency cups" >&5 -$as_echo "$as_me: error: Could not download build dependency cups" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not download build dependency cups" "$LINENO" 5 fi CUPS=$depdir if test "x$theroot" != x; then @@ -31068,150 +28835,11 @@ $as_echo "$as_me: error: Could not download build dependency cups" >&2;} fi if test "x$CUPS_FOUND" = xno; then # Are the cups headers installed in the default /usr/include location? - - -for ac_header in cups/cups.h cups/ppd.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## ----------------------------------------- ## -## Report this to build-dev@openjdk.java.net ## -## ----------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then + for ac_header in cups/cups.h cups/ppd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -31226,7 +28854,7 @@ done if test "x$CUPS_FOUND" = xno; then # Getting nervous now? Lets poke around for standard Solaris third-party # package installation locations. - { $as_echo "$as_me:$LINENO: checking for cups headers" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cups headers" >&5 $as_echo_n "checking for cups headers... " >&6; } if test -s /opt/sfw/cups/include/cups/cups.h; then # An SFW package seems to be installed! @@ -31237,7 +28865,7 @@ $as_echo_n "checking for cups headers... " >&6; } CUPS_FOUND=yes CUPS_CFLAGS="-I/opt/csw/include" fi - { $as_echo "$as_me:$LINENO: result: $CUPS_FOUND" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_FOUND" >&5 $as_echo "$CUPS_FOUND" >&6; } fi if test "x$CUPS_FOUND" = xno; then @@ -31266,9 +28894,7 @@ $as_echo "$CUPS_FOUND" >&6; } HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." fi - { { $as_echo "$as_me:$LINENO: error: Could not find cups! $HELP_MSG " >&5 -$as_echo "$as_me: error: Could not find cups! $HELP_MSG " >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find cups! $HELP_MSG " "$LINENO" 5 fi fi @@ -31283,7 +28909,7 @@ fi # # Check whether --with-freetype was given. -if test "${with_freetype+set}" = set; then +if test "${with_freetype+set}" = set; then : withval=$with_freetype; fi @@ -31293,7 +28919,7 @@ USING_SYSTEM_FT_LIB=false if test "x$FREETYPE2_NOT_NEEDED" = xyes; then if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then - { $as_echo "$as_me:$LINENO: WARNING: freetype not used, so --with-freetype is ignored" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: freetype not used, so --with-freetype is ignored" >&5 $as_echo "$as_me: WARNING: freetype not used, so --with-freetype is ignored" >&2;} fi FREETYPE2_CFLAGS= @@ -31320,11 +28946,9 @@ else # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of with_freetype, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of with_freetype, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of with_freetype, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of with_freetype" >&5 -$as_echo "$as_me: error: Cannot locate the the path of with_freetype" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of with_freetype" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -31363,7 +28987,7 @@ $as_echo "$as_me: error: Cannot locate the the path of with_freetype" >&2;} if test "x$path" != "x$new_path"; then with_freetype="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting with_freetype to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting with_freetype to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting with_freetype to \"$new_path\"" >&6;} fi @@ -31401,7 +29025,7 @@ $as_echo "$as_me: Rewriting with_freetype to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then with_freetype="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting with_freetype to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting with_freetype to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting with_freetype to \"$new_path\"" >&6;} fi @@ -31413,18 +29037,14 @@ $as_echo "$as_me: Rewriting with_freetype to \"$new_path\"" >&6;} path="$with_freetype" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of with_freetype, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of with_freetype, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of with_freetype, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of with_freetype, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of with_freetype, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of with_freetype, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi @@ -31445,22 +29065,16 @@ $as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} if test "x$FREETYPE2_FOUND" = xyes; then # Verify that the directories exist if ! test -d "$with_freetype/lib" || ! test -d "$with_freetype/include"; then - { { $as_echo "$as_me:$LINENO: error: Could not find the expected directories $with_freetype/lib and $with_freetype/include" >&5 -$as_echo "$as_me: error: Could not find the expected directories $with_freetype/lib and $with_freetype/include" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find the expected directories $with_freetype/lib and $with_freetype/include" "$LINENO" 5 fi # List the contents of the lib. FREETYPELIB=`ls $with_freetype/lib/libfreetype.so $with_freetype/lib/freetype.dll 2> /dev/null` if test "x$FREETYPELIB" = x; then - { { $as_echo "$as_me:$LINENO: error: Could not find libfreetype.so nor freetype.dll in $with_freetype/lib" >&5 -$as_echo "$as_me: error: Could not find libfreetype.so nor freetype.dll in $with_freetype/lib" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find libfreetype.so nor freetype.dll in $with_freetype/lib" "$LINENO" 5 fi # Check one h-file if ! test -s "$with_freetype/include/ft2build.h"; then - { { $as_echo "$as_me:$LINENO: error: Could not find $with_freetype/include/ft2build.h" >&5 -$as_echo "$as_me: error: Could not find $with_freetype/include/ft2build.h" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find $with_freetype/include/ft2build.h" "$LINENO" 5 fi fi fi @@ -31486,7 +29100,7 @@ $as_echo "$as_me: error: Could not find $with_freetype/include/ft2build.h" >&2;} resource=${builddep_freetype2} fi if test "x$resource" != x; then - { $as_echo "$as_me:$LINENO: Using builddeps $resource for freetype2" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Using builddeps $resource for freetype2" >&5 $as_echo "$as_me: Using builddeps $resource for freetype2" >&6;} # If the resource in the builddeps.conf file is an existing directory, # for example /java/linux/cups @@ -31507,22 +29121,18 @@ $as_echo "$as_me: Using builddeps $resource for freetype2" >&6;} extension=${filename#*.} installdir=$with_builddeps_dir/$filebase if test ! -f $installdir/$filename.unpacked; then - { $as_echo "$as_me:$LINENO: Downloading build dependency freetype2 from $with_builddeps_server/$resource and installing into $installdir" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Downloading build dependency freetype2 from $with_builddeps_server/$resource and installing into $installdir" >&5 $as_echo "$as_me: Downloading build dependency freetype2 from $with_builddeps_server/$resource and installing into $installdir" >&6;} if test ! -d $installdir; then mkdir -p $installdir fi if test ! -d $installdir; then - { { $as_echo "$as_me:$LINENO: error: Could not create directory $installdir" >&5 -$as_echo "$as_me: error: Could not create directory $installdir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create directory $installdir" "$LINENO" 5 fi tmpfile=`mktemp $installdir/freetype2.XXXXXXXXX` touch $tmpfile if test ! -f $tmpfile; then - { { $as_echo "$as_me:$LINENO: error: Could not create files in directory $installdir" >&5 -$as_echo "$as_me: error: Could not create files in directory $installdir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create files in directory $installdir" "$LINENO" 5 fi # $with_builddeps_server/$resource is the ftp://abuilddeps.server.com/libs/cups.zip @@ -31560,16 +29170,12 @@ $as_echo "$as_me: error: Could not create files in directory $installdir" >&2;} ) | ftp -in $FTPSERVER fi if test "x$VALID_TOOL" != xyes; then - { { $as_echo "$as_me:$LINENO: error: I do not know how to use the tool: $BDEPS_FTP" >&5 -$as_echo "$as_me: error: I do not know how to use the tool: $BDEPS_FTP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "I do not know how to use the tool: $BDEPS_FTP" "$LINENO" 5 fi mv $tmpfile $installdir/$filename if test ! -s $installdir/$filename; then - { { $as_echo "$as_me:$LINENO: error: Could not download $with_builddeps_server/$resource" >&5 -$as_echo "$as_me: error: Could not download $with_builddeps_server/$resource" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not download $with_builddeps_server/$resource" "$LINENO" 5 fi case "$extension" in zip) echo "Unzipping $installdir/$filename..." @@ -31581,9 +29187,7 @@ $as_echo "$as_me: error: Could not download $with_builddeps_server/$resource" >& tgz) echo "Untaring $installdir/$filename..." (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked) ;; - *) { { $as_echo "$as_me:$LINENO: error: Cannot handle build depency archive with extension $extension" >&5 -$as_echo "$as_me: error: Cannot handle build depency archive with extension $extension" >&2;} - { (exit 1); exit 1; }; } + *) as_fn_error $? "Cannot handle build depency archive with extension $extension" "$LINENO" 5 ;; esac fi @@ -31600,9 +29204,7 @@ $as_echo "$as_me: error: Cannot handle build depency archive with extension $ext thecflags=${builddep_freetype2_CFLAGS} thelibs=${builddep_freetype2_LIBS} if test "x$depdir" = x; then - { { $as_echo "$as_me:$LINENO: error: Could not download build dependency freetype2" >&5 -$as_echo "$as_me: error: Could not download build dependency freetype2" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not download build dependency freetype2" "$LINENO" 5 fi FREETYPE2=$depdir if test "x$theroot" != x; then @@ -31643,11 +29245,9 @@ $as_echo "$as_me: error: Could not download build dependency freetype2" >&2;} # It is also a way to make sure we got the proper file name for the real test later on. test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` if test "x$test_shortpath" = x; then - { $as_echo "$as_me:$LINENO: The path of FREETYPELOCATION, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPELOCATION, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of FREETYPELOCATION, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Cannot locate the the path of FREETYPELOCATION" >&5 -$as_echo "$as_me: error: Cannot locate the the path of FREETYPELOCATION" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot locate the the path of FREETYPELOCATION" "$LINENO" 5 fi # Call helper function which possibly converts this using DOS-style short mode. @@ -31686,7 +29286,7 @@ $as_echo "$as_me: error: Cannot locate the the path of FREETYPELOCATION" >&2;} if test "x$path" != "x$new_path"; then FREETYPELOCATION="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting FREETYPELOCATION to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FREETYPELOCATION to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting FREETYPELOCATION to \"$new_path\"" >&6;} fi @@ -31724,7 +29324,7 @@ $as_echo "$as_me: Rewriting FREETYPELOCATION to \"$new_path\"" >&6;} if test "x$path" != "x$new_path"; then FREETYPELOCATION="$new_path" - { $as_echo "$as_me:$LINENO: Rewriting FREETYPELOCATION to \"$new_path\"" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FREETYPELOCATION to \"$new_path\"" >&5 $as_echo "$as_me: Rewriting FREETYPELOCATION to \"$new_path\"" >&6;} fi @@ -31736,58 +29336,50 @@ $as_echo "$as_me: Rewriting FREETYPELOCATION to \"$new_path\"" >&6;} path="$FREETYPELOCATION" if test ! -f "$path" && test ! -d "$path"; then - { { $as_echo "$as_me:$LINENO: error: The path of FREETYPELOCATION, which resolves as \"$path\", is not found." >&5 -$as_echo "$as_me: error: The path of FREETYPELOCATION, which resolves as \"$path\", is not found." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "The path of FREETYPELOCATION, which resolves as \"$path\", is not found." "$LINENO" 5 fi has_space=`$ECHO "$path" | $GREP " "` if test "x$has_space" != x; then - { $as_echo "$as_me:$LINENO: The path of FREETYPELOCATION, which resolves as \"$path\", is invalid." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPELOCATION, which resolves as \"$path\", is invalid." >&5 $as_echo "$as_me: The path of FREETYPELOCATION, which resolves as \"$path\", is invalid." >&6;} - { { $as_echo "$as_me:$LINENO: error: Spaces are not allowed in this path." >&5 -$as_echo "$as_me: error: Spaces are not allowed in this path." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 fi fi - { $as_echo "$as_me:$LINENO: checking for freetype in some standard windows locations" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype in some standard windows locations" >&5 $as_echo_n "checking for freetype in some standard windows locations... " >&6; } if test -s "$FREETYPELOCATION/include/ft2build.h" && test -d "$FREETYPELOCATION/include/freetype2/freetype"; then FREETYPE2_CFLAGS="-I$FREETYPELOCATION/include/freetype2 -I$FREETYPELOCATION/include" FREETYPE2_LIBS="$FREETYPELOCATION/lib/freetype.lib" FREETYPE2_LIB_PATH="$FREETYPELOCATION/lib" if ! test -s "$FREETYPE2_LIBS"; then - { { $as_echo "$as_me:$LINENO: error: Could not find $FREETYPE2_LIBS" >&5 -$as_echo "$as_me: error: Could not find $FREETYPE2_LIBS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find $FREETYPE2_LIBS" "$LINENO" 5 fi if ! test -s "$FREETYPE2_LIB_PATH/freetype.dll"; then - { { $as_echo "$as_me:$LINENO: error: Could not find $FREETYPE2_LIB_PATH/freetype.dll" >&5 -$as_echo "$as_me: error: Could not find $FREETYPE2_LIB_PATH/freetype.dll" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find $FREETYPE2_LIB_PATH/freetype.dll" "$LINENO" 5 fi USING_SYSTEM_FT_LIB=true FREETYPE2_FOUND=yes fi - { $as_echo "$as_me:$LINENO: result: $FREETYPE2_FOUND" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE2_FOUND" >&5 $as_echo "$FREETYPE2_FOUND" >&6; } fi if test "x$FREETYPE2_FOUND" = xno; then pkg_failed=no -{ $as_echo "$as_me:$LINENO: checking for FREETYPE2" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for FREETYPE2" >&5 $as_echo_n "checking for FREETYPE2... " >&6; } if test -n "$FREETYPE2_CFLAGS"; then pkg_cv_FREETYPE2_CFLAGS="$FREETYPE2_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"freetype2\"") >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"freetype2\""; } >&5 ($PKG_CONFIG --exists --print-errors "freetype2") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then pkg_cv_FREETYPE2_CFLAGS=`$PKG_CONFIG --cflags "freetype2" 2>/dev/null` else pkg_failed=yes @@ -31799,11 +29391,11 @@ if test -n "$FREETYPE2_LIBS"; then pkg_cv_FREETYPE2_LIBS="$FREETYPE2_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"freetype2\"") >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"freetype2\""; } >&5 ($PKG_CONFIG --exists --print-errors "freetype2") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then pkg_cv_FREETYPE2_LIBS=`$PKG_CONFIG --libs "freetype2" 2>/dev/null` else pkg_failed=yes @@ -31829,7 +29421,7 @@ fi # Put the nasty error message in config.log where it belongs echo "$FREETYPE2_PKG_ERRORS" >&5 - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } FREETYPE2_FOUND=no elif test $pkg_failed = untried; then @@ -31837,7 +29429,7 @@ elif test $pkg_failed = untried; then else FREETYPE2_CFLAGS=$pkg_cv_FREETYPE2_CFLAGS FREETYPE2_LIBS=$pkg_cv_FREETYPE2_LIBS - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } FREETYPE2_FOUND=yes fi @@ -31850,7 +29442,7 @@ fi fi fi if test "x$FREETYPE2_FOUND" = xno; then - { $as_echo "$as_me:$LINENO: checking for freetype in some standard locations" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype in some standard locations" >&5 $as_echo_n "checking for freetype in some standard locations... " >&6; } if test -s /usr/X11/include/ft2build.h && test -d /usr/X11/include/freetype2/freetype; then @@ -31866,38 +29458,14 @@ $as_echo_n "checking for freetype in some standard locations... " >&6; } PREV_LDFLAGS="$LDFLAGS" CXXFLAGS="$CXXFLAGS $DEFAULT_FREETYPE_CFLAGS" LDFLAGS="$LDFLAGS $DEFAULT_FREETYPE_LIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include FT_FREETYPE_H int main() { return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : # Yes, the default cflags and libs did the trick. FREETYPE2_FOUND=yes @@ -31905,20 +29473,15 @@ $as_echo "$ac_try_echo") >&5 FREETYPE2_LIBS="$DEFAULT_FREETYPE_LIBS" else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - FREETYPE2_FOUND=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext CXXCFLAGS="$PREV_CXXFLAGS" LDFLAGS="$PREV_LDFLAGS" - { $as_echo "$as_me:$LINENO: result: $FREETYPE2_FOUND" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE2_FOUND" >&5 $as_echo "$FREETYPE2_FOUND" >&6; } USING_SYSTEM_FT_LIB=true fi @@ -31948,27 +29511,21 @@ $as_echo "$FREETYPE2_FOUND" >&6; } HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." fi - { { $as_echo "$as_me:$LINENO: error: Could not find freetype2! $HELP_MSG " >&5 -$as_echo "$as_me: error: Could not find freetype2! $HELP_MSG " >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find freetype2! $HELP_MSG " "$LINENO" 5 fi if test "x$OPENJDK_TARGET_OS" != xwindows; then # AC_CHECK_LIB does not support use of cl.exe PREV_LDFLAGS="$LDFLAGS" LDFLAGS="$FREETYPE2_LIBS" - { $as_echo "$as_me:$LINENO: checking for FT_Init_FreeType in -lfreetype" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FT_Init_FreeType in -lfreetype" >&5 $as_echo_n "checking for FT_Init_FreeType in -lfreetype... " >&6; } -if test "${ac_cv_lib_freetype_FT_Init_FreeType+set}" = set; then +if test "${ac_cv_lib_freetype_FT_Init_FreeType+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lfreetype $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -31986,48 +29543,21 @@ return FT_Init_FreeType (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_freetype_FT_Init_FreeType=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_freetype_FT_Init_FreeType=no + ac_cv_lib_freetype_FT_Init_FreeType=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5 $as_echo "$ac_cv_lib_freetype_FT_Init_FreeType" >&6; } -if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = x""yes; then +if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = x""yes; then : FREETYPE2_FOUND=true else - { { $as_echo "$as_me:$LINENO: error: Could not find freetype2! $HELP_MSG " >&5 -$as_echo "$as_me: error: Could not find freetype2! $HELP_MSG " >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find freetype2! $HELP_MSG " "$LINENO" 5 fi LDFLAGS="$PREV_LDFLAGS" @@ -32048,26 +29578,26 @@ fi # # Check whether --with-alsa was given. -if test "${with_alsa+set}" = set; then +if test "${with_alsa+set}" = set; then : withval=$with_alsa; fi # Check whether --with-alsa-include was given. -if test "${with_alsa_include+set}" = set; then +if test "${with_alsa_include+set}" = set; then : withval=$with_alsa_include; fi # Check whether --with-alsa-lib was given. -if test "${with_alsa_lib+set}" = set; then +if test "${with_alsa_lib+set}" = set; then : withval=$with_alsa_lib; fi if test "x$ALSA_NOT_NEEDED" = xyes; then if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then - { $as_echo "$as_me:$LINENO: WARNING: alsa not used, so --with-alsa is ignored" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: alsa not used, so --with-alsa is ignored" >&5 $as_echo "$as_me: WARNING: alsa not used, so --with-alsa is ignored" >&2;} fi ALSA_CFLAGS= @@ -32076,9 +29606,7 @@ else ALSA_FOUND=no if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then - { { $as_echo "$as_me:$LINENO: error: It is not possible to disable the use of alsa. Remove the --without-alsa option." >&5 -$as_echo "$as_me: error: It is not possible to disable the use of alsa. Remove the --without-alsa option." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "It is not possible to disable the use of alsa. Remove the --without-alsa option." "$LINENO" 5 fi if test "x${with_alsa}" != x; then @@ -32116,7 +29644,7 @@ $as_echo "$as_me: error: It is not possible to disable the use of alsa. Remove t resource=${builddep_alsa} fi if test "x$resource" != x; then - { $as_echo "$as_me:$LINENO: Using builddeps $resource for alsa" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Using builddeps $resource for alsa" >&5 $as_echo "$as_me: Using builddeps $resource for alsa" >&6;} # If the resource in the builddeps.conf file is an existing directory, # for example /java/linux/cups @@ -32137,22 +29665,18 @@ $as_echo "$as_me: Using builddeps $resource for alsa" >&6;} extension=${filename#*.} installdir=$with_builddeps_dir/$filebase if test ! -f $installdir/$filename.unpacked; then - { $as_echo "$as_me:$LINENO: Downloading build dependency alsa from $with_builddeps_server/$resource and installing into $installdir" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Downloading build dependency alsa from $with_builddeps_server/$resource and installing into $installdir" >&5 $as_echo "$as_me: Downloading build dependency alsa from $with_builddeps_server/$resource and installing into $installdir" >&6;} if test ! -d $installdir; then mkdir -p $installdir fi if test ! -d $installdir; then - { { $as_echo "$as_me:$LINENO: error: Could not create directory $installdir" >&5 -$as_echo "$as_me: error: Could not create directory $installdir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create directory $installdir" "$LINENO" 5 fi tmpfile=`mktemp $installdir/alsa.XXXXXXXXX` touch $tmpfile if test ! -f $tmpfile; then - { { $as_echo "$as_me:$LINENO: error: Could not create files in directory $installdir" >&5 -$as_echo "$as_me: error: Could not create files in directory $installdir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create files in directory $installdir" "$LINENO" 5 fi # $with_builddeps_server/$resource is the ftp://abuilddeps.server.com/libs/cups.zip @@ -32190,16 +29714,12 @@ $as_echo "$as_me: error: Could not create files in directory $installdir" >&2;} ) | ftp -in $FTPSERVER fi if test "x$VALID_TOOL" != xyes; then - { { $as_echo "$as_me:$LINENO: error: I do not know how to use the tool: $BDEPS_FTP" >&5 -$as_echo "$as_me: error: I do not know how to use the tool: $BDEPS_FTP" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "I do not know how to use the tool: $BDEPS_FTP" "$LINENO" 5 fi mv $tmpfile $installdir/$filename if test ! -s $installdir/$filename; then - { { $as_echo "$as_me:$LINENO: error: Could not download $with_builddeps_server/$resource" >&5 -$as_echo "$as_me: error: Could not download $with_builddeps_server/$resource" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not download $with_builddeps_server/$resource" "$LINENO" 5 fi case "$extension" in zip) echo "Unzipping $installdir/$filename..." @@ -32211,9 +29731,7 @@ $as_echo "$as_me: error: Could not download $with_builddeps_server/$resource" >& tgz) echo "Untaring $installdir/$filename..." (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked) ;; - *) { { $as_echo "$as_me:$LINENO: error: Cannot handle build depency archive with extension $extension" >&5 -$as_echo "$as_me: error: Cannot handle build depency archive with extension $extension" >&2;} - { (exit 1); exit 1; }; } + *) as_fn_error $? "Cannot handle build depency archive with extension $extension" "$LINENO" 5 ;; esac fi @@ -32230,9 +29748,7 @@ $as_echo "$as_me: error: Cannot handle build depency archive with extension $ext thecflags=${builddep_alsa_CFLAGS} thelibs=${builddep_alsa_LIBS} if test "x$depdir" = x; then - { { $as_echo "$as_me:$LINENO: error: Could not download build dependency alsa" >&5 -$as_echo "$as_me: error: Could not download build dependency alsa" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not download build dependency alsa" "$LINENO" 5 fi ALSA=$depdir if test "x$theroot" != x; then @@ -32256,18 +29772,18 @@ $as_echo "$as_me: error: Could not download build dependency alsa" >&2;} if test "x$ALSA_FOUND" = xno; then pkg_failed=no -{ $as_echo "$as_me:$LINENO: checking for ALSA" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ALSA" >&5 $as_echo_n "checking for ALSA... " >&6; } if test -n "$ALSA_CFLAGS"; then pkg_cv_ALSA_CFLAGS="$ALSA_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"alsa\"") >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"alsa\""; } >&5 ($PKG_CONFIG --exists --print-errors "alsa") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then pkg_cv_ALSA_CFLAGS=`$PKG_CONFIG --cflags "alsa" 2>/dev/null` else pkg_failed=yes @@ -32279,11 +29795,11 @@ if test -n "$ALSA_LIBS"; then pkg_cv_ALSA_LIBS="$ALSA_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"alsa\"") >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"alsa\""; } >&5 ($PKG_CONFIG --exists --print-errors "alsa") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then pkg_cv_ALSA_LIBS=`$PKG_CONFIG --libs "alsa" 2>/dev/null` else pkg_failed=yes @@ -32309,7 +29825,7 @@ fi # Put the nasty error message in config.log where it belongs echo "$ALSA_PKG_ERRORS" >&5 - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ALSA_FOUND=no elif test $pkg_failed = untried; then @@ -32317,157 +29833,18 @@ elif test $pkg_failed = untried; then else ALSA_CFLAGS=$pkg_cv_ALSA_CFLAGS ALSA_LIBS=$pkg_cv_ALSA_LIBS - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ALSA_FOUND=yes fi fi if test "x$ALSA_FOUND" = xno; then - -for ac_header in alsa/asoundlib.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## ----------------------------------------- ## -## Report this to build-dev@openjdk.java.net ## -## ----------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then + for ac_header in alsa/asoundlib.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "alsa/asoundlib.h" "ac_cv_header_alsa_asoundlib_h" "$ac_includes_default" +if test "x$ac_cv_header_alsa_asoundlib_h" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_ALSA_ASOUNDLIB_H 1 _ACEOF ALSA_FOUND=yes ALSA_CFLAGS=-Iignoreme @@ -32506,9 +29883,7 @@ done HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." fi - { { $as_echo "$as_me:$LINENO: error: Could not find alsa! $HELP_MSG " >&5 -$as_echo "$as_me: error: Could not find alsa! $HELP_MSG " >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not find alsa! $HELP_MSG " "$LINENO" 5 fi fi @@ -32524,19 +29899,14 @@ fi # USE_EXTERNAL_LIBJPEG=true - -{ $as_echo "$as_me:$LINENO: checking for main in -ljpeg" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ljpeg" >&5 $as_echo_n "checking for main in -ljpeg... " >&6; } -if test "${ac_cv_lib_jpeg_main+set}" = set; then +if test "${ac_cv_lib_jpeg_main+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ljpeg $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -32548,43 +29918,18 @@ return main (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_jpeg_main=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_jpeg_main=no + ac_cv_lib_jpeg_main=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_jpeg_main" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_main" >&5 $as_echo "$ac_cv_lib_jpeg_main" >&6; } -if test "x$ac_cv_lib_jpeg_main" = x""yes; then +if test "x$ac_cv_lib_jpeg_main" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBJPEG 1 _ACEOF @@ -32593,7 +29938,7 @@ _ACEOF else USE_EXTERNAL_LIBJPEG=false - { $as_echo "$as_me:$LINENO: Will use jpeg decoder bundled with the OpenJDK source" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use jpeg decoder bundled with the OpenJDK source" >&5 $as_echo "$as_me: Will use jpeg decoder bundled with the OpenJDK source" >&6;} fi @@ -32606,19 +29951,14 @@ fi # USE_EXTERNAL_LIBJPEG=true - -{ $as_echo "$as_me:$LINENO: checking for main in -lgif" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgif" >&5 $as_echo_n "checking for main in -lgif... " >&6; } -if test "${ac_cv_lib_gif_main+set}" = set; then +if test "${ac_cv_lib_gif_main+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgif $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -32630,43 +29970,18 @@ return main (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_gif_main=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_gif_main=no + ac_cv_lib_gif_main=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_gif_main" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_main" >&5 $as_echo "$ac_cv_lib_gif_main" >&6; } -if test "x$ac_cv_lib_gif_main" = x""yes; then +if test "x$ac_cv_lib_gif_main" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGIF 1 _ACEOF @@ -32675,7 +29990,7 @@ _ACEOF else USE_EXTERNAL_LIBGIF=false - { $as_echo "$as_me:$LINENO: Will use gif decoder bundled with the OpenJDK source" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use gif decoder bundled with the OpenJDK source" >&5 $as_echo "$as_me: Will use gif decoder bundled with the OpenJDK source" >&6;} fi @@ -32689,23 +30004,19 @@ fi # Check whether --with-zlib was given. -if test "${with_zlib+set}" = set; then +if test "${with_zlib+set}" = set; then : withval=$with_zlib; fi -{ $as_echo "$as_me:$LINENO: checking for compress in -lz" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 $as_echo_n "checking for compress in -lz... " >&6; } -if test "${ac_cv_lib_z_compress+set}" = set; then +if test "${ac_cv_lib_z_compress+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -32723,50 +30034,25 @@ return compress (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_z_compress=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_z_compress=no + ac_cv_lib_z_compress=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_z_compress" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 $as_echo "$ac_cv_lib_z_compress" >&6; } -if test "x$ac_cv_lib_z_compress" = x""yes; then +if test "x$ac_cv_lib_z_compress" = x""yes; then : ZLIB_FOUND=yes else ZLIB_FOUND=no fi -{ $as_echo "$as_me:$LINENO: checking for which zlib to use" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for which zlib to use" >&5 $as_echo_n "checking for which zlib to use... " >&6; } DEFAULT_ZLIB=bundled @@ -32793,24 +30079,20 @@ fi if test "x${with_zlib}" = "xbundled"; then USE_EXTERNAL_LIBZ=false - { $as_echo "$as_me:$LINENO: result: bundled" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: bundled" >&5 $as_echo "bundled" >&6; } elif test "x${with_zlib}" = "xsystem"; then if test "x${ZLIB_FOUND}" = "xyes"; then USE_EXTERNAL_LIBZ=true - { $as_echo "$as_me:$LINENO: result: system" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: system" >&5 $as_echo "system" >&6; } else - { $as_echo "$as_me:$LINENO: result: system not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: system not found" >&5 $as_echo "system not found" >&6; } - { { $as_echo "$as_me:$LINENO: error: --with-zlib=system specified, but no zlib found!" >&5 -$as_echo "$as_me: error: --with-zlib=system specified, but no zlib found!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "--with-zlib=system specified, but no zlib found!" "$LINENO" 5 fi else - { { $as_echo "$as_me:$LINENO: error: Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'" >&5 -$as_echo "$as_me: error: Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'" "$LINENO" 5 fi @@ -32825,11 +30107,7 @@ LIBZIP_CAN_USE_MMAP=true # Check if altzone exists in time.h # -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -32840,43 +30118,16 @@ return (int)altzone; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : has_altzone=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - has_altzone=no + has_altzone=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test "x$has_altzone" = xyes; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_ALTZONE 1 -_ACEOF +$as_echo "#define HAVE_ALTZONE 1" >>confdefs.h fi @@ -32885,19 +30136,14 @@ fi # Check the maths library # - -{ $as_echo "$as_me:$LINENO: checking for cos in -lm" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 $as_echo_n "checking for cos in -lm... " >&6; } -if test "${ac_cv_lib_m_cos+set}" = set; then +if test "${ac_cv_lib_m_cos+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -32915,43 +30161,18 @@ return cos (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_m_cos=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_m_cos=no + ac_cv_lib_m_cos=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_m_cos" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 $as_echo "$ac_cv_lib_m_cos" >&6; } -if test "x$ac_cv_lib_m_cos" = x""yes; then +if test "x$ac_cv_lib_m_cos" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -32960,7 +30181,7 @@ _ACEOF else - { $as_echo "$as_me:$LINENO: Maths library was not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Maths library was not found" >&5 $as_echo "$as_me: Maths library was not found" >&6;} fi @@ -32973,19 +30194,14 @@ fi save_LIBS="$LIBS" LIBS="" - -{ $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then +if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -33003,43 +30219,18 @@ return dlopen (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_dl_dlopen=no + ac_cv_lib_dl_dlopen=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF @@ -33061,13 +30252,11 @@ LIBS="$save_LIBS" # # Check whether --with-stdc++lib was given. -if test "${with_stdc++lib+set}" = set; then - withval=$with_stdc++lib; +if test "${with_stdc__lib+set}" = set; then : + withval=$with_stdc__lib; if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \ && test "x$with_stdc__lib" != xdefault; then - { { $as_echo "$as_me:$LINENO: error: Bad parameter value --with-stdc++lib=$with_stdc__lib!" >&5 -$as_echo "$as_me: error: Bad parameter value --with-stdc++lib=$with_stdc__lib!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Bad parameter value --with-stdc++lib=$with_stdc__lib!" "$LINENO" 5 fi else @@ -33078,7 +30267,7 @@ fi if test "x$OPENJDK_TARGET_OS" = xlinux; then # Test if -lstdc++ works. - { $as_echo "$as_me:$LINENO: checking if dynamic link of stdc++ is possible" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if dynamic link of stdc++ is possible" >&5 $as_echo_n "checking if dynamic link of stdc++ is possible... " >&6; } ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -33088,11 +30277,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -lstdc++" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -33103,38 +30288,13 @@ return 0; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : has_dynamic_libstdcxx=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - has_dynamic_libstdcxx=no + has_dynamic_libstdcxx=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext CXXFLAGS="$OLD_CXXFLAGS" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -33142,11 +30302,11 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - { $as_echo "$as_me:$LINENO: result: $has_dynamic_libstdcxx" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_dynamic_libstdcxx" >&5 $as_echo "$has_dynamic_libstdcxx" >&6; } # Test if stdc++ can be linked statically. - { $as_echo "$as_me:$LINENO: checking if static link of stdc++ is possible" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if static link of stdc++ is possible" >&5 $as_echo_n "checking if static link of stdc++ is possible... " >&6; } STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic" ac_ext=cpp @@ -33159,11 +30319,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu OLD_CXX="$CXX" LIBS="$STATIC_STDCXX_FLAGS" CXX="$CC" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -33174,38 +30330,13 @@ return 0; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_cxx_try_link "$LINENO"; then : has_static_libstdcxx=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - has_static_libstdcxx=no + has_static_libstdcxx=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS="$OLD_LIBS" CXX="$OLD_CXX" ac_ext=cpp @@ -33214,28 +30345,22 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - { $as_echo "$as_me:$LINENO: result: $has_static_libstdcxx" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_static_libstdcxx" >&5 $as_echo "$has_static_libstdcxx" >&6; } if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then - { { $as_echo "$as_me:$LINENO: error: Cannot link to stdc++, neither dynamically nor statically!" >&5 -$as_echo "$as_me: error: Cannot link to stdc++, neither dynamically nor statically!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Cannot link to stdc++, neither dynamically nor statically!" "$LINENO" 5 fi if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then - { { $as_echo "$as_me:$LINENO: error: Static linking of libstdc++ was not possible!" >&5 -$as_echo "$as_me: error: Static linking of libstdc++ was not possible!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Static linking of libstdc++ was not possible!" "$LINENO" 5 fi if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then - { { $as_echo "$as_me:$LINENO: error: Dynamic linking of libstdc++ was not possible!" >&5 -$as_echo "$as_me: error: Dynamic linking of libstdc++ was not possible!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Dynamic linking of libstdc++ was not possible!" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: checking how to link with libstdc++" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libstdc++" >&5 $as_echo_n "checking how to link with libstdc++... " >&6; } # If dynamic was requested, it's available since it would fail above otherwise. # If dynamic wasn't requested, go with static unless it isn't available. @@ -33243,13 +30368,13 @@ $as_echo_n "checking how to link with libstdc++... " >&6; } LIBCXX="$LIBCXX -lstdc++" LDCXX="$CXX" STATIC_CXX_SETTING="STATIC_CXX=false" - { $as_echo "$as_me:$LINENO: result: dynamic" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: dynamic" >&5 $as_echo "dynamic" >&6; } else LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS" LDCXX="$CC" STATIC_CXX_SETTING="STATIC_CXX=true" - { $as_echo "$as_me:$LINENO: result: static" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: static" >&5 $as_echo "static" >&6; } fi fi @@ -33277,7 +30402,7 @@ fi # called fixpath. FIXPATH= if test "x$OPENJDK_BUILD_OS" = xwindows; then - { $as_echo "$as_me:$LINENO: checking if fixpath can be created" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fixpath can be created" >&5 $as_echo_n "checking if fixpath can be created... " >&6; } FIXPATH_SRC="$SRC_ROOT/common/src/fixpath.c" FIXPATH_BIN="$OUTPUT_ROOT/fixpath.exe" @@ -33303,29 +30428,25 @@ $as_echo_n "checking if fixpath can be created... " >&6; } cd $CURDIR if test ! -x $OUTPUT_ROOT/fixpath.exe; then - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } cat $OUTPUT_ROOT/fixpath1.log - { { $as_echo "$as_me:$LINENO: error: Could not create $OUTPUT_ROOT/fixpath.exe" >&5 -$as_echo "$as_me: error: Could not create $OUTPUT_ROOT/fixpath.exe" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not create $OUTPUT_ROOT/fixpath.exe" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - { $as_echo "$as_me:$LINENO: checking if fixpath.exe works" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fixpath.exe works" >&5 $as_echo_n "checking if fixpath.exe works... " >&6; } cd $OUTPUT_ROOT $FIXPATH $CC $SRC_ROOT/common/src/fixpath.c -Fe$OUTPUT_ROOT/fixpath2.exe > $OUTPUT_ROOT/fixpath2.log 2>&1 cd $CURDIR if test ! -x $OUTPUT_ROOT/fixpath2.exe; then - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } cat $OUTPUT_ROOT/fixpath2.log - { { $as_echo "$as_me:$LINENO: error: fixpath did not work!" >&5 -$as_echo "$as_me: error: fixpath did not work!" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "fixpath did not work!" "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } rm -f $OUTPUT_ROOT/fixpath?.??? $OUTPUT_ROOT/fixpath.obj fi @@ -33363,14 +30484,14 @@ fi # How many cores do we have on this build system? # Check whether --with-num-cores was given. -if test "${with_num_cores+set}" = set; then +if test "${with_num_cores+set}" = set; then : withval=$with_num_cores; fi if test "x$with_num_cores" = x; then # The number of cores were not specified, try to probe them. - { $as_echo "$as_me:$LINENO: checking for number of cores" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for number of cores" >&5 $as_echo_n "checking for number of cores... " >&6; } NUM_CORES=1 FOUND_CORES=no @@ -33398,12 +30519,12 @@ $as_echo_n "checking for number of cores... " >&6; } CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` if test "x$FOUND_CORES" = xyes; then - { $as_echo "$as_me:$LINENO: result: $NUM_CORES" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NUM_CORES" >&5 $as_echo "$NUM_CORES" >&6; } else - { $as_echo "$as_me:$LINENO: result: could not detect number of cores, defaulting to 1" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not detect number of cores, defaulting to 1" >&5 $as_echo "could not detect number of cores, defaulting to 1" >&6; } - { $as_echo "$as_me:$LINENO: WARNING: This will disable all parallelism from build!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: This will disable all parallelism from build!" >&5 $as_echo "$as_me: WARNING: This will disable all parallelism from build!" >&2;} fi @@ -33419,14 +30540,14 @@ fi # How much memory do we have on this build system? # Check whether --with-memory-size was given. -if test "${with_memory_size+set}" = set; then +if test "${with_memory_size+set}" = set; then : withval=$with_memory_size; fi if test "x$with_memory_size" = x; then # The memory size was not specified, try to probe it. - { $as_echo "$as_me:$LINENO: checking for memory size" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for memory size" >&5 $as_echo_n "checking for memory size... " >&6; } # Default to 1024 MB MEMORY_SIZE=1024 @@ -33454,12 +30575,12 @@ $as_echo_n "checking for memory size... " >&6; } fi if test "x$FOUND_MEM" = xyes; then - { $as_echo "$as_me:$LINENO: result: $MEMORY_SIZE MB" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEMORY_SIZE MB" >&5 $as_echo "$MEMORY_SIZE MB" >&6; } else - { $as_echo "$as_me:$LINENO: result: could not detect memory size, defaulting to 1024 MB" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not detect memory size, defaulting to 1024 MB" >&5 $as_echo "could not detect memory size, defaulting to 1024 MB" >&6; } - { $as_echo "$as_me:$LINENO: WARNING: This might seriously impact build performance!" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: This might seriously impact build performance!" >&5 $as_echo "$as_me: WARNING: This might seriously impact build performance!" >&2;} fi @@ -33473,7 +30594,7 @@ fi # Check whether --with-sjavac-server-java was given. -if test "${with_sjavac_server_java+set}" = set; then +if test "${with_sjavac_server_java+set}" = set; then : withval=$with_sjavac_server_java; fi @@ -33482,9 +30603,7 @@ if test "x$with_sjavac_server_java" != x; then SJAVAC_SERVER_JAVA="$with_sjavac_server_java" FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""` if test "x$FOUND_VERSION" = x; then - { { $as_echo "$as_me:$LINENO: error: Could not execute server java: $SJAVAC_SERVER_JAVA" >&5 -$as_echo "$as_me: error: Could not execute server java: $SJAVAC_SERVER_JAVA" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Could not execute server java: $SJAVAC_SERVER_JAVA" "$LINENO" 5 fi else SJAVAC_SERVER_JAVA="" @@ -33514,7 +30633,7 @@ fi # Check whether --with-sjavac-server-cores was given. -if test "${with_sjavac_server_cores+set}" = set; then +if test "${with_sjavac_server_cores+set}" = set; then : withval=$with_sjavac_server_cores; fi @@ -33668,25 +30787,25 @@ else MAX_COMPILERS_IN_HEAP=`expr $MAX_HEAP_MEM / 501` if test "$SJAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then - { $as_echo "$as_me:$LINENO: checking if number of server cores must be reduced" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if number of server cores must be reduced" >&5 $as_echo_n "checking if number of server cores must be reduced... " >&6; } SJAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP" - { $as_echo "$as_me:$LINENO: result: yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB" >&5 $as_echo "yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB" >&6; } fi fi -{ $as_echo "$as_me:$LINENO: checking whether to use sjavac" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use sjavac" >&5 $as_echo_n "checking whether to use sjavac... " >&6; } # Check whether --enable-sjavac was given. -if test "${enable_sjavac+set}" = set; then +if test "${enable_sjavac+set}" = set; then : enableval=$enable_sjavac; ENABLE_SJAVAC="${enableval}" else ENABLE_SJAVAC='no' fi -{ $as_echo "$as_me:$LINENO: result: $ENABLE_SJAVAC" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ENABLE_SJAVAC" >&5 $as_echo "$ENABLE_SJAVAC" >&6; } @@ -33707,7 +30826,7 @@ fi # Can the C/C++ compiler use precompiled headers? # # Check whether --enable-precompiled-headers was given. -if test "${enable_precompiled_headers+set}" = set; then +if test "${enable_precompiled_headers+set}" = set; then : enableval=$enable_precompiled_headers; ENABLE_PRECOMPH=${enable_precompiled_headers} else ENABLE_PRECOMPH=yes @@ -33722,16 +30841,16 @@ fi if test "x$ENABLE_PRECOMPH" = xyes; then # Check that the compiler actually supports precomp headers. if test "x$GCC" = xyes; then - { $as_echo "$as_me:$LINENO: checking that precompiled headers work" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking that precompiled headers work" >&5 $as_echo_n "checking that precompiled headers work... " >&6; } echo "int alfa();" > conftest.h $CXX -x c++-header conftest.h -o conftest.hpp.gch 2>&5 >&5 if test ! -f conftest.hpp.gch; then USE_PRECOMPILED_HEADER=0 - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } else - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi rm -f conftest.h conftest.hpp.gch @@ -33744,7 +30863,7 @@ fi # Setup use of ccache, if available # Check whether --enable-ccache was given. -if test "${enable_ccache+set}" = set; then +if test "${enable_ccache+set}" = set; then : enableval=$enable_ccache; ENABLE_CCACHE=${enable_ccache} else ENABLE_CCACHE=yes @@ -33753,9 +30872,9 @@ fi if test "x$ENABLE_CCACHE" = xyes; then # Extract the first word of "ccache", so it can be a program name with args. set dummy ccache; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CCACHE+set}" = set; then +if test "${ac_cv_path_CCACHE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CCACHE in @@ -33768,14 +30887,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CCACHE="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -33783,18 +30902,18 @@ esac fi CCACHE=$ac_cv_path_CCACHE if test -n "$CCACHE"; then - { $as_echo "$as_me:$LINENO: result: $CCACHE" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CCACHE" >&5 $as_echo "$CCACHE" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else - { $as_echo "$as_me:$LINENO: checking for ccache" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ccache" >&5 $as_echo_n "checking for ccache... " >&6; } - { $as_echo "$as_me:$LINENO: result: explicitly disabled" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: explicitly disabled" >&5 $as_echo "explicitly disabled" >&6; } CCACHE= fi @@ -33802,7 +30921,7 @@ $as_echo "explicitly disabled" >&6; } # Check whether --with-ccache-dir was given. -if test "${with_ccache_dir+set}" = set; then +if test "${with_ccache_dir+set}" = set; then : withval=$with_ccache_dir; fi @@ -33819,25 +30938,21 @@ fi CCACHE_FOUND="true" # Only use ccache if it is 3.1.4 or later, which supports # precompiled headers. - { $as_echo "$as_me:$LINENO: checking if ccache supports precompiled headers" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ccache supports precompiled headers" >&5 $as_echo_n "checking if ccache supports precompiled headers... " >&6; } HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.[456789]) 2> /dev/null` if test "x$HAS_GOOD_CCACHE" = x; then - { $as_echo "$as_me:$LINENO: result: no, disabling ccache" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, disabling ccache" >&5 $as_echo "no, disabling ccache" >&6; } CCACHE= else - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - { $as_echo "$as_me:$LINENO: checking if C-compiler supports ccache precompiled headers" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if C-compiler supports ccache precompiled headers" >&5 $as_echo_n "checking if C-compiler supports ccache precompiled headers... " >&6; } PUSHED_FLAGS="$CXXFLAGS" CXXFLAGS="-fpch-preprocess $CXXFLAGS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -33848,39 +30963,18 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : CC_KNOWS_CCACHE_TRICK=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CC_KNOWS_CCACHE_TRICK=no + CC_KNOWS_CCACHE_TRICK=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS="$PUSHED_FLAGS" if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - { $as_echo "$as_me:$LINENO: result: no, disabling ccaching of precompiled headers" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, disabling ccaching of precompiled headers" >&5 $as_echo "no, disabling ccaching of precompiled headers" >&6; } CCACHE= fi @@ -33910,7 +31004,7 @@ $as_echo "no, disabling ccaching of precompiled headers" >&6; } # Check for some common pitfalls -{ $as_echo "$as_me:$LINENO: checking if build directory is on local disk" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if build directory is on local disk" >&5 $as_echo_n "checking if build directory is on local disk... " >&6; } # df -l lists only local disks; if the given directory is not found then @@ -33936,7 +31030,7 @@ $as_echo_n "checking if build directory is on local disk... " >&6; } fi fi -{ $as_echo "$as_me:$LINENO: result: $OUTPUT_DIR_IS_LOCAL" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $OUTPUT_DIR_IS_LOCAL" >&5 $as_echo "$OUTPUT_DIR_IS_LOCAL" >&6; } # Check if the user has any old-style ALT_ variables set. @@ -33994,13 +31088,13 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; + *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done @@ -34008,8 +31102,8 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" @@ -34032,11 +31126,11 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi @@ -34050,14 +31144,15 @@ DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -34069,9 +31164,10 @@ LTLIBOBJS=$ac_ltlibobjs ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -34081,17 +31177,18 @@ cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 debug=false ac_cs_recheck=false ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -34099,23 +31196,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; esac - fi - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - as_nl=' ' export as_nl @@ -34123,7 +31212,13 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -34134,7 +31229,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in + case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -34157,13 +31252,6 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -34173,15 +31261,15 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in +case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done IFS=$as_save_IFS ;; @@ -34193,12 +31281,16 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } + exit 1 fi -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' @@ -34210,7 +31302,89 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# Required to use basename. +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -34224,8 +31398,12 @@ else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -34245,76 +31423,25 @@ $as_echo X/"$0" | } s/.*/./; q'` -# CDPATH. -$as_unset CDPATH - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in +case `echo -n x` in #((((( -n*) - case `echo 'x\c'` in + case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -34343,8 +31470,56 @@ fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false @@ -34363,10 +31538,10 @@ else if test -d "$1"; then test -d "$1/."; else - case $1 in + case $1 in #( -*)set "./$1";; esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' @@ -34381,13 +31556,19 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 -# Save the log message, to keep $[0] and so on meaningful, and to +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -34418,13 +31599,15 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. -Usage: $0 [OPTION]... [FILE]... +Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit + --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files @@ -34440,16 +31623,18 @@ $config_files Configuration headers: $config_headers -Report bugs to ." +Report bugs to . +OpenJDK home page: ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ OpenJDK config.status jdk8 -configured by $0, generated by GNU Autoconf 2.63, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.67, + with options \\"\$ac_cs_config\\" -Copyright (C) 2008 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -34465,11 +31650,16 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -34483,27 +31673,29 @@ do ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac - CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" + as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac - CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" + as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - { $as_echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; };; + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ @@ -34511,11 +31703,10 @@ Try \`$0 --help' for more information." >&2 ac_cs_silent=: ;; # This is an error. - -*) { $as_echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } ;; + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; - *) ac_config_targets="$ac_config_targets $1" + *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac @@ -34569,9 +31760,7 @@ do "$OUTPUT_ROOT/spec.sh") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in" ;; "$OUTPUT_ROOT/Makefile") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in" ;; - *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done @@ -34597,7 +31786,7 @@ $debug || trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 + trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. @@ -34608,11 +31797,7 @@ $debug || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || -{ - $as_echo "$as_me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -34620,7 +31805,13 @@ $debug || if test -n "$CONFIG_FILES"; then -ac_cr=' ' +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' @@ -34637,24 +31828,18 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -34676,7 +31861,7 @@ s/'"$ac_delim"'$// t delim :nl h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p @@ -34690,7 +31875,7 @@ s/.\{148\}// t nl :delim h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p @@ -34743,22 +31928,28 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 -$as_echo "$as_me: error: could not setup config files machinery" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -34786,9 +31977,7 @@ for ac_last_try in false false :; do if test -z "$ac_t"; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -34873,9 +32062,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 -$as_echo "$as_me: error: could not setup config headers machinery" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -34888,9 +32075,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 -$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} - { (exit 1); exit 1; }; };; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -34918,12 +32103,10 @@ $as_echo "$as_me: error: invalid tag $ac_tag" >&2;} [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - ac_file_inputs="$ac_file_inputs '$ac_f'" + as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't @@ -34934,7 +32117,7 @@ $as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. @@ -34947,9 +32130,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } ;; + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -34977,47 +32158,7 @@ $as_echo X"$ac_file" | q } s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } + as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in @@ -35065,7 +32206,6 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= - ac_sed_dataroot=' /datarootdir/ { p @@ -35075,12 +32215,11 @@ ac_sed_dataroot=' /@docdir@/p /@infodir@/p /@localedir@/p -/@mandir@/p -' +/@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 @@ -35090,7 +32229,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; + s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF @@ -35117,26 +32256,22 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -35147,25 +32282,19 @@ $as_echo "$as_me: error: could not create $ac_file" >&2;} $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 -$as_echo "$as_me: error: could not create -" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; @@ -35175,15 +32304,12 @@ $as_echo "$as_me: error: could not create -" >&2;} done # for ac_tag -{ (exit 0); exit 0; } +as_fn_exit 0 _ACEOF -chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -35204,10 +32330,10 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index 8dc3fc7bb4b..f345f4ec18a 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -938,10 +938,17 @@ else fi fi LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \ - -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server \ - -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client \ -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}" + # On some platforms (mac) the linker warns about non existing -L dirs. + # Only add client dir if client is being built. Otherwise server should + # be enough + if test "x$JVM_VARIANT_CLIENT" = xtrue; then + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client" + else + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server" + fi + LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm" if test "x$COMPILER_NAME" = xossc; then LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc" From 318015ba7acc7c73d3c69020eb14438f21e9b508 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 28 Nov 2012 13:20:43 +0100 Subject: [PATCH 50/94] 8001460: build-infra: Linker warnings on macosx Remove creation of empty i386 section from fdlibm Reviewed-by: ohair --- jdk/makefiles/CompileNativeLibraries.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/makefiles/CompileNativeLibraries.gmk b/jdk/makefiles/CompileNativeLibraries.gmk index e898ed294fd..49a3f20f4d5 100644 --- a/jdk/makefiles/CompileNativeLibraries.gmk +++ b/jdk/makefiles/CompileNativeLibraries.gmk @@ -104,7 +104,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFDLIBM,\ LANG:=C,\ CFLAGS:=$(CFLAGS_JDKLIB) \ -I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\ - LDFLAGS:=-nostdlib -r -arch i386 -arch x86_64,\ + LDFLAGS:=-nostdlib -r -arch x86_64,\ OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm)) $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) : $(BUILD_LIBFDLIBM) From bf822bfa138aef0781db348754900a12b4deb590 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 28 Nov 2012 13:29:35 +0100 Subject: [PATCH 51/94] 8003477: build-infra: Remove explicit source file listings for libs when possible Reviewed-by: ohair, ohrstrom --- jdk/makefiles/CompileNativeLibraries.gmk | 206 +++-------------------- 1 file changed, 25 insertions(+), 181 deletions(-) diff --git a/jdk/makefiles/CompileNativeLibraries.gmk b/jdk/makefiles/CompileNativeLibraries.gmk index 49a3f20f4d5..056f57a8a61 100644 --- a/jdk/makefiles/CompileNativeLibraries.gmk +++ b/jdk/makefiles/CompileNativeLibraries.gmk @@ -905,57 +905,34 @@ endif ########################################################################################## -BUILD_LIBZIP_FILES:=\ - CRC32.c \ - Adler32.c \ - Deflater.c \ - Inflater.c \ - ZipFile.c \ - zip_util.c - +BUILD_LIBZIP_EXCLUDES := ifeq ($(USE_EXTERNAL_LIBZ),true) - LIBZ:=-lz + LIBZ := -lz + LIBZIP_EXCLUDES += zlib-1.2.5 else -BUILD_LIBZIP_FILES += \ - compress.c \ - deflate.c \ - gzclose.c \ - gzlib.c \ - gzread.c \ - gzwrite.c \ - infback.c \ - inffast.c \ - inflate.c \ - inftrees.c \ - trees.c \ - uncompr.c \ - zadler32.c \ - zcrc32.c \ - zutil.c -LIBZ_INCLUDE:=-I$(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5 + ZLIB_CPPFLAGS := -I$(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5 endif -BUILD_LIBZIP_REORDER:= +BUILD_LIBZIP_REORDER := ifeq ($(OPENJDK_TARGET_OS), solaris) ifneq ($(OPENJDK_TARGET_CPU), x86_64) - BUILD_LIBZIP_REORDER:=$(JDK_TOPDIR)/makefiles/mapfiles/libzip/reorder-$(OPENJDK_TARGET_CPU) + BUILD_LIBZIP_REORDER := $(JDK_TOPDIR)/makefiles/mapfiles/libzip/reorder-$(OPENJDK_TARGET_CPU) endif endif ifeq ($(LIBZIP_CAN_USE_MMAP), true) - BUILD_LIBZIP_MMAP:=-DUSE_MMAP + BUILD_LIBZIP_MMAP := -DUSE_MMAP endif $(eval $(call SetupNativeCompilation,BUILD_LIBZIP,\ LIBRARY:=zip,\ OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ - SRC:=$(JDK_TOPDIR)/src/share/native/java/util/zip \ - $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5,\ - INCLUDE_FILES:=$(BUILD_LIBZIP_FILES), \ LANG:=C,\ OPTIMIZATION:=LOW, \ + SRC:=$(JDK_TOPDIR)/src/share/native/java/util/zip,\ + EXCLUDES:=$(LIBZIP_EXCLUDES),\ CFLAGS:=$(CFLAGS_JDKLIB) \ - $(LIBZ_INCLUDE) \ + $(ZLIB_CPPFLAGS) \ -I$(JDK_TOPDIR)/src/share/native/java/io \ -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/io,\ CFLAGS_posix:=$(BUILD_LIBZIP_MMAP) -UDEBUG,\ @@ -1238,15 +1215,7 @@ ifdef OPENJDK $(eval $(call SetupNativeCompilation,BUILD_LIBLCMS,\ LIBRARY:=lcms,\ OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ - SRC:=$(JDK_TOPDIR)/src/share/native/sun/java2d/cmm/lcms \ - $(JDK_TOPDIR)/src/share/native/sun/java2d/,\ - INCLUDE_FILES:=cmscam02.c cmscgats.c cmscnvrt.c cmserr.c \ - cmsgamma.c cmsgmt.c cmsintrp.c cmsio0.c \ - cmsio1.c cmslut.c cmsmd5.c cmsmtrx.c \ - cmsnamed.c cmsopt.c cmshalf.c cmspack.c cmspcs.c \ - cmsplugin.c cmsps2.c cmssamp.c cmssm.c \ - cmstypes.c cmsvirt.c cmswtpnt.c cmsxform.c \ - LCMS.c,\ + SRC:=$(JDK_TOPDIR)/src/share/native/sun/java2d/cmm/lcms,\ LANG:=C,\ OPTIMIZATION:=LOW, \ CFLAGS:=$(filter-out -xc99=%none,$(CFLAGS_JDKLIB)) \ @@ -2006,7 +1975,7 @@ $(BUILD_LIBNIO) : $(BUILD_LIBNET) ########################################################################################## ifeq ($(OPENJDK_TARGET_OS_API),posix) - # TODO make this work on macosx + ifneq ($(OPENJDK_TARGET_OS),macosx) SCTP_WERROR := -Werror @@ -2034,7 +2003,6 @@ ifeq ($(OPENJDK_TARGET_OS_API),posix) LDFLAGS_SUFFIX_posix:=-lnio -lnet,\ LDFLAGS_SUFFIX_solaris:=-lsocket -ljava -ljvm -lc,\ LDFLAGS_SUFFIX_macosx:=-ljava -ljvm,\ - INCLUDE_FILES:=SctpNet.c SctpChannelImpl.c SctpServerChannelImpl.c,\ OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsctp)) BUILD_LIBRARIES += $(BUILD_LIBSCTP) @@ -2105,7 +2073,7 @@ endif ifneq ($(USE_EXTERNAL_LIBZ),true) BUILD_LIBJLI_SRC_DIRS += $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5 - LIBJLI_CFLAGS += $(LIBZ_INCLUDE) + LIBJLI_CFLAGS += $(ZLIB_CPPFLAGS) BUILD_LIBJLI_FILES += \ inflate.c \ inftrees.c \ @@ -2416,8 +2384,14 @@ LIBSPLASHSCREEN_DIRS:=\ $(JDK_TOPDIR)/src/share/native/sun/awt/giflib \ $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg \ $(JDK_TOPDIR)/src/share/native/sun/awt/libpng \ - $(JDK_TOPDIR)/src/share/native/sun/awt/splashscreen \ - $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt/splashscreen + $(JDK_TOPDIR)/src/share/native/sun/awt/splashscreen + +ifneq ($(OPENJDK_TARGET_OS), macosx) + LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt/splashscreen +else + LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/awt/splashscreen +endif + LIBSPLASHSCREEN_CFLAGS:=-DSPLASHSCREEN -DPNG_NO_MMX_CODE \ $(foreach dir,$(LIBSPLASHSCREEN_DIRS),-I$(dir)) @@ -2443,104 +2417,11 @@ else LIBSPLASHSCREEN_CFLAGS += -DWITH_WIN32 endif -LIBSPLASHSCREEN_FILES:=\ - java_awt_SplashScreen.c \ - splashscreen_gfx_impl.c \ - splashscreen_gif.c \ - splashscreen_impl.c \ - splashscreen_jpeg.c \ - splashscreen_png.c \ - png.c \ - pngerror.c \ - pngget.c \ - pngmem.c \ - pngpread.c \ - pngread.c \ - pngrio.c \ - pngrtran.c \ - pngrutil.c \ - pngset.c \ - pngtrans.c \ - pngwio.c \ - pngwrite.c \ - pngwtran.c \ - pngwutil.c \ - dgif_lib.c \ - gif_err.c \ - gifalloc.c \ - jcomapi.c \ - jdapimin.c \ - jdapistd.c \ - jdcoefct.c \ - jdcolor.c \ - jddctmgr.c \ - jdhuff.c \ - jdinput.c \ - jdmainct.c \ - jdmarker.c \ - jdmaster.c \ - jdmerge.c \ - jdphuff.c \ - jdpostct.c \ - jdsample.c \ - jerror.c \ - jidctflt.c \ - jidctfst.c \ - jidctint.c \ - jidctred.c \ - jmemmgr.c \ - jmemnobs.c \ - jquant1.c \ - jquant2.c \ - jutils.c \ - jcapimin.c \ - jcapistd.c \ - jccoefct.c \ - jccolor.c \ - jcdctmgr.c \ - jchuff.c \ - jcinit.c \ - jcmainct.c \ - jcmarker.c \ - jcmaster.c \ - jcparam.c \ - jcphuff.c \ - jcprepct.c \ - jcsample.c \ - jctrans.c \ - jdtrans.c \ - jfdctflt.c \ - jfdctfst.c \ - jfdctint.c - -ifneq ($(OPENJDK_TARGET_OS), macosx) -LIBSPLASHSCREEN_FILES += splashscreen_sys.c -else -LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/awt/splashscreen -LIBSPLASHSCREEN_FILES += splashscreen_sys.m -endif - LIBSPLASHSCREEN_LDFLAGS_SUFFIX:= ifneq ($(USE_EXTERNAL_LIBZ),true) LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib-1.2.5 - LIBSPLASHSCREEN_CFLAGS += $(LIBZ_INCLUDE) - LIBSPLASHSCREEN_FILES += \ - compress.c \ - deflate.c \ - gzclose.c \ - gzlib.c \ - gzread.c \ - gzwrite.c \ - infback.c \ - inffast.c \ - inflate.c \ - inftrees.c \ - trees.c \ - uncompr.c \ - zadler32.c \ - zcrc32.c \ - zutil.c + LIBSPLASHSCREEN_CFLAGS += $(ZLIB_CPPFLAGS) endif ifeq ($(OPENJDK_TARGET_OS), macosx) @@ -2560,7 +2441,7 @@ $(eval $(call SetupNativeCompilation,LIBSPLASHSCREEN,\ LIBRARY:=splashscreen,\ OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ SRC:=$(LIBSPLASHSCREEN_DIRS),\ - INCLUDE_FILES:=$(LIBSPLASHSCREEN_FILES),\ + EXCLUDE_FILES:=imageioJPEG.c jpegdecoder.c pngtest.c,\ LANG:=C,\ OPTIMIZATION:=LOW, \ CFLAGS:=$(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB),\ @@ -2683,14 +2564,13 @@ endif BUILD_LIBKRB5_NAME:= ifeq ($(OPENJDK_TARGET_OS), windows) BUILD_LIBKRB5_NAME:=w2k_lsa_auth - BUILD_LIBKRB5_FILES:=NativeCreds.c WindowsDirectory.c BUILD_LIBKRB5_SRC:=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/krb5 BUILD_LIBKRB5_LIBS:=advapi32.lib Secur32.lib netapi32.lib kernel32.lib user32.lib \ gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib \ ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib else ifeq ($(OPENJDK_TARGET_OS), macosx) BUILD_LIBKRB5_NAME:=osxkrb5 - BUILD_LIBKRB5_FILES:=nativeccache.c + BUILD_LIBKRB5_SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/krb5 BUILD_LIBKRB5_LIBS:=-framework Kerberos endif @@ -2698,9 +2578,7 @@ ifneq ($(BUILD_LIBKRB5_NAME),) $(eval $(call SetupNativeCompilation,BUILD_LIBKRB5,\ LIBRARY:=$(BUILD_LIBKRB5_NAME),\ OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ - SRC:=$(JDK_TOPDIR)/src/share/native/sun/security/krb5 \ - $(BUILD_LIBKRB5_SRC) ,\ - INCLUDE_FILES:=$(BUILD_LIBKRB5_FILES),\ + SRC:=$(BUILD_LIBKRB5_SRC),\ LANG:=C,\ OPTIMIZATION:=LOW, \ CFLAGS:=$(CFLAGS_JDKLIB) \ @@ -3071,18 +2949,11 @@ endif ifeq ($(OPENJDK_TARGET_OS), macosx) -LIBAPPLESCRIPTENGINE_FILES:=\ - AppleScriptEngine.m \ - AppleScriptExecutionContext.m \ - AS_NS_ConversionUtils.m \ - NS_Java_ConversionUtils.m - $(eval $(call SetupNativeCompilation,BUILD_LIBAPPLESCRIPTENGINE,\ LIBRARY:=AppleScriptEngine,\ OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ SRC:=$(JDK_TOPDIR)/src/macosx/native/apple/applescript,\ LANG:=C,\ - INCLUDE_FILES:=$(LIBAPPLESCRIPTENGINE_FILES),\ OPTIMIZATION:=LOW, \ CFLAGS:=$(CFLAGS_JDKLIB) \ -I$(JDK_TOPDIR)/src/macosx/native/apple/applescript \ @@ -3107,18 +2978,11 @@ endif ifeq ($(OPENJDK_TARGET_OS), macosx) -LIBOSXAPP_FILES:=\ - NSApplicationAWT.m \ - QueuingApplicationDelegate.m \ - PropertiesUtilities.m \ - ThreadUtilities.m - $(eval $(call SetupNativeCompilation,BUILD_LIBOSXAPP,\ LIBRARY:=osxapp,\ OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ SRC:=$(JDK_TOPDIR)/src/macosx/native/sun/osxapp,\ LANG:=C,\ - INCLUDE_FILES:=$(LIBOSXAPP_FILES),\ OPTIMIZATION:=LOW, \ CFLAGS:=$(CFLAGS_JDKLIB) \ -I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp \ @@ -3151,14 +3015,6 @@ endif ifeq ($(OPENJDK_TARGET_OS), macosx) -LIBOSX_FILES:=\ - Dispatch.m \ - CFileManager.m \ - KeystoreImpl.m \ - JavaAppLauncher.m \ - MacOSXPreferencesFile.m \ - SCDynamicStoreConfig.m - LIBOSX_DIRS:=\ $(JDK_TOPDIR)/src/macosx/native/com/apple/concurrent \ $(JDK_TOPDIR)/src/macosx/native/java/util \ @@ -3171,7 +3027,6 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBOSX,\ OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ SRC:=$(LIBOSX_DIRS),\ LANG:=C,\ - INCLUDE_FILES:=$(LIBOSX_FILES),\ OPTIMIZATION:=LOW, \ CFLAGS:=$(CFLAGS_JDKLIB) \ $(foreach dir,$(LIBOSX_DIRS),-I$(dir)) \ @@ -3341,22 +3196,11 @@ endif ifeq ($(OPENJDK_TARGET_OS), macosx) -LIBOSXUI_FILES:=\ - AquaFileView.m \ - AquaLookAndFeel.m \ - AquaNativeResources.m \ - JRSUIConstantSync.m \ - JRSUIController.m \ - JRSUIFocus.m \ - ScreenPopupFactory.m \ - ScreenMenu.m - $(eval $(call SetupNativeCompilation,BUILD_LIBOSXUI,\ LIBRARY:=osxui,\ OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ SRC:=$(JDK_TOPDIR)/src/macosx/native/com/apple/laf,\ LANG:=C,\ - INCLUDE_FILES:=$(LIBOSXUI_FILES),\ OPTIMIZATION:=LOW, \ CFLAGS:=$(CFLAGS_JDKLIB) \ -I$(JDK_TOPDIR)/src/macosx/native/com/apple/laf \ From 29a342dabef46191f63024b4dd9e5400357aa3af Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 28 Nov 2012 13:37:50 +0100 Subject: [PATCH 52/94] 8003844: build-infra: docs target isn't working properly Adding resources to bootstrap javadoc.jar. Adding missing .js resource suffix Reviewed-by: ohair, jjg, ohrstrom --- langtools/makefiles/BuildLangtools.gmk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/langtools/makefiles/BuildLangtools.gmk b/langtools/makefiles/BuildLangtools.gmk index c5870703870..6fbbddd9aaa 100644 --- a/langtools/makefiles/BuildLangtools.gmk +++ b/langtools/makefiles/BuildLangtools.gmk @@ -38,6 +38,9 @@ $(eval $(call SetupJavaCompiler,BOOT_JAVAC,\ SERVER_JVM:=$(SJAVAC_SERVER_JAVA),\ FLAGS:=-XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror)) +# javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied. +RESOURCE_SUFFIXES:=.gif .xml .css .js javax.tools.JavaCompilerTool + # Now setup the compilation of the properties compilation tool. You can depend # upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we # add src/share/classes to the sourcepath. This is necessary since the GenStubs @@ -99,6 +102,7 @@ ifeq ($(PROPS_ARE_CREATED),yes) DISABLE_SJAVAC:=true,\ SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\ EXCLUDES:=com/sun/tools/javac/nio,\ + COPY:=$(RESOURCE_SUFFIXES),\ BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap)) $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC,$(BUILD_BOOTSTRAP_LANGTOOLS),\ @@ -119,6 +123,7 @@ ifeq ($(PROPS_ARE_CREATED),yes) $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVADOC,$(BUILD_BOOTSTRAP_LANGTOOLS),\ SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javadoc.jar,\ + SUFFIXES:=.class $(RESOURCE_SUFFIXES),\ JARMAIN:=com.sun.tools.javadoc.Main)) # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not @@ -172,9 +177,6 @@ ifeq ($(PROPS_ARE_CREATED),yes) SERVER_DIR:=$(SJAVAC_SERVER_DIR),\ SERVER_JVM:=$(SJAVAC_SERVER_JAVA))) - # javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied. - RESOURCE_SUFFIXES:=.gif .xml .css javax.tools.JavaCompilerTool - $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC,\ SETUP:=GENERATE_NEWBYTECODE,\ SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \ From 858cebeb663134d76779720889d0006caa21ac16 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 28 Nov 2012 13:40:17 +0100 Subject: [PATCH 53/94] 8003844: build-infra: docs target isn't working properly Fixed docs and docs-clean target. Added compare support for docs. Reviewed-by: ohair, jjg, ohrstrom --- common/bin/compare.sh | 43 ++++++++++++++++++++++ common/makefiles/Main.gmk | 5 ++- common/makefiles/javadoc/Javadoc.gmk | 54 +++++++++++++--------------- 3 files changed, 72 insertions(+), 30 deletions(-) diff --git a/common/bin/compare.sh b/common/bin/compare.sh index 015f9e2de26..afe9ef7cee6 100644 --- a/common/bin/compare.sh +++ b/common/bin/compare.sh @@ -290,6 +290,7 @@ compare_general_files() { for f in $GENERAL_FILES do if [ -e $OTHER_DIR/$f ]; then + SUFFIX="${f##*.}" if [ "$(basename $f)" = "release" ]; then # Ignore differences in change numbers in release file. OTHER_FILE=$WORK_DIR/$f.other @@ -298,6 +299,22 @@ compare_general_files() { $MKDIR -p $(dirname $THIS_FILE) $CAT $OTHER_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $OTHER_FILE $CAT $THIS_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $THIS_FILE + elif [ "x$SUFFIX" = "xhtml" ]; then + # Ignore time stamps in docs files + OTHER_FILE=$WORK_DIR/$f.other + THIS_FILE=$WORK_DIR/$f.this + $MKDIR -p $(dirname $OTHER_FILE) + $MKDIR -p $(dirname $THIS_FILE) + $CAT $OTHER_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \ + -e 's/\(\)/\1(removed)\2/' \ + -e 's/\(Monday\|Tuesday\|Wednesday\|Thursday\|Friday\|Saturday\|Sunday\), [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* \(AM\|PM\) [A-Z][A-Z]*/(removed)/' \ + -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \ + > $OTHER_FILE + $CAT $THIS_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \ + -e 's/\(\)/\1(removed)\2/' \ + -e 's/\(Monday\|Tuesday\|Wednesday\|Thursday\|Friday\|Saturday\|Sunday\), [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* \(AM\|PM\) [A-Z][A-Z]*/(removed)/' \ + -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \ + > $THIS_FILE else OTHER_FILE=$OTHER_DIR/$f THIS_FILE=$THIS_DIR/$f @@ -1111,6 +1128,22 @@ if [ -z "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then echo "Skipping bundle compare!" fi +if [ -d "$THIS/docs" ]; then + THIS_DOCS="$THIS/docs" +fi + +if [ -d "$OTHER/docs" ]; then + OTHER_DOCS="$OTHER/docs" +fi + +if [ -z "$THIS_DOCS" ]; then + echo "WARNING! Docs haven't been built and won't be compared." +fi + +if [ -z "$OTHER_DOCS" ]; then + echo "WARNING! Other build doesn't contain docs, skipping doc compare." +fi + ########################################################################################## # Do the work @@ -1148,6 +1181,12 @@ if [ "$CMP_NAMES" = "true" ]; then echo -n "J2RE Bundle " compare_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle fi + if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then + echo -n "Docs " + compare_dirs $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs + echo -n "Docs " + compare_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs + fi fi if [ "$CMP_PERMS" = "true" ]; then @@ -1211,6 +1250,10 @@ if [ "$CMP_GENERAL" = "true" ]; then echo -n "J2RE Bundle " compare_general_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle fi + if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then + echo -n "Docs " + compare_general_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs + fi fi if [ "$CMP_ZIPS" = "true" ]; then diff --git a/common/makefiles/Main.gmk b/common/makefiles/Main.gmk index 7e0baaee52b..33f3cf24952 100644 --- a/common/makefiles/Main.gmk +++ b/common/makefiles/Main.gmk @@ -165,7 +165,7 @@ $(OUTPUT_ROOT)/source_tips: FRC # Remove everything, except the output from configure. -clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-overlay-images clean-bootcycle-build +clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-overlay-images clean-bootcycle-build clean-docs @($(CD) $(OUTPUT_ROOT) && $(RM) -r tmp source_tips build.log* build-trace*.log*) @$(ECHO) Cleaned all build artifacts. @@ -201,6 +201,9 @@ clean-overlay-images: $(call CleanComponent,overlay-images) clean-bootcycle-build: $(call CleanComponent,bootcycle-build) +clean-docs: + $(call CleanComponent,docs) + $(call CleanComponent,docstemp) .PHONY: langtools corba jaxp jaxws hotspot jdk images overlay-images install .PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only diff --git a/common/makefiles/javadoc/Javadoc.gmk b/common/makefiles/javadoc/Javadoc.gmk index 74233153939..84f0b5f8494 100644 --- a/common/makefiles/javadoc/Javadoc.gmk +++ b/common/makefiles/javadoc/Javadoc.gmk @@ -50,17 +50,12 @@ BUILD_NUMBER=$(JDK_BUILD_NUMBER) BOOT_JAVA_CMD=$(JAVA) -# Langtools -JAVAC_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/javac.jar JAVADOC_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/javadoc.jar -DOCLETS_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/doclets.jar JAVADOC_CMD = $(BOOT_JAVA_CMD) \ -Xmx1024m \ -Djava.awt.headless=true \ - "-Xbootclasspath/p:$(JAVADOC_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)$(CLASSPATH_SEPARATOR)$(DOCLETS_JAR)" \ - -jar $(JAVADOC_JAR) - -JAVADOC_CMD = javadoc + "-Xbootclasspath/p:$(JAVADOC_JAR)" \ + -jar $(JAVADOC_JAR) -bootclasspath $(JDK_OUTPUTDIR)/classes # Copyright year for beginning of Java and some of the apis # (Needed when creating the javadocs) @@ -113,7 +108,8 @@ DOCSDIR_URL = {@docroot}/$(GET2DOCSDIR) # Url to copyright html file COPYRIGHT_URL-7 = $(DOCSDIR_URL)/legal/cpyr.html -COPYRIGHT_URL-8 = $(DOCSDIR_URL)/legal/cpyr.html +# This isn't added in old build yet. +#COPYRIGHT_URL-8 = $(DOCSDIR_URL)/legal/cpyr.html COPYRIGHT_URL = $(COPYRIGHT_URL-$(JDK_MINOR_VERSION)) # Url to bug filing site @@ -125,7 +121,8 @@ BUG_SUBMIT_LINE = Submit a bug or feature # Url to devdocs page # Was: http://java.sun.com/javase/6/webnotes/devdocs-vs-specs.html DEV_DOCS_URL-7 = http://download.oracle.com/javase/7/docs/index.html -DEV_DOCS_URL-8 = http://download.oracle.com/javase/7/docs/index.html +# This isn't added in old build yet. +#DEV_DOCS_URL-8 = http://download.oracle.com/javase/7/docs/index.html DEV_DOCS_URL = $(DEV_DOCS_URL-$(JDK_MINOR_VERSION)) DOCS_BASE_URL = http://download.oracle.com/javase/7/docs @@ -142,9 +139,10 @@ $(FULL_COMPANY_NAME) in the US and other countries. # Otherwise, you get "No packages or classes specified." due # to $(CLASSPATH_SEPARATOR) being interpreted as an end of # command (newline or shell ; character) -ALL_SOURCE_DIRS = $(JDK_IMPSRC) \ +ALL_SOURCE_DIRS = $(JDK_SHARE_CLASSES) \ + $(JDK_IMPSRC) \ $(JDK_GENSRC) \ - $(JDK_SHARE_CLASSES) \ + $(JDK_OUTPUTDIR)/gendocsrc_rmic \ $(JDK_TOPDIR)/src/solaris/classes \ $(JDK_TOPDIR)/src/windows/classes \ $(JDK_SHARE_SRC)/doc/stub @@ -440,7 +438,7 @@ docletapidocs: $(DOCLETAPI_INDEX_FILE) $(DOCLETAPI_INDEX_FILE): GET2DOCSDIR=$(DOCLETAPI2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(DOCLETAPI_INDEX_FILE): $(DOCLETAPI_OPTIONS_FILE) $(DOCLETAPI_PACKAGES_FILE) +$(DOCLETAPI_INDEX_FILE): $(DOCLETAPI_OPTIONS_FILE) $(DOCLETAPI_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(DOCLETAPI_OPTIONS_FILE),$(DOCLETAPI_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ @@ -481,7 +479,7 @@ TAGLETAPI_BOTTOM := $(call CommonTrademarkBottom,$(TAGLETAPI_FIRST_COPYRIGHT_Y TAGLETAPI_TEMPDIR = $(DOCSTMPDIR)/taglets_temp # The index.html, options, and packages files -TAGLETAPI_INDEX_FILE = $(TAGLETAPI_DOCDIR)/com/sun/tools/doclets/Taglet.html +TAGLETAPI_INDEX_FILE = $(TAGLETAPI_DOCDIR)/index.html TAGLETAPI_OPTIONS_FILE = $(DOCSTMPDIR)/tagletapi.options TAGLETAPI_PACKAGES_FILE = $(DOCSTMPDIR)/tagletapi.packages @@ -491,7 +489,7 @@ tagletapidocs: $(TAGLETAPI_INDEX_FILE) $(TAGLETAPI_INDEX_FILE): GET2DOCSDIR=$(TAGLETAPI2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(TAGLETAPI_INDEX_FILE): $(TAGLETAPI_OPTIONS_FILE) $(TAGLETAPI_PACKAGES_FILE) +$(TAGLETAPI_INDEX_FILE): $(TAGLETAPI_OPTIONS_FILE) $(TAGLETAPI_PACKAGES_FILE) coredocs $(prep-javadoc) $(RM) -r $(TAGLETAPI_TEMPDIR) $(MKDIR) -p $(TAGLETAPI_TEMPDIR) @@ -517,9 +515,7 @@ $(TAGLETAPI_OPTIONS_FILE): # Create a file with the package names in it $(TAGLETAPI_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(TAGLETAPI_PKGS)) $(prep-target) - $(call PackageFilter,$(TAGLETAPI_PKGS)) - $(GREP) "$(TAGLETAPI_FILE)" $@ > $@.tmp - $(MV) $@.tmp $@ + @($(ECHO) "$(JDK_IMPSRC)/$(TAGLETAPI_FILE)" ) > $@ ############################################################# # @@ -549,7 +545,7 @@ domapidocs: $(DOMAPI_INDEX_FILE) $(DOMAPI_INDEX_FILE): GET2DOCSDIR=$(DOMAPI2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(DOMAPI_INDEX_FILE): $(DOMAPI_OPTIONS_FILE) $(DOMAPI_PACKAGES_FILE) +$(DOMAPI_INDEX_FILE): $(DOMAPI_OPTIONS_FILE) $(DOMAPI_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(DOMAPI_OPTIONS_FILE),$(DOMAPI_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ @@ -611,7 +607,7 @@ jdidocs: $(JDI_INDEX_FILE) $(JDI_INDEX_FILE): GET2DOCSDIR=$(JDI2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(JDI_INDEX_FILE): $(JDI_OPTIONS_FILE) $(JDI_PACKAGES_FILE) +$(JDI_INDEX_FILE): $(JDI_OPTIONS_FILE) $(JDI_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(JDI_OPTIONS_FILE),$(JDI_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ @@ -698,7 +694,7 @@ jaasdocs: $(JAAS_INDEX_FILE) $(JAAS_INDEX_FILE): GET2DOCSDIR=$(JAAS2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(JAAS_INDEX_FILE): $(JAAS_OPTIONS_FILE) $(JAAS_PACKAGES_FILE) +$(JAAS_INDEX_FILE): $(JAAS_OPTIONS_FILE) $(JAAS_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(JAAS_OPTIONS_FILE),$(JAAS_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ @@ -750,7 +746,7 @@ jgssdocs: $(JGSS_INDEX_FILE) $(JGSS_INDEX_FILE): GET2DOCSDIR=$(JGSS2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(JGSS_INDEX_FILE): $(JGSS_OPTIONS_FILE) $(JGSS_PACKAGES_FILE) +$(JGSS_INDEX_FILE): $(JGSS_OPTIONS_FILE) $(JGSS_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(JGSS_OPTIONS_FILE),$(JGSS_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ @@ -802,7 +798,7 @@ smartcardiodocs: $(SMARTCARDIO_INDEX_FILE) $(SMARTCARDIO_INDEX_FILE): GET2DOCSDIR=$(SMARTCARDIO2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(SMARTCARDIO_INDEX_FILE): $(SMARTCARDIO_OPTIONS_FILE) $(SMARTCARDIO_PACKAGES_FILE) +$(SMARTCARDIO_INDEX_FILE): $(SMARTCARDIO_OPTIONS_FILE) $(SMARTCARDIO_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(SMARTCARDIO_OPTIONS_FILE),$(SMARTCARDIO_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ @@ -852,7 +848,7 @@ httpserverdocs: $(HTTPSERVER_INDEX_HTML) $(HTTPSERVER_INDEX_HTML): GET2DOCSDIR=$(HTTPSERVER2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(HTTPSERVER_INDEX_HTML): $(HTTPSERVER_OPTIONS_FILE) $(HTTPSERVER_PACKAGES_FILE) +$(HTTPSERVER_INDEX_HTML): $(HTTPSERVER_OPTIONS_FILE) $(HTTPSERVER_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(HTTPSERVER_OPTIONS_FILE),$(HTTPSERVER_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ @@ -887,7 +883,7 @@ ALL_OTHER_TARGETS += mgmtdocs MGMT_DOCDIR := $(JRE_API_DOCSDIR)/management/extension MGMT2COREAPI := ../../$(JDKJRE2COREAPI) JVM_MIB_NAME := JVM-MANAGEMENT-MIB.mib -JVM_MIB_SRC := $(CLOSED_SRC)/share/classes/sun/management/snmp/$(JVM_MIB_NAME) +JVM_MIB_SRC := $(JDK_TOPDIR)/src/closed/share/classes/sun/management/snmp/$(JVM_MIB_NAME) MGMT_DOCTITLE := Monitoring and Management Interface for the Java$(TRADEMARK) Platform MGMT_WINDOWTITLE := Monitoring and Management Interface for the Java Platform MGMT_HEADER := Monitoring and Management Interface for the Java Platform @@ -906,7 +902,7 @@ mgmtdocs: $(MGMT_INDEX_FILE) $(MGMT_INDEX_FILE): GET2DOCSDIR=$(MGMT2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(MGMT_INDEX_FILE): $(MGMT_OPTIONS_FILE) $(MGMT_PACKAGES_FILE) +$(MGMT_INDEX_FILE): $(MGMT_OPTIONS_FILE) $(MGMT_PACKAGES_FILE) coredocs $(prep-javadoc) @if [ -f $(JVM_MIB_SRC) ] ; then \ $(ECHO) "$(CP) $(JVM_MIB_SRC) $(@D)/.."; \ @@ -963,7 +959,7 @@ attachdocs: $(ATTACH_INDEX_HTML) $(ATTACH_INDEX_HTML): GET2DOCSDIR=$(ATTACH2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(ATTACH_INDEX_HTML): $(ATTACH_OPTIONS_FILE) $(ATTACH_PACKAGES_FILE) +$(ATTACH_INDEX_HTML): $(ATTACH_OPTIONS_FILE) $(ATTACH_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(ATTACH_OPTIONS_FILE),$(ATTACH_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ @@ -1013,7 +1009,7 @@ jconsoledocs: $(JCONSOLE_INDEX_HTML) $(JCONSOLE_INDEX_HTML): GET2DOCSDIR=$(JCONSOLE2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(JCONSOLE_INDEX_HTML): $(JCONSOLE_OPTIONS_FILE) $(JCONSOLE_PACKAGES_FILE) +$(JCONSOLE_INDEX_HTML): $(JCONSOLE_OPTIONS_FILE) $(JCONSOLE_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(JCONSOLE_OPTIONS_FILE),$(JCONSOLE_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ @@ -1065,7 +1061,7 @@ treeapidocs: $(TREEAPI_INDEX_HTML) $(TREEAPI_INDEX_HTML): GET2DOCSDIR=$(TREEAPI2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(TREEAPI_INDEX_HTML): $(TREEAPI_OPTIONS_FILE) $(TREEAPI_PACKAGES_FILE) +$(TREEAPI_INDEX_HTML): $(TREEAPI_OPTIONS_FILE) $(TREEAPI_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(TREEAPI_OPTIONS_FILE),$(TREEAPI_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ @@ -1116,7 +1112,7 @@ sctpdocs: $(SCTPAPI_INDEX_HTML) $(SCTPAPI_INDEX_HTML): GET2DOCSDIR=$(SCTPAPI2COREAPI)/.. # Run javadoc if the index file is out of date or missing -$(SCTPAPI_INDEX_HTML): $(SCTPAPI_OPTIONS_FILE) $(SCTPAPI_PACKAGES_FILE) +$(SCTPAPI_INDEX_HTML): $(SCTPAPI_OPTIONS_FILE) $(SCTPAPI_PACKAGES_FILE) coredocs $(prep-javadoc) $(call JavadocSummary,$(SCTPAPI_OPTIONS_FILE),$(SCTPAPI_PACKAGES_FILE)) $(JAVADOC_CMD) -d $(@D) \ From 760fa576587c4cf078a43e0062f246dfc4f3d114 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 28 Nov 2012 13:48:36 +0100 Subject: [PATCH 54/94] 8003528: build-infra: Diffs in libjava and hotspot libs on solaris Linking against server jvm first if available. Adding filters and exceptions for hotspot lib compare on solaris. Reviewed-by: ohair, ohrstrom --- common/autoconf/generated-configure.sh | 10 ++++++---- common/autoconf/toolchain.m4 | 8 +++++--- common/bin/compare_exceptions.sh.incl | 19 +++++++++++++++++-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 47151032873..141c99d1798 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3672,7 +3672,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1354104798 +DATE_WHEN_GENERATED=1354106772 ############################################################################### # @@ -27585,9 +27585,11 @@ else -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}" # On some platforms (mac) the linker warns about non existing -L dirs. - # Only add client dir if client is being built. Otherwise server should - # be enough - if test "x$JVM_VARIANT_CLIENT" = xtrue; then + # Add server first if available. Linking aginst client does not always produce the same results. + # Only add client dir if client is being built. Default to server for other variants. + if test "x$JVM_VARIANT_SERVER" = xtrue; then + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server" + elif test "x$JVM_VARIANT_CLIENT" = xtrue; then LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client" else LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server" diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index f345f4ec18a..406a2511677 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -941,9 +941,11 @@ else -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}" # On some platforms (mac) the linker warns about non existing -L dirs. - # Only add client dir if client is being built. Otherwise server should - # be enough - if test "x$JVM_VARIANT_CLIENT" = xtrue; then + # Add server first if available. Linking aginst client does not always produce the same results. + # Only add client dir if client is being built. Default to server for other variants. + if test "x$JVM_VARIANT_SERVER" = xtrue; then + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server" + elif test "x$JVM_VARIANT_CLIENT" = xtrue; then LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client" else LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server" diff --git a/common/bin/compare_exceptions.sh.incl b/common/bin/compare_exceptions.sh.incl index 654c684f43d..0127e9a4eb3 100644 --- a/common/bin/compare_exceptions.sh.incl +++ b/common/bin/compare_exceptions.sh.incl @@ -291,6 +291,14 @@ ACCEPTED_SMALL_SIZE_DIFF=" ./jre/plugin/i386/ns4/libjavaplugin.so ./jre/plugin/i386/ns7/libjavaplugin_oji.so ./jre/lib/i386/server/libjvm.so +./jre/lib/i386/client/64/libjvm_db.so +./jre/lib/i386/client/64/libjvm_dtrace.so +./jre/lib/i386/client/libjvm_db.so +./jre/lib/i386/client/libjvm_dtrace.so +./jre/lib/i386/server/64/libjvm_db.so +./jre/lib/i386/server/64/libjvm_dtrace.so +./jre/lib/i386/server/libjvm_db.so +./jre/lib/i386/server/libjvm_dtrace.so ./bin/appletviewer ./bin/extcheck ./bin/idlj @@ -348,7 +356,9 @@ ACCEPTED_SMALL_SIZE_DIFF=" SKIP_FULLDUMP_DIFF="true" # Filter random C++ symbol strings. -DIS_DIFF_FILTER="$SED -e s/\.[a-zA-Z0-9_\$]\{15,15\}//g" +# Some numbers differ randomly. +# Can't use space in these expressions as the shell will mess with them. +DIS_DIFF_FILTER="$SED -e s/\.[a-zA-Z0-9_\$]\{15,15\}//g -e s/\([0-9a-f][0-9a-f].\)\{2,8\}[0-9a-f][0-9a-f]//g -e s/\(0x\)[0-9a-f]*\([,(>]\)/\1\2/g -e s/\(0x\)[0-9a-f]*$/\1/g -e s/\(\#.\)[0-9a-f]*\(.<\)/\1\2/g -e s/[\.A-Za-z0-9%]\{16,16\}$//g" fi @@ -426,6 +436,9 @@ ACCEPTED_SMALL_SIZE_DIFF=" ./jre/lib/amd64/libzip.so ./jre/lib/amd64/server/64/libjvm_db.so ./jre/lib/amd64/server/64/libjvm_dtrace.so +./jre/lib/amd64/server/libjvm.so +./jre/lib/amd64/server/libjvm_db.so +./jre/lib/amd64/server/libjvm_dtrace.so ./bin/amd64/appletviewer ./bin/amd64/extcheck ./bin/amd64/idlj @@ -480,7 +493,9 @@ ACCEPTED_SMALL_SIZE_DIFF=" SKIP_FULLDUMP_DIFF="true" # Filter random C++ symbol strings. -DIS_DIFF_FILTER="$SED -e s/\.[a-zA-Z0-9_\$]\{15,15\}//g" +# Some numbers differ randomly. +# Can't use space in these expressions as the shell will mess with them. +DIS_DIFF_FILTER="$SED -e s/\.[a-zA-Z0-9_\$]\{15,15\}//g -e s/\([0-9a-f][0-9a-f].\)\{2,8\}[0-9a-f][0-9a-f]//g -e s/\(0x\)[0-9a-f]*\([,(>]\)/\1\2/g -e s/\(0x\)[0-9a-f]*$/\1/g -e s/\(\#.\)[0-9a-f]*\(.<\)/\1\2/g -e s/[\.A-Za-z0-9%]\{16,16\}$//g" fi From 861d5c3e011d4249789bcb886faddfff43bdd4fa Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 28 Nov 2012 13:49:33 +0100 Subject: [PATCH 55/94] 8003528: build-infra: Diffs in libjava and hotspot libs on solaris Reorder libraries on link command line to match old build. Reviewed-by: ohair, ohrstrom --- jdk/makefiles/CompileNativeLibraries.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/makefiles/CompileNativeLibraries.gmk b/jdk/makefiles/CompileNativeLibraries.gmk index 056f57a8a61..23bf459ba2e 100644 --- a/jdk/makefiles/CompileNativeLibraries.gmk +++ b/jdk/makefiles/CompileNativeLibraries.gmk @@ -240,7 +240,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA,\ LDFLAGS:=$(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX_posix:=-ljvm -lverify, \ - LDFLAGS_SUFFIX_solaris:=-lnsl -lsocket -lscf $(LIBDL) $(BUILD_LIBFDLIBM) -lc,\ + LDFLAGS_SUFFIX_solaris:=-lsocket -lnsl -lscf $(LIBDL) $(BUILD_LIBFDLIBM) -lc,\ LDFLAGS_SUFFIX_linux:=$(LIBDL) $(BUILD_LIBFDLIBM),\ LDFLAGS_SUFFIX_macosx:=-L$(JDK_OUTPUTDIR)/objs/ -lfdlibm \ -framework CoreFoundation \ From 2f74d6d52eb9d0104a177358539d40f532244572 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 28 Nov 2012 14:10:00 +0100 Subject: [PATCH 56/94] 8003482: build-infra: Use correct manifest in security jars Reviewed-by: ohair, ohrstrom --- jdk/makefiles/CreateJars.gmk | 47 ++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/jdk/makefiles/CreateJars.gmk b/jdk/makefiles/CreateJars.gmk index 65b506a0396..c317d8d795c 100644 --- a/jdk/makefiles/CreateJars.gmk +++ b/jdk/makefiles/CreateJars.gmk @@ -419,6 +419,23 @@ $(eval $(call SetupArchive,BUILD_JSSE_JAR,,\ JARS+=$(IMAGES_OUTPUTDIR)/lib/jsse.jar +########################################################################################## +# Create manifest for security jars + +# +# Include these extra attributes for now, should probably take out. +# +JCE_MANIFEST := $(IMAGES_OUTPUTDIR)/lib/_the.security.manifest.mf +$(JCE_MANIFEST): $(MAINMANIFEST) + $(MKDIR) -p $(@D) + $(RM) $@ $@.tmp + $(SED) -e "s#@@RELEASE@@#$(JDK_VERSION)#" \ + -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \ + $(MAINMANIFEST) >> $@.tmp + $(ECHO) "Extension-Name: javax.crypto" >> $@.tmp + $(ECHO) "Implementation-Vendor-Id: com.sun" >> $@.tmp + $(MV) $@.tmp $@ + ########################################################################################## SUNPKCS11_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunpkcs11.jar @@ -440,8 +457,11 @@ else SUFFIXES:=.class,\ INCLUDES:=sun/security/pkcs11,\ JAR:=$(SUNPKCS11_JAR_DST), \ + MANIFEST:=$(JCE_MANIFEST), \ SKIP_METAINF := true)) + $(SUNPKCS11_JAR_DST): $(JCE_MANIFEST) + endif JARS += $(SUNPKCS11_JAR_DST) @@ -452,9 +472,9 @@ SUNEC_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunec.jar ifndef OPENJDK -SUNEC_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/ec/sunec.jar + SUNEC_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/ec/sunec.jar -$(SUNEC_JAR_DST) : $(SUNEC_JAR_SRC) + $(SUNEC_JAR_DST) : $(SUNEC_JAR_SRC) @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunEC provider..." $(MKDIR) -p $(@D) $(RM) $@ @@ -462,13 +482,16 @@ $(SUNEC_JAR_DST) : $(SUNEC_JAR_SRC) else -$(eval $(call SetupArchive,BUILD_SUNEC_JAR,,\ + $(eval $(call SetupArchive,BUILD_SUNEC_JAR,,\ SRCS:=$(JDK_OUTPUTDIR)/classes, \ SUFFIXES:=.class,\ INCLUDES:=sun/security/ec,\ JAR:=$(SUNEC_JAR_DST), \ + MANIFEST:=$(JCE_MANIFEST), \ SKIP_METAINF := true)) + $(SUNEC_JAR_DST): $(JCE_MANIFEST) + endif JARS += $(SUNEC_JAR_DST) @@ -505,9 +528,11 @@ else SUFFIXES:=.class,\ INCLUDES:= com/sun/crypto/provider,\ JAR:=$(SUNJCE_PROVIDER_JAR_DST), \ - MANIFEST := $(JDK_TOPDIR)/make/tools/manifest.mf, \ - EXTRA_MANIFEST_ATTR := Extension-Name: javax.crypto\nImplementation-Vendor-Id: com.sun, \ + MANIFEST:=$(JCE_MANIFEST), \ SKIP_METAINF := true)) + + $(SUNJCE_PROVIDER_JAR_DST): $(JCE_MANIFEST) + endif JARS += $(SUNJCE_PROVIDER_JAR_DST) @@ -516,9 +541,9 @@ JCE_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/jce.jar ifndef OPENJDK -JCE_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/jce/jce.jar + JCE_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/jce/jce.jar -$(JCE_JAR_DST) : $(JCE_JAR_SRC) + $(JCE_JAR_DST) : $(JCE_JAR_SRC) @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt jce.jar..." $(MKDIR) -p $(@D) $(RM) $@ @@ -526,14 +551,16 @@ $(JCE_JAR_DST) : $(JCE_JAR_SRC) else -$(eval $(call SetupArchive,BUILD_JCE_JAR,,\ + $(eval $(call SetupArchive,BUILD_JCE_JAR,,\ SRCS:=$(JDK_OUTPUTDIR)/classes, \ SUFFIXES:=.class,\ INCLUDES:= javax/crypto sun/security/internal,\ JAR:=$(JCE_JAR_DST), \ - MANIFEST := $(JDK_TOPDIR)/make/tools/manifest.mf, \ - EXTRA_MANIFEST_ATTR := Extension-Name: javax.crypto\nImplementation-Vendor-Id: com.sun, \ + MANIFEST:=$(JCE_MANIFEST), \ SKIP_METAINF := true)) + + $(JCE_JAR_DST): $(JCE_MANIFEST) + endif JARS += $(JCE_JAR_DST) From 1cf41521cce23c4f0305d2df27aebac639d97889 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Thu, 29 Nov 2012 14:07:47 -0800 Subject: [PATCH 57/94] 7175464: entrySetView field is never updated in NavigableSubMap The method entrySet() in AscendingSubMap and DescendingSubMap failed to cache the entrySetView. Reviewed-by: alanb, psandoz --- jdk/src/share/classes/java/util/TreeMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/java/util/TreeMap.java b/jdk/src/share/classes/java/util/TreeMap.java index 59a0eaadd7c..14d75e7187b 100644 --- a/jdk/src/share/classes/java/util/TreeMap.java +++ b/jdk/src/share/classes/java/util/TreeMap.java @@ -1759,7 +1759,7 @@ public class TreeMap public Set> entrySet() { EntrySetView es = entrySetView; - return (es != null) ? es : new AscendingEntrySetView(); + return (es != null) ? es : (entrySetView = new AscendingEntrySetView()); } TreeMap.Entry subLowest() { return absLowest(); } @@ -1840,7 +1840,7 @@ public class TreeMap public Set> entrySet() { EntrySetView es = entrySetView; - return (es != null) ? es : new DescendingEntrySetView(); + return (es != null) ? es : (entrySetView = new DescendingEntrySetView()); } TreeMap.Entry subLowest() { return absHighest(); } From 2a4b35660e5a7f3caf34ef584bd71b7dc5c4eccf Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Thu, 29 Nov 2012 14:09:45 -0800 Subject: [PATCH 58/94] 6553074: String{Buffer,Builder}.indexOf(Str, int) contains unnecessary allocation It is not necessary to extract the value array with toCharArray. The value array can now be used directly. Reviewed-by: alanb --- .../java/lang/AbstractStringBuilder.java | 13 +++---- jdk/src/share/classes/java/lang/String.java | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java index b87ebd73d9a..fc513f55efe 100644 --- a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java +++ b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java @@ -177,11 +177,10 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { ensureCapacityInternal(newLength); if (count < newLength) { - for (; count < newLength; count++) - value[count] = '\0'; - } else { - count = newLength; + Arrays.fill(value, count, newLength, '\0'); } + + count = newLength; } /** @@ -1308,8 +1307,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { * {@code null}. */ public int indexOf(String str, int fromIndex) { - return String.indexOf(value, 0, count, - str.toCharArray(), 0, str.length(), fromIndex); + return String.indexOf(value, 0, count, str, fromIndex); } /** @@ -1352,8 +1350,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { * {@code null}. */ public int lastIndexOf(String str, int fromIndex) { - return String.lastIndexOf(value, 0, count, - str.toCharArray(), 0, str.length(), fromIndex); + return String.lastIndexOf(value, 0, count, str, fromIndex); } /** diff --git a/jdk/src/share/classes/java/lang/String.java b/jdk/src/share/classes/java/lang/String.java index f9550874c9e..d73a2f7c2e9 100644 --- a/jdk/src/share/classes/java/lang/String.java +++ b/jdk/src/share/classes/java/lang/String.java @@ -1705,6 +1705,24 @@ public final class String str.value, 0, str.value.length, fromIndex); } + /** + * Code shared by String and AbstractStringBuilder to do searches. The + * source is the character array being searched, and the target + * is the string being searched for. + * + * @param source the characters being searched. + * @param sourceOffset offset of the source string. + * @param sourceCount count of the source string. + * @param target the characters being searched for. + * @param fromIndex the index to begin searching from. + */ + static int indexOf(char[] source, int sourceOffset, int sourceCount, + String target, int fromIndex) { + return indexOf(source, sourceOffset, sourceCount, + target.value, 0, target.value.length, + fromIndex); + } + /** * Code shared by String and StringBuffer to do searches. The * source is the character array being searched, and the target @@ -1796,6 +1814,24 @@ public final class String str.value, 0, str.value.length, fromIndex); } + /** + * Code shared by String and AbstractStringBuilder to do searches. The + * source is the character array being searched, and the target + * is the string being searched for. + * + * @param source the characters being searched. + * @param sourceOffset offset of the source string. + * @param sourceCount count of the source string. + * @param target the characters being searched for. + * @param fromIndex the index to begin searching from. + */ + static int lastIndexOf(char[] source, int sourceOffset, int sourceCount, + String target, int fromIndex) { + return lastIndexOf(source, sourceOffset, sourceCount, + target.value, 0, target.value.length, + fromIndex); + } + /** * Code shared by String and StringBuffer to do searches. The * source is the character array being searched, and the target From 2d91430e91f2a0c0c7ee5f2db0f110de125b5187 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Wed, 28 Nov 2012 17:31:35 -0800 Subject: [PATCH 59/94] 8004131: move jdi tests out of core testset Reviewed-by: alanb, chegar --- jdk/make/jprt.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/make/jprt.properties b/jdk/make/jprt.properties index cbf8540e02f..4bd2d4b84c6 100644 --- a/jdk/make/jprt.properties +++ b/jdk/make/jprt.properties @@ -86,7 +86,6 @@ jprt.make.rule.core.test.targets= \ ${jprt.my.test.target.set:TESTNAME=jdk_jmx}, \ ${jprt.my.test.target.set:TESTNAME=jdk_text}, \ ${jprt.my.test.target.set:TESTNAME=jdk_tools}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_jdi}, \ ${jprt.my.test.target.set:TESTNAME=jdk_jfr}, \ ${jprt.my.test.target.set:TESTNAME=jdk_other} @@ -103,6 +102,7 @@ jprt.make.rule.all.test.targets= \ ${jprt.my.test.target.set:TESTNAME=jdk_beans1}, \ ${jprt.my.test.target.set:TESTNAME=jdk_beans2}, \ ${jprt.my.test.target.set:TESTNAME=jdk_beans3}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_jdi}, \ ${jprt.my.test.target.set:TESTNAME=jdk_sound}, \ ${jprt.my.test.target.set:TESTNAME=jdk_swing} From c7ff8ac152daf2964a7d8c708ba0d7a2c1a44bfb Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 18:29:57 +0200 Subject: [PATCH 60/94] Added tag jdk8-b65 for changeset a2cf4d4a4843 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 412216e3cd1..5c0787f4e9a 100644 --- a/.hgtags +++ b/.hgtags @@ -186,3 +186,4 @@ cdaa6122185f9bf512dcd6600f56bfccc4824e8c jdk8-b61 8d9d430b4244b95f5cf1ebe719f834a1ac5d6cd5 jdk8-b62 21ee1dd7b809639284900a128b9b656a592ebc7a jdk8-b63 70fa4b11f26522e69b51fd652215f60ce350bac3 jdk8-b64 +a2cf4d4a484378caea2e827ed604b2bbae58bdba jdk8-b65 From 32e0bb9c4e558ffbda041a81fdf3283ca87cf343 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 29 Nov 2012 11:31:01 -0800 Subject: [PATCH 61/94] Added tag jdk8-b66 for changeset bc93357f4936 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 9ec2d1da2f1..0181b2d733a 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -187,3 +187,4 @@ cec8fa02f15634acd7d02d04b0b2d8c044cdbaaa jdk8-b60 f117a3e06f78a258074674ad17601f99bcb1ce0d jdk8-b63 26dbd73fb7662a29b3e47179fdc88a0bfa4e231e jdk8-b64 130d3a54d28becaac0846137256c2684adb34c33 jdk8-b65 +4d337fae2250135729ee9ed2bf8baf3c60da5d6d jdk8-b66 From dd422778629a7484dd8a9b156f624dc56bb87507 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Thu, 29 Nov 2012 14:43:46 -0800 Subject: [PATCH 62/94] 8004134: More ProblemList.txt updates (11/2012) Reviewed-by: alanb --- jdk/test/ProblemList.txt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index e17da5e9b91..2552ba0f017 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -141,6 +141,9 @@ java/lang/management/MemoryMXBean/LowMemoryTest2.sh generic-all # jdk_management +# 7158614 +sun/management/jmxremote/startstop/JMXStartStopTest.sh linux-all + ############################################################################ # jdk_jmx @@ -162,6 +165,9 @@ javax/management/remote/mandatory/notif/DiffHBTest.java generic-all # 6988950 demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all +# 7027502 +demo/jvmti/hprof/MonitorTest.java generic-all + ############################################################################ # jdk_net @@ -204,6 +210,9 @@ java/net/CookieHandler/CookieManagerTest.java macosx-all # jdk_io +# 7160013 +java/io/File/MaxPathLength.java windows-all + ############################################################################ # jdk_nio @@ -225,6 +234,9 @@ java/nio/channels/DatagramChannel/ChangingAddress.java macosx-all # 7132677 java/nio/channels/Selector/OutOfBand.java macosx-all +# 8003895 +java/nio/channels/AsynchronousChannelGroup/Unbounded.java windows-amd64 + ############################################################################ # jdk_rmi @@ -242,7 +254,7 @@ java/rmi/reliability/benchmark/runRmiBench.sh generic-all java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java generic-all # 7195095 -sun/rmi/transport/proxy/EagerHttpFallback.java linux-all +sun/rmi/transport/proxy/EagerHttpFallback.java generic-all ############################################################################ @@ -283,6 +295,12 @@ sun/security/tools/keytool/standard.sh solaris-all # 8000439: NPG: REGRESSION : sun/security/krb5/auto/MaxRetries.java fails with timeout sun/security/krb5/auto/MaxRetries.java solaris-sparcv9 +# 7194428 +sun/security/mscapi/ShortRSAKey1024.sh windows-all + +# 8000897, vm crash +sun/security/provider/DSA/TestAlgParameterGenerator.java generic-all + ############################################################################ # jdk_sound From c1126e37273c10ecc181bee9dc29d1c8fb05a073 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Fri, 30 Nov 2012 08:17:02 +0100 Subject: [PATCH 63/94] 7155168: java/util/TimeZone/Bug6912560.java: expected Asia/Tokyo Reviewed-by: okutsu --- jdk/test/java/util/TimeZone/Bug6912560.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jdk/test/java/util/TimeZone/Bug6912560.java b/jdk/test/java/util/TimeZone/Bug6912560.java index c641f3329c6..e88ffb04c19 100644 --- a/jdk/test/java/util/TimeZone/Bug6912560.java +++ b/jdk/test/java/util/TimeZone/Bug6912560.java @@ -40,6 +40,9 @@ public class Bug6912560 { // set the user.timezone property String tzname = "Asia/Tokyo"; System.setProperty("user.timezone", tzname); + // make sure the timezone will be initialized by + // the next call to TimeZone.getDefault() + TimeZone.setDefault(null); System.setSecurityManager(new SecurityManager()); TimeZone tz = TimeZone.getDefault(); From 4b272f6fddc2a152d25f2559685fc4a42bb41a6a Mon Sep 17 00:00:00 2001 From: Shi Jun Zhang Date: Fri, 30 Nov 2012 17:24:54 +0800 Subject: [PATCH 64/94] 8004211: Remove unused dlinfo local variable in launcher code Reviewed-by: alanb --- jdk/src/solaris/bin/java_md_solinux.c | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/src/solaris/bin/java_md_solinux.c b/jdk/src/solaris/bin/java_md_solinux.c index 46ae9d635ea..f3cf522d323 100644 --- a/jdk/src/solaris/bin/java_md_solinux.c +++ b/jdk/src/solaris/bin/java_md_solinux.c @@ -811,7 +811,6 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative) jboolean LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) { - Dl_info dlinfo; void *libjvm; JLI_TraceLauncher("JVM path is %s\n", jvmpath); From 2f3796af9d91abcfc718d3f3a0de08223d4a45d7 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Fri, 30 Nov 2012 11:18:16 +0000 Subject: [PATCH 65/94] 8003949: LogManager, downgrade normative reference to ${java.home}/lib/logging.properties Reviewed-by: psandoz, mchung --- .../classes/java/util/logging/LogManager.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/jdk/src/share/classes/java/util/logging/LogManager.java b/jdk/src/share/classes/java/util/logging/LogManager.java index 69c3504ab19..8d83108b712 100644 --- a/jdk/src/share/classes/java/util/logging/LogManager.java +++ b/jdk/src/share/classes/java/util/logging/LogManager.java @@ -56,20 +56,14 @@ import sun.security.action.GetPropertyAction; * At startup the LogManager class is located using the * java.util.logging.manager system property. *

- * By default, the LogManager reads its initial configuration from - * a properties file "lib/logging.properties" in the JRE directory. - * If you edit that property file you can change the default logging - * configuration for all uses of that JRE. - *

- * In addition, the LogManager uses two optional system properties that - * allow more control over reading the initial configuration: + * The LogManager defines two optional system properties that allow control over + * the initial configuration: *

    *
  • "java.util.logging.config.class" *
  • "java.util.logging.config.file" *
- * These two properties may be set via the Preferences API, or as - * command line property definitions to the "java" command, or as - * system property definitions passed to JNI_CreateJavaVM. + * These two properties may be specified on the command line to the "java" + * command, or as system property definitions passed to JNI_CreateJavaVM. *

* If the "java.util.logging.config.class" property is set, then the * property value is treated as a class name. The given class will be @@ -84,9 +78,10 @@ import sun.security.action.GetPropertyAction; * to specify a properties file (in java.util.Properties format). The * initial logging configuration will be read from this file. *

- * If neither of these properties is defined then, as described - * above, the LogManager will read its initial configuration from - * a properties file "lib/logging.properties" in the JRE directory. + * If neither of these properties is defined then the LogManager uses its + * default configuration. The default configuration is typically loaded from the + * properties file "{@code lib/logging.properties}" in the Java installation + * directory. *

* The properties for loggers and Handlers will have names starting * with the dot-separated name for the handler or logger. From a42dd61e4578d1b8490be93c4cd6b8304aadda1e Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Fri, 30 Nov 2012 16:29:32 +0000 Subject: [PATCH 66/94] 7165762: (aio) Default thread pool should be configured so that threads terminated after a timeout period Reviewed-by: chegar --- jdk/src/share/classes/sun/nio/ch/ThreadPool.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/jdk/src/share/classes/sun/nio/ch/ThreadPool.java b/jdk/src/share/classes/sun/nio/ch/ThreadPool.java index 4efcfd5304e..6a2fe42c747 100644 --- a/jdk/src/share/classes/sun/nio/ch/ThreadPool.java +++ b/jdk/src/share/classes/sun/nio/ch/ThreadPool.java @@ -102,11 +102,7 @@ public class ThreadPool { if (threadFactory == null) threadFactory = defaultThreadFactory; // create thread pool - ExecutorService executor = - new ThreadPoolExecutor(0, Integer.MAX_VALUE, - Long.MAX_VALUE, TimeUnit.MILLISECONDS, - new SynchronousQueue(), - threadFactory); + ExecutorService executor = Executors.newCachedThreadPool(threadFactory); return new ThreadPool(executor, false, initialSize); } From 5b7045b5ba4dfd325411b2ed18733b1a88f86540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Borggr=C3=A9n-Franck?= Date: Fri, 30 Nov 2012 09:47:17 +0100 Subject: [PATCH 67/94] 8004110: Remove debug code form sun/reflect/annotation/AnnotationSupport.java Reviewed-by: jjg, darcy --- .../classes/sun/reflect/annotation/AnnotationSupport.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/sun/reflect/annotation/AnnotationSupport.java b/jdk/src/share/classes/sun/reflect/annotation/AnnotationSupport.java index a019d4b506e..3046792b161 100644 --- a/jdk/src/share/classes/sun/reflect/annotation/AnnotationSupport.java +++ b/jdk/src/share/classes/sun/reflect/annotation/AnnotationSupport.java @@ -37,7 +37,7 @@ import sun.reflect.Reflection; import sun.misc.JavaLangAccess; public final class AnnotationSupport { - private static JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess(); + private static final JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess(); /** * Finds and returns _one_ annotation of the type indicated by @@ -104,7 +104,7 @@ public final class AnnotationSupport { /** * Unpacks the {@code annotationMap} parameter into an array of * {@code Annotation}s. This method will unpack all repeating - * annotaions containers (once). An annotation type is marked as a + * annotations containers (once). An annotation type is marked as a * container by meta-annotating it the with the {@code * ContainerFor} annotation. * @@ -175,7 +175,6 @@ public final class AnnotationSupport { IllegalArgumentException | // parameters doesn't match InvocationTargetException | // the value method threw an exception ClassCastException e) { // well, a cast failed ... - e.getCause().printStackTrace(); throw new InvalidContainerAnnotationError(containerInstance + " is an invalid container for repeating annotations", e, containerInstance, From d7cae9afff8024c7e6828b68f4288e00b9b2c5f2 Mon Sep 17 00:00:00 2001 From: Kurchi Subhra Hazra Date: Fri, 30 Nov 2012 12:00:07 -0800 Subject: [PATCH 68/94] 7197662: (prefs) java/util/prefs/AddNodeChangeListener.java fails by timeout or by "couldn't get file lock" Set -Djava.util.prefs.userRoot to current working directory of user in the prefs tests Reviewed-by: alanb, chegar, weijun, dxu --- jdk/test/java/util/prefs/AddNodeChangeListener.java | 3 ++- jdk/test/java/util/prefs/CheckUserPrefsStorage.sh | 8 ++++---- jdk/test/java/util/prefs/CommentsInXml.java | 3 ++- jdk/test/java/util/prefs/ConflictInFlush.java | 3 ++- jdk/test/java/util/prefs/ExportNode.java | 3 ++- jdk/test/java/util/prefs/ExportSubtree.java | 7 ++++--- jdk/test/java/util/prefs/PrefsSpi.sh | 6 +++++- jdk/test/java/util/prefs/RemoveNullKeyCheck.java | 3 ++- jdk/test/java/util/prefs/RemoveReadOnlyNode.java | 9 +++++---- jdk/test/java/util/prefs/RemoveUnregedListener.java | 3 ++- 10 files changed, 30 insertions(+), 18 deletions(-) diff --git a/jdk/test/java/util/prefs/AddNodeChangeListener.java b/jdk/test/java/util/prefs/AddNodeChangeListener.java index 8b506dc7e18..761ed2b48cf 100644 --- a/jdk/test/java/util/prefs/AddNodeChangeListener.java +++ b/jdk/test/java/util/prefs/AddNodeChangeListener.java @@ -24,9 +24,10 @@ */ /* @test - * @bug 7160252 + * @bug 7160252 7197662 * @summary Checks if events are delivered to a listener * when a child node is added or removed + * @run main/othervm -Djava.util.prefs.userRoot=. AddNodeChangeListener */ import java.util.prefs.*; diff --git a/jdk/test/java/util/prefs/CheckUserPrefsStorage.sh b/jdk/test/java/util/prefs/CheckUserPrefsStorage.sh index 71ded594cb2..5314b120c0c 100644 --- a/jdk/test/java/util/prefs/CheckUserPrefsStorage.sh +++ b/jdk/test/java/util/prefs/CheckUserPrefsStorage.sh @@ -22,10 +22,10 @@ # # @test -# @bug 7198073 +# @bug 7198073 7197662 # @build CheckUserPrefFirst CheckUserPrefLater # @run shell CheckUserPrefsStorage.sh -# @summary Tests that user preferences are stored in the +# @summary Tests that user preferences are stored in the # permanent storage # @@ -50,14 +50,14 @@ case "$OS" in esac # run CheckUserPrefFirst - creates and stores a user pref -${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} CheckUserPrefFirst +${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} -Djava.util.prefs.userRoot=. CheckUserPrefFirst result=$? if [ "$result" -ne "0" ]; then exit 1 fi # run CheckUserPrefLater - Looks for the stored pref -${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} CheckUserPrefLater +${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} -Djava.util.prefs.userRoot=. CheckUserPrefLater result=$? if [ "$result" -ne "0" ]; then exit 1 diff --git a/jdk/test/java/util/prefs/CommentsInXml.java b/jdk/test/java/util/prefs/CommentsInXml.java index bf8cdb9f7de..47011af880b 100644 --- a/jdk/test/java/util/prefs/CommentsInXml.java +++ b/jdk/test/java/util/prefs/CommentsInXml.java @@ -23,8 +23,9 @@ /* * @test - * @bug 4619564 + * @bug 4619564 7197662 * @summary XMl Comments in Preferences File lead to ClassCastException + * @run main/othervm -Djava.util.prefs.userRoot=. CommentsInXml * @author kladko */ diff --git a/jdk/test/java/util/prefs/ConflictInFlush.java b/jdk/test/java/util/prefs/ConflictInFlush.java index 290bab7d5e8..1f13ca736ef 100644 --- a/jdk/test/java/util/prefs/ConflictInFlush.java +++ b/jdk/test/java/util/prefs/ConflictInFlush.java @@ -23,8 +23,9 @@ /* * @test - * @bug 4703132 + * @bug 4703132 7197662 * @summary flush() throws an IllegalStateException on a removed node + * @run main/othervm -Djava.util.prefs.userRoot=. ConflictInFlush * @author Sucheta Dambalkar */ diff --git a/jdk/test/java/util/prefs/ExportNode.java b/jdk/test/java/util/prefs/ExportNode.java index 5ecab0ffd41..601b18920b3 100644 --- a/jdk/test/java/util/prefs/ExportNode.java +++ b/jdk/test/java/util/prefs/ExportNode.java @@ -24,9 +24,10 @@ /* * @test - * @bug 4387136 4947349 + * @bug 4387136 4947349 7197662 * @summary Due to a bug in XMLSupport.putPreferencesInXml(...), * node's keys would not get exported. + * @run main/othervm -Djava.util.prefs.userRoot=. ExportNode * @author Konstantin Kladko */ import java.util.prefs.*; diff --git a/jdk/test/java/util/prefs/ExportSubtree.java b/jdk/test/java/util/prefs/ExportSubtree.java index 36bfe79d53f..f1e632c6b4e 100644 --- a/jdk/test/java/util/prefs/ExportSubtree.java +++ b/jdk/test/java/util/prefs/ExportSubtree.java @@ -23,9 +23,10 @@ /* @test - @bug 6203576 4700020 - @summary checks if the output of exportSubtree() is identical to - the output from previous release. + * @bug 6203576 4700020 7197662 + * @summary checks if the output of exportSubtree() is identical to + * the output from previous release. + * @run main/othervm -Djava.util.prefs.userRoot=. ExportSubtree */ import java.io.*; diff --git a/jdk/test/java/util/prefs/PrefsSpi.sh b/jdk/test/java/util/prefs/PrefsSpi.sh index 10a0ded018f..b140b306260 100644 --- a/jdk/test/java/util/prefs/PrefsSpi.sh +++ b/jdk/test/java/util/prefs/PrefsSpi.sh @@ -24,7 +24,7 @@ # # @test -# @bug 4991526 6514993 +# @bug 4991526 6514993 7197662 # @summary Unit test for Preferences jar providers # # @build PrefsSpi @@ -89,12 +89,16 @@ case "`uname`" in Windows*|CYGWIN* ) CPS=';';; *) CPS=':';; esac Sys "$java" "-cp" "$TESTCLASSES${CPS}extDir/PrefsSpi.jar" \ -Djava.util.prefs.PreferencesFactory=StubPreferencesFactory \ + -Djava.util.prefs.userRoot=. \ PrefsSpi "StubPreferences" Sys "$java" "-cp" "$TESTCLASSES" \ + -Djava.util.prefs.userRoot=. \ PrefsSpi "java.util.prefs.*" Sys "$java" "-cp" "$TESTCLASSES${CPS}extDir/PrefsSpi.jar" \ + -Djava.util.prefs.userRoot=. \ PrefsSpi "StubPreferences" Sys "$java" "-cp" "$TESTCLASSES" "-Djava.ext.dirs=extDir" \ + -Djava.util.prefs.userRoot=. \ PrefsSpi "StubPreferences" rm -rf jarDir extDir diff --git a/jdk/test/java/util/prefs/RemoveNullKeyCheck.java b/jdk/test/java/util/prefs/RemoveNullKeyCheck.java index c74f0d82d37..eac63d5ead8 100644 --- a/jdk/test/java/util/prefs/RemoveNullKeyCheck.java +++ b/jdk/test/java/util/prefs/RemoveNullKeyCheck.java @@ -22,9 +22,10 @@ */ /* @test - * @bug 7160242 7165118 + * @bug 7160242 7165118 7197662 * @summary Check if NullPointerException is thrown if the key passed * to remove() is null. + * @run main/othervm -Djava.util.prefs.userRoot=. RemoveNullKeyCheck */ import java.util.prefs.Preferences; diff --git a/jdk/test/java/util/prefs/RemoveReadOnlyNode.java b/jdk/test/java/util/prefs/RemoveReadOnlyNode.java index 501a337b757..ca7684fc0f9 100644 --- a/jdk/test/java/util/prefs/RemoveReadOnlyNode.java +++ b/jdk/test/java/util/prefs/RemoveReadOnlyNode.java @@ -23,10 +23,11 @@ /* @test - @bug 6178148 - @summary check if wrong exception gets thrown if one of the child - nodes is readonly on underlying filesystem when node is - being removed. + * @bug 6178148 7197662 + * @summary check if wrong exception gets thrown if one of the child + * nodes is readonly on underlying filesystem when node is + * being removed. + * @run main/othervm -Djava.util.prefs.userRoot=. RemoveReadOnlyNode */ import java.io.*; diff --git a/jdk/test/java/util/prefs/RemoveUnregedListener.java b/jdk/test/java/util/prefs/RemoveUnregedListener.java index 901dde3e0a0..126a7d79f1e 100644 --- a/jdk/test/java/util/prefs/RemoveUnregedListener.java +++ b/jdk/test/java/util/prefs/RemoveUnregedListener.java @@ -23,9 +23,10 @@ /* @test - * @bug 4705094 + * @bug 4705094 7197662 * @summary Checks if correct exception gets thrown when removing an * unregistered NodeChangeListener . + * @run main/othervm -Djava.util.prefs.userRoot=. RemoveUnregedListener */ import java.util.prefs.*; From e78a1eb083f4b3be4aec82e1168d26713af0683a Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Sat, 1 Dec 2012 11:36:25 -0800 Subject: [PATCH 69/94] 8004212: java.util.Base64 methods decodeArray and decodeBuffer should return the number of bytes written To return the length instead of position Reviewed-by: alanb --- jdk/src/share/classes/java/util/Base64.java | 12 ++--- jdk/test/java/util/Base64/TestBase64.java | 51 ++++++++++++++++++++- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/jdk/src/share/classes/java/util/Base64.java b/jdk/src/share/classes/java/util/Base64.java index db46a3e4b5a..a44c5d0c5a9 100644 --- a/jdk/src/share/classes/java/util/Base64.java +++ b/jdk/src/share/classes/java/util/Base64.java @@ -901,7 +901,7 @@ public class Base64 { shiftto -= 6; if (shiftto < 0) { if (dl < dp + 3) - return dp; + return dp - dp0; da[dp++] = (byte)(bits >> 16); da[dp++] = (byte)(bits >> 8); da[dp++] = (byte)(bits); @@ -912,7 +912,7 @@ public class Base64 { } if (shiftto == 6) { if (dl - dp < 1) - return dp; + return dp - dp0; if (padding && (sp + 1 != sl || sa[sp++] != '=')) throw new IllegalArgumentException( "Input buffer has wrong 4-byte ending unit"); @@ -920,7 +920,7 @@ public class Base64 { mark = sp; } else if (shiftto == 0) { if (dl - dp < 2) - return dp; + return dp - dp0; if (padding && sp != sl) throw new IllegalArgumentException( "Input buffer has wrong 4-byte ending unit"); @@ -969,7 +969,7 @@ public class Base64 { shiftto -= 6; if (shiftto < 0) { if (dl < dp + 3) - return dp; + return dp - dp0; dst.put(dp++, (byte)(bits >> 16)); dst.put(dp++, (byte)(bits >> 8)); dst.put(dp++, (byte)(bits)); @@ -980,7 +980,7 @@ public class Base64 { } if (shiftto == 6) { if (dl - dp < 1) - return dp; + return dp - dp0; if (padding && (sp + 1 != sl || src.get(sp++) != '=')) throw new IllegalArgumentException( "Input buffer has wrong 4-byte ending unit"); @@ -988,7 +988,7 @@ public class Base64 { mark = sp; } else if (shiftto == 0) { if (dl - dp < 2) - return dp; + return dp - dp0; if (padding && sp != sl) throw new IllegalArgumentException( "Input buffer has wrong 4-byte ending unit"); diff --git a/jdk/test/java/util/Base64/TestBase64.java b/jdk/test/java/util/Base64/TestBase64.java index 84e3885511d..6b37772d7f6 100644 --- a/jdk/test/java/util/Base64/TestBase64.java +++ b/jdk/test/java/util/Base64/TestBase64.java @@ -22,7 +22,7 @@ */ /** - * @test 4235519 + * @test 4235519 8004212 * @summary tests java.util.Base64 */ @@ -106,6 +106,9 @@ public class TestBase64 { Base64.getDecoder().decode(ByteBuffer.wrap(decoded), ByteBuffer.allocate(1024)); }}); checkIAE(new Runnable() { public void run() { Base64.getDecoder().decode(ByteBuffer.wrap(decoded), ByteBuffer.allocateDirect(1024)); }}); + + // test return value from decode(ByteBuffer, ByteBuffer) + testDecBufRet(); } private static sun.misc.BASE64Encoder sunmisc = new sun.misc.BASE64Encoder(); @@ -351,6 +354,52 @@ public class TestBase64 { } catch (IllegalArgumentException iae) {} } + + private static void testDecBufRet() throws Throwable { + Random rnd = new java.util.Random(); + Base64.Encoder encoder = Base64.getEncoder(); + Base64.Decoder decoder = Base64.getDecoder(); + // src pos, len expected + int[][] tests = { { 6, 3, 3, 3}, // xxx xxx -> yyyy yyyy + { 6, 3, 4, 3}, + { 6, 3, 5, 3}, + { 6, 3, 6, 6}, + { 6, 11, 4, 3}, + { 6, 11, 4, 3}, + { 6, 11, 5, 3}, + { 6, 11, 6, 6}, + { 7, 3, 6, 6}, // xxx xxx x -> yyyy yyyy yy== + { 7, 3, 7, 7}, + { 7, 11, 6, 6}, + { 7, 11, 7, 7}, + { 8, 3, 6, 6}, // xxx xxx xx -> yyyy yyyy yyy= + { 8, 3, 7, 6}, + { 8, 3, 8, 8}, + { 8, 13, 6, 6}, + { 8, 13, 7, 6}, + { 8, 13, 8, 8}, + + }; + ByteBuffer dstBuf = ByteBuffer.allocate(100); + for (boolean direct : new boolean[] { false, true}) { + for (int[] test : tests) { + byte[] src = new byte[test[0]]; + rnd.nextBytes(src); + ByteBuffer srcBuf = direct ? ByteBuffer.allocate(100) + : ByteBuffer.allocateDirect(100); + srcBuf.put(encoder.encode(src)).flip(); + dstBuf.clear().position(test[1]).limit(test[1]+ test[2]); + int ret = decoder.decode(srcBuf, dstBuf); + if (ret != test[3]) { + System.out.printf(" [%6s] src=%d, pos=%d, len=%d, expected=%d, ret=%d%n", + direct?"direct":"", + test[0], test[1], test[2], test[3], ret); + throw new RuntimeException("ret != expected"); + } + } + } + } + private static final void testEncode(Base64.Encoder enc, ByteBuffer bin, byte[] expected) throws Throwable { From d2d5213b87ac4d97860024297ccc35fabd6b1846 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Sun, 2 Dec 2012 16:37:31 +0000 Subject: [PATCH 70/94] 8003846: Override mechanism for currency data should not require creating currency.properties in java.home Reviewed-by: naoto --- jdk/src/share/classes/java/util/Currency.java | 22 ++-- .../java/util/Currency/PropertiesTest.java | 47 ++++---- jdk/test/java/util/Currency/PropertiesTest.sh | 105 ++++++++++-------- 3 files changed, 91 insertions(+), 83 deletions(-) diff --git a/jdk/src/share/classes/java/util/Currency.java b/jdk/src/share/classes/java/util/Currency.java index 5f2a2143952..f201dae410a 100644 --- a/jdk/src/share/classes/java/util/Currency.java +++ b/jdk/src/share/classes/java/util/Currency.java @@ -56,12 +56,13 @@ import sun.util.logging.PlatformLogger; * no public constructor. You obtain a Currency instance using * the getInstance methods. *

- * Users can supersede the Java runtime currency data by creating a properties - * file named <JAVA_HOME>/lib/currency.properties. The contents - * of the properties file are key/value pairs of the ISO 3166 country codes - * and the ISO 4217 currency data respectively. The value part consists of - * three ISO 4217 values of a currency, i.e., an alphabetic code, a numeric - * code, and a minor unit. Those three ISO 4217 values are separated by commas. + * Users can supersede the Java runtime currency data by means of the system + * property {@code java.util.currency.data}. If this system property is + * defined then its value is the location of a properties file, the contents of + * which are key/value pairs of the ISO 3166 country codes and the ISO 4217 + * currency data respectively. The value part consists of three ISO 4217 values + * of a currency, i.e., an alphabetic code, a numeric code, and a minor unit. + * Those three ISO 4217 values are separated by commas. * The lines which start with '#'s are considered comment lines. An optional UTC * timestamp may be specified per currency entry if users need to specify a * cutover date indicating when the new data comes into effect. The timestamp is @@ -246,10 +247,13 @@ public final class Currency implements Serializable { } // look for the properties file for overrides + String propsFile = System.getProperty("java.util.currency.data"); + if (propsFile == null) { + propsFile = homeDir + File.separator + "lib" + + File.separator + "currency.properties"; + } try { - File propFile = new File(homeDir + File.separator + - "lib" + File.separator + - "currency.properties"); + File propFile = new File(propsFile); if (propFile.exists()) { Properties props = new Properties(); try (FileReader fr = new FileReader(propFile)) { diff --git a/jdk/test/java/util/Currency/PropertiesTest.java b/jdk/test/java/util/Currency/PropertiesTest.java index ab78ec08f3a..4b84e06584e 100644 --- a/jdk/test/java/util/Currency/PropertiesTest.java +++ b/jdk/test/java/util/Currency/PropertiesTest.java @@ -27,22 +27,15 @@ import java.util.*; import java.util.regex.*; public class PropertiesTest { - public static void main(String[] s) throws Exception { - for (int i = 0; i < s.length; i ++) { - if ("-d".equals(s[i])) { - i++; - if (i == s.length) { - throw new RuntimeException("-d needs output file name"); - } else { - dump(s[i]); - } - } else if ("-c".equals(s[i])) { - if (i+2 == s.length) { - throw new RuntimeException("-d needs two file name arguments, before and after respectively"); - } else { - compare(s[++i], s[++i]); - } - } + public static void main(String[] args) throws Exception { + if (args.length == 2 && args[0].equals("-d")) { + dump(args[1]); + } else if (args.length == 4 && args[0].equals("-c")) { + compare(args[1], args[2], args[3]); + } else { + System.err.println("Usage: java PropertiesTest -d "); + System.err.println(" java PropertiesTest -c "); + System.exit(-1); } } @@ -77,15 +70,17 @@ public class PropertiesTest { pw.close(); } - private static void compare(String beforeFile, String afterFile) throws Exception { + private static void compare(String beforeFile, String afterFile, String propsFile) + throws IOException + { // load file contents Properties before = new Properties(); + try (Reader reader = new FileReader(beforeFile)) { + before.load(reader); + } Properties after = new Properties(); - try { - before.load(new FileReader(beforeFile)); - after.load(new FileReader(afterFile)); - } catch (IOException ioe) { - throw new RuntimeException(ioe); + try (Reader reader = new FileReader(afterFile)) { + after.load(reader); } // remove the same contents from the 'after' properties @@ -103,13 +98,9 @@ public class PropertiesTest { } // now look at the currency.properties - String propFileName = System.getProperty("java.home") + File.separator + - "lib" + File.separator + "currency.properties"; Properties p = new Properties(); - try { - p.load(new FileReader(propFileName)); - } catch (IOException ioe) { - throw new RuntimeException(ioe); + try (Reader reader = new FileReader(propsFile)) { + p.load(reader); } // test each replacements diff --git a/jdk/test/java/util/Currency/PropertiesTest.sh b/jdk/test/java/util/Currency/PropertiesTest.sh index f016eed3d81..874e7ac3018 100644 --- a/jdk/test/java/util/Currency/PropertiesTest.sh +++ b/jdk/test/java/util/Currency/PropertiesTest.sh @@ -1,7 +1,29 @@ #!/bin/sh + +# Copyright (c) 2007, 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + # @test -# @bug 6332666 7180362 +# @bug 6332666 7180362 8003846 # @summary tests the capability of replacing the currency data with user # specified currency properties file # @build PropertiesTest @@ -36,7 +58,7 @@ case "$OS" in ;; Windows* | CYGWIN* ) PS=";" - FS="\\" + FS="/" ;; * ) echo "Unrecognized system!" @@ -44,23 +66,31 @@ case "$OS" in ;; esac -# Currency dump path #1. Just dump currencies with the bare JRE +failures=0 -# run -RUNCMD="${TESTJAVA}${FS}bin${FS}java -classpath ${TESTCLASSES} PropertiesTest -d dump1" +run() { + echo '' + sh -xc "${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} $*" 2>&1 + if [ $? != 0 ]; then failures=`expr $failures + 1`; fi +} -echo ${RUNCMD} -${RUNCMD} -result=$? +PROPS=${TESTSRC}${FS}currency.properties -if [ $result -eq 0 ] -then - echo "Execution successful" -else - echo "Execution of the test case failed." -fi -# Currency dump path #2. Dump currencies using the JRE with replacement currencies +# Dump built-in currency data + +run PropertiesTest -d dump1 + + +# Dump built-in currency data + overrides in properties file specified +# by system property. + +run -Djava.util.currency.data=${PROPS} PropertiesTest -d dump2 +run PropertiesTest -c dump1 dump2 ${PROPS} + + +# Dump built-in currency data + overrides in properties file copied into +# JRE image. # copy the test properties file COPIED=0 @@ -79,44 +109,27 @@ then else PROPLOCATION=${WRITABLEJDK}${FS}lib fi -cp ${TESTSRC}${FS}currency.properties $PROPLOCATION +cp ${PROPS} $PROPLOCATION # run -RUNCMD="${WRITABLEJDK}${FS}bin${FS}java -classpath ${TESTCLASSES} PropertiesTest -d dump2" - -echo ${RUNCMD} -${RUNCMD} -result=$? - -if [ $result -eq 0 ] -then - echo "Execution successful" -else - echo "Execution of the test case failed." -fi - -# Now compare the two dump files - -RUNCMD="${WRITABLEJDK}${FS}bin${FS}java -classpath ${TESTCLASSES} PropertiesTest -c dump1 dump2" - -echo ${RUNCMD} -${RUNCMD} -result=$? - -if [ $result -eq 0 ] -then - echo "Execution successful" -else - echo "Execution of the test case failed." -fi +echo '' +sh -xc "${WRITABLEJDK}${FS}bin${FS}java -cp ${TESTCLASSES} PropertiesTest -d dump3" +if [ $? != 0 ]; then failures=`expr $failures + 1`; fi # Cleanup -rm -f dump1 -rm -f dump2 rm -f ${PROPLOCATION}${FS}currency.properties if [ $COPIED -eq 1 ] then rm -rf $WRITABLEJDK fi -exit $result +# compare the two dump files +run PropertiesTest -c dump1 dump3 ${PROPS} + + +# Results +echo '' +if [ $failures -gt 0 ]; + then echo "$failures tests failed"; + else echo "All tests passed"; fi +exit $failures From ecdf296456ae0b7368bbbf8db45b54215e8f125c Mon Sep 17 00:00:00 2001 From: Bill Pittore Date: Sun, 2 Dec 2012 19:16:56 -0500 Subject: [PATCH 71/94] 7200297: agent code does not handle multiple boot library path elements correctly When bug 6819213 was fixed it enabled sun.boot.library.path property to contain multiple paths. Code in agents does not handle multiple paths when attempting to find dependent shared libs. Reviewed-by: dholmes, sspitsyn, dsamersoff --- jdk/src/share/back/debugInit.c | 35 +++++++++++------- jdk/src/share/back/error_messages.c | 11 ++++-- jdk/src/share/back/transport.c | 6 ++-- jdk/src/share/demo/jvmti/hprof/hprof.h | 3 +- jdk/src/share/demo/jvmti/hprof/hprof_init.c | 17 ++++++--- jdk/src/solaris/back/linker_md.c | 30 ++++++++++++++-- jdk/src/solaris/demo/jvmti/hprof/hprof_md.c | 29 +++++++++++++-- jdk/src/solaris/npt/npt_md.h | 4 +-- jdk/src/windows/back/linker_md.c | 40 +++++++++++++++++---- jdk/src/windows/demo/jvmti/hprof/hprof_md.c | 39 ++++++++++++++++---- jdk/src/windows/npt/npt_md.h | 22 +++--------- 11 files changed, 175 insertions(+), 61 deletions(-) diff --git a/jdk/src/share/back/debugInit.c b/jdk/src/share/back/debugInit.c index 490099b06c5..25ffbffc91a 100644 --- a/jdk/src/share/back/debugInit.c +++ b/jdk/src/share/back/debugInit.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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 @@ -37,6 +37,7 @@ #include "debugLoop.h" #include "bag.h" #include "invoker.h" +#include "sys.h" /* How the options get to OnLoad: */ #define XDEBUG "-Xdebug" @@ -201,6 +202,8 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) jint jvmtiCompileTimeMajorVersion; jint jvmtiCompileTimeMinorVersion; jint jvmtiCompileTimeMicroVersion; + char *boot_path = NULL; + char npt_lib[MAXPATHLEN]; /* See if it's already loaded */ if ( gdata!=NULL && gdata->isLoaded==JNI_TRUE ) { @@ -227,18 +230,6 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) vmInitialized = JNI_FALSE; gdata->vmDead = JNI_FALSE; - /* Npt and Utf function init */ - NPT_INITIALIZE(&(gdata->npt), NPT_VERSION, NULL); - if (gdata->npt == NULL) { - ERROR_MESSAGE(("JDWP: unable to initialize NPT library")); - return JNI_ERR; - } - gdata->npt->utf = (gdata->npt->utfInitialize)(NULL); - if (gdata->npt->utf == NULL) { - ERROR_MESSAGE(("JDWP: UTF function initialization failed")); - return JNI_ERR; - } - /* Get the JVMTI Env, IMPORTANT: Do this first! For jvmtiAllocate(). */ error = JVM_FUNC_PTR(vm,GetEnv) (vm, (void **)&(gdata->jvmti), JVMTI_VERSION_1); @@ -277,6 +268,24 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) forceExit(1); /* Kill entire process, no core dump wanted */ } + JVMTI_FUNC_PTR(gdata->jvmti, GetSystemProperty) + (gdata->jvmti, (const char *)"sun.boot.library.path", + &boot_path); + + dbgsysBuildLibName(npt_lib, sizeof(npt_lib), boot_path, NPT_LIBNAME); + /* Npt and Utf function init */ + NPT_INITIALIZE(npt_lib, &(gdata->npt), NPT_VERSION, NULL); + jvmtiDeallocate(boot_path); + if (gdata->npt == NULL) { + ERROR_MESSAGE(("JDWP: unable to initialize NPT library")); + return JNI_ERR; + } + gdata->npt->utf = (gdata->npt->utfInitialize)(NULL); + if (gdata->npt->utf == NULL) { + ERROR_MESSAGE(("JDWP: UTF function initialization failed")); + return JNI_ERR; + } + /* Parse input options */ if (!parseOptions(options)) { /* No message necessary, should have been printed out already */ diff --git a/jdk/src/share/back/error_messages.c b/jdk/src/share/back/error_messages.c index 13a04b5173a..2ec5bbfa2e5 100644 --- a/jdk/src/share/back/error_messages.c +++ b/jdk/src/share/back/error_messages.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. 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 @@ -70,8 +70,13 @@ vprint_message(FILE *fp, const char *prefix, const char *suffix, len = (int)strlen((char*)utf8buf); /* Convert to platform encoding (ignore errors, dangerous area) */ - (void)(gdata->npt->utf8ToPlatform)(gdata->npt->utf, - utf8buf, len, pbuf, MAX_MESSAGE_LEN); + if (gdata->npt != NULL) { + (void)(gdata->npt->utf8ToPlatform)(gdata->npt->utf, + utf8buf, len, pbuf, MAX_MESSAGE_LEN); + } else { + /* May be called before NPT is initialized so don't fault */ + strncpy(pbuf, (char*)utf8buf, len); + } (void)fprintf(fp, "%s%s%s", prefix, pbuf, suffix); } diff --git a/jdk/src/share/back/transport.c b/jdk/src/share/back/transport.c index b3154941729..40608b31239 100644 --- a/jdk/src/share/back/transport.c +++ b/jdk/src/share/back/transport.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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 @@ -144,7 +144,9 @@ loadTransport(char *name, jdwpTransportEnv **transportPtr) /* First, look in sun.boot.library.path. This should find the standard * dt_socket and dt_shmem transport libraries, or any library * that was delivered with the J2SE. - * Note: Java property sun.boot.library.path contains a single directory. + * Note: Since 6819213 fixed, Java property sun.boot.library.path can + * contain multiple paths. Dll_dir is the first entry and + * -Dsun.boot.library.path entries are appended. */ libdir = gdata->property_sun_boot_library_path; if (libdir == NULL) { diff --git a/jdk/src/share/demo/jvmti/hprof/hprof.h b/jdk/src/share/demo/jvmti/hprof/hprof.h index 6e61affce11..ec9fbf01870 100644 --- a/jdk/src/share/demo/jvmti/hprof/hprof.h +++ b/jdk/src/share/demo/jvmti/hprof/hprof.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -65,6 +65,7 @@ #include "jni.h" #include "jvmti.h" #include "classfile_constants.h" +#include "jvm_md.h" #ifndef SKIP_NPT #include "npt.h" /* To get NptEnv for doing character conversions */ diff --git a/jdk/src/share/demo/jvmti/hprof/hprof_init.c b/jdk/src/share/demo/jvmti/hprof/hprof_init.c index 9183800c428..328c474d410 100644 --- a/jdk/src/share/demo/jvmti/hprof/hprof_init.c +++ b/jdk/src/share/demo/jvmti/hprof/hprof_init.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1899,6 +1899,7 @@ load_library(char *name) */ getSystemProperty("sun.boot.library.path", &boot_path); md_build_library_name(lname, FILENAME_MAX, boot_path, name); + jvmtiDeallocate(boot_path); handle = md_load_library(lname, err_buf, (int)sizeof(err_buf)); if ( handle == NULL ) { /* This may be necessary on Windows. */ @@ -1941,6 +1942,9 @@ lookup_library_symbol(void *library, char **symbols, int nsymbols) JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) { + char *boot_path = NULL; + char npt_lib[JVM_MAXPATHLEN]; + /* See if it's already loaded */ if ( gdata!=NULL && gdata->isLoaded==JNI_TRUE ) { HPROF_ERROR(JNI_TRUE, "Cannot load this JVM TI agent twice, check your java command line for duplicate hprof options."); @@ -1957,9 +1961,15 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) gdata->jvm = vm; + /* Get the JVMTI environment */ + getJvmti(); + #ifndef SKIP_NPT + getSystemProperty("sun.boot.library.path", &boot_path); /* Load in NPT library for character conversions */ - NPT_INITIALIZE(&(gdata->npt), NPT_VERSION, NULL); + md_build_library_name(npt_lib, sizeof(npt_lib), boot_path, NPT_LIBNAME); + jvmtiDeallocate(boot_path); + NPT_INITIALIZE(npt_lib, &(gdata->npt), NPT_VERSION, NULL); if ( gdata->npt == NULL ) { HPROF_ERROR(JNI_TRUE, "Cannot load npt library"); } @@ -1969,9 +1979,6 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) } #endif - /* Get the JVMTI environment */ - getJvmti(); - /* Lock needed to protect debug_malloc() code, which is not MT safe */ #ifdef DEBUG gdata->debug_malloc_lock = createRawMonitor("HPROF debug_malloc lock"); diff --git a/jdk/src/solaris/back/linker_md.c b/jdk/src/solaris/back/linker_md.c index 5cc83f3df89..a1cbcce3fcf 100644 --- a/jdk/src/solaris/back/linker_md.c +++ b/jdk/src/solaris/back/linker_md.c @@ -54,6 +54,32 @@ #define LIB_SUFFIX "so" #endif +static void dll_build_name(char* buffer, size_t buflen, + const char* pname, const char* fname) { + // Based on os_solaris.cpp + + char *path_sep = PATH_SEPARATOR; + char *pathname = (char *)pname; + while (strlen(pathname) > 0) { + char *p = strchr(pathname, *path_sep); + if (p == NULL) { + p = pathname + strlen(pathname); + } + /* check for NULL path */ + if (p == pathname) { + continue; + } + (void)snprintf(buffer, buflen, "%.*s/lib%s." LIB_SUFFIX, (p - pathname), + pathname, fname); + + if (access(buffer, F_OK) == 0) { + break; + } + pathname = p + 1; + *buffer = '\0'; + } +} + /* * create a string for the JNI native function name by adding the * appropriate decorations. @@ -76,16 +102,16 @@ dbgsysBuildLibName(char *holder, int holderlen, char *pname, char *fname) { const int pnamelen = pname ? strlen(pname) : 0; + *holder = '\0'; /* Quietly truncate on buffer overflow. Should be an error. */ if (pnamelen + (int)strlen(fname) + 10 > holderlen) { - *holder = '\0'; return; } if (pnamelen == 0) { (void)snprintf(holder, holderlen, "lib%s." LIB_SUFFIX, fname); } else { - (void)snprintf(holder, holderlen, "%s/lib%s." LIB_SUFFIX, pname, fname); + dll_build_name(holder, holderlen, pname, fname); } } diff --git a/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c b/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c index 284a2e6fee7..1df2271ce4e 100644 --- a/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c +++ b/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c @@ -380,6 +380,31 @@ md_ntohl(unsigned l) return ntohl(l); } +static void dll_build_name(char* buffer, size_t buflen, + const char* pname, const char* fname) { + // Loosely based on os_solaris.cpp + + char *pathname = (char *)pname; + while (strlen(pathname) > 0) { + char *p = strchr(pathname, ':'); + if (p == NULL) { + p = pathname + strlen(pathname); + } + /* check for NULL path */ + if (p == pathname) { + continue; + } + (void)snprintf(buffer, buflen, "%.*s/lib%s" JNI_LIB_SUFFIX, + (p - pathname), pathname, fname); + + if (access(buffer, F_OK) == 0) { + break; + } + pathname = p + 1; + *buffer = '\0'; + } +} + /* Create the actual fill filename for a dynamic library. */ void md_build_library_name(char *holder, int holderlen, char *pname, char *fname) @@ -389,9 +414,9 @@ md_build_library_name(char *holder, int holderlen, char *pname, char *fname) /* Length of options directory location. */ pnamelen = pname ? strlen(pname) : 0; + *holder = '\0'; /* Quietly truncate on buffer overflow. Should be an error. */ if (pnamelen + (int)strlen(fname) + 10 > holderlen) { - *holder = '\0'; return; } @@ -399,7 +424,7 @@ md_build_library_name(char *holder, int holderlen, char *pname, char *fname) if (pnamelen == 0) { (void)snprintf(holder, holderlen, "lib%s" JNI_LIB_SUFFIX, fname); } else { - (void)snprintf(holder, holderlen, "%s/lib%s" JNI_LIB_SUFFIX, pname, fname); + dll_build_name(holder, holderlen, pname, fname); } } diff --git a/jdk/src/solaris/npt/npt_md.h b/jdk/src/solaris/npt/npt_md.h index 9b0c33655a3..76d5b663c04 100644 --- a/jdk/src/solaris/npt/npt_md.h +++ b/jdk/src/solaris/npt/npt_md.h @@ -36,14 +36,14 @@ #define NPT_LIBNAME "npt" -#define NPT_INITIALIZE(pnpt,version,options) \ +#define NPT_INITIALIZE(path,pnpt,version,options) \ { \ void *_handle; \ void *_sym; \ \ if ( (pnpt) == NULL ) NPT_ERROR("NptEnv* is NULL"); \ *(pnpt) = NULL; \ - _handle = dlopen(JNI_LIB_NAME(NPT_LIBNAME), RTLD_LAZY); \ + _handle = dlopen(path, RTLD_LAZY); \ if ( _handle == NULL ) NPT_ERROR("Cannot open library"); \ _sym = dlsym(_handle, "nptInitialize"); \ if ( _sym == NULL ) NPT_ERROR("Cannot find nptInitialize"); \ diff --git a/jdk/src/windows/back/linker_md.c b/jdk/src/windows/back/linker_md.c index a651eee4b87..e3ca2584cef 100644 --- a/jdk/src/windows/back/linker_md.c +++ b/jdk/src/windows/back/linker_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. 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 @@ -32,11 +32,42 @@ #include #include #include +#include #include "sys.h" #include "path_md.h" +static void dll_build_name(char* buffer, size_t buflen, + const char* pname, const char* fname) { + // Based on os_windows.cpp + + char *path_sep = PATH_SEPARATOR; + char *pathname = (char *)pname; + while (strlen(pathname) > 0) { + char *p = strchr(pathname, *path_sep); + if (p == NULL) { + p = pathname + strlen(pathname); + } + /* check for NULL path */ + if (p == pathname) { + continue; + } + if (*(p-1) == ':' || *(p-1) == '\\') { + (void)_snprintf(buffer, buflen, "%.*s%s.dll", (p - pathname), + pathname, fname); + } else { + (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (p - pathname), + pathname, fname); + } + if (_access(buffer, 0) == 0) { + break; + } + pathname = p + 1; + *buffer = '\0'; + } +} + /* * From system_md.c v1.54 */ @@ -80,20 +111,17 @@ void dbgsysBuildLibName(char *holder, int holderlen, char *pname, char *fname) { const int pnamelen = pname ? (int)strlen(pname) : 0; - const char c = (pnamelen > 0) ? pname[pnamelen-1] : 0; + *holder = '\0'; /* Quietly truncates on buffer overflow. Should be an error. */ if (pnamelen + (int)strlen(fname) + 10 > holderlen) { - *holder = '\0'; return; } if (pnamelen == 0) { sprintf(holder, "%s.dll", fname); - } else if (c == ':' || c == '\\') { - sprintf(holder, "%s%s.dll", pname, fname); } else { - sprintf(holder, "%s\\%s.dll", pname, fname); + dll_build_name(holder, holderlen, pname, fname); } } diff --git a/jdk/src/windows/demo/jvmti/hprof/hprof_md.c b/jdk/src/windows/demo/jvmti/hprof/hprof_md.c index 2f3ba24fc9a..e5cbeda0f69 100644 --- a/jdk/src/windows/demo/jvmti/hprof/hprof_md.c +++ b/jdk/src/windows/demo/jvmti/hprof/hprof_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -367,28 +367,53 @@ get_last_error_string(char *buf, int len) return 0; } +static void dll_build_name(char* buffer, size_t buflen, + const char* pname, const char* fname) { + // Loosley based on os_windows.cpp + + char *pathname = (char *)pname; + while (strlen(pathname) > 0) { + char *p = strchr(pathname, ';'); + if (p == NULL) { + p = pathname + strlen(pathname); + } + /* check for NULL path */ + if (p == pathname) { + continue; + } + if (*(p-1) == ':' || *(p-1) == '\\') { + (void)_snprintf(buffer, buflen, "%.*s%s.dll", (p - pathname), + pathname, fname); + } else { + (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (p - pathname), + pathname, fname); + } + if (_access(buffer, 0) == 0) { + break; + } + pathname = p + 1; + *buffer = '\0'; + } +} + /* Build a machine dependent library name out of a path and file name. */ void md_build_library_name(char *holder, int holderlen, char *pname, char *fname) { int pnamelen; - char c; pnamelen = pname ? (int)strlen(pname) : 0; - c = (pnamelen > 0) ? pname[pnamelen-1] : 0; + *holder = '\0'; /* Quietly truncates on buffer overflow. Should be an error. */ if (pnamelen + strlen(fname) + 10 > (unsigned int)holderlen) { - *holder = '\0'; return; } if (pnamelen == 0) { sprintf(holder, "%s.dll", fname); - } else if (c == ':' || c == '\\') { - sprintf(holder, "%s%s.dll", pname, fname); } else { - sprintf(holder, "%s\\%s.dll", pname, fname); + dll_build_name(holder, holderlen, pname, fname); } } diff --git a/jdk/src/windows/npt/npt_md.h b/jdk/src/windows/npt/npt_md.h index 50747ddd7fd..e4e5dc3ffe3 100644 --- a/jdk/src/windows/npt/npt_md.h +++ b/jdk/src/windows/npt/npt_md.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2012, Oracle and/or its affiliates. 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 @@ -33,30 +33,16 @@ #include #include -#define NPT_LIBNAME "npt.dll" +#define NPT_LIBNAME "npt" -#define NPT_INITIALIZE(pnpt,version,options) \ +#define NPT_INITIALIZE(path,pnpt,version,options) \ { \ - HINSTANCE jvm; \ void *_handle; \ void *_sym; \ - char buf[FILENAME_MAX+32]; \ - char *lastSlash; \ \ if ( (pnpt) == NULL ) NPT_ERROR("NptEnv* is NULL"); \ - _handle = NULL; \ *(pnpt) = NULL; \ - buf[0] = 0; \ - jvm = GetModuleHandle("jvm.dll"); \ - if ( jvm == NULL ) NPT_ERROR("Cannot find jvm.dll"); \ - GetModuleFileName(jvm, buf, FILENAME_MAX); \ - lastSlash = strrchr(buf, '\\'); \ - if ( lastSlash != NULL ) { \ - *lastSlash = '\0'; \ - (void)strcat(buf, "\\..\\"); \ - (void)strcat(buf, NPT_LIBNAME); \ - _handle = LoadLibrary(buf); \ - } \ + _handle = LoadLibrary(path); \ if ( _handle == NULL ) NPT_ERROR("Cannot open library"); \ _sym = GetProcAddress(_handle, "nptInitialize"); \ if ( _sym == NULL ) NPT_ERROR("Cannot find nptInitialize"); \ From fdd109b467a44b2f69cedea8cbae5500422f5044 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Mon, 3 Dec 2012 17:14:03 +0800 Subject: [PATCH 72/94] 7198507: [TEST_BUG] sun/security/tools/keytool/console.sh should be rewritten Reviewed-by: xuelei --- .../sun/security/tools/keytool/console.sh | 143 +++++++++++------- 1 file changed, 91 insertions(+), 52 deletions(-) diff --git a/jdk/test/sun/security/tools/keytool/console.sh b/jdk/test/sun/security/tools/keytool/console.sh index 994befcde28..ec0f05961f8 100644 --- a/jdk/test/sun/security/tools/keytool/console.sh +++ b/jdk/test/sun/security/tools/keytool/console.sh @@ -31,62 +31,101 @@ # @run shell/manual console.sh if [ "$ALT_PASS" = "" ]; then - export PASS=äöäöäöäö + PASSW=äöäöäö else - export PASS=$ALT_PASS + PASSW=$ALT_PASS +fi + +KS=/tmp/kkk.$$ + +cat <<____ + +ATTENTION +=============================================================== + +This test is about non-ASCII password input compatibility between +JDK 5.0 and later versions. Before running the test, make sure that -- + + \$J5 points to a JDK 5.0 installation + \$JM points to the current installation + +The password string used in this test is $PASSW. If you find difficulty +entering it in in your system, feel free to change it to something else +by providing \$ALT_PASS. It should be no less than 6 characters and include +some non-ASCII characters. + +For each test, type into the characters as described in the test header. + means the RETURN (or ENTER key). Please wait for a little while +after is pressed each time. + +\$J5 is now $J5 +\$JM is now $JM + +____ + + +if [ "$J5" = "" -o "$JM" = "" ]; then + echo "Define \$J5 and \$JM first" + exit 1 fi -echo "ATTENTION" -echo "===============================================================" -echo -echo "This test is about console password input compatibility between" -echo "Tiger and Mustang. Before running the test, make sure that --" -echo "\$J5 points to a JDK 5.0 installation" -echo "\$JM points to a JDK 6 installation". -echo -echo "The password string used in this test is $PASS. If you find difficulty" -echo "entering it in in your system, feel free to change it to something else" -echo "by providing \$ALT_PASS (should be not less than 6 characters)" -echo -echo "For all prompt of \"Enter keystore password\", type $PASS and press ENTER" -echo "For all prompt of \"Enter key password for (RETURN if same as keystore password)\", press ENTER" -echo "If you see both the prompts appear, say --" -echo " Enter key password for " -echo " (RETURN if same as keystore password): Enter keystore password:" -echo "only response to the last prompt by typing $PASS and press ENTER" -echo -echo "Only if all the command run correctly without showing any error " -echo "or warning, this test passes." -echo echo "Press ENTER to start the test, or Ctrl-C to stop it" -read +read x + echo -echo "Test #1: 5->6, non-prompt" -rm kkk -$J5/bin/keytool -keystore kkk -genkey -dname CN=olala -storepass $PASS -$JM/bin/keytool -keystore kkk -list -storepass $PASS -echo "Test #2: 6->5, non-prompt" -rm kkk -$JM/bin/keytool -keystore kkk -genkey -dname CN=olala -storepass $PASS -$J5/bin/keytool -keystore kkk -list -storepass $PASS -echo "Test #3: 5->6, prompt" -rm kkk -$J5/bin/keytool -keystore kkk -genkey -dname CN=olala -$JM/bin/keytool -keystore kkk -list -echo $PASS| $J5/bin/keytool -keystore kkk -list -echo $PASS| $JM/bin/keytool -keystore kkk -list -echo "Test #4: 6->5, prompt" -rm kkk -$JM/bin/keytool -keystore kkk -genkey -dname CN=olala -$J5/bin/keytool -keystore kkk -list -echo $PASS| $JM/bin/keytool -keystore kkk -list -echo $PASS| $J5/bin/keytool -keystore kkk -list -echo "Test #5: 5->6, pipe" -rm kkk -echo $PASS| $J5/bin/keytool -keystore kkk -genkey -dname CN=olala -$JM/bin/keytool -keystore kkk -list -echo $PASS| $J5/bin/keytool -keystore kkk -list -echo $PASS| $JM/bin/keytool -keystore kkk -list -rm kkk +echo "==========================================" +echo "Test #1: 5->6, non-prompt. Please type " +echo "==========================================" +echo +rm $KS 2> /dev/null +$J5/bin/keytool -keystore $KS -genkey -dname CN=olala -storepass $PASSW || exit 1 +$JM/bin/keytool -keystore $KS -list -storepass $PASSW || exit 2 + +echo "==========================================" +echo "Test #2: 6->5, non-prompt. Please type " +echo "==========================================" +echo + +rm $KS 2> /dev/null +$JM/bin/keytool -keystore $KS -genkey -dname CN=olala -storepass $PASSW || exit 3 +$J5/bin/keytool -keystore $KS -list -storepass $PASSW || exit 4 + +echo "============================================================" +echo "Test #3: 5->6, prompt. Please type $PASSW $PASSW " +echo "============================================================" +echo + +rm $KS 2> /dev/null +$J5/bin/keytool -keystore $KS -genkey -dname CN=olala || exit 5 +$JM/bin/keytool -keystore $KS -list || exit 6 +echo $PASSW| $J5/bin/keytool -keystore $KS -list || exit 7 +echo $PASSW| $JM/bin/keytool -keystore $KS -list || exit 8 + +echo "=======================================================================" +echo "Test #4: 6->5, prompt. Please type $PASSW $PASSW $PASSW " +echo "=======================================================================" +echo + +rm $KS 2> /dev/null +$JM/bin/keytool -keystore $KS -genkey -dname CN=olala || exit 9 +$J5/bin/keytool -keystore $KS -list || exit 10 +echo $PASSW| $JM/bin/keytool -keystore $KS -list || exit 11 +echo $PASSW| $J5/bin/keytool -keystore $KS -list || exit 12 + +echo "===========================================" +echo "Test #5: 5->6, pipe. Please type $PASSW " +echo "===========================================" +echo + +rm $KS 2> /dev/null +echo $PASSW| $J5/bin/keytool -keystore $KS -genkey -dname CN=olala || exit 13 +$JM/bin/keytool -keystore $KS -list || exit 14 +echo $PASSW| $J5/bin/keytool -keystore $KS -list || exit 15 +echo $PASSW| $JM/bin/keytool -keystore $KS -list || exit 16 + +rm $KS 2> /dev/null + +echo +echo "Success" exit 0 From eb66ce8b2e09073d6bae323a2b81751215e1f224 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Mon, 3 Dec 2012 06:00:19 -0800 Subject: [PATCH 73/94] 8004184: security tests leave JSSEServer running Use othervm mode to release resources, and correct the system properties issues in JSSE Reviewed-by: chegar --- .../sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java b/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java index 5ccaa0ab72a..2788f03f8ad 100644 --- a/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java +++ b/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. 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 @@ -21,6 +21,11 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 6405536 @@ -28,6 +33,7 @@ * @author Andreas Sterbenz * @library .. * @library ../../../../java/security/testlibrary + * @run main/othervm ClientJSSEServerJSSE */ import java.security.*; From e4c0346aa9da705d4e34c9b8d11ff8c252df049c Mon Sep 17 00:00:00 2001 From: Jason Uh Date: Mon, 3 Dec 2012 11:07:20 -0500 Subject: [PATCH 74/94] 7199143: RFE: OCSP revocation checker should provide possibility to specify connection timeout Added com.sun.security.ocsp.timeout system property to control timeout Reviewed-by: mullan, vinnie --- .../sun/security/provider/certpath/OCSP.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/sun/security/provider/certpath/OCSP.java b/jdk/src/share/classes/sun/security/provider/certpath/OCSP.java index 365741f4932..f57c832bfa5 100644 --- a/jdk/src/share/classes/sun/security/provider/certpath/OCSP.java +++ b/jdk/src/share/classes/sun/security/provider/certpath/OCSP.java @@ -43,6 +43,7 @@ import java.util.List; import java.util.Map; import static sun.security.provider.certpath.OCSPResponse.*; +import sun.security.action.GetIntegerAction; import sun.security.util.Debug; import sun.security.util.ObjectIdentifier; import sun.security.x509.AccessDescription; @@ -69,7 +70,31 @@ public final class OCSP { private static final Debug debug = Debug.getInstance("certpath"); - private static final int CONNECT_TIMEOUT = 15000; // 15 seconds + private static final int DEFAULT_CONNECT_TIMEOUT = 15000; + + /** + * Integer value indicating the timeout length, in seconds, to be + * used for the OCSP check. A timeout of zero is interpreted as + * an infinite timeout. + */ + private static final int CONNECT_TIMEOUT = initializeTimeout(); + + /** + * Initialize the timeout length by getting the OCSP timeout + * system property. If the property has not been set, or if its + * value is negative, set the timeout length to the default. + */ + private static int initializeTimeout() { + int tmp = java.security.AccessController.doPrivileged( + new GetIntegerAction("com.sun.security.ocsp.timeout", + DEFAULT_CONNECT_TIMEOUT)); + if (tmp < 0) { + tmp = DEFAULT_CONNECT_TIMEOUT; + } + // Convert to milliseconds, as the system property will be + // specified in seconds + return tmp * 1000; + } private OCSP() {} From 00ad2900ddde9e7147b8cbfd7f3af77880f9397e Mon Sep 17 00:00:00 2001 From: Dan Xu Date: Tue, 4 Dec 2012 14:07:30 +0000 Subject: [PATCH 75/94] 7142921: (fs) Files.probeContentType reports a MIME type of "text/plain" on Ubuntu 11.04 7144997: (fs) Files.probeContentType returns null on Solaris 64-bit Reviewed-by: alanb, mduigou --- jdk/make/java/nio/Makefile | 6 + jdk/make/java/nio/mapfile-linux | 2 + jdk/makefiles/CompileJavaClasses.gmk | 1 + jdk/makefiles/CompileNativeLibraries.gmk | 1 + jdk/makefiles/mapfiles/libnio/mapfile-linux | 2 + .../sun/nio/fs/BsdFileSystemProvider.java | 2 - .../sun/nio/fs/LinuxFileSystemProvider.java | 11 +- .../sun/nio/fs/MacOSXFileSystemProvider.java | 15 +- .../sun/nio/fs/MagicFileTypeDetector.java | 79 +++++++ .../sun/nio/fs/MimeTypesFileTypeDetector.java | 208 ++++++++++++++++++ .../sun/nio/fs/SolarisFileSystemProvider.java | 10 +- .../sun/nio/fs/UnixFileSystemProvider.java | 20 ++ .../native/sun/nio/fs/MagicFileTypeDetector.c | 108 +++++++++ 13 files changed, 458 insertions(+), 7 deletions(-) create mode 100644 jdk/src/solaris/classes/sun/nio/fs/MagicFileTypeDetector.java create mode 100644 jdk/src/solaris/classes/sun/nio/fs/MimeTypesFileTypeDetector.java create mode 100644 jdk/src/solaris/native/sun/nio/fs/MagicFileTypeDetector.c diff --git a/jdk/make/java/nio/Makefile b/jdk/make/java/nio/Makefile index 94a50dc4bcb..9eebd5cc4ea 100644 --- a/jdk/make/java/nio/Makefile +++ b/jdk/make/java/nio/Makefile @@ -69,6 +69,7 @@ FILES_java += \ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \ \ sun/nio/fs/GnomeFileTypeDetector.java \ + sun/nio/fs/MimeTypesFileTypeDetector.java \ sun/nio/fs/PollingWatchService.java \ sun/nio/fs/SolarisAclFileAttributeView.java \ sun/nio/fs/SolarisFileStore.java \ @@ -202,6 +203,8 @@ FILES_java += \ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \ \ sun/nio/fs/GnomeFileTypeDetector.java \ + sun/nio/fs/MagicFileTypeDetector.java \ + sun/nio/fs/MimeTypesFileTypeDetector.java \ sun/nio/fs/LinuxDosFileAttributeView.java \ sun/nio/fs/LinuxFileStore.java \ sun/nio/fs/LinuxFileSystem.java \ @@ -239,6 +242,7 @@ FILES_c += \ UnixAsynchronousSocketChannelImpl.c \ \ GnomeFileTypeDetector.c \ + MagicFileTypeDetector.c \ LinuxNativeDispatcher.c \ LinuxWatchService.c \ UnixCopyFile.c \ @@ -254,6 +258,7 @@ FILES_export += \ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \ \ sun/nio/fs/GnomeFileTypeDetector.java \ + sun/nio/fs/MagicFileTypeDetector.java \ sun/nio/fs/LinuxNativeDispatcher.java \ sun/nio/fs/LinuxWatchService.java \ sun/nio/fs/UnixCopyFile.java \ @@ -277,6 +282,7 @@ FILES_java += \ sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \ \ + sun/nio/fs/MimeTypesFileTypeDetector.java \ sun/nio/fs/BsdFileStore.java \ sun/nio/fs/BsdFileSystem.java \ sun/nio/fs/BsdFileSystemProvider.java \ diff --git a/jdk/make/java/nio/mapfile-linux b/jdk/make/java/nio/mapfile-linux index d78a74400b3..92c7d318894 100644 --- a/jdk/make/java/nio/mapfile-linux +++ b/jdk/make/java/nio/mapfile-linux @@ -130,6 +130,8 @@ SUNWprivate_1.1 { Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio; Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs; Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs; + Java_sun_nio_fs_MagicFileTypeDetector_initialize0; + Java_sun_nio_fs_MagicFileTypeDetector_probe0; Java_sun_nio_fs_LinuxWatchService_eventSize; Java_sun_nio_fs_LinuxWatchService_eventOffsets; Java_sun_nio_fs_LinuxWatchService_inotifyInit; diff --git a/jdk/makefiles/CompileJavaClasses.gmk b/jdk/makefiles/CompileJavaClasses.gmk index 1c5913dd167..93ab2f25a35 100644 --- a/jdk/makefiles/CompileJavaClasses.gmk +++ b/jdk/makefiles/CompileJavaClasses.gmk @@ -121,6 +121,7 @@ ifneq ($(OPENJDK_TARGET_OS),linux) sun/nio/fs/LinuxFileStore.java \ sun/nio/fs/LinuxFileSystem.java \ sun/nio/fs/LinuxFileSystemProvider.java \ + sun/nio/fs/MagicFileTypeDetector.java \ sun/nio/fs/LinuxNativeDispatcher.java \ sun/nio/fs/LinuxUserDefinedFileAttributeView.java \ sun/nio/fs/LinuxWatchService.java diff --git a/jdk/makefiles/CompileNativeLibraries.gmk b/jdk/makefiles/CompileNativeLibraries.gmk index 23bf459ba2e..1461085b5d1 100644 --- a/jdk/makefiles/CompileNativeLibraries.gmk +++ b/jdk/makefiles/CompileNativeLibraries.gmk @@ -1897,6 +1897,7 @@ ifeq ($(OPENJDK_TARGET_OS), linux) UnixAsynchronousServerSocketChannelImpl.c \ UnixAsynchronousSocketChannelImpl.c \ GnomeFileTypeDetector.c \ + MagicFileTypeDetector.c \ LinuxNativeDispatcher.c \ LinuxWatchService.c \ UnixCopyFile.c \ diff --git a/jdk/makefiles/mapfiles/libnio/mapfile-linux b/jdk/makefiles/mapfiles/libnio/mapfile-linux index d78a74400b3..92c7d318894 100644 --- a/jdk/makefiles/mapfiles/libnio/mapfile-linux +++ b/jdk/makefiles/mapfiles/libnio/mapfile-linux @@ -130,6 +130,8 @@ SUNWprivate_1.1 { Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio; Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs; Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs; + Java_sun_nio_fs_MagicFileTypeDetector_initialize0; + Java_sun_nio_fs_MagicFileTypeDetector_probe0; Java_sun_nio_fs_LinuxWatchService_eventSize; Java_sun_nio_fs_LinuxWatchService_eventOffsets; Java_sun_nio_fs_LinuxWatchService_inotifyInit; diff --git a/jdk/src/solaris/classes/sun/nio/fs/BsdFileSystemProvider.java b/jdk/src/solaris/classes/sun/nio/fs/BsdFileSystemProvider.java index eaf49ddd2a7..3bb08d7d94c 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/BsdFileSystemProvider.java +++ b/jdk/src/solaris/classes/sun/nio/fs/BsdFileSystemProvider.java @@ -25,8 +25,6 @@ package sun.nio.fs; -import java.nio.file.*; -import java.nio.file.attribute.*; import java.io.IOException; /** diff --git a/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java b/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java index 557fc16e5d6..5cf76fb3d05 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java +++ b/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java @@ -29,6 +29,8 @@ import java.nio.file.*; import java.nio.file.attribute.*; import java.nio.file.spi.FileTypeDetector; import java.io.IOException; +import java.security.AccessController; +import sun.security.action.GetPropertyAction; /** * Linux implementation of FileSystemProvider @@ -100,6 +102,13 @@ public class LinuxFileSystemProvider extends UnixFileSystemProvider { @Override FileTypeDetector getFileTypeDetector() { - return new GnomeFileTypeDetector(); + Path userMimeTypes = Paths.get(AccessController.doPrivileged( + new GetPropertyAction("user.home")), ".mime.types"); + Path etcMimeTypes = Paths.get("/etc/mime.types"); + + return chain(new GnomeFileTypeDetector(), + new MimeTypesFileTypeDetector(userMimeTypes), + new MimeTypesFileTypeDetector(etcMimeTypes), + new MagicFileTypeDetector()); } } diff --git a/jdk/src/solaris/classes/sun/nio/fs/MacOSXFileSystemProvider.java b/jdk/src/solaris/classes/sun/nio/fs/MacOSXFileSystemProvider.java index 528603fa791..bf50e71b1c7 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/MacOSXFileSystemProvider.java +++ b/jdk/src/solaris/classes/sun/nio/fs/MacOSXFileSystemProvider.java @@ -25,9 +25,11 @@ package sun.nio.fs; -import java.nio.file.*; -import java.nio.file.attribute.*; -import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.spi.FileTypeDetector; +import java.security.AccessController; +import sun.security.action.GetPropertyAction; /** * MacOSX implementation of FileSystemProvider @@ -42,4 +44,11 @@ public class MacOSXFileSystemProvider extends BsdFileSystemProvider { MacOSXFileSystem newFileSystem(String dir) { return new MacOSXFileSystem(this, dir); } + + @Override + FileTypeDetector getFileTypeDetector() { + Path userMimeTypes = Paths.get(AccessController.doPrivileged( + new GetPropertyAction("user.home")), ".mime.types"); + return new MimeTypesFileTypeDetector(userMimeTypes); + } } diff --git a/jdk/src/solaris/classes/sun/nio/fs/MagicFileTypeDetector.java b/jdk/src/solaris/classes/sun/nio/fs/MagicFileTypeDetector.java new file mode 100644 index 00000000000..11bc3a529d7 --- /dev/null +++ b/jdk/src/solaris/classes/sun/nio/fs/MagicFileTypeDetector.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.nio.fs; + +import java.io.IOException; +import java.nio.file.Path; +import java.security.AccessController; +import java.security.PrivilegedAction; + +/** + * File type detector that uses the libmagic to guess the MIME type of a file. + */ + +class MagicFileTypeDetector extends AbstractFileTypeDetector { + + private static final String UNKNOW_MIME_TYPE = "application/octet-stream"; + + // true if libmagic is available and successfully loaded + private final boolean libmagicAvailable; + + public MagicFileTypeDetector() { + libmagicAvailable = initialize0(); + } + + @Override + protected String implProbeContentType(Path obj) throws IOException { + if (!libmagicAvailable || !(obj instanceof UnixPath)) + return null; + + UnixPath path = (UnixPath) obj; + path.checkRead(); + + NativeBuffer buffer = NativeBuffers.asNativeBuffer(path.getByteArrayForSysCalls()); + try { + byte[] type = probe0(buffer.address()); + String mimeType = (type == null) ? null : new String(type); + return UNKNOW_MIME_TYPE.equals(mimeType) ? null : mimeType; + } finally { + buffer.release(); + } + } + + private static native boolean initialize0(); + + private static native byte[] probe0(long pathAddress); + + static { + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + System.loadLibrary("nio"); + return null; + } + }); + } +} diff --git a/jdk/src/solaris/classes/sun/nio/fs/MimeTypesFileTypeDetector.java b/jdk/src/solaris/classes/sun/nio/fs/MimeTypesFileTypeDetector.java new file mode 100644 index 00000000000..8878703a343 --- /dev/null +++ b/jdk/src/solaris/classes/sun/nio/fs/MimeTypesFileTypeDetector.java @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.nio.fs; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * File type detector that uses a file extension to look up its MIME type + * based on a mime.types file. + */ + +class MimeTypesFileTypeDetector extends AbstractFileTypeDetector { + + // path to mime.types file + private final Path mimeTypesFile; + + // map of extension to MIME type + private Map mimeTypeMap; + + // set to true when file loaded + private volatile boolean loaded = false; + + public MimeTypesFileTypeDetector(Path filePath) { + mimeTypesFile = filePath; + } + + @Override + protected String implProbeContentType(Path path) { + Path fn = path.getFileName(); + if (fn == null) + return null; // no file name + + String ext = getExtension(fn.toString()); + if (ext.isEmpty()) + return null; // no extension + + loadMimeTypes(); + if (mimeTypeMap == null || mimeTypeMap.isEmpty()) + return null; + + // Case-sensitive search + String mimeType; + do { + mimeType = mimeTypeMap.get(ext); + if (mimeType == null) + ext = getExtension(ext); + } while (mimeType == null && !ext.isEmpty()); + + return mimeType; + } + + // Get the extension of a file name. + private static String getExtension(String name) { + String ext = ""; + if (name != null && !name.isEmpty()) { + int dot = name.indexOf('.'); + if ((dot >= 0) && (dot < name.length() - 1)) { + ext = name.substring(dot + 1); + } + } + return ext; + } + + /** + * Parse the mime types file, and store the type-extension mappings into + * mimeTypeMap. The mime types file is not loaded until the first probe + * to achieve the lazy initialization. It adopts double-checked locking + * optimization to reduce the locking overhead. + */ + private void loadMimeTypes() { + if (!loaded) { + synchronized (this) { + if (!loaded) { + List lines = AccessController.doPrivileged( + new PrivilegedAction>() { + @Override + public List run() { + try { + return Files.readAllLines(mimeTypesFile, + Charset.defaultCharset()); + } catch (IOException ignore) { + return Collections.emptyList(); + } + } + }); + + mimeTypeMap = new HashMap<>(lines.size()); + String entry = ""; + for (String line : lines) { + entry += line; + if (entry.endsWith("\\")) { + entry = entry.substring(0, entry.length() - 1); + continue; + } + parseMimeEntry(entry); + entry = ""; + } + if (!entry.isEmpty()) { + parseMimeEntry(entry); + } + loaded = true; + } + } + } + } + + /** + * Parse a mime-types entry, which can have the following formats. + * 1) Simple space-delimited format + * image/jpeg jpeg jpg jpe JPG + * + * 2) Netscape key-value pair format + * type=application/x-java-jnlp-file desc="Java Web Start" exts="jnlp" + * or + * type=text/html exts=htm,html + */ + private void parseMimeEntry(String entry) { + entry = entry.trim(); + if (entry.isEmpty() || entry.charAt(0) == '#') + return; + + entry = entry.replaceAll("\\s*#.*", ""); + int equalIdx = entry.indexOf('='); + if (equalIdx > 0) { + // Parse a mime-types command having the key-value pair format + final String TYPEEQUAL = "type="; + String typeRegex = "\\b" + TYPEEQUAL + + "(\"\\p{Graph}+?/\\p{Graph}+?\"|\\p{Graph}+/\\p{Graph}+\\b)"; + Pattern typePattern = Pattern.compile(typeRegex); + Matcher typeMatcher = typePattern.matcher(entry); + + if (typeMatcher.find()) { + String type = typeMatcher.group().substring(TYPEEQUAL.length()); + if (type.charAt(0) == '"') { + type = type.substring(1, type.length() - 1); + } + + final String EXTEQUAL = "exts="; + String extRegex = "\\b" + EXTEQUAL + + "(\"[\\p{Graph}|\\p{Blank}]+?\"|\\p{Graph}+\\b)"; + Pattern extPattern = Pattern.compile(extRegex); + Matcher extMatcher = extPattern.matcher(entry); + + if (extMatcher.find()) { + String exts = + extMatcher.group().substring(EXTEQUAL.length()); + if (exts.charAt(0) == '"') { + exts = exts.substring(1, exts.length() - 1); + } + String[] extList = exts.split("[\\p{Blank}|\\p{Punct}]+"); + for (String ext : extList) { + putIfAbsent(ext, type); + } + } + } + } else { + // Parse a mime-types command having the space-delimited format + String[] elements = entry.split("\\s+"); + int i = 1; + while (i < elements.length) { + putIfAbsent(elements[i++], elements[0]); + } + } + } + + private void putIfAbsent(String key, String value) { + if (key != null && !key.isEmpty() && + value != null && !value.isEmpty() && + !mimeTypeMap.containsKey(key)) + { + mimeTypeMap.put(key, value); + } + } +} diff --git a/jdk/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java b/jdk/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java index cb34adf3b9a..d81bac1b656 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java +++ b/jdk/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java @@ -29,6 +29,8 @@ import java.nio.file.*; import java.nio.file.attribute.*; import java.nio.file.spi.FileTypeDetector; import java.io.IOException; +import java.security.AccessController; +import sun.security.action.GetPropertyAction; /** * Solaris implementation of FileSystemProvider @@ -83,6 +85,12 @@ public class SolarisFileSystemProvider extends UnixFileSystemProvider { @Override FileTypeDetector getFileTypeDetector() { - return new GnomeFileTypeDetector(); + Path userMimeTypes = Paths.get(AccessController.doPrivileged( + new GetPropertyAction("user.home")), ".mime.types"); + Path etcMimeTypes = Paths.get("/etc/mime.types"); + + return chain(new GnomeFileTypeDetector(), + new MimeTypesFileTypeDetector(userMimeTypes), + new MimeTypesFileTypeDetector(etcMimeTypes)); } } diff --git a/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java b/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java index 5058f3147cb..fc0f943a97a 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java +++ b/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java @@ -509,4 +509,24 @@ public abstract class UnixFileSystemProvider }; } + /** + * Returns a {@code FileTypeDetector} that chains the given array of file + * type detectors. When the {@code implProbeContentType} method is invoked + * then each of the detectors is invoked in turn, the result from the + * first to detect the file type is returned. + */ + final FileTypeDetector chain(final AbstractFileTypeDetector... detectors) { + return new AbstractFileTypeDetector() { + @Override + protected String implProbeContentType(Path file) throws IOException { + for (AbstractFileTypeDetector detector : detectors) { + String result = detector.implProbeContentType(file); + if (result != null && !result.isEmpty()) { + return result; + } + } + return null; + } + }; + } } diff --git a/jdk/src/solaris/native/sun/nio/fs/MagicFileTypeDetector.c b/jdk/src/solaris/native/sun/nio/fs/MagicFileTypeDetector.c new file mode 100644 index 00000000000..b70c6f76487 --- /dev/null +++ b/jdk/src/solaris/native/sun/nio/fs/MagicFileTypeDetector.c @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include "jni.h" +#include "jni_util.h" +#include "jvm.h" +#include "jlong.h" + +#include +#include + +#define MAGIC_MIME_TYPE 0x000010 /* Return the MIME type */ + +typedef struct magic_set magic_t; + +typedef magic_t* (*magic_open_func)(int flags); +typedef int (*magic_load_func)(magic_t* cookie, const char* filename); +typedef const char* (*magic_file_func)(magic_t* cookie, const char* filename); +typedef void (*magic_close_func)(magic_t* cookie); + +static void* magic_handle; +static magic_open_func magic_open; +static magic_load_func magic_load; +static magic_file_func magic_file; +static magic_close_func magic_close; + +#include "sun_nio_fs_MagicFileTypeDetector.h" + +JNIEXPORT jboolean JNICALL +Java_sun_nio_fs_MagicFileTypeDetector_initialize0 + (JNIEnv* env, jclass this) +{ + magic_handle = dlopen("libmagic.so", RTLD_LAZY); + if (magic_handle == NULL) { + magic_handle = dlopen("libmagic.so.1", RTLD_LAZY); + if (magic_handle == NULL) { + return JNI_FALSE; + } + } + + magic_open = (magic_open_func)dlsym(magic_handle, "magic_open"); + + magic_load = (magic_load_func)dlsym(magic_handle, "magic_load"); + + magic_file = (magic_file_func)dlsym(magic_handle, "magic_file"); + + magic_close = (magic_close_func)dlsym(magic_handle, "magic_close"); + + if (magic_open == NULL || + magic_load == NULL || + magic_file == NULL || + magic_close == NULL) + { + dlclose(magic_handle); + return JNI_FALSE; + } + + return JNI_TRUE; +} + +JNIEXPORT jbyteArray JNICALL +Java_sun_nio_fs_MagicFileTypeDetector_probe0 + (JNIEnv* env, jclass this, jlong pathAddress) +{ + char* path = (char*)jlong_to_ptr(pathAddress); + magic_t* cookie; + jbyteArray result = NULL; + + cookie = (*magic_open)(MAGIC_MIME_TYPE); + + if (cookie != NULL) { + if ((*magic_load)(cookie, NULL) != -1) { + const char* type = (*magic_file)(cookie, path); + if (type != NULL) { + jsize len = strlen(type); + result = (*env)->NewByteArray(env, len); + if (result != NULL) { + (*env)->SetByteArrayRegion(env, result, 0, len, (jbyte*)type); + } + } + } + (*magic_close)(cookie); + } + + return result; +} From e6ab16c28399018f91087b708a90324c517d3aca Mon Sep 17 00:00:00 2001 From: Krystal Mo Date: Tue, 4 Dec 2012 15:10:03 +0000 Subject: [PATCH 76/94] 8004066: TEST_BUG: test/java/lang/Math/DivModTests.java assumes ArithmeticException message Reviewed-by: twisti, alanb, dholmes --- jdk/test/java/lang/Math/DivModTests.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/jdk/test/java/lang/Math/DivModTests.java b/jdk/test/java/lang/Math/DivModTests.java index 43e88bdcebb..2cea8cb8c12 100644 --- a/jdk/test/java/lang/Math/DivModTests.java +++ b/jdk/test/java/lang/Math/DivModTests.java @@ -65,7 +65,7 @@ public class DivModTests { * Math and StrictMath tested and the same results are expected for both. */ static void testIntFloorDivMod() { - testIntFloorDivMod(4, 0, new ArithmeticException("/ by zero"), new ArithmeticException("/ by zero")); // Should throw ArithmeticException + testIntFloorDivMod(4, 0, new ArithmeticException(), new ArithmeticException()); // Should throw ArithmeticException testIntFloorDivMod(4, 3, 1, 1); testIntFloorDivMod(3, 3, 1, 0); testIntFloorDivMod(2, 3, 0, 2); @@ -151,7 +151,7 @@ public class DivModTests { * Test the floorDiv and floorMod methods for primitive long. */ static void testLongFloorDivMod() { - testLongFloorDivMod(4L, 0L, new ArithmeticException("/ by zero"), new ArithmeticException("/ by zero")); // Should throw ArithmeticException + testLongFloorDivMod(4L, 0L, new ArithmeticException(), new ArithmeticException()); // Should throw ArithmeticException testLongFloorDivMod(4L, 3L, 1L, 1L); testLongFloorDivMod(3L, 3L, 1L, 0L); testLongFloorDivMod(2L, 3L, 0L, 2L); @@ -385,9 +385,7 @@ public class DivModTests { } // Handle special case to compare ArithmeticExceptions if (result instanceof ArithmeticException && expected instanceof ArithmeticException) { - ArithmeticException ae1 = (ArithmeticException)result; - ArithmeticException ae2 = (ArithmeticException)expected; - return ae1.getMessage().equals(ae2.getMessage()); + return true; } return false; } From f436d23492139ecf715e3396ace118b342569572 Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Tue, 4 Dec 2012 20:21:19 +0000 Subject: [PATCH 77/94] 8003596: TEST_BUG: java/util/logging/CheckLockLocationTest.java failing [win] Reviewed-by: alanb --- jdk/test/ProblemList.txt | 3 -- .../util/logging/CheckLockLocationTest.java | 49 +++++++++++++------ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 2552ba0f017..b41e357bdb3 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -363,9 +363,6 @@ java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java generic-all # Filed 6772009 java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all -# 8003596 -java/util/logging/CheckLockLocationTest.java windows-all - # 7041639, Solaris DSA keypair generation bug java/util/TimeZone/TimeZoneDatePermissionCheck.sh solaris-all diff --git a/jdk/test/java/util/logging/CheckLockLocationTest.java b/jdk/test/java/util/logging/CheckLockLocationTest.java index 0eb98c0d4a0..ebf31a30c12 100644 --- a/jdk/test/java/util/logging/CheckLockLocationTest.java +++ b/jdk/test/java/util/logging/CheckLockLocationTest.java @@ -42,17 +42,22 @@ public class CheckLockLocationTest { private static final String NOT_A_DIR = "not-a-dir"; private static final String WRITABLE_DIR = "writable-dir"; private static final String NON_EXISTENT_DIR = "non-existent-dir"; + private static boolean runNonWritableDirTest; public static void main(String... args) throws IOException { // we'll base all file creation attempts on the system temp directory, // %t and also try specifying non-existent directories and plain files // that should be directories, and non-writable directories, // to exercise all code paths of checking the lock location + // Note that on platforms like Windows that don't support + // setWritable() on a directory, we'll skip the non-writable + // directory test if setWritable(false) returns false. + // File writableDir = setup(); // we now have three files/directories to work with: // writableDir // notAdir - // nonWritableDir + // nonWritableDir (may not be possible on some platforms) // nonExistentDir (which doesn't exist) runTests(writableDir); } @@ -79,15 +84,19 @@ public class CheckLockLocationTest { } // Test 2: creating FileHandler in non-writable directory should fail - try { - new FileHandler("%t/" + NON_WRITABLE_DIR + "/log.log"); - throw new RuntimeException("Test failed: should not have been able" - + " to create FileHandler for " + "%t/" + NON_WRITABLE_DIR - + "/log.log in non-writable directory."); - } catch (IOException ex) { - // check for the right exception - if (!(ex instanceof AccessDeniedException)) { - throw new RuntimeException("Test failed: Expected exception was not an AccessDeniedException", ex); + if (runNonWritableDirTest) { + try { + new FileHandler("%t/" + NON_WRITABLE_DIR + "/log.log"); + throw new RuntimeException("Test failed: should not have been able" + + " to create FileHandler for " + "%t/" + NON_WRITABLE_DIR + + "/log.log in non-writable directory."); + } catch (IOException ex) { + // check for the right exception + if (!(ex instanceof AccessDeniedException)) { + throw new RuntimeException( + "Test failed: Expected exception was not an " + + "AccessDeniedException", ex); + } } } @@ -99,8 +108,11 @@ public class CheckLockLocationTest { + "/log.log in non-directory."); } catch (IOException ex) { // check for the right exception - if (!(ex instanceof FileSystemException && ex.getMessage().contains("Not a directory"))) { - throw new RuntimeException("Test failed: Expected exception was not a FileSystemException", ex); + if (!(ex instanceof FileSystemException + && ex.getMessage().contains("Not a directory"))) { + throw new RuntimeException( + "Test failed: Expected exception was not a " + + "FileSystemException", ex); } } @@ -113,7 +125,8 @@ public class CheckLockLocationTest { } catch (IOException ex) { // check for the right exception if (!(ex instanceof NoSuchFileException)) { - throw new RuntimeException("Test failed: Expected exception was not a NoSuchFileException", ex); + throw new RuntimeException("Test failed: Expected exception " + + "was not a NoSuchFileException", ex); } } } @@ -162,10 +175,14 @@ public class CheckLockLocationTest { nonWritableDir.deleteOnExit(); // make it non-writable - if (!nonWritableDir.setWritable(false)) { - throw new RuntimeException("Test setup failed: unable to make" + if (nonWritableDir.setWritable(false)) { + runNonWritableDirTest = true; + } else { + runNonWritableDirTest = false; + System.out.println( "Test Setup WARNING: unable to make" + " working directory " + nonWritableDir.getAbsolutePath() - + " non-writable."); + + " non-writable on platform " + System.getProperty("os.name")); + } // make sure non-existent directory really doesn't exist From a3f91508bde28453debd141029b8f8fe880fdf90 Mon Sep 17 00:00:00 2001 From: Jason Uh Date: Tue, 4 Dec 2012 17:40:41 -0500 Subject: [PATCH 78/94] 8004188: Rename src/share/lib/security/java.security to java.security-linux Reviewed-by: mullan, mchung --- jdk/make/java/security/Makefile | 3 ++- .../share/lib/security/{java.security => java.security-linux} | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename jdk/src/share/lib/security/{java.security => java.security-linux} (100%) diff --git a/jdk/make/java/security/Makefile b/jdk/make/java/security/Makefile index d68d0a03510..bbb0ca4f757 100644 --- a/jdk/make/java/security/Makefile +++ b/jdk/make/java/security/Makefile @@ -40,7 +40,8 @@ AUTO_FILES_JAVA_DIRS = java/security # Directories # -PROPS_SRC = $(TOPDIR)/src/share/lib/security/java.security +# The default security properties file is for linux +PROPS_SRC = $(TOPDIR)/src/share/lib/security/java.security-linux ifeq ($(PLATFORM), solaris) PROPS_SRC = $(TOPDIR)/src/share/lib/security/java.security-solaris diff --git a/jdk/src/share/lib/security/java.security b/jdk/src/share/lib/security/java.security-linux similarity index 100% rename from jdk/src/share/lib/security/java.security rename to jdk/src/share/lib/security/java.security-linux From f5797a2ffe18a59e5098b7469d1dcb07eca5009f Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 5 Dec 2012 12:20:00 +0000 Subject: [PATCH 79/94] 8004491: Build breakage on Linux due to 8004188 Reviewed-by: chegar, erikj --- jdk/makefiles/CopyFiles.gmk | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/jdk/makefiles/CopyFiles.gmk b/jdk/makefiles/CopyFiles.gmk index e0c8d620f2d..be24ab22819 100644 --- a/jdk/makefiles/CopyFiles.gmk +++ b/jdk/makefiles/CopyFiles.gmk @@ -356,21 +356,9 @@ COPY_FILES += $(JVMCFG) ########################################################################################## -PROPS_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.security +PROPS_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.security-$(OPENJDK_TARGET_OS) PROPS_DST := $(JDK_OUTPUTDIR)/lib/security/java.security -ifeq ($(OPENJDK_TARGET_OS), solaris) - PROPS_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.security-solaris -endif - -ifeq ($(OPENJDK_TARGET_OS), windows) - PROPS_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.security-windows -endif - -ifeq ($(OPENJDK_TARGET_OS), macosx) - PROPS_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.security-macosx -endif - $(PROPS_DST): $(PROPS_SRC) $(MKDIR) -p $(@D) $(RM) $@ From aab1dbdc30e7a141443a2b26c51afad85c5fc969 Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Wed, 5 Dec 2012 21:08:14 -0800 Subject: [PATCH 80/94] 8004317: TestLibrary.getUnusedRandomPort() fails intermittently, but exception not reported Reviewed-by: alanb, dmocek, smarks --- .../java/rmi/testlibrary/TestLibrary.java | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/jdk/test/java/rmi/testlibrary/TestLibrary.java b/jdk/test/java/rmi/testlibrary/TestLibrary.java index 734d8050918..07ed308355c 100644 --- a/jdk/test/java/rmi/testlibrary/TestLibrary.java +++ b/jdk/test/java/rmi/testlibrary/TestLibrary.java @@ -54,6 +54,7 @@ import java.rmi.server.RemoteRef; import java.rmi.server.UnicastRemoteObject; import java.util.Enumeration; import java.util.Properties; + import sun.rmi.registry.RegistryImpl; import sun.rmi.server.UnicastServerRef; import sun.rmi.transport.Endpoint; @@ -92,6 +93,7 @@ public class TestLibrary { public final static int INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT = 64003; public final static int INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT = 64004; public final static int READTEST_REGISTRY_PORT = 64005; + private final static int MAX_SERVER_SOCKET_TRIES = 10; static void mesg(Object mesg) { System.err.println("TEST_LIBRARY: " + mesg.toString()); @@ -125,36 +127,15 @@ public class TestLibrary { bomb(null, e); } - /** - * Property accessors - */ - private static boolean getBoolean(String name) { - return (new Boolean(getProperty(name, "false")).booleanValue()); - } - private static Integer getInteger(String name) { - int val = 0; - Integer value = null; - - String propVal = getProperty(name, null); - if (propVal == null) { - return null; - } - - try { - value = new Integer(Integer.parseInt(propVal)); - } catch (NumberFormatException nfe) { - } - return value; - } public static String getProperty(String property, String defaultVal) { final String prop = property; final String def = defaultVal; - return ((String) java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction() { - public Object run() { + return java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public String run() { return System.getProperty(prop, def); } - })); + }); } /** @@ -169,9 +150,9 @@ public class TestLibrary { public static void setProperty(String property, String value) { final String prop = property; final String val = value; - java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction() { - public Object run() { + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Void run() { System.setProperty(prop, val); return null; } @@ -188,7 +169,7 @@ public class TestLibrary { out.println("-------------------Test environment----------" + "---------"); - for(Enumeration keys = System.getProperties().keys(); + for(Enumeration keys = System.getProperties().keys(); keys.hasMoreElements();) { String property = (String) keys.nextElement(); @@ -252,7 +233,7 @@ public class TestLibrary { /* * Obtain the URL for the codebase. */ - URL codebaseURL = dstDir.toURL(); + URL codebaseURL = dstDir.toURI().toURL(); /* * Specify where we will copy the class definition from, if @@ -407,26 +388,46 @@ public class TestLibrary { */ public static int getUnusedRandomPort() { int numTries = 0; - int unusedRandomPort = FIXED_PORT_MIN; - Exception ex = null; + IOException ex = null; - while (numTries++ < 10) { + while (numTries++ < MAX_SERVER_SOCKET_TRIES) { + int unusedRandomPort = -1; ex = null; //reset try (ServerSocket ss = new ServerSocket(0)) { unusedRandomPort = ss.getLocalPort(); - } catch (Exception e) { + } catch (IOException e) { ex = e; + // temporarily print stack trace here until we find out why + // tests are failing. + System.err.println("TestLibrary.getUnusedRandomPort() caught " + + "exception on iteration " + numTries + + (numTries==MAX_SERVER_SOCKET_TRIES ? " (the final try)." + : ".")); + ex.printStackTrace(); } - if (!isReservedPort(unusedRandomPort)) { - return unusedRandomPort; + if (unusedRandomPort >= 0) { + if (isReservedPort(unusedRandomPort)) { + System.out.println("INFO: On try # " + numTries + + (numTries==MAX_SERVER_SOCKET_TRIES ? ", the final try, ": ",") + + " ServerSocket(0) returned the reserved port " + + unusedRandomPort + + " in TestLibrary.getUnusedRandomPort() "); + } else { + return unusedRandomPort; + } } } // If we're here, then either an exception was thrown or the port is // a reserved port. - throw new RuntimeException("Error getting unused random port.", ex); + if (ex==null) { + throw new RuntimeException("Error getting unused random port. The" + +" last port returned by ServerSocket(0) was a reserved port"); + } else { + throw new RuntimeException("Error getting unused random port.", ex); + } } /** From fbc76e673a6386e4739f50103ffc3b4f5d7d128f Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Thu, 6 Dec 2012 15:51:44 -0500 Subject: [PATCH 81/94] 8004374: CachedRowSetSwriter.writeData reports wrong number of conflicts in SyncProviderException Reviewed-by: naoto --- .../rowset/internal/CachedRowSetWriter.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java b/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java index 8824f8c0f0a..db14e424b29 100644 --- a/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java +++ b/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java @@ -264,7 +264,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { * false otherwise */ public boolean writeData(RowSetInternal caller) throws SQLException { - boolean conflict = false; + long conflicts = 0; boolean showDel = false; PreparedStatement pstmtIns = null; iChangedValsInDbAndCRS = 0; @@ -337,8 +337,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { while (crs.next()) { if (crs.rowDeleted()) { // The row has been deleted. - if (conflict = (deleteOriginalRow(crs, this.crsResolve)) == true) { + if (deleteOriginalRow(crs, this.crsResolve)) { status.add(rows, SyncResolver.DELETE_ROW_CONFLICT); + conflicts++; } else { // delete happened without any occurrence of conflicts // so update status accordingly @@ -349,8 +350,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { // The row has been inserted. pstmtIns = con.prepareStatement(insertCmd); - if ( (conflict = insertNewRow(crs, pstmtIns, this.crsResolve)) == true) { + if (insertNewRow(crs, pstmtIns, this.crsResolve)) { status.add(rows, SyncResolver.INSERT_ROW_CONFLICT); + conflicts++; } else { // insert happened without any occurrence of conflicts // so update status accordingly @@ -358,8 +360,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { } } else if (crs.rowUpdated()) { // The row has been updated. - if ( conflict = (updateOriginalRow(crs)) == true) { + if (updateOriginalRow(crs)) { status.add(rows, SyncResolver.UPDATE_ROW_CONFLICT); + conflicts++; } else { // update happened without any occurrence of conflicts // so update status accordingly @@ -395,21 +398,12 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { // reset crs.setShowDeleted(showDel); - boolean boolConf = false; - for (int j=1;j Date: Thu, 6 Dec 2012 21:55:55 -0800 Subject: [PATCH 82/94] 8003881: Prevent lambda implementing inner classes from allowing the creation of new instances Lambda implementing inner classes now has private constructor (thanks Kumar) Reviewed-by: ksrini --- .../invoke/InnerClassLambdaMetafactory.java | 53 +++- .../LambdaAccessControlDoPrivilegedTest.java | 226 ++++++++++++++++++ .../lambda/LambdaAccessControlTest.java | 49 ++++ 3 files changed, 317 insertions(+), 11 deletions(-) create mode 100644 jdk/test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java create mode 100644 jdk/test/java/lang/invoke/lambda/LambdaAccessControlTest.java diff --git a/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java index 9e786e8f5b9..13999001cdc 100644 --- a/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java +++ b/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java @@ -25,15 +25,15 @@ package java.lang.invoke; -import java.io.FileOutputStream; -import java.io.IOException; +import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.security.ProtectionDomain; import java.util.concurrent.atomic.AtomicInteger; -import sun.util.logging.PlatformLogger; import jdk.internal.org.objectweb.asm.*; import static jdk.internal.org.objectweb.asm.Opcodes.*; import sun.misc.Unsafe; +import java.security.AccessController; +import java.security.PrivilegedAction; /** * InnerClassLambdaMetafactory @@ -120,13 +120,34 @@ import sun.misc.Unsafe; * * @return a CallSite, which, when invoked, will return an instance of the * functional interface - * @throws ReflectiveOperationException + * @throws ReflectiveOperationException, LambdaConversionException */ @Override CallSite buildCallSite() throws ReflectiveOperationException, LambdaConversionException { final Class innerClass = spinInnerClass(); if (invokedType.parameterCount() == 0) { - return new ConstantCallSite(MethodHandles.constant(samBase, innerClass.newInstance())); + final Constructor[] ctrs = AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public Constructor[] run() { + return innerClass.getDeclaredConstructors(); + } + }); + if (ctrs.length != 1) { + throw new ReflectiveOperationException("Expected one lambda constructor for " + + innerClass.getCanonicalName() + ", got " + ctrs.length); + } + // The lambda implementing inner class constructor is private, set + // it accessible (by us) before creating the constant sole instance + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + ctrs[0].setAccessible(true); + return null; + } + }); + Object inst = ctrs[0].newInstance(); + return new ConstantCallSite(MethodHandles.constant(samBase, inst)); } else { return new ConstantCallSite( MethodHandles.Lookup.IMPL_LOOKUP @@ -144,7 +165,7 @@ import sun.misc.Unsafe; private Class spinInnerClass() throws LambdaConversionException { String samName = samBase.getName().replace('.', '/'); - cw.visit(CLASSFILE_VERSION, ACC_PUBLIC + ACC_SUPER, lambdaClassName, null, NAME_MAGIC_ACCESSOR_IMPL, + cw.visit(CLASSFILE_VERSION, ACC_SUPER, lambdaClassName, null, NAME_MAGIC_ACCESSOR_IMPL, isSerializable ? new String[]{samName, NAME_SERIALIZABLE} : new String[]{samName}); // Generate final fields to be filled in by constructor @@ -186,17 +207,27 @@ import sun.misc.Unsafe; final byte[] classBytes = cw.toByteArray(); - if (System.getProperty("debug.dump.generated") != null) { + /*** Uncomment to dump the generated file System.out.printf("Loaded: %s (%d bytes) %n", lambdaClassName, classBytes.length); try (FileOutputStream fos = new FileOutputStream(lambdaClassName.replace('/', '.') + ".class")) { fos.write(classBytes); } catch (IOException ex) { - PlatformLogger.getLogger(InnerClassLambdaMetafactory.class.getName()).severe(ex.getMessage(), ex); + Logger.getLogger(InnerClassLambdaMetafactory.class.getName()).log(Level.SEVERE, null, ex); } - } + ***/ ClassLoader loader = targetClass.getClassLoader(); - ProtectionDomain pd = (loader == null) ? null : targetClass.getProtectionDomain(); + ProtectionDomain pd = (loader == null) + ? null + : AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public ProtectionDomain run() { + return targetClass.getProtectionDomain(); + } + } + ); + return (Class) Unsafe.getUnsafe().defineClass(lambdaClassName, classBytes, 0, classBytes.length, loader, pd); } @@ -205,7 +236,7 @@ import sun.misc.Unsafe; */ private void generateConstructor() { // Generate constructor - MethodVisitor ctor = cw.visitMethod(ACC_PUBLIC, NAME_CTOR, constructorDesc, null, null); + MethodVisitor ctor = cw.visitMethod(ACC_PRIVATE, NAME_CTOR, constructorDesc, null, null); ctor.visitCode(); ctor.visitVarInsn(ALOAD, 0); ctor.visitMethodInsn(INVOKESPECIAL, NAME_MAGIC_ACCESSOR_IMPL, NAME_CTOR, METHOD_DESCRIPTOR_VOID); diff --git a/jdk/test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java b/jdk/test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java new file mode 100644 index 00000000000..8c3d1c5ed5b --- /dev/null +++ b/jdk/test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003881 + * @summary tests DoPrivileged action (implemented as lambda expressions) by + * inserting them into the BootClassPath. + * @compile -XDignore.symbol.file LambdaAccessControlDoPrivilegedTest.java + * @run main/othervm LambdaAccessControlDoPrivilegedTest + */ +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class LambdaAccessControlDoPrivilegedTest extends LUtils { + public static void main(String... args) { + final List scratch = new ArrayList(); + scratch.clear(); + scratch.add("import java.security.*;"); + scratch.add("public class DoPriv {"); + scratch.add("public static void main(String... args) {"); + scratch.add("String prop = AccessController.doPrivileged((PrivilegedAction) () -> {"); + scratch.add("return System.getProperty(\"user.home\");"); + scratch.add("});"); + scratch.add("}"); + scratch.add("}"); + File doprivJava = new File("DoPriv.java"); + File doprivClass = getClassFile(doprivJava); + createFile(doprivJava, scratch); + + scratch.clear(); + scratch.add("public class Bar {"); + scratch.add("public static void main(String... args) {"); + scratch.add("System.out.println(\"sun.boot.class.path\" + \"=\" +"); + scratch.add(" System.getProperty(\"sun.boot.class.path\", \"\"));"); + scratch.add("System.setSecurityManager(new SecurityManager());"); + scratch.add("DoPriv.main();"); + scratch.add("}"); + scratch.add("}"); + + File barJava = new File("Bar.java"); + File barClass = getClassFile(barJava); + createFile(barJava, scratch); + + String[] javacArgs = {barJava.getName(), doprivJava.getName()}; + compile(javacArgs); + File jarFile = new File("foo.jar"); + String[] jargs = {"cvf", jarFile.getName(), doprivClass.getName()}; + jarTool.run(jargs); + doprivJava.delete(); + doprivClass.delete(); + TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), + "-Xbootclasspath/p:foo.jar", + "-cp", ".", "Bar"); + tr.assertZero("testDoPrivileged fails"); + barJava.delete(); + barClass.delete(); + jarFile.delete(); + } +} + +/* + * support infrastructure to invoke a java class from the command line + */ +class LUtils { + static final sun.tools.jar.Main jarTool = + new sun.tools.jar.Main(System.out, System.err, "jar-tool"); + static final com.sun.tools.javac.Main javac = + new com.sun.tools.javac.Main(); + static final File cwd = new File(".").getAbsoluteFile(); + static final String JAVAHOME = System.getProperty("java.home"); + static final boolean isWindows = + System.getProperty("os.name", "unknown").startsWith("Windows"); + //static final boolean isSDK = JAVAHOME.endsWith("jre"); + static final File JAVA_BIN_FILE = new File(JAVAHOME, "bin"); + static final File JAVA_CMD = new File(JAVA_BIN_FILE, + isWindows ? "java.exe" : "java"); + + protected LUtils() { + } + + public static void compile(String... args) { + if (javac.compile(args) != 0) { + throw new RuntimeException("compilation fails"); + } + } + + static void createFile(File outFile, List content) { + try { + Files.write(outFile.getAbsoluteFile().toPath(), content, + Charset.defaultCharset()); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + + static File getClassFile(File javaFile) { + return javaFile.getName().endsWith(".java") + ? new File(javaFile.getName().replace(".java", ".class")) + : null; + } + + static String getSimpleName(File inFile) { + String fname = inFile.getName(); + return fname.substring(0, fname.indexOf(".")); + } + + static TestResult doExec(String... cmds) { + return doExec(null, null, cmds); + } + + /* + * A method which executes a java cmd and returns the results in a container + */ + static TestResult doExec(Map envToSet, + java.util.Set envToRemove, String... cmds) { + String cmdStr = ""; + for (String x : cmds) { + cmdStr = cmdStr.concat(x + " "); + } + ProcessBuilder pb = new ProcessBuilder(cmds); + Map env = pb.environment(); + if (envToRemove != null) { + for (String key : envToRemove) { + env.remove(key); + } + } + if (envToSet != null) { + env.putAll(envToSet); + } + BufferedReader rdr = null; + try { + List outputList = new ArrayList<>(); + pb.redirectErrorStream(true); + Process p = pb.start(); + rdr = new BufferedReader(new InputStreamReader(p.getInputStream())); + String in = rdr.readLine(); + while (in != null) { + outputList.add(in); + in = rdr.readLine(); + } + p.waitFor(); + p.destroy(); + + return new TestResult(cmdStr, p.exitValue(), outputList, + env, new Throwable("current stack of the test")); + } catch (Exception ex) { + ex.printStackTrace(); + throw new RuntimeException(ex.getMessage()); + } + } + + static class TestResult { + String cmd; + int exitValue; + List testOutput; + Map env; + Throwable t; + + public TestResult(String str, int rv, List oList, + Map env, Throwable t) { + cmd = str; + exitValue = rv; + testOutput = oList; + this.env = env; + this.t = t; + } + + void assertZero(String message) { + if (exitValue != 0) { + System.err.println(this); + throw new RuntimeException(message); + } + } + + @Override + public String toString() { + StringWriter sw = new StringWriter(); + PrintWriter status = new PrintWriter(sw); + status.println("Cmd: " + cmd); + status.println("Return code: " + exitValue); + status.println("Environment variable:"); + for (String x : env.keySet()) { + status.println("\t" + x + "=" + env.get(x)); + } + status.println("Output:"); + for (String x : testOutput) { + status.println("\t" + x); + } + status.println("Exception:"); + status.println(t.getMessage()); + t.printStackTrace(status); + + return sw.getBuffer().toString(); + } + } +} diff --git a/jdk/test/java/lang/invoke/lambda/LambdaAccessControlTest.java b/jdk/test/java/lang/invoke/lambda/LambdaAccessControlTest.java new file mode 100644 index 00000000000..361a4cffcce --- /dev/null +++ b/jdk/test/java/lang/invoke/lambda/LambdaAccessControlTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003881 + * @summary tests Lambda expression with a a security manager at top level + * @compile -XDignore.symbol.file LambdaAccessControlTest.java + * + * @run main/othervm LambdaAccessControlTest + */ + +public class LambdaAccessControlTest extends LUtils { + public static void main(String... args) { + System.setSecurityManager(new SecurityManager()); + JJ iii = (new CC())::impl; + System.out.printf(">>> %s\n", iii.foo(44)); + iii = DD::impl; + System.out.printf(">>> %s\n", iii.foo(44)); + return; + } +} +/* + * support classes for the test + */ +interface II { Object foo(T x); } +interface JJ extends II { } +class CC { String impl(int i) { return "impl:"+i; }} +class DD { static String impl(int i) { return "impl:"+i; }} From 4698a5c96de864d2af3b381ce9929373a6ea855c Mon Sep 17 00:00:00 2001 From: David Dehaven Date: Sun, 9 Dec 2012 07:43:12 -0800 Subject: [PATCH 83/94] 8004042: Arrrghs.java test failed on windows with access error Reviewed-by: smarks, jjh, ksrini --- jdk/test/tools/launcher/Arrrghs.java | 5 ++- jdk/test/tools/launcher/TestHelper.java | 45 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/jdk/test/tools/launcher/Arrrghs.java b/jdk/test/tools/launcher/Arrrghs.java index 364589f5ad0..9bf9f21b465 100644 --- a/jdk/test/tools/launcher/Arrrghs.java +++ b/jdk/test/tools/launcher/Arrrghs.java @@ -27,7 +27,7 @@ * 6894719 6968053 7151434 7146424 * @summary Argument parsing validation. * @compile -XDignore.symbol.file Arrrghs.java - * @run main Arrrghs + * @run main/othervm Arrrghs */ import java.io.BufferedReader; @@ -204,8 +204,7 @@ public class Arrrghs extends TestHelper { // exiting the process prematurely can terminate the stderr. scratchpad.add(javaCmd + " -version " + inArgs); File batFile = new File("atest.bat"); - java.nio.file.Files.deleteIfExists(batFile.toPath()); - createFile(batFile, scratchpad); + createAFile(batFile, scratchpad); TestResult tr = doExec(batFile.getName()); diff --git a/jdk/test/tools/launcher/TestHelper.java b/jdk/test/tools/launcher/TestHelper.java index e630dd5df54..0115f057142 100644 --- a/jdk/test/tools/launcher/TestHelper.java +++ b/jdk/test/tools/launcher/TestHelper.java @@ -358,6 +358,51 @@ public class TestHelper { Files.copy(src.toPath(), dst.toPath(), COPY_ATTRIBUTES, REPLACE_EXISTING); } + /** + * Attempt to create a file at the given location. If an IOException + * occurs then back off for a moment and try again. When a number of + * attempts fail, give up and throw an exception. + */ + void createAFile(File aFile, List contents) throws IOException { + IOException cause = null; + for (int attempts = 0; attempts < 10; attempts++) { + try { + Files.write(aFile.getAbsoluteFile().toPath(), contents, + Charset.defaultCharset(), CREATE, TRUNCATE_EXISTING, WRITE); + if (cause != null) { + /* + * report attempts and errors that were encountered + * for diagnostic purposes + */ + System.err.println("Created batch file " + + aFile + " in " + (attempts + 1) + + " attempts"); + System.err.println("Errors encountered: " + cause); + cause.printStackTrace(); + } + return; + } catch (IOException ioe) { + if (cause != null) { + // chain the exceptions so they all get reported for diagnostics + cause.addSuppressed(ioe); + } else { + cause = ioe; + } + } + + try { + Thread.sleep(500); + } catch (InterruptedException ie) { + if (cause != null) { + // cause should alway be non-null here + ie.addSuppressed(cause); + } + throw new RuntimeException("Interrupted while creating batch file", ie); + } + } + throw new RuntimeException("Unable to create batch file", cause); + } + static void createFile(File outFile, List content) throws IOException { Files.write(outFile.getAbsoluteFile().toPath(), content, Charset.defaultCharset(), CREATE_NEW); From 8be8c66772e9df60ba3cddf39d3d39241577e8f0 Mon Sep 17 00:00:00 2001 From: Dan Xu Date: Sun, 9 Dec 2012 19:13:08 +0000 Subject: [PATCH 84/94] 7194370: (fs) WatchService fails if volume S/N is 0 [win] Reviewed-by: alanb, forax --- .../windows/classes/sun/nio/fs/WindowsFileAttributes.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java b/jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java index dffa4f06e8d..208435dc97e 100644 --- a/jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java +++ b/jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. 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 @@ -383,20 +383,14 @@ class WindowsFileAttributes } int volSerialNumber() { - if (volSerialNumber == 0) - throw new AssertionError("Should not get here"); return volSerialNumber; } int fileIndexHigh() { - if (volSerialNumber == 0) - throw new AssertionError("Should not get here"); return fileIndexHigh; } int fileIndexLow() { - if (volSerialNumber == 0) - throw new AssertionError("Should not get here"); return fileIndexLow; } From 78a8ed73a26526e996d32e9468a15a74c86cbd6d Mon Sep 17 00:00:00 2001 From: Masayoshi Okutsu Date: Mon, 10 Dec 2012 10:52:11 +0900 Subject: [PATCH 85/94] 8000983: Support narrow display names for calendar fields 8003267: Support generic time zone names in TimeZoneNameProvider (SPI) Reviewed-by: naoto --- .../src/build/tools/cldrconverter/Bundle.java | 221 ++++++- .../tools/cldrconverter/BundleGenerator.java | 21 +- .../tools/cldrconverter/CLDRConverter.java | 62 +- .../tools/cldrconverter/LDMLParseHandler.java | 64 +- .../cldrconverter/MetaZonesParseHandler.java | 3 +- .../ResourceBundleGenerator.java | 51 +- .../classes/java/text/DateFormatSymbols.java | 11 +- .../classes/java/text/SimpleDateFormat.java | 47 +- jdk/src/share/classes/java/util/Calendar.java | 98 ++- .../java/util/JapaneseImperialCalendar.java | 48 +- jdk/src/share/classes/java/util/TimeZone.java | 49 +- .../java/util/spi/CalendarNameProvider.java | 21 +- .../java/util/spi/TimeZoneNameProvider.java | 32 +- .../sun/text/resources/FormatData.java | 61 +- .../sun/text/resources/ar/FormatData_ar.java | 11 + .../sun/text/resources/be/FormatData_be.java | 28 + .../sun/text/resources/bg/FormatData_bg.java | 11 + .../sun/text/resources/ca/FormatData_ca.java | 39 ++ .../sun/text/resources/cs/FormatData_cs.java | 11 + .../sun/text/resources/da/FormatData_da.java | 11 + .../sun/text/resources/de/FormatData_de.java | 11 + .../sun/text/resources/el/FormatData_el.java | 11 + .../sun/text/resources/es/FormatData_es.java | 11 + .../sun/text/resources/et/FormatData_et.java | 11 + .../sun/text/resources/fi/FormatData_fi.java | 45 ++ .../sun/text/resources/fr/FormatData_fr.java | 11 + .../text/resources/hi/FormatData_hi_IN.java | 11 + .../sun/text/resources/hr/FormatData_hr.java | 39 ++ .../sun/text/resources/hu/FormatData_hu.java | 11 + .../sun/text/resources/is/FormatData_is.java | 39 ++ .../sun/text/resources/it/FormatData_it.java | 11 + .../sun/text/resources/iw/FormatData_iw.java | 22 + .../sun/text/resources/ja/FormatData_ja.java | 11 + .../sun/text/resources/ko/FormatData_ko.java | 11 + .../sun/text/resources/lt/FormatData_lt.java | 39 ++ .../sun/text/resources/lv/FormatData_lv.java | 11 + .../sun/text/resources/mk/FormatData_mk.java | 11 + .../sun/text/resources/ms/FormatData_ms.java | 39 ++ .../sun/text/resources/mt/FormatData_mt.java | 11 + .../sun/text/resources/nl/FormatData_nl.java | 11 + .../sun/text/resources/pl/FormatData_pl.java | 11 + .../sun/text/resources/pt/FormatData_pt.java | 11 + .../sun/text/resources/ro/FormatData_ro.java | 40 ++ .../sun/text/resources/ru/FormatData_ru.java | 22 + .../sun/text/resources/sk/FormatData_sk.java | 11 + .../sun/text/resources/sl/FormatData_sl.java | 11 + .../sun/text/resources/sq/FormatData_sq.java | 11 + .../sun/text/resources/sr/FormatData_sr.java | 23 + .../sun/text/resources/sv/FormatData_sv.java | 51 ++ .../sun/text/resources/th/FormatData_th.java | 34 + .../sun/text/resources/tr/FormatData_tr.java | 28 + .../sun/text/resources/uk/FormatData_uk.java | 11 + .../sun/text/resources/vi/FormatData_vi.java | 11 + .../sun/text/resources/zh/FormatData_zh.java | 28 + .../util/cldr/CLDRLocaleProviderAdapter.java | 5 - .../locale/provider/CalendarDataUtility.java | 1 - .../provider/CalendarNameProviderImpl.java | 122 ++-- .../util/locale/provider/LocaleResources.java | 12 +- .../provider/SPILocaleProviderAdapter.java | 7 + .../provider/TimeZoneNameProviderImpl.java | 73 ++- .../locale/provider/TimeZoneNameUtility.java | 190 ++++-- .../sun/util/resources/LocaleData.java | 53 +- .../resources/OpenListResourceBundle.java | 20 +- .../sun/util/resources/TimeZoneNames.java | 480 +++++++++----- .../util/resources/TimeZoneNamesBundle.java | 45 +- .../Calendar/GenericTimeZoneNamesTest.java | 57 ++ .../util/Calendar/GenericTimeZoneNamesTest.sh | 47 ++ .../java/util/Calendar/NarrowNamesTest.java | 172 ++++++ .../java/util/Calendar/NarrowNamesTest.sh | 41 ++ .../util/PluggableLocale/GenericTest.java | 2 + .../TimeZoneNameProviderTest.java | 25 + .../TimeZoneNameProviderTest.sh | 4 +- .../java/util/PluggableLocale/barprovider.jar | Bin 14680 -> 15507 bytes .../GenericTimeZoneNameProviderImpl.java | 58 ++ .../util/PluggableLocale/providersrc/Makefile | 1 + .../java.util.spi.TimeZoneNameProvider | 1 + jdk/test/sun/text/resources/LocaleData | 583 ++++++++++++++++++ .../sun/text/resources/LocaleDataTest.java | 2 +- 78 files changed, 3097 insertions(+), 484 deletions(-) create mode 100644 jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.java create mode 100644 jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh create mode 100644 jdk/test/java/util/Calendar/NarrowNamesTest.java create mode 100644 jdk/test/java/util/Calendar/NarrowNamesTest.sh create mode 100644 jdk/test/java/util/PluggableLocale/providersrc/GenericTimeZoneNameProviderImpl.java diff --git a/jdk/make/tools/src/build/tools/cldrconverter/Bundle.java b/jdk/make/tools/src/build/tools/cldrconverter/Bundle.java index dc277ea684e..701ea4b057d 100644 --- a/jdk/make/tools/src/build/tools/cldrconverter/Bundle.java +++ b/jdk/make/tools/src/build/tools/cldrconverter/Bundle.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -86,7 +87,23 @@ class Bundle { private final static String[] ERA_KEYS = { "long.Eras", "Eras", - "short.Eras" + "narrow.Eras" + }; + + // Keys for individual time zone names + private final static String TZ_GEN_LONG_KEY = "timezone.displayname.generic.long"; + private final static String TZ_GEN_SHORT_KEY = "timezone.displayname.generic.short"; + private final static String TZ_STD_LONG_KEY = "timezone.displayname.standard.long"; + private final static String TZ_STD_SHORT_KEY = "timezone.displayname.standard.short"; + private final static String TZ_DST_LONG_KEY = "timezone.displayname.daylight.long"; + private final static String TZ_DST_SHORT_KEY = "timezone.displayname.daylight.short"; + private final static String[] ZONE_NAME_KEYS = { + TZ_STD_LONG_KEY, + TZ_STD_SHORT_KEY, + TZ_DST_LONG_KEY, + TZ_DST_SHORT_KEY, + TZ_GEN_LONG_KEY, + TZ_GEN_SHORT_KEY }; private final String id; @@ -98,6 +115,7 @@ class Bundle { return bundles.get(id); } + @SuppressWarnings("ConvertToStringSwitch") Bundle(String id, String cldrPath, String bundles, String currencies) { this.id = id; this.cldrPath = cldrPath; @@ -242,9 +260,12 @@ class Bundle { // handle multiple inheritance for month and day names handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "MonthNames"); handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "MonthAbbreviations"); + handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "MonthNarrows"); handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "DayNames"); handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "DayAbbreviations"); + handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "DayNarrows"); handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "AmPmMarkers"); + handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "narrow.AmPmMarkers"); adjustEraNames(myMap, calendarType); @@ -253,6 +274,99 @@ class Bundle { handleDateTimeFormatPatterns(DATETIME_PATTERN_KEYS, myMap, parentsMap, calendarType, "DateTimePatterns"); } + // if myMap has any empty timezone or metazone names, weed out them. + // Fill in any missing abbreviations if locale is "en". + for (Iterator it = myMap.keySet().iterator(); it.hasNext();) { + String key = it.next(); + if (key.startsWith(CLDRConverter.TIMEZONE_ID_PREFIX) + || key.startsWith(CLDRConverter.METAZONE_ID_PREFIX)) { + @SuppressWarnings("unchecked") + Map nameMap = (Map) myMap.get(key); + if (nameMap.isEmpty()) { + // Some zones have only exemplarCity, which become empty. + // Remove those from the map. + it.remove(); + continue; + } + + if (id.startsWith("en")) { + fillInAbbrs(key, nameMap); + } + } + } + for (Iterator it = myMap.keySet().iterator(); it.hasNext();) { + String key = it.next(); + if (key.startsWith(CLDRConverter.TIMEZONE_ID_PREFIX) + || key.startsWith(CLDRConverter.METAZONE_ID_PREFIX)) { + @SuppressWarnings("unchecked") + Map nameMap = (Map) myMap.get(key); + // Convert key/value pairs to an array. + String[] names = new String[ZONE_NAME_KEYS.length]; + int ix = 0; + for (String nameKey : ZONE_NAME_KEYS) { + String name = nameMap.get(nameKey); + if (name == null) { + @SuppressWarnings("unchecked") + Map parentNames = (Map) parentsMap.get(key); + if (parentNames != null) { + name = parentNames.get(nameKey); + } + } + names[ix++] = name; + } + if (hasNulls(names)) { + String metaKey = toMetaZoneKey(key); + if (metaKey != null) { + Object obj = myMap.get(metaKey); + if (obj instanceof String[]) { + String[] metaNames = (String[]) obj; + for (int i = 0; i < names.length; i++) { + if (names[i] == null) { + names[i] = metaNames[i]; + } + } + } else if (obj instanceof Map) { + @SuppressWarnings("unchecked") + Map m = (Map) obj; + for (int i = 0; i < names.length; i++) { + if (names[i] == null) { + names[i] = m.get(ZONE_NAME_KEYS[i]); + } + } + } + } + // If there are still any nulls, try filling in them from en data. + if (hasNulls(names) && !id.equals("en")) { + @SuppressWarnings("unchecked") + String[] enNames = (String[]) Bundle.getBundle("en").getTargetMap().get(key); + if (enNames == null) { + if (metaKey != null) { + @SuppressWarnings("unchecked") + String[] metaNames = (String[]) Bundle.getBundle("en").getTargetMap().get(metaKey); + enNames = metaNames; + } + } + if (enNames != null) { + for (int i = 0; i < names.length; i++) { + if (names[i] == null) { + names[i] = enNames[i]; + } + } + } + // If there are still nulls, give up names. + if (hasNulls(names)) { + names = null; + } + } + } + // replace the Map with the array + if (names != null) { + myMap.put(key, names); + } else { + it.remove(); + } + } + } return myMap; } @@ -352,20 +466,10 @@ class Bundle { realKeys[index] = realKey; eraNames[index++] = value; } - if (eraNames[0] != null) { - if (eraNames[1] != null) { - if (eraNames[2] == null) { - // Eras -> short.Eras - // long.Eras -> Eras - map.put(realKeys[2], map.get(realKeys[1])); - map.put(realKeys[1], map.get(realKeys[0])); - } - } else { - // long.Eras -> Eras - map.put(realKeys[1], map.get(realKeys[0])); + for (int i = 0; i < eraNames.length; i++) { + if (eraNames[i] == null) { + map.put(realKeys[i], null); } - // remove long.Eras - map.remove(realKeys[0]); } } @@ -473,6 +577,86 @@ class Bundle { return jrePattern.toString(); } + private String toMetaZoneKey(String tzKey) { + if (tzKey.startsWith(CLDRConverter.TIMEZONE_ID_PREFIX)) { + String tz = tzKey.substring(CLDRConverter.TIMEZONE_ID_PREFIX.length()); + String meta = CLDRConverter.handlerMetaZones.get(tz); + if (meta != null) { + return CLDRConverter.METAZONE_ID_PREFIX + meta; + } + } + return null; + } + + private void fillInAbbrs(String key, Map map) { + fillInAbbrs(TZ_STD_LONG_KEY, TZ_STD_SHORT_KEY, map); + fillInAbbrs(TZ_DST_LONG_KEY, TZ_DST_SHORT_KEY, map); + fillInAbbrs(TZ_GEN_LONG_KEY, TZ_GEN_SHORT_KEY, map); + + // If the standard std is "Standard Time" and daylight std is "Summer Time", + // replace the standard std with the generic std to avoid using + // the same abbrivation except for Australia time zone names. + String std = map.get(TZ_STD_SHORT_KEY); + String dst = map.get(TZ_DST_SHORT_KEY); + String gen = map.get(TZ_GEN_SHORT_KEY); + if (std != null) { + if (dst == null) { + // if dst is null, create long and short names from the standard + // std. ("Something Standard Time" to "Something Daylight Time", + // or "Something Time" to "Something Summer Time") + String name = map.get(TZ_STD_LONG_KEY); + if (name != null) { + if (name.contains("Standard Time")) { + name = name.replace("Standard Time", "Daylight Time"); + } else if (name.endsWith("Mean Time")) { + name = name.replace("Mean Time", "Summer Time"); + } else if (name.endsWith(" Time")) { + name = name.replace(" Time", " Summer Time"); + } + map.put(TZ_DST_LONG_KEY, name); + fillInAbbrs(TZ_DST_LONG_KEY, TZ_DST_SHORT_KEY, map); + } + } + if (gen == null) { + String name = map.get(TZ_STD_LONG_KEY); + if (name != null) { + if (name.endsWith("Standard Time")) { + name = name.replace("Standard Time", "Time"); + } else if (name.endsWith("Mean Time")) { + name = name.replace("Mean Time", "Time"); + } + map.put(TZ_GEN_LONG_KEY, name); + fillInAbbrs(TZ_GEN_LONG_KEY, TZ_GEN_SHORT_KEY, map); + } + } + } + } + + private void fillInAbbrs(String longKey, String shortKey, Map map) { + String abbr = map.get(shortKey); + if (abbr == null) { + String name = map.get(longKey); + if (name != null) { + abbr = toAbbr(name); + if (abbr != null) { + map.put(shortKey, abbr); + } + } + } + } + + private String toAbbr(String name) { + String[] substrs = name.split("\\s+"); + StringBuilder sb = new StringBuilder(); + for (String s : substrs) { + char c = s.charAt(0); + if (c >= 'A' && c <= 'Z') { + sb.append(c); + } + } + return sb.length() > 0 ? sb.toString() : null; + } + private void convert(CalendarType calendarType, char cldrLetter, int count, StringBuilder sb) { switch (cldrLetter) { case 'G': @@ -539,4 +723,13 @@ class Bundle { sb.append(c); } } + + private static boolean hasNulls(Object[] array) { + for (int i = 0; i < array.length; i++) { + if (array[i] == null) { + return true; + } + } + return false; + } } diff --git a/jdk/make/tools/src/build/tools/cldrconverter/BundleGenerator.java b/jdk/make/tools/src/build/tools/cldrconverter/BundleGenerator.java index f06a903a26e..14760bcbb4d 100644 --- a/jdk/make/tools/src/build/tools/cldrconverter/BundleGenerator.java +++ b/jdk/make/tools/src/build/tools/cldrconverter/BundleGenerator.java @@ -30,8 +30,27 @@ import java.util.Map; import java.util.SortedSet; public interface BundleGenerator { + static enum BundleType { + PLAIN("java.util.ListResourceBundle"), + OPEN("sun.util.resources.OpenListResourceBundle"), + TIMEZONE("sun.util.resources.TimeZoneNamesBundle"); + + private final String pathName, className; + private BundleType(String name) { + pathName = name; + int x = name.lastIndexOf('.'); + className = name.substring(x + 1); + } + String getPathName() { + return pathName; + } + String getClassName() { + return className; + } + }; + public void generateBundle(String packageName, String baseName, String localeID, - boolean useJava, Map map, boolean open) throws IOException; + boolean useJava, Map map, BundleType type) throws IOException; public void generateMetaInfo(Map> metaInfo) throws IOException; } diff --git a/jdk/make/tools/src/build/tools/cldrconverter/CLDRConverter.java b/jdk/make/tools/src/build/tools/cldrconverter/CLDRConverter.java index 106e3475a8e..1d5cd5e2d8f 100644 --- a/jdk/make/tools/src/build/tools/cldrconverter/CLDRConverter.java +++ b/jdk/make/tools/src/build/tools/cldrconverter/CLDRConverter.java @@ -25,6 +25,7 @@ package build.tools.cldrconverter; +import build.tools.cldrconverter.BundleGenerator.BundleType; import java.io.File; import java.nio.file.DirectoryStream; import java.nio.file.FileSystems; @@ -58,9 +59,8 @@ public class CLDRConverter { static final String CURRENCY_SYMBOL_PREFIX = "currency.symbol."; static final String CURRENCY_NAME_PREFIX = "currency.displayname."; static final String TIMEZONE_ID_PREFIX = "timezone.id."; - static final String TIMEZONE_NAME_PREFIX = "timezone.displayname."; + static final String ZONE_NAME_PREFIX = "timezone.displayname."; static final String METAZONE_ID_PREFIX = "metazone.id."; - static final String METAZONE_NAME_PREFIX = "metazone.displayname."; private static SupplementDataParseHandler handlerSuppl; static NumberingSystemsParseHandler handlerNumbering; @@ -236,7 +236,14 @@ public class CLDRConverter { if (sb.indexOf("root") == -1) { sb.append("root"); } - retList.add(new Bundle(id, sb.toString(), null, null)); + Bundle b = new Bundle(id, sb.toString(), null, null); + // Insert the bundle for en at the top so that it will get + // processed first. + if ("en".equals(id)) { + retList.add(0, b); + } else { + retList.add(b); + } } } } @@ -312,6 +319,7 @@ public class CLDRConverter { Map> metaInfo = new HashMap<>(); metaInfo.put("LocaleNames", new TreeSet()); metaInfo.put("CurrencyNames", new TreeSet()); + metaInfo.put("TimeZoneNames", new TreeSet()); metaInfo.put("CalendarData", new TreeSet()); metaInfo.put("FormatData", new TreeSet()); @@ -348,24 +356,28 @@ public class CLDRConverter { Map localeNamesMap = extractLocaleNames(targetMap, bundle.getID()); if (!localeNamesMap.isEmpty() || bundle.isRoot()) { metaInfo.get("LocaleNames").add(toLanguageTag(bundle.getID())); - bundleGenerator.generateBundle("util", "LocaleNames", bundle.getID(), true, localeNamesMap, true); + bundleGenerator.generateBundle("util", "LocaleNames", bundle.getID(), true, localeNamesMap, BundleType.OPEN); } } if (bundleTypes.contains(Bundle.Type.CURRENCYNAMES)) { Map currencyNamesMap = extractCurrencyNames(targetMap, bundle.getID(), bundle.getCurrencies()); if (!currencyNamesMap.isEmpty() || bundle.isRoot()) { metaInfo.get("CurrencyNames").add(toLanguageTag(bundle.getID())); - bundleGenerator.generateBundle("util", "CurrencyNames", bundle.getID(), true, currencyNamesMap, true); + bundleGenerator.generateBundle("util", "CurrencyNames", bundle.getID(), true, currencyNamesMap, BundleType.OPEN); } } if (bundleTypes.contains(Bundle.Type.TIMEZONENAMES)) { Map zoneNamesMap = extractZoneNames(targetMap, bundle.getID()); + if (!zoneNamesMap.isEmpty() || bundle.isRoot()) { + metaInfo.get("TimeZoneNames").add(toLanguageTag(bundle.getID())); + bundleGenerator.generateBundle("util", "TimeZoneNames", bundle.getID(), true, zoneNamesMap, BundleType.TIMEZONE); + } } if (bundleTypes.contains(Bundle.Type.CALENDARDATA)) { Map calendarDataMap = extractCalendarData(targetMap, bundle.getID()); if (!calendarDataMap.isEmpty() || bundle.isRoot()) { metaInfo.get("CalendarData").add(toLanguageTag(bundle.getID())); - bundleGenerator.generateBundle("util", "CalendarData", bundle.getID(), true, calendarDataMap, false); + bundleGenerator.generateBundle("util", "CalendarData", bundle.getID(), true, calendarDataMap, BundleType.PLAIN); } } if (bundleTypes.contains(Bundle.Type.FORMATDATA)) { @@ -373,9 +385,10 @@ public class CLDRConverter { // LocaleData.getAvailableLocales depends on having FormatData bundles around if (!formatDataMap.isEmpty() || bundle.isRoot()) { metaInfo.get("FormatData").add(toLanguageTag(bundle.getID())); - bundleGenerator.generateBundle("text", "FormatData", bundle.getID(), true, formatDataMap, false); + bundleGenerator.generateBundle("text", "FormatData", bundle.getID(), true, formatDataMap, BundleType.PLAIN); } } + // For testing SortedSet allLocales = new TreeSet<>(); allLocales.addAll(metaInfo.get("CurrencyNames")); @@ -431,6 +444,7 @@ public class CLDRConverter { private KeyComparator() { } + @Override public int compare(String o1, String o2) { int len1 = o1.length(); int len2 = o2.length(); @@ -476,7 +490,26 @@ public class CLDRConverter { } private static Map extractZoneNames(Map map, String id) { - return null; + Map names = new HashMap<>(); + for (String tzid : handlerMetaZones.keySet()) { + String tzKey = TIMEZONE_ID_PREFIX + tzid; + Object data = map.get(tzKey); + if (data instanceof String[]) { + names.put(tzid, data); + } else { + String meta = handlerMetaZones.get(tzid); + if (meta != null) { + String metaKey = METAZONE_ID_PREFIX + meta; + data = map.get(metaKey); + if (data instanceof String[]) { + // Keep the metazone prefix here. + names.put(metaKey, data); + names.put(tzid, meta); + } + } + } + } + return names; } private static Map extractCalendarData(Map map, String id) { @@ -494,11 +527,19 @@ public class CLDRConverter { copyIfPresent(map, prefix + "standalone.MonthNames", formatData); copyIfPresent(map, prefix + "MonthAbbreviations", formatData); copyIfPresent(map, prefix + "standalone.MonthAbbreviations", formatData); + copyIfPresent(map, prefix + "MonthNarrow", formatData); + copyIfPresent(map, prefix + "standalone.MonthNarrows", formatData); copyIfPresent(map, prefix + "DayNames", formatData); + copyIfPresent(map, prefix + "standalone.DayNames", formatData); copyIfPresent(map, prefix + "DayAbbreviations", formatData); + copyIfPresent(map, prefix + "standalone.DayAbbreviations", formatData); + copyIfPresent(map, prefix + "DayNarrows", formatData); + copyIfPresent(map, prefix + "standalone.DayNarrows", formatData); copyIfPresent(map, prefix + "AmPmMarkers", formatData); + copyIfPresent(map, prefix + "narrow.AmPmMarkers", formatData); + copyIfPresent(map, prefix + "long.Eras", formatData); copyIfPresent(map, prefix + "Eras", formatData); - copyIfPresent(map, prefix + "short.Eras", formatData); + copyIfPresent(map, prefix + "narrow.Eras", formatData); copyIfPresent(map, prefix + "TimePatterns", formatData); copyIfPresent(map, prefix + "DatePatterns", formatData); copyIfPresent(map, prefix + "DateTimePatterns", formatData); @@ -560,7 +601,6 @@ public class CLDRConverter { if (x == 0 || escapeSpace) { outBuffer.append('\\'); } - outBuffer.append(' '); break; case '\\': @@ -584,7 +624,7 @@ public class CLDRConverter { outBuffer.append('f'); break; default: - if (!USE_UTF8 && ((aChar < 0x0020) || (aChar > 0x007e))) { + if (aChar < 0x0020 || (!USE_UTF8 && aChar > 0x007e)) { formatter.format("\\u%04x", (int)aChar); } else { if (specialSaveChars.indexOf(aChar) != -1) { diff --git a/jdk/make/tools/src/build/tools/cldrconverter/LDMLParseHandler.java b/jdk/make/tools/src/build/tools/cldrconverter/LDMLParseHandler.java index 128eaf6ef57..812aab244fa 100644 --- a/jdk/make/tools/src/build/tools/cldrconverter/LDMLParseHandler.java +++ b/jdk/make/tools/src/build/tools/cldrconverter/LDMLParseHandler.java @@ -155,6 +155,9 @@ class LDMLParseHandler extends AbstractLDMLHandler { case "abbreviated": pushStringArrayEntry(qName, attributes, prefix + "MonthAbbreviations/" + getContainerKey(), 13); break; + case "narrow": + pushStringArrayEntry(qName, attributes, prefix + "MonthNarrows/" + getContainerKey(), 13); + break; default: pushIgnoredContainer(qName); break; @@ -191,6 +194,9 @@ class LDMLParseHandler extends AbstractLDMLHandler { case "abbreviated": pushStringArrayEntry(qName, attributes, prefix + "DayAbbreviations/" + getContainerKey(), 7); break; + case "narrow": + pushStringArrayEntry(qName, attributes, prefix + "DayNarrows/" + getContainerKey(), 7); + break; default: pushIgnoredContainer(qName); break; @@ -219,25 +225,36 @@ class LDMLParseHandler extends AbstractLDMLHandler { case "dayPeriodWidth": // for FormatData // create string array entry for am/pm. only keeping wide - if ("wide".equals(attributes.getValue("type"))) { + switch (attributes.getValue("type")) { + case "wide": pushStringArrayEntry(qName, attributes, "AmPmMarkers/" + getContainerKey(), 2); - } else { + break; + case "narrow": + pushStringArrayEntry(qName, attributes, "narrow.AmPmMarkers/" + getContainerKey(), 2); + break; + default: pushIgnoredContainer(qName); + break; } break; case "dayPeriod": // for FormatData // add to string array entry of AmPmMarkers element - switch (attributes.getValue("type")) { - case "am": - pushStringArrayElement(qName, attributes, 0); - break; - case "pm": - pushStringArrayElement(qName, attributes, 1); - break; - default: + if (attributes.getValue("alt") == null) { + switch (attributes.getValue("type")) { + case "am": + pushStringArrayElement(qName, attributes, 0); + break; + case "pm": + pushStringArrayElement(qName, attributes, 1); + break; + default: + pushIgnoredContainer(qName); + break; + } + } else { + // discard alt values pushIgnoredContainer(qName); - break; } break; case "eraNames": @@ -269,7 +286,7 @@ class LDMLParseHandler extends AbstractLDMLHandler { assert currentContainer instanceof IgnoredContainer; pushIgnoredContainer(qName); } else { - String key = currentCalendarType.keyElementName() + "short.Eras"; + String key = currentCalendarType.keyElementName() + "narrow.Eras"; pushStringArrayEntry(qName, attributes, key, currentCalendarType.getEraLength(qName)); } break; @@ -301,15 +318,15 @@ class LDMLParseHandler extends AbstractLDMLHandler { break; case "zone": { - String zone = attributes.getValue("type"); + String tzid = attributes.getValue("type"); // Olson tz id zonePrefix = CLDRConverter.TIMEZONE_ID_PREFIX; - put(zonePrefix + zone, new HashMap()); - pushKeyContainer(qName, attributes, zone); + put(zonePrefix + tzid, new HashMap()); + pushKeyContainer(qName, attributes, tzid); } break; case "metazone": { - String zone = attributes.getValue("type"); + String zone = attributes.getValue("type"); // LDML meta zone id zonePrefix = CLDRConverter.METAZONE_ID_PREFIX; put(zonePrefix + zone, new HashMap()); pushKeyContainer(qName, attributes, zone); @@ -323,16 +340,12 @@ class LDMLParseHandler extends AbstractLDMLHandler { zoneNameStyle = "short"; pushContainer(qName, attributes); break; - case "generic": // not used in JDK - pushIgnoredContainer(qName); + case "generic": // generic name + case "standard": // standard time name + case "daylight": // daylight saving (summer) time name + pushStringEntry(qName, attributes, CLDRConverter.ZONE_NAME_PREFIX + qName + "." + zoneNameStyle); break; - case "standard": // standard time - pushStringEntry(qName, attributes, CLDRConverter.TIMEZONE_NAME_PREFIX + "standard." + zoneNameStyle); - break; - case "daylight": - pushStringEntry(qName, attributes, CLDRConverter.TIMEZONE_NAME_PREFIX + "daylight." + zoneNameStyle); - break; - case "exemplarCity": + case "exemplarCity": // not used in JDK pushIgnoredContainer(qName); break; @@ -530,6 +543,7 @@ class LDMLParseHandler extends AbstractLDMLHandler { case "timeZoneNames": zonePrefix = null; break; + case "generic": case "standard": case "daylight": if (zonePrefix != null && (currentContainer instanceof Entry)) { diff --git a/jdk/make/tools/src/build/tools/cldrconverter/MetaZonesParseHandler.java b/jdk/make/tools/src/build/tools/cldrconverter/MetaZonesParseHandler.java index 5c6f50b4ae9..99be8cfd882 100644 --- a/jdk/make/tools/src/build/tools/cldrconverter/MetaZonesParseHandler.java +++ b/jdk/make/tools/src/build/tools/cldrconverter/MetaZonesParseHandler.java @@ -46,8 +46,9 @@ class MetaZonesParseHandler extends AbstractLDMLHandler { return null; } + // metaZone: ID -> metazone + // per locale: ID -> names, metazone -> names @Override - @SuppressWarnings("fallthrough") public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { switch (qName) { case "timezone": diff --git a/jdk/make/tools/src/build/tools/cldrconverter/ResourceBundleGenerator.java b/jdk/make/tools/src/build/tools/cldrconverter/ResourceBundleGenerator.java index 2d031fa8ba3..c7826a2519b 100644 --- a/jdk/make/tools/src/build/tools/cldrconverter/ResourceBundleGenerator.java +++ b/jdk/make/tools/src/build/tools/cldrconverter/ResourceBundleGenerator.java @@ -28,14 +28,16 @@ package build.tools.cldrconverter; import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.util.Formatter; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.SortedSet; class ResourceBundleGenerator implements BundleGenerator { - @Override public void generateBundle(String packageName, String baseName, String localeID, boolean useJava, - Map map, boolean open) throws IOException { + Map map, BundleType type) throws IOException { String suffix = useJava ? ".java" : ".properties"; String lang = CLDRConverter.getLanguageCode(localeID); String dirName = CLDRConverter.DESTINATION_DIR + File.separator + "sun" + File.separator @@ -67,6 +69,28 @@ class ResourceBundleGenerator implements BundleGenerator { encoding = "iso-8859-1"; } + Formatter fmt = null; + if (type == BundleType.TIMEZONE) { + fmt = new Formatter(); + Set metaKeys = new HashSet<>(); + for (String key : map.keySet()) { + if (key.startsWith(CLDRConverter.METAZONE_ID_PREFIX)) { + String meta = key.substring(CLDRConverter.METAZONE_ID_PREFIX.length()); + String[] value; + value = (String[]) map.get(key); + fmt.format(" final String[] %s = new String[] {\n", meta); + for (String s : value) { + fmt.format(" \"%s\",\n", CLDRConverter.saveConvert(s, useJava)); + } + fmt.format(" };\n"); + metaKeys.add(key); + } + } + for (String key : metaKeys) { + map.remove(key); + } + } + try (PrintWriter out = new PrintWriter(file, encoding)) { // Output copyright headers out.println(CopyrightHeaders.getOpenJDKCopyright()); @@ -74,16 +98,15 @@ class ResourceBundleGenerator implements BundleGenerator { if (useJava) { out.println("package sun." + packageName + ";\n"); - if (open) { - out.println("import sun.util.resources.OpenListResourceBundle;\n"); - out.println("public class " + baseName + ("root".equals(localeID) ? "" : "_" + localeID) + " extends OpenListResourceBundle {"); - } else { - out.println("import java.util.ListResourceBundle;\n"); - out.println("public class " + baseName + ("root".equals(localeID) ? "" : "_" + localeID) + " extends ListResourceBundle {"); - } + out.printf("import %s;\n\n", type.getPathName()); + out.printf("public class %s%s extends %s {\n", baseName, "root".equals(localeID) ? "" : "_" + localeID, type.getClassName()); + out.println(" @Override\n" + - " protected final Object[][] getContents() {\n" + - " final Object[][] data = new Object[][] {"); + " protected final Object[][] getContents() {"); + if (fmt != null) { + out.print(fmt.toString()); + } + out.println(" final Object[][] data = new Object[][] {"); } for (String key : map.keySet()) { if (useJava) { @@ -91,7 +114,11 @@ class ResourceBundleGenerator implements BundleGenerator { if (value == null) { CLDRConverter.warning("null value for " + key); } else if (value instanceof String) { - out.println(" { \"" + key + "\", \"" + CLDRConverter.saveConvert((String) value, useJava) + "\" },"); + if (type == BundleType.TIMEZONE) { + out.printf(" { \"%s\", %s },\n", key, CLDRConverter.saveConvert((String) value, useJava)); + } else { + out.printf(" { \"%s\", \"%s\" },\n", key, CLDRConverter.saveConvert((String) value, useJava)); + } } else if (value instanceof String[]) { String[] values = (String[]) value; out.println(" { \"" + key + "\",\n new String[] {"); diff --git a/jdk/src/share/classes/java/text/DateFormatSymbols.java b/jdk/src/share/classes/java/text/DateFormatSymbols.java index ee688abd9b6..bde39a66ed1 100644 --- a/jdk/src/share/classes/java/text/DateFormatSymbols.java +++ b/jdk/src/share/classes/java/text/DateFormatSymbols.java @@ -688,7 +688,16 @@ public class DateFormatSymbols implements Serializable, Cloneable { } ResourceBundle resource = adapter.getLocaleData().getDateFormatData(locale); - eras = resource.getStringArray("Eras"); + // JRE and CLDR use different keys + // JRE: Eras, short.Eras and narrow.Eras + // CLDR: long.Eras, Eras and narrow.Eras + if (resource.containsKey("Eras")) { + eras = resource.getStringArray("Eras"); + } else if (resource.containsKey("long.Eras")) { + eras = resource.getStringArray("long.Eras"); + } else if (resource.containsKey("short.Eras")) { + eras = resource.getStringArray("short.Eras"); + } months = resource.getStringArray("MonthNames"); shortMonths = resource.getStringArray("MonthAbbreviations"); ampms = resource.getStringArray("AmPmMarkers"); diff --git a/jdk/src/share/classes/java/text/SimpleDateFormat.java b/jdk/src/share/classes/java/text/SimpleDateFormat.java index b434b6b782a..0c1f4aa6a61 100644 --- a/jdk/src/share/classes/java/text/SimpleDateFormat.java +++ b/jdk/src/share/classes/java/text/SimpleDateFormat.java @@ -48,12 +48,13 @@ import java.util.GregorianCalendar; import java.util.Locale; import java.util.Map; import java.util.SimpleTimeZone; +import java.util.SortedMap; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.calendar.CalendarUtils; import sun.util.calendar.ZoneInfoFile; +import sun.util.locale.provider.LocaleProviderAdapter; /** * SimpleDateFormat is a concrete class for formatting and @@ -1593,6 +1594,17 @@ public class SimpleDateFormat extends DateFormat { private int matchString(String text, int start, int field, Map data, CalendarBuilder calb) { if (data != null) { + // TODO: make this default when it's in the spec. + if (data instanceof SortedMap) { + for (String name : data.keySet()) { + if (text.regionMatches(true, start, name, 0, name.length())) { + calb.set(field, data.get(name)); + return start + name.length(); + } + } + return -start; + } + String bestMatch = null; for (String name : data.keySet()) { @@ -1803,7 +1815,7 @@ public class SimpleDateFormat extends DateFormat { boolean obeyCount, boolean[] ambiguousYear, ParsePosition origPos, boolean useFollowingMinusSignAsDelimiter, CalendarBuilder calb) { - Number number = null; + Number number; int value = 0; ParsePosition pos = new ParsePosition(0); pos.index = start; @@ -1876,9 +1888,7 @@ public class SimpleDateFormat extends DateFormat { return index; } } else { - Map map = calendar.getDisplayNames(field, - Calendar.ALL_STYLES, - locale); + Map map = getDisplayNamesMap(field, locale); if ((index = matchString(text, start, field, map, calb)) > 0) { return index; } @@ -1940,7 +1950,7 @@ public class SimpleDateFormat extends DateFormat { // count >= 3 // i.e., MMM or MMMM // Want to be able to parse both short and long forms. // Try count == 4 first: - int newStart = 0; + int newStart; if ((newStart = matchString(text, start, Calendar.MONTH, formatData.getMonths(), calb)) > 0) { return newStart; @@ -1951,9 +1961,7 @@ public class SimpleDateFormat extends DateFormat { return index; } } else { - Map map = calendar.getDisplayNames(field, - Calendar.ALL_STYLES, - locale); + Map map = getDisplayNamesMap(field, locale); if ((index = matchString(text, start, field, map, calb)) > 0) { return index; } @@ -1979,7 +1987,7 @@ public class SimpleDateFormat extends DateFormat { if (useDateFormatSymbols) { // Want to be able to parse both short and long forms. // Try count == 4 (DDDD) first: - int newStart = 0; + int newStart; if ((newStart=matchString(text, start, Calendar.DAY_OF_WEEK, formatData.getWeekdays(), calb)) > 0) { return newStart; @@ -2008,7 +2016,7 @@ public class SimpleDateFormat extends DateFormat { return index; } } else { - Map map = calendar.getDisplayNames(field, Calendar.ALL_STYLES, locale); + Map map = getDisplayNamesMap(field, locale); if ((index = matchString(text, start, field, map, calb)) > 0) { return index; } @@ -2098,7 +2106,7 @@ public class SimpleDateFormat extends DateFormat { break parsing; } - int sign = 0; + int sign; char c = text.charAt(pos.index); if (c == 'Z') { calb.set(Calendar.ZONE_OFFSET, 0).set(Calendar.DST_OFFSET, 0); @@ -2340,6 +2348,21 @@ public class SimpleDateFormat extends DateFormat { && formatData.equals(that.formatData)); } + private static final int[] REST_OF_STYLES = { + Calendar.SHORT_STANDALONE, Calendar.LONG_FORMAT, Calendar.LONG_STANDALONE, + }; + private Map getDisplayNamesMap(int field, Locale locale) { + Map map = calendar.getDisplayNames(field, Calendar.SHORT_FORMAT, locale); + // Get all SHORT and LONG styles (avoid NARROW styles). + for (int style : REST_OF_STYLES) { + Map m = calendar.getDisplayNames(field, style, locale); + if (m != null) { + map.putAll(m); + } + } + return map; + } + /** * After reading an object from the input stream, the format * pattern in the object is verified. diff --git a/jdk/src/share/classes/java/util/Calendar.java b/jdk/src/share/classes/java/util/Calendar.java index f641a37e632..9b61012003e 100644 --- a/jdk/src/share/classes/java/util/Calendar.java +++ b/jdk/src/share/classes/java/util/Calendar.java @@ -53,9 +53,7 @@ import java.text.DateFormat; import java.text.DateFormatSymbols; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import java.util.spi.CalendarDataProvider; import sun.util.BuddhistCalendar; -import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.calendar.ZoneInfo; import sun.util.locale.provider.CalendarDataUtility; @@ -743,6 +741,32 @@ public abstract class Calendar implements Serializable, Cloneable, Comparablefield in the given style, or - * null if no string representation is + * {@code field} in the given {@code style}, or + * {@code null} if no string representation is * applicable. * @exception IllegalArgumentException - * if field or style is invalid, - * or if this Calendar is non-lenient and any + * if {@code field} or {@code style} is invalid, + * or if this {@code Calendar} is non-lenient and any * of the calendar fields have invalid values * @exception NullPointerException - * if locale is null + * if {@code locale} is null * @since 1.6 */ public String getDisplayName(int field, int style, Locale locale) { - if (!checkDisplayNameParams(field, style, SHORT, LONG, locale, + if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } - // the standalone styles are supported only through CalendarDataProviders. - if (isStandaloneStyle(style)) { + // the standalone and narrow styles are supported only through CalendarDataProviders. + if (isStandaloneStyle(style) || isNarrowStyle(style)) { return CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, get(field), style, locale); @@ -1513,26 +1538,30 @@ public abstract class Calendar implements Serializable, Cloneable, ComparableMap containing all names of the calendar - * field in the given style and - * locale and their corresponding field values. For - * example, if this Calendar is a {@link + * Returns a {@code Map} containing all names of the calendar + * {@code field} in the given {@code style} and + * {@code locale} and their corresponding field values. For + * example, if this {@code Calendar} is a {@link * GregorianCalendar}, the returned map would contain "Jan" to * {@link #JANUARY}, "Feb" to {@link #FEBRUARY}, and so on, in the * {@linkplain #SHORT short} style in an English locale. * + *

Narrow names may not be unique due to use of single characters, + * such as "S" for Sunday and Saturday. In that case narrow names are not + * included in the returned {@code Map}. + * *

The values of other calendar fields may be taken into * account to determine a set of display names. For example, if - * this Calendar is a lunisolar calendar system and + * this {@code Calendar} is a lunisolar calendar system and * the year value given by the {@link #YEAR} field has a leap * month, this method would return month names containing the leap * month name, and month names are mapped to their values specific * for the year. * *

The default implementation supports display names contained in - * a {@link DateFormatSymbols}. For example, if field - * is {@link #MONTH} and style is {@link - * #ALL_STYLES}, this method returns a Map containing + * a {@link DateFormatSymbols}. For example, if {@code field} + * is {@link #MONTH} and {@code style} is {@link + * #ALL_STYLES}, this method returns a {@code Map} containing * all strings returned by {@link DateFormatSymbols#getShortMonths()} * and {@link DateFormatSymbols#getMonths()}. * @@ -1541,30 +1570,31 @@ public abstract class Calendar implements Serializable, Cloneable, ComparableMap containing all display names in - * style and locale and their - * field values, or null if no display names - * are defined for field + * @return a {@code Map} containing all display names in + * {@code style} and {@code locale} and their + * field values, or {@code null} if no display names + * are defined for {@code field} * @exception IllegalArgumentException - * if field or style is invalid, - * or if this Calendar is non-lenient and any + * if {@code field} or {@code style} is invalid, + * or if this {@code Calendar} is non-lenient and any * of the calendar fields have invalid values * @exception NullPointerException - * if locale is null + * if {@code locale} is null * @since 1.6 */ public Map getDisplayNames(int field, int style, Locale locale) { - if (!checkDisplayNameParams(field, style, ALL_STYLES, LONG, locale, + if (!checkDisplayNameParams(field, style, ALL_STYLES, NARROW_FORMAT, locale, ERA_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } if (style == ALL_STYLES || isStandaloneStyle(style)) { return CalendarDataUtility.retrieveFieldValueNames(getCalendarType(), field, style, locale); } - // SHORT or LONG + // SHORT, LONG, or NARROW return getDisplayNamesImpl(field, style, locale); } @@ -1599,6 +1629,12 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable getDisplayNames(int field, int style, Locale locale) { - if (!checkDisplayNameParams(field, style, ALL_STYLES, LONG, locale, + if (!checkDisplayNameParams(field, style, ALL_STYLES, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } - Map names = CalendarDataUtility.retrieveFieldValueNames("japanese", field, style, locale); + Map names; + names = CalendarDataUtility.retrieveFieldValueNames(getCalendarType(), field, style, locale); // If strings[] has fewer than eras[], get more names from eras[]. - if (field == ERA) { - int size = names.size(); - if (style == ALL_STYLES) { - size /= 2; // SHORT and LONG - } - if (size < eras.length) { - int baseStyle = getBaseStyle(style); - for (int i = size; i < eras.length; i++) { - Era era = eras[i]; - if (baseStyle == ALL_STYLES || baseStyle == SHORT) { - names.put(era.getAbbreviation(), i); + if (names != null) { + if (field == ERA) { + int size = names.size(); + if (style == ALL_STYLES) { + Set values = new HashSet<>(); + // count unique era values + for (String key : names.keySet()) { + values.add(names.get(key)); } - if (baseStyle == ALL_STYLES || baseStyle == LONG) { - names.put(era.getName(), i); + size = values.size(); + } + if (size < eras.length) { + int baseStyle = getBaseStyle(style); + for (int i = size; i < eras.length; i++) { + Era era = eras[i]; + if (baseStyle == ALL_STYLES || baseStyle == SHORT + || baseStyle == NARROW_FORMAT) { + names.put(era.getAbbreviation(), i); + } + if (baseStyle == ALL_STYLES || baseStyle == LONG) { + names.put(era.getName(), i); + } } } } diff --git a/jdk/src/share/classes/java/util/TimeZone.java b/jdk/src/share/classes/java/util/TimeZone.java index 13ede9c2a12..9d9fbcc8fd1 100644 --- a/jdk/src/share/classes/java/util/TimeZone.java +++ b/jdk/src/share/classes/java/util/TimeZone.java @@ -43,12 +43,12 @@ import java.lang.ref.SoftReference; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.concurrent.ConcurrentHashMap; -import sun.misc.SharedSecrets; import sun.misc.JavaAWTAccess; +import sun.misc.SharedSecrets; import sun.security.action.GetPropertyAction; -import sun.util.locale.provider.TimeZoneNameUtility; import sun.util.calendar.ZoneInfo; import sun.util.calendar.ZoneInfoFile; +import sun.util.locale.provider.TimeZoneNameUtility; /** * TimeZone represents a time zone offset, and also figures out daylight @@ -399,28 +399,23 @@ abstract public class TimeZone implements Serializable, Cloneable { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } - String id = getID(); - String[] names = getDisplayNames(id, locale); - if (names == null) { - if (id.startsWith("GMT") && id.length() > 3) { - char sign = id.charAt(3); - if (sign == '+' || sign == '-') { - return id; - } - } - int offset = getRawOffset(); - if (daylight) { - offset += getDSTSavings(); - } - return ZoneInfoFile.toCustomID(offset); + String name = TimeZoneNameUtility.retrieveDisplayName(id, daylight, style, locale); + if (name != null) { + return name; } - int index = daylight ? 3 : 1; - if (style == SHORT) { - index++; + if (id.startsWith("GMT") && id.length() > 3) { + char sign = id.charAt(3); + if (sign == '+' || sign == '-') { + return id; + } } - return names[index]; + int offset = getRawOffset(); + if (daylight) { + offset += getDSTSavings(); + } + return ZoneInfoFile.toCustomID(offset); } private static class DisplayNames { @@ -429,9 +424,12 @@ abstract public class TimeZone implements Serializable, Cloneable { // Map(key=id, value=SoftReference(Map(key=locale, value=displaynames))) private static final Map>> CACHE = new ConcurrentHashMap<>(); + + private DisplayNames() { + } } - private static final String[] getDisplayNames(String id, Locale locale) { + private static String[] getDisplayNames(String id, Locale locale) { Map>> displayNames = DisplayNames.CACHE; SoftReference> ref = displayNames.get(id); @@ -631,14 +629,14 @@ abstract public class TimeZone implements Serializable, Cloneable { } private static synchronized TimeZone setDefaultZone() { - TimeZone tz = null; + TimeZone tz; // get the time zone ID from the system properties String zoneID = AccessController.doPrivileged( new GetPropertyAction("user.timezone")); // if the time zone ID is not set (yet), perform the // platform to Java time zone ID mapping. - if (zoneID == null || zoneID.equals("")) { + if (zoneID == null || zoneID.isEmpty()) { String country = AccessController.doPrivileged( new GetPropertyAction("user.country")); String javaHome = AccessController.doPrivileged( @@ -670,8 +668,9 @@ abstract public class TimeZone implements Serializable, Cloneable { assert tz != null; final String id = zoneID; - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { System.setProperty("user.timezone", id); return null; } diff --git a/jdk/src/share/classes/java/util/spi/CalendarNameProvider.java b/jdk/src/share/classes/java/util/spi/CalendarNameProvider.java index 20122cf5466..8e8d54e8ecd 100644 --- a/jdk/src/share/classes/java/util/spi/CalendarNameProvider.java +++ b/jdk/src/share/classes/java/util/spi/CalendarNameProvider.java @@ -174,7 +174,8 @@ public abstract class CalendarNameProvider extends LocaleServiceProvider { *

{@code style} gives the style of the string representation. It is one * of {@link Calendar#SHORT_FORMAT} ({@link Calendar#SHORT SHORT}), * {@link Calendar#SHORT_STANDALONE}, {@link Calendar#LONG_FORMAT} - * ({@link Calendar#LONG LONG}), or {@link Calendar#LONG_STANDALONE}. + * ({@link Calendar#LONG LONG}), {@link Calendar#LONG_STANDALONE}, + * {@link Calendar#NARROW_FORMAT}, or {@link Calendar#NARROW_STANDALONE}. * *

For example, the following call will return {@code "Sunday"}. *

@@ -195,8 +196,10 @@ public abstract class CalendarNameProvider extends LocaleServiceProvider {
      *              the string representation style: one of {@link
      *              Calendar#SHORT_FORMAT} ({@link Calendar#SHORT SHORT}),
      *              {@link Calendar#SHORT_STANDALONE}, {@link
-     *              Calendar#LONG_FORMAT} ({@link Calendar#LONG LONG}), or
-     *              {@link Calendar#LONG_STANDALONE}
+     *              Calendar#LONG_FORMAT} ({@link Calendar#LONG LONG}),
+     *              {@link Calendar#LONG_STANDALONE},
+     *              {@link Calendar#NARROW_FORMAT},
+     *              or {@link Calendar#NARROW_STANDALONE}
      * @param locale
      *              the desired locale
      * @return the string representation of the {@code field value}, or {@code
@@ -226,8 +229,11 @@ public abstract class CalendarNameProvider extends LocaleServiceProvider {
      * 

{@code style} gives the style of the string representation. It must be * one of {@link Calendar#ALL_STYLES}, {@link Calendar#SHORT_FORMAT} ({@link * Calendar#SHORT SHORT}), {@link Calendar#SHORT_STANDALONE}, {@link - * Calendar#LONG_FORMAT} ({@link Calendar#LONG LONG}), or {@link - * Calendar#LONG_STANDALONE}. + * Calendar#LONG_FORMAT} ({@link Calendar#LONG LONG}), {@link + * Calendar#LONG_STANDALONE}, {@link Calendar#NARROW_FORMAT}, or + * {@link Calendar#NARROW_STANDALONE}. Note that narrow names may + * not be unique due to use of single characters, such as "S" for Sunday + * and Saturday, and that no narrow names are included in that case. * *

For example, the following call will return a {@code Map} containing * {@code "January"} to {@link Calendar#JANUARY}, {@code "Jan"} to {@link @@ -247,8 +253,9 @@ public abstract class CalendarNameProvider extends LocaleServiceProvider { * {@link Calendar#ALL_STYLES}, {@link Calendar#SHORT_FORMAT} * ({@link Calendar#SHORT SHORT}), {@link * Calendar#SHORT_STANDALONE}, {@link Calendar#LONG_FORMAT} - * ({@link Calendar#LONG LONG}), or {@link - * Calendar#LONG_STANDALONE}. + * ({@link Calendar#LONG LONG}), {@link Calendar#LONG_STANDALONE}, + * {@link Calendar#NARROW_FORMAT}, + * or {@link Calendar#NARROW_STANDALONE} * @param locale * the desired locale * @return a {@code Map} containing all display names of {@code field} in diff --git a/jdk/src/share/classes/java/util/spi/TimeZoneNameProvider.java b/jdk/src/share/classes/java/util/spi/TimeZoneNameProvider.java index 730b507ca97..766c4e38463 100644 --- a/jdk/src/share/classes/java/util/spi/TimeZoneNameProvider.java +++ b/jdk/src/share/classes/java/util/spi/TimeZoneNameProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. 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 @@ -77,4 +77,34 @@ public abstract class TimeZoneNameProvider extends LocaleServiceProvider { * @see java.util.TimeZone#getDisplayName(boolean, int, java.util.Locale) */ public abstract String getDisplayName(String ID, boolean daylight, int style, Locale locale); + + /** + * Returns a generic name for the given time zone {@code ID} that's suitable + * for presentation to the user in the specified {@code locale}. Generic + * time zone names are neutral from standard time and daylight saving + * time. For example, "PT" is the short generic name of time zone ID {@code + * America/Los_Angeles}, while its short standard time and daylight saving + * time names are "PST" and "PDT", respectively. Refer to + * {@link #getDisplayName(String, boolean, int, Locale) getDisplayName} + * for valid time zone IDs. + * + *

The default implementation of this method returns {@code null}. + * + * @param ID a time zone ID string + * @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or + * {@link java.util.TimeZone#SHORT TimeZone.SHORT} + * @param locale the desired locale + * @return the human-readable generic name of the given time zone in the + * given locale, or {@code null} if it's not available. + * @exception IllegalArgumentException if style is invalid, + * or locale isn't one of the locales returned from + * {@link LocaleServiceProvider#getAvailableLocales() + * getAvailableLocales()}. + * @exception NullPointerException if ID or locale + * is {@code null} + * @since 1.8 + */ + public String getGenericDisplayName(String ID, int style, Locale locale) { + return null; + } } diff --git a/jdk/src/share/classes/sun/text/resources/FormatData.java b/jdk/src/share/classes/sun/text/resources/FormatData.java index 2031cb42228..d6c306709a8 100644 --- a/jdk/src/share/classes/sun/text/resources/FormatData.java +++ b/jdk/src/share/classes/sun/text/resources/FormatData.java @@ -50,6 +50,20 @@ public class FormatData extends ListResourceBundle { * Overrides ListResourceBundle */ protected final Object[][] getContents() { + final String[] buddhistEras = new String[] { // Thai Buddhist calendar era strings + "BC", // BC + "B.E." // Buddhist Era + }; + + // Japanese imperial calendar era abbreviations + final String[] japaneseEraAbbrs = new String[] { + "", + "M", + "T", + "S", + "H", + }; + return new Object[][] { { "MonthNames", new String[] { @@ -107,29 +121,49 @@ public class FormatData extends ListResourceBundle { "Sat" // abb Saturday } }, + { "DayNarrows", + new String[] { + "S", + "M", + "T", + "W", + "T", + "F", + "S", + } + }, { "AmPmMarkers", new String[] { "AM", // am marker "PM" // pm marker } }, + { "narrow.AmPmMarkers", + new String[] { + "a", // am marker + "p" // pm marker + } + }, { "Eras", new String[] { // era strings for GregorianCalendar "BC", "AD" } }, - { "buddhist.Eras", - new String[] { // Thai Buddhist calendar era strings - "BC", // BC - "B.E." // Buddhist Era + { "narrow.Eras", + new String[] { + "B", + "A", } }, + { "buddhist.Eras", + buddhistEras + }, { "buddhist.short.Eras", - new String[] { // Thai Buddhist calendar era strings - "BC", // BC - "B.E." // Buddhist Era - } + buddhistEras + }, + { "buddhist.narrow.Eras", + buddhistEras }, { "japanese.Eras", new String[] { // Japanese imperial calendar era strings @@ -141,13 +175,10 @@ public class FormatData extends ListResourceBundle { } }, { "japanese.short.Eras", - new String[] { // Japanese imperial calendar era abbreviations - "", - "M", - "T", - "S", - "H", - } + japaneseEraAbbrs + }, + { "japanese.narrow.Eras", + japaneseEraAbbrs }, { "japanese.FirstYear", new String[] { // Japanese imperial calendar year name diff --git a/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar.java b/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar.java index 98b2e4e4e9e..a6593b0a45c 100644 --- a/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar.java +++ b/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar.java @@ -107,6 +107,17 @@ public class FormatData_ar extends ListResourceBundle { "\u0633" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u062d", + "\u0646", + "\u062b", + "\u0631", + "\u062e", + "\u062c", + "\u0633", + } + }, { "AmPmMarkers", new String[] { "\u0635", // am marker diff --git a/jdk/src/share/classes/sun/text/resources/be/FormatData_be.java b/jdk/src/share/classes/sun/text/resources/be/FormatData_be.java index 754532659ff..7bf6c012163 100644 --- a/jdk/src/share/classes/sun/text/resources/be/FormatData_be.java +++ b/jdk/src/share/classes/sun/text/resources/be/FormatData_be.java @@ -85,6 +85,23 @@ public class FormatData_be extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "\u0441", + "\u043b", + "\u0441", + "\u043a", + "\u043c", + "\u0447", + "\u043b", + "\u0436", + "\u0432", + "\u043a", + "\u043b", + "\u0441", + "", + } + }, { "DayNames", new String[] { "\u043d\u044f\u0434\u0437\u0435\u043b\u044f", // Sunday @@ -107,6 +124,17 @@ public class FormatData_be extends ListResourceBundle { "\u0441\u0431" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u043d", + "\u043f", + "\u0430", + "\u0441", + "\u0447", + "\u043f", + "\u0441", + } + }, { "Eras", new String[] { // era strings "\u0434\u0430 \u043d.\u0435.", diff --git a/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg.java b/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg.java index 2fe39282e35..2b7285eefad 100644 --- a/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg.java +++ b/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg.java @@ -107,6 +107,17 @@ public class FormatData_bg extends ListResourceBundle { "\u0421\u0431" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u043d", + "\u043f", + "\u0432", + "\u0441", + "\u0447", + "\u043f", + "\u0441", + } + }, { "Eras", new String[] { // era strings "\u043f\u0440.\u043d.\u0435.", diff --git a/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca.java b/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca.java index 2f9cf3967d3..d6774dbacb6 100644 --- a/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca.java +++ b/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca.java @@ -119,6 +119,23 @@ public class FormatData_ca extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "g", + "f", + "m", + "a", + "m", + "j", + "j", + "a", + "s", + "o", + "n", + "d", + "", + } + }, { "DayNames", new String[] { "diumenge", // Sunday @@ -141,6 +158,28 @@ public class FormatData_ca extends ListResourceBundle { "ds." // abb Saturday } }, + { "DayNarrows", + new String[] { + "G", + "L", // Note: contributed item in CDLR + "T", + "C", + "J", + "V", + "S", + } + }, + { "standalone.DayNarrows", + new String[] { + "g", + "l", + "t", + "c", + "j", + "v", + "s", + } + }, { "NumberElements", new String[] { ",", // decimal separator diff --git a/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs.java b/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs.java index 2bbc8c03bdf..e0d34098b09 100644 --- a/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs.java +++ b/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs.java @@ -141,6 +141,17 @@ public class FormatData_cs extends ListResourceBundle { "So" // abb Saturday } }, + { "DayNarrows", + new String[] { + "N", + "P", + "\u00da", + "S", + "\u010c", + "P", + "S", + } + }, { "AmPmMarkers", new String[] { "dop.", // am marker diff --git a/jdk/src/share/classes/sun/text/resources/da/FormatData_da.java b/jdk/src/share/classes/sun/text/resources/da/FormatData_da.java index d9535cf551e..2686877c0a3 100644 --- a/jdk/src/share/classes/sun/text/resources/da/FormatData_da.java +++ b/jdk/src/share/classes/sun/text/resources/da/FormatData_da.java @@ -124,6 +124,17 @@ public class FormatData_da extends ListResourceBundle { "l\u00f8" // abb Saturday } }, + { "DayNarrows", + new String[] { + "S", + "M", + "T", + "O", + "T", + "F", + "L", + } + }, { "NumberElements", new String[] { ",", // decimal separator diff --git a/jdk/src/share/classes/sun/text/resources/de/FormatData_de.java b/jdk/src/share/classes/sun/text/resources/de/FormatData_de.java index d2fe2f22190..3f55bb20ba6 100644 --- a/jdk/src/share/classes/sun/text/resources/de/FormatData_de.java +++ b/jdk/src/share/classes/sun/text/resources/de/FormatData_de.java @@ -124,6 +124,17 @@ public class FormatData_de extends ListResourceBundle { "Sa" // abb Saturday } }, + { "DayNarrows", + new String[] { + "S", + "M", + "D", + "M", + "D", + "F", + "S", + } + }, { "Eras", new String[] { // era strings "v. Chr.", diff --git a/jdk/src/share/classes/sun/text/resources/el/FormatData_el.java b/jdk/src/share/classes/sun/text/resources/el/FormatData_el.java index 49e0602f525..fd91ad2aea3 100644 --- a/jdk/src/share/classes/sun/text/resources/el/FormatData_el.java +++ b/jdk/src/share/classes/sun/text/resources/el/FormatData_el.java @@ -124,6 +124,17 @@ public class FormatData_el extends ListResourceBundle { "\u03a3\u03b1\u03b2" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u039a", + "\u0394", + "\u03a4", + "\u03a4", + "\u03a0", + "\u03a0", + "\u03a3", + } + }, { "AmPmMarkers", new String[] { "\u03c0\u03bc", // am marker diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es.java index 3ee44ba042b..f19685dd83d 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es.java @@ -104,6 +104,17 @@ public class FormatData_es extends ListResourceBundle { "s\u00e1b" // abb Saturday } }, + { "DayNarrows", + new String[] { + "D", + "L", + "M", + "X", + "J", + "V", + "S", + } + }, { "NumberPatterns", new String[] { "#,##0.###;-#,##0.###", // decimal pattern diff --git a/jdk/src/share/classes/sun/text/resources/et/FormatData_et.java b/jdk/src/share/classes/sun/text/resources/et/FormatData_et.java index 90f4dcc7daa..844b8af4285 100644 --- a/jdk/src/share/classes/sun/text/resources/et/FormatData_et.java +++ b/jdk/src/share/classes/sun/text/resources/et/FormatData_et.java @@ -104,6 +104,17 @@ public class FormatData_et extends ListResourceBundle { "L" // abb Saturday } }, + { "DayNarrows", + new String[] { + "P", + "E", + "T", + "K", + "N", + "R", + "L", + } + }, { "Eras", new String[] { // era strings "e.m.a.", diff --git a/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi.java b/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi.java index d8a610d6056..91c5ea9a57a 100644 --- a/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi.java +++ b/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi.java @@ -116,6 +116,23 @@ public class FormatData_fi extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "T", + "H", + "M", + "H", + "T", + "K", + "H", + "E", + "S", + "L", + "M", + "J", + "", + } + }, { "DayNames", new String[] { "sunnuntai", // Sunday @@ -138,6 +155,28 @@ public class FormatData_fi extends ListResourceBundle { "la" // abb Saturday } }, + { "DayNarrows", + new String[] { + "S", + "M", + "T", + "K", + "T", + "P", + "L", + } + }, + { "standalone.DayNarrows", + new String[] { + "S", + "M", + "T", + "K", + "T", + "P", + "L", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -181,6 +220,12 @@ public class FormatData_fi extends ListResourceBundle { "ip." // pm marker } }, + { "narrow.AmPmMarkers", + new String[] { + "ap.", + "ip.", + } + }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr.java b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr.java index de857d7c879..f0354ec1066 100644 --- a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr.java +++ b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr.java @@ -104,6 +104,17 @@ public class FormatData_fr extends ListResourceBundle { "sam." // abb Saturday } }, + { "DayNarrows", + new String[] { + "D", + "L", + "M", + "M", + "J", + "V", + "S", + } + }, { "Eras", new String[] { // era strings "BC", diff --git a/jdk/src/share/classes/sun/text/resources/hi/FormatData_hi_IN.java b/jdk/src/share/classes/sun/text/resources/hi/FormatData_hi_IN.java index b6c1647275f..7f1deb81c3a 100644 --- a/jdk/src/share/classes/sun/text/resources/hi/FormatData_hi_IN.java +++ b/jdk/src/share/classes/sun/text/resources/hi/FormatData_hi_IN.java @@ -99,6 +99,17 @@ public class FormatData_hi_IN extends ListResourceBundle { "\u0936\u0928\u093f" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u0930", + "\u0938\u094b", + "\u092e\u0902", + "\u092c\u0941", + "\u0917\u0941", + "\u0936\u0941", + "\u0936", + } + }, { "AmPmMarkers", new String[] { "\u092a\u0942\u0930\u094d\u0935\u093e\u0939\u094d\u0928", // am marker diff --git a/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr.java b/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr.java index 635b3b97ff2..cec08671ca1 100644 --- a/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr.java +++ b/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr.java @@ -116,6 +116,23 @@ public class FormatData_hr extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "1.", + "2.", + "3.", + "4.", + "5.", + "6.", + "7.", + "8.", + "9.", + "10.", + "11.", + "12.", + "", + } + }, { "DayNames", new String[] { "nedjelja", // Sunday @@ -138,6 +155,28 @@ public class FormatData_hr extends ListResourceBundle { "sub" // abb Saturday } }, + { "DayNarrows", + new String[] { + "N", + "P", + "U", + "S", + "\u010c", + "P", + "S", + } + }, + { "standalone.DayNarrows", + new String[] { + "n", + "p", + "u", + "s", + "\u010d", + "p", + "s", + } + }, { "NumberElements", new String[] { ",", // decimal separator diff --git a/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu.java b/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu.java index a1ab3906f44..0f00a40aa5f 100644 --- a/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu.java +++ b/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu.java @@ -104,6 +104,17 @@ public class FormatData_hu extends ListResourceBundle { "Szo" // abb Saturday } }, + { "DayNarrows", + new String[] { + "V", + "H", + "K", + "Sz", + "Cs", + "P", + "Sz", + } + }, { "AmPmMarkers", new String[] { "DE", // am marker diff --git a/jdk/src/share/classes/sun/text/resources/is/FormatData_is.java b/jdk/src/share/classes/sun/text/resources/is/FormatData_is.java index 9a3e0ff21cb..6b6d92c6421 100644 --- a/jdk/src/share/classes/sun/text/resources/is/FormatData_is.java +++ b/jdk/src/share/classes/sun/text/resources/is/FormatData_is.java @@ -82,6 +82,23 @@ public class FormatData_is extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "j", + "f", + "m", + "a", + "m", + "j", + "j", + "\u00e1", + "s", + "o", + "n", + "d", + "", + } + }, { "DayNames", new String[] { "sunnudagur", // Sunday @@ -104,6 +121,28 @@ public class FormatData_is extends ListResourceBundle { "lau." // abb Saturday } }, + { "DayNarrows", + new String[] { + "S", + "M", + "\u00de", + "M", + "F", + "F", + "L", + } + }, + { "standalone.DayNarrows", + new String[] { + "s", + "m", + "\u00fe", + "m", + "f", + "f", + "l", + } + }, { "NumberElements", new String[] { ",", // decimal separator diff --git a/jdk/src/share/classes/sun/text/resources/it/FormatData_it.java b/jdk/src/share/classes/sun/text/resources/it/FormatData_it.java index a9843cca23d..5b3fa9ca82e 100644 --- a/jdk/src/share/classes/sun/text/resources/it/FormatData_it.java +++ b/jdk/src/share/classes/sun/text/resources/it/FormatData_it.java @@ -121,6 +121,17 @@ public class FormatData_it extends ListResourceBundle { "sab" // abb Saturday } }, + { "DayNarrows", + new String[] { + "D", + "L", + "M", + "M", + "G", + "V", + "S", + } + }, { "Eras", new String[] { // era strings "BC", diff --git a/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw.java b/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw.java index cfadcdfbf93..80fb1ac4b83 100644 --- a/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw.java +++ b/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw.java @@ -121,6 +121,28 @@ public class FormatData_iw extends ListResourceBundle { "\u05e9" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u05d0", + "\u05d1", + "\u05d2", + "\u05d3", + "\u05d4", + "\u05d5", + "\u05e9", + } + }, + { "standalone.DayNarrows", + new String[] { + "\u05d0", + "\u05d1", + "\u05d2", + "\u05d3", + "\u05d4", + "\u05d5", + "\u05e9", + } + }, { "Eras", new String[] { // era strings "\u05dc\u05e1\u05d4\"\u05e0", diff --git a/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja.java b/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja.java index 6217d5a4a16..a45992952ea 100644 --- a/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja.java +++ b/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja.java @@ -104,6 +104,17 @@ public class FormatData_ja extends ListResourceBundle { "\u571f" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u65e5", + "\u6708", + "\u706b", + "\u6c34", + "\u6728", + "\u91d1", + "\u571f", + } + }, { "AmPmMarkers", new String[] { "\u5348\u524d", // am marker diff --git a/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko.java b/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko.java index b574bfba890..fc8badb82bf 100644 --- a/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko.java +++ b/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko.java @@ -104,6 +104,17 @@ public class FormatData_ko extends ListResourceBundle { "\ud1a0" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\uc77c", + "\uc6d4", + "\ud654", + "\uc218", + "\ubaa9", + "\uae08", + "\ud1a0", + } + }, { "AmPmMarkers", new String[] { "\uc624\uc804", // am marker diff --git a/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt.java b/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt.java index 6fdb6c10858..9e949ecf563 100644 --- a/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt.java +++ b/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt.java @@ -99,6 +99,23 @@ public class FormatData_lt extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "S", + "V", + "K", + "B", + "G", + "B", + "L", + "R", + "R", + "S", + "L", + "G", + "", + } + }, { "DayNames", new String[] { "Sekmadienis", // Sunday @@ -121,6 +138,28 @@ public class FormatData_lt extends ListResourceBundle { "\u0160t" // abb Saturday } }, + { "DayNarrows", + new String[] { + "S", + "P", + "A", + "T", + "K", + "P", + "\u0160", + } + }, + { "standalone.DayNarrows", + new String[] { + "S", + "P", + "A", + "T", + "K", + "P", + "\u0160", + } + }, { "Eras", new String[] { // era strings "pr.Kr.", diff --git a/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv.java b/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv.java index e1aadceb01b..ff9eb470d4b 100644 --- a/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv.java +++ b/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv.java @@ -121,6 +121,17 @@ public class FormatData_lv extends ListResourceBundle { "S" // abb Saturday } }, + { "DayNarrows", + new String[] { + "S", + "P", + "O", + "T", + "C", + "P", + "S", + } + }, { "Eras", new String[] { // era strings "pm\u0113", diff --git a/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk.java b/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk.java index ba42eeb0ae9..cd09d3ef1ee 100644 --- a/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk.java +++ b/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk.java @@ -104,6 +104,17 @@ public class FormatData_mk extends ListResourceBundle { "\u0441\u0430\u0431." // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u043d", + "\u043f", + "\u0432", + "\u0441", + "\u0447", + "\u043f", + "\u0441", + } + }, { "Eras", new String[] { // era strings "\u043f\u0440.\u043d.\u0435.", diff --git a/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms.java b/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms.java index e3936d86fe9..13a8d51dd1d 100644 --- a/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms.java +++ b/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms.java @@ -81,6 +81,23 @@ public class FormatData_ms extends ListResourceBundle { "", } }, + { "standalone.MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "O", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "Ahad", @@ -103,6 +120,28 @@ public class FormatData_ms extends ListResourceBundle { "Sab", } }, + { "DayNarrows", + new String[] { + "A", + "I", + "S", + "R", + "K", + "J", + "S", + } + }, + { "standalone.DayNarrows", + new String[] { + "A", + "I", + "S", + "R", + "K", + "J", + "S", + } + }, { "Eras", new String[] { "BCE", diff --git a/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt.java b/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt.java index 49751272506..4ef0957eba5 100644 --- a/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt.java +++ b/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt.java @@ -103,6 +103,17 @@ public class FormatData_mt extends ListResourceBundle { "Sib", } }, + { "DayNarrows", + new String[] { + "\u0126", + "T", + "T", + "E", + "\u0126", + "\u0120", + "S", + } + }, { "AmPmMarkers", new String[] { "QN", diff --git a/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl.java b/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl.java index 4d041dd46fd..78b937c2d64 100644 --- a/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl.java +++ b/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl.java @@ -104,6 +104,17 @@ public class FormatData_nl extends ListResourceBundle { "za" // abb Saturday } }, + { "DayNarrows", + new String[] { + "Z", + "M", + "D", + "W", + "D", + "V", + "Z", + } + }, { "Eras", new String[] { // era strings for GregorianCalendar "v. Chr.", diff --git a/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl.java b/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl.java index 3e52ed187da..824645ef0db 100644 --- a/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl.java +++ b/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl.java @@ -121,6 +121,17 @@ public class FormatData_pl extends ListResourceBundle { "So" // abb Saturday } }, + { "DayNarrows", + new String[] { + "N", + "P", + "W", + "\u015a", + "C", + "P", + "S", + } + }, { "Eras", new String[] { // era strings "p.n.e.", diff --git a/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java b/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java index e926701019a..4a0de29ad54 100644 --- a/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java +++ b/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java @@ -104,6 +104,17 @@ public class FormatData_pt extends ListResourceBundle { "S\u00e1b" // abb Saturday } }, + { "DayNarrows", + new String[] { + "D", + "S", + "T", + "Q", + "Q", + "S", + "S", + } + }, { "NumberElements", new String[] { ",", // decimal al separator diff --git a/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro.java b/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro.java index 49a0cb13e89..c28502c1072 100644 --- a/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro.java +++ b/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro.java @@ -82,6 +82,23 @@ public class FormatData_ro extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "I", + "F", + "M", + "A", + "M", + "I", + "I", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "duminic\u0103", // Sunday @@ -104,6 +121,29 @@ public class FormatData_ro extends ListResourceBundle { "S" // abb Saturday } }, + // commented out DayNarrows because most names are contributed. +// { "DayNarrows", +// new String[] { +// "D", +// "", +// "", +// "", +// "", +// "", +// "", +// } +// }, + { "standalone.DayNarrows", + new String[] { + "D", + "L", + "M", + "M", + "J", + "V", + "S", + } + }, { "Eras", new String[] { // era strings "d.C.", diff --git a/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru.java b/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru.java index 2eb144aee66..820bf53497f 100644 --- a/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru.java +++ b/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru.java @@ -138,6 +138,28 @@ public class FormatData_ru extends ListResourceBundle { "\u0421\u0431" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u0412", + "\u041f\u043d", + "\u0412\u0442", + "\u0421", + "\u0427", + "\u041f", + "\u0421", // contributed item in CLDR + } + }, + { "standalone.DayNarrows", + new String[] { + "\u0412", + "\u041f", + "\u0412", + "\u0421", + "\u0427", + "\u041f", + "\u0421", + } + }, { "Eras", new String[] { // era strings "\u0434\u043e \u043d.\u044d.", diff --git a/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk.java b/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk.java index 38787ad81b0..110985614a9 100644 --- a/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk.java +++ b/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk.java @@ -138,6 +138,17 @@ public class FormatData_sk extends ListResourceBundle { "So" // abb Saturday } }, + { "DayNarrows", + new String[] { + "N", + "P", + "U", + "S", + "\u0160", + "P", + "S", + } + }, { "Eras", new String[] { // era strings "pred n.l.", diff --git a/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl.java b/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl.java index 65be14ab2c6..34ce565af9c 100644 --- a/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl.java +++ b/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl.java @@ -121,6 +121,17 @@ public class FormatData_sl extends ListResourceBundle { "Sob" // abb Saturday } }, + { "DayNarrows", + new String[] { + "n", + "p", + "t", + "s", + "\u010d", + "p", + "s", + } + }, { "Eras", new String[] { // era strings "pr.n.\u0161.", diff --git a/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq.java b/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq.java index b7f4038cb9b..0984bb613b1 100644 --- a/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq.java +++ b/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq.java @@ -104,6 +104,17 @@ public class FormatData_sq extends ListResourceBundle { "Sht" // abb Saturday } }, + { "DayNarrows", + new String[] { + "D", + "H", + "M", + "M", + "E", + "P", + "S", + } + }, { "AmPmMarkers", new String[] { "PD", // am marker diff --git a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr.java b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr.java index fb96b66f60e..d331a8d9a3f 100644 --- a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr.java +++ b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr.java @@ -103,12 +103,35 @@ public class FormatData_sr extends ListResourceBundle { "\u0441\u0443\u0431", } }, + { "DayNarrows", + new String[] { + "\u043d", + "\u043f", + "\u0443", + "\u0441", + "\u0447", + "\u043f", + "\u0441", + } + }, { "Eras", new String[] { "\u043f. \u043d. \u0435.", "\u043d. \u0435", } }, + { "short.Eras", + new String[] { + "\u043f. \u043d. \u0435.", + "\u043d. \u0435.", + } + }, + { "narrow.Eras", + new String[] { + "\u043f.\u043d.\u0435.", + "\u043d.\u0435.", + } + }, { "NumberPatterns", new String[] { "#,##0.###", diff --git a/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv.java b/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv.java index a7aca447af8..7368a49c0ea 100644 --- a/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv.java +++ b/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv.java @@ -82,6 +82,23 @@ public class FormatData_sv extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "s\u00f6ndag", // Sunday @@ -104,12 +121,46 @@ public class FormatData_sv extends ListResourceBundle { "l\u00f6" // abb Saturday } }, + { "DayNarrows", + new String[] { + "S", + "M", + "T", + "O", + "T", + "F", + "L", + } + }, + { "standalone.DayNarrows", + new String[] { + "S", + "M", + "T", + "O", + "T", + "F", + "L", + } + }, + { "narrow.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, { "AmPmMarkers", new String[] { "fm", // am marker "em" // pm marker } }, + { "narrow.AmPmMarkers", + new String[] { + "f", + "e", + } + }, { "NumberElements", new String[] { ",", // decimal separator diff --git a/jdk/src/share/classes/sun/text/resources/th/FormatData_th.java b/jdk/src/share/classes/sun/text/resources/th/FormatData_th.java index 4313b905fb1..bec15d10191 100644 --- a/jdk/src/share/classes/sun/text/resources/th/FormatData_th.java +++ b/jdk/src/share/classes/sun/text/resources/th/FormatData_th.java @@ -99,6 +99,23 @@ public class FormatData_th extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "\u0e21.\u0e04.", + "\u0e01.\u0e1e.", + "\u0e21\u0e35.\u0e04.", + "\u0e40\u0e21.\u0e22.", + "\u0e1e.\u0e04.", + "\u0e21\u0e34.\u0e22.", + "\u0e01.\u0e04.", + "\u0e2a.\u0e04.", + "\u0e01.\u0e22.", + "\u0e15.\u0e04.", + "\u0e1e.\u0e22.", + "\u0e18.\u0e04.", + "", + } + }, { "DayNames", new String[] { "\u0e27\u0e31\u0e19\u0e2d\u0e32\u0e17\u0e34\u0e15\u0e22\u0e4c", // Sunday @@ -121,6 +138,17 @@ public class FormatData_th extends ListResourceBundle { "\u0e2a." // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u0e2d", + "\u0e08", + "\u0e2d", + "\u0e1e", + "\u0e1e", + "\u0e28", + "\u0e2a", + } + }, { "AmPmMarkers", new String[] { "\u0e01\u0e48\u0e2d\u0e19\u0e40\u0e17\u0e35\u0e48\u0e22\u0e07", // am marker @@ -145,6 +173,12 @@ public class FormatData_th extends ListResourceBundle { "\u0e04.\u0e28." } }, + { "narrow.Eras", + new String[] { + "\u0e01\u0e48\u0e2d\u0e19 \u0e04.\u0e28.", + "\u0e04.\u0e28.", + } + }, { "buddhist.TimePatterns", timePatterns }, diff --git a/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr.java b/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr.java index 9df7ac1e578..2be1b12f588 100644 --- a/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr.java +++ b/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr.java @@ -82,6 +82,23 @@ public class FormatData_tr extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "O", + "\u015e", + "M", + "N", + "M", + "H", + "T", + "A", + "E", + "E", + "K", + "A", + "", + } + }, { "DayNames", new String[] { "Pazar", // Sunday @@ -104,6 +121,17 @@ public class FormatData_tr extends ListResourceBundle { "Cmt" // abb Saturday } }, + { "DayNarrows", + new String[] { + "P", + "P", + "S", + "\u00c7", + "P", + "C", + "C", + } + }, { "NumberPatterns", new String[] { "#,##0.###;-#,##0.###", // decimal pattern diff --git a/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk.java b/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk.java index d9514e05137..7aa0e0c451b 100644 --- a/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk.java +++ b/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk.java @@ -138,6 +138,17 @@ public class FormatData_uk extends ListResourceBundle { "\u0441\u0431" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u041d", + "\u041f", + "\u0412", + "\u0421", + "\u0427", + "\u041f", + "\u0421", + } + }, { "Eras", new String[] { // era strings "\u0434\u043e \u043d.\u0435.", diff --git a/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi.java b/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi.java index c5e43eedea1..fd892d96606 100644 --- a/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi.java +++ b/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi.java @@ -106,6 +106,17 @@ public class FormatData_vi extends ListResourceBundle { "Th 7" // abb Saturday } }, + { "DayNarrows", + new String[] { + "CN", + "T2", + "T3", + "T4", + "T5", + "T6", + "T7", + } + }, { "AmPmMarkers", new String[] { "SA", // am marker diff --git a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh.java b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh.java index 57bf686d7f1..57dbe2a0c61 100644 --- a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh.java +++ b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh.java @@ -82,6 +82,23 @@ public class FormatData_zh extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthNarrows", + new String[] { + "1\u6708", + "2\u6708", + "3\u6708", + "4\u6708", + "5\u6708", + "6\u6708", + "7\u6708", + "8\u6708", + "9\u6708", + "10\u6708", + "11\u6708", + "12\u6708", + "", + } + }, { "DayNames", new String[] { "\u661f\u671f\u65e5", // Sunday @@ -104,6 +121,17 @@ public class FormatData_zh extends ListResourceBundle { "\u661f\u671f\u516d" // abb Saturday } }, + { "DayNarrows", + new String[] { + "\u65e5", + "\u4e00", + "\u4e8c", + "\u4e09", + "\u56db", + "\u4e94", + "\u516d", + } + }, { "AmPmMarkers", new String[] { "\u4e0a\u5348", // am marker diff --git a/jdk/src/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java b/jdk/src/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java index e8411346394..77f7b843d64 100644 --- a/jdk/src/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java +++ b/jdk/src/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java @@ -88,11 +88,6 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter { return null; } - @Override - public TimeZoneNameProvider getTimeZoneNameProvider() { - return null; - } - @Override public Locale[] getAvailableLocales() { Set all = createLanguageTagSet("All"); diff --git a/jdk/src/share/classes/sun/util/locale/provider/CalendarDataUtility.java b/jdk/src/share/classes/sun/util/locale/provider/CalendarDataUtility.java index e86e27234bd..f181c98d655 100644 --- a/jdk/src/share/classes/sun/util/locale/provider/CalendarDataUtility.java +++ b/jdk/src/share/classes/sun/util/locale/provider/CalendarDataUtility.java @@ -25,7 +25,6 @@ package sun.util.locale.provider; -import java.util.Calendar; import static java.util.Calendar.*; import java.util.Locale; import java.util.Map; diff --git a/jdk/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java b/jdk/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java index 1f262a8445a..20be38607f8 100644 --- a/jdk/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java +++ b/jdk/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java @@ -52,7 +52,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av @Override public String getDisplayName(String calendarType, int field, int value, int style, Locale locale) { String name = null; - String key = getKey(calendarType, field, style); + String key = getResourceKey(calendarType, field, style); if (key != null) { ResourceBundle rb = LocaleProviderAdapter.forType(type).getLocaleData().getDateFormatData(locale); if (rb.containsKey(key)) { @@ -64,9 +64,10 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av name = strings[value]; // If name is empty in standalone, try its `format' style. if (name.length() == 0 - && (style == SHORT_STANDALONE || style == LONG_STANDALONE)) { + && (style == SHORT_STANDALONE || style == LONG_STANDALONE + || style == NARROW_STANDALONE)) { name = getDisplayName(calendarType, field, value, - style == SHORT_STANDALONE ? SHORT_FORMAT : LONG_FORMAT, + getBaseStyle(style), locale); } } @@ -75,15 +76,17 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av return name; } + private static int[] REST_OF_STYLES = { + SHORT_STANDALONE, LONG_FORMAT, LONG_STANDALONE, + NARROW_FORMAT, NARROW_STANDALONE + }; @Override public Map getDisplayNames(String calendarType, int field, int style, Locale locale) { Map names; if (style == ALL_STYLES) { names = getDisplayNamesImpl(calendarType, field, SHORT_FORMAT, locale); - if (field != AM_PM) { - for (int st : new int[] { SHORT_STANDALONE, LONG_FORMAT, LONG_STANDALONE }) { - names.putAll(getDisplayNamesImpl(calendarType, field, st, locale)); - } + for (int st : REST_OF_STYLES) { + names.putAll(getDisplayNamesImpl(calendarType, field, st, locale)); } } else { // specific style @@ -94,26 +97,28 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av private Map getDisplayNamesImpl(String calendarType, int field, int style, Locale locale) { - String key = getKey(calendarType, field, style); + String key = getResourceKey(calendarType, field, style); Map map = new TreeMap<>(LengthBasedComparator.INSTANCE); if (key != null) { ResourceBundle rb = LocaleProviderAdapter.forType(type).getLocaleData().getDateFormatData(locale); if (rb.containsKey(key)) { String[] strings = rb.getStringArray(key); - if (field == YEAR) { - if (strings.length > 0) { - map.put(strings[0], 1); - } - } else { - int base = (field == DAY_OF_WEEK) ? 1 : 0; - for (int i = 0; i < strings.length; i++) { - String name = strings[i]; - // Ignore any empty string (some standalone month names - // are not defined) - if (name.length() == 0) { - continue; + if (!hasDuplicates(strings)) { + if (field == YEAR) { + if (strings.length > 0) { + map.put(strings[0], 1); + } + } else { + int base = (field == DAY_OF_WEEK) ? 1 : 0; + for (int i = 0; i < strings.length; i++) { + String name = strings[i]; + // Ignore any empty string (some standalone month names + // are not defined) + if (name.length() == 0) { + continue; + } + map.put(name, base + i); } - map.put(name, base + i); } } } @@ -121,6 +126,10 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av return map; } + private int getBaseStyle(int style) { + return style & ~(SHORT_STANDALONE - SHORT_FORMAT); + } + /** * Comparator implementation for TreeMap which iterates keys from longest * to shortest. @@ -180,55 +189,92 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av return langtags; } - private int getIntData(String key, Locale locale) { - ResourceBundle rb = LocaleProviderAdapter.forType(type).getLocaleData().getCalendarData(locale); - if (rb.containsKey(key)) { - String firstday = rb.getString(key); - return Integer.parseInt(firstday); + private boolean hasDuplicates(String[] strings) { + int len = strings.length; + for (int i = 0; i < len - 1; i++) { + String a = strings[i]; + if (a != null) { + for (int j = i + 1; j < len; j++) { + if (a.equals(strings[j])) { + return true; + } + } + } } - // Note that the base bundle of CLDR doesn't have the Calendar week parameters. - return 0; + return false; } - private String getKey(String type, int field, int style) { - boolean standalone = (style & 0x8000) != 0; - style &= ~0x8000; + private String getResourceKey(String type, int field, int style) { + int baseStyle = getBaseStyle(style); + boolean isStandalone = (style != baseStyle); if ("gregory".equals(type)) { type = null; } - + boolean isNarrow = (baseStyle == NARROW_FORMAT); StringBuilder key = new StringBuilder(); switch (field) { case ERA: if (type != null) { key.append(type).append('.'); } - if (style == SHORT) { - key.append("short."); + if (isNarrow) { + key.append("narrow."); + } else { + // JRE and CLDR use different resource key conventions + // due to historical reasons. (JRE DateFormatSymbols.getEras returns + // abbreviations while other getShort*() return abbreviations.) + if (this.type == LocaleProviderAdapter.Type.JRE) { + if (baseStyle == SHORT) { + key.append("short."); + } + } else { // CLDR + if (baseStyle == LONG) { + key.append("long."); + } + } } key.append("Eras"); break; case YEAR: - key.append(type).append(".FirstYear"); + if (!isNarrow) { + key.append(type).append(".FirstYear"); + } break; case MONTH: - if (standalone) { + if (isStandalone) { key.append("standalone."); } - key.append(style == SHORT ? "MonthAbbreviations" : "MonthNames"); + key.append("Month").append(toStyleName(baseStyle)); break; case DAY_OF_WEEK: - key.append(style == SHORT ? "DayAbbreviations" : "DayNames"); + // support standalone narrow day names + if (isStandalone && isNarrow) { + key.append("standalone."); + } + key.append("Day").append(toStyleName(baseStyle)); break; case AM_PM: + if (isNarrow) { + key.append("narrow."); + } key.append("AmPmMarkers"); break; } return key.length() > 0 ? key.toString() : null; } + + private String toStyleName(int baseStyle) { + switch (baseStyle) { + case SHORT: + return "Abbreviations"; + case NARROW_FORMAT: + return "Narrows"; + } + return "Names"; + } } diff --git a/jdk/src/share/classes/sun/util/locale/provider/LocaleResources.java b/jdk/src/share/classes/sun/util/locale/provider/LocaleResources.java index 16aae9ac423..ff389f61b35 100644 --- a/jdk/src/share/classes/sun/util/locale/provider/LocaleResources.java +++ b/jdk/src/share/classes/sun/util/locale/provider/LocaleResources.java @@ -46,7 +46,7 @@ import java.util.Locale; import java.util.ResourceBundle; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import sun.util.resources.OpenListResourceBundle; +import sun.util.resources.TimeZoneNamesBundle; /** * Central accessor to locale-dependent resources. @@ -67,13 +67,13 @@ public class LocaleResources { this.locale = locale; } - public OpenListResourceBundle getTimeZoneNames() { - OpenListResourceBundle tznames = (OpenListResourceBundle) cache.get("TimeZoneNames"); + public TimeZoneNamesBundle getTimeZoneNames() { + TimeZoneNamesBundle tznames = (TimeZoneNamesBundle) cache.get("TimeZoneNames"); if (tznames == null) { tznames = adapter.getLocaleData().getTimeZoneNames(locale); - OpenListResourceBundle olrb = (OpenListResourceBundle) cache.putIfAbsent("TimeZoneNames", tznames); - if (olrb != null) { - tznames = olrb; + TimeZoneNamesBundle tznb = (TimeZoneNamesBundle) cache.putIfAbsent("TimeZoneNames", tznames); + if (tznb != null) { + tznames = tznb; } } return tznames; diff --git a/jdk/src/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java b/jdk/src/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java index 15de9f52283..59de0e2a629 100644 --- a/jdk/src/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java +++ b/jdk/src/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java @@ -604,5 +604,12 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { assert tznp != null; return tznp.getDisplayName(ID, daylight, style, locale); } + + @Override + public String getGenericDisplayName(String ID, int style, Locale locale) { + TimeZoneNameProvider tznp = getImpl(locale); + assert tznp != null; + return tznp.getGenericDisplayName(ID, style, locale); + } } } diff --git a/jdk/src/share/classes/sun/util/locale/provider/TimeZoneNameProviderImpl.java b/jdk/src/share/classes/sun/util/locale/provider/TimeZoneNameProviderImpl.java index ff092861824..28fd7af5a90 100644 --- a/jdk/src/share/classes/sun/util/locale/provider/TimeZoneNameProviderImpl.java +++ b/jdk/src/share/classes/sun/util/locale/provider/TimeZoneNameProviderImpl.java @@ -25,11 +25,14 @@ package sun.util.locale.provider; +import java.util.LinkedHashSet; import java.util.Locale; -import java.util.ResourceBundle; +import java.util.Map; import java.util.Set; import java.util.TimeZone; import java.util.spi.TimeZoneNameProvider; +import sun.util.calendar.ZoneInfo; +import sun.util.resources.TimeZoneNamesBundle; /** * Concrete implementation of the @@ -96,21 +99,67 @@ public class TimeZoneNameProviderImpl extends TimeZoneNameProvider { */ @Override public String getDisplayName(String id, boolean daylight, int style, Locale locale) { + String[] names = getDisplayNameArray(id, 5, locale); + if (names != null) { + int index = daylight ? 3 : 1; + if (style == TimeZone.SHORT) { + index++; + } + return names[index]; + } + return null; + } + + @Override + public String getGenericDisplayName(String id, int style, Locale locale) { + String[] names = getDisplayNameArray(id, 7, locale); + if (names != null && names.length >= 7) { + return names[(style == TimeZone.LONG) ? 5 : 6]; + } + return null; + } + + private String[] getDisplayNameArray(String id, int n, Locale locale) { if (id == null || locale == null) { throw new NullPointerException(); } - LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); - ResourceBundle rb = adapter.getLocaleResources(locale).getTimeZoneNames(); - if (rb.containsKey(id)) { - String[] names = rb.getStringArray(id); - int index = daylight ? 3 : 1; - if (style == TimeZone.SHORT) { - index++; - } - return names[index]; - } + TimeZoneNamesBundle rb = adapter.getLocaleResources(locale).getTimeZoneNames(); + return rb.containsKey(id) ? rb.getStringArray(id, n) : null; + } - return null; + /** + * Returns a String[][] as the DateFormatSymbols.getZoneStrings() value for + * the given locale. This method is package private. + * + * @param locale a Locale for time zone names + * @return an array of time zone names arrays + */ + String[][] getZoneStrings(Locale locale) { + LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); + TimeZoneNamesBundle rb = adapter.getLocaleResources(locale).getTimeZoneNames(); + Set keyset = rb.keySet(); + // Use a LinkedHashSet to preseve the order + Set value = new LinkedHashSet<>(); + for (String key : keyset) { + value.add(rb.getStringArray(key)); + } + + // Add aliases data for CLDR + if (type == LocaleProviderAdapter.Type.CLDR) { + // Note: TimeZoneNamesBundle creates a String[] on each getStringArray call. + Map aliases = ZoneInfo.getAliasTable(); + for (String alias : aliases.keySet()) { + if (!keyset.contains(alias)) { + String tzid = aliases.get(alias); + if (keyset.contains(tzid)) { + String[] val = rb.getStringArray(tzid); + val[0] = alias; + value.add(val); + } + } + } + } + return value.toArray(new String[0][]); } } diff --git a/jdk/src/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java b/jdk/src/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java index c28b0cb65c7..a8e09a0d6cf 100644 --- a/jdk/src/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java +++ b/jdk/src/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java @@ -26,28 +26,28 @@ package sun.util.locale.provider; import java.lang.ref.SoftReference; -import java.util.Enumeration; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.spi.TimeZoneNameProvider; import sun.util.calendar.ZoneInfo; import sun.util.resources.OpenListResourceBundle; +import sun.util.resources.TimeZoneNamesBundle; /** * Utility class that deals with the localized time zone names * * @author Naoto Sato + * @author Masayoshi Okutsu */ public final class TimeZoneNameUtility { /** * cache to hold time zone resource bundles. Keyed by Locale */ - private static ConcurrentHashMap> cachedBundles = + private static ConcurrentHashMap> cachedBundles = new ConcurrentHashMap<>(); /** @@ -73,15 +73,19 @@ public final class TimeZoneNameUtility { } private static String[][] loadZoneStrings(Locale locale) { + // If the provider is a TimeZoneNameProviderImpl, call its getZoneStrings + // in order to avoid per-ID retrieval. + LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(TimeZoneNameProvider.class, locale); + TimeZoneNameProvider provider = adapter.getTimeZoneNameProvider(); + if (provider instanceof TimeZoneNameProviderImpl) { + return ((TimeZoneNameProviderImpl)provider).getZoneStrings(locale); + } + + // Performs per-ID retrieval. List zones = new LinkedList<>(); OpenListResourceBundle rb = getBundle(locale); - Enumeration keys = rb.getKeys(); - String[] names; - - while(keys.hasMoreElements()) { - String key = keys.nextElement(); - - names = retrieveDisplayNames(rb, key, locale); + for (String key : rb.keySet()) { + String[] names = retrieveDisplayNamesImpl(key, locale); if (names != null) { zones.add(names); } @@ -95,24 +99,50 @@ public final class TimeZoneNameUtility { * Retrieve display names for a time zone ID. */ public static String[] retrieveDisplayNames(String id, Locale locale) { - OpenListResourceBundle rb = getBundle(locale); - return retrieveDisplayNames(rb, id, locale); - } - - private static String[] retrieveDisplayNames(OpenListResourceBundle rb, - String id, Locale locale) { if (id == null || locale == null) { throw new NullPointerException(); } - - LocaleServiceProviderPool pool = - LocaleServiceProviderPool.getPool(TimeZoneNameProvider.class); - return pool.getLocalizedObject(TimeZoneNameGetter.INSTANCE, locale, id); + return retrieveDisplayNamesImpl(id, locale); } - private static OpenListResourceBundle getBundle(Locale locale) { - OpenListResourceBundle rb; - SoftReference data = cachedBundles.get(locale); + /** + * Retrieves a generic time zone display name for a time zone ID. + * + * @param id time zone ID + * @param style TimeZone.LONG or TimeZone.SHORT + * @param locale desired Locale + * @return the requested generic time zone display name, or null if not found. + */ + public static String retrieveGenericDisplayName(String id, int style, Locale locale) { + LocaleServiceProviderPool pool = + LocaleServiceProviderPool.getPool(TimeZoneNameProvider.class); + return pool.getLocalizedObject(TimeZoneNameGetter.INSTANCE, locale, "generic", style, id); + } + + /** + * Retrieves a standard or daylight-saving time name for the given time zone ID. + * + * @param id time zone ID + * @param daylight true for a daylight saving time name, or false for a standard time name + * @param style TimeZone.LONG or TimeZone.SHORT + * @param locale desired Locale + * @return the requested time zone name, or null if not found. + */ + public static String retrieveDisplayName(String id, boolean daylight, int style, Locale locale) { + LocaleServiceProviderPool pool = + LocaleServiceProviderPool.getPool(TimeZoneNameProvider.class); + return pool.getLocalizedObject(TimeZoneNameGetter.INSTANCE, locale, daylight ? "dst" : "std", style, id); + } + + private static String[] retrieveDisplayNamesImpl(String id, Locale locale) { + LocaleServiceProviderPool pool = + LocaleServiceProviderPool.getPool(TimeZoneNameProvider.class); + return pool.getLocalizedObject(TimeZoneNameArrayGetter.INSTANCE, locale, id); + } + + private static TimeZoneNamesBundle getBundle(Locale locale) { + TimeZoneNamesBundle rb; + SoftReference data = cachedBundles.get(locale); if (data == null || ((rb = data.get()) == null)) { rb = LocaleProviderAdapter.forJRE().getLocaleData().getTimeZoneNames(locale); @@ -127,19 +157,18 @@ public final class TimeZoneNameUtility { * Obtains a localized time zone strings from a TimeZoneNameProvider * implementation. */ - private static class TimeZoneNameGetter + private static class TimeZoneNameArrayGetter implements LocaleServiceProviderPool.LocalizedObjectGetter{ - private static final TimeZoneNameGetter INSTANCE = - new TimeZoneNameGetter(); + private static final TimeZoneNameArrayGetter INSTANCE = + new TimeZoneNameArrayGetter(); @Override public String[] getObject(TimeZoneNameProvider timeZoneNameProvider, - Locale locale, - String requestID, - Object... params) { + Locale locale, + String requestID, + Object... params) { assert params.length == 0; - String queryID = requestID; // First, try to get names with the request ID String[] names = buildZoneStrings(timeZoneNameProvider, locale, requestID); @@ -150,21 +179,15 @@ public final class TimeZoneNameUtility { if (aliases != null) { // Check whether this id is an alias, if so, // look for the standard id. - if (aliases.containsKey(queryID)) { - String prevID = queryID; - while ((queryID = aliases.get(queryID)) != null) { - prevID = queryID; - } - queryID = prevID; + String canonicalID = aliases.get(requestID); + if (canonicalID != null) { + names = buildZoneStrings(timeZoneNameProvider, locale, canonicalID); } - - names = buildZoneStrings(timeZoneNameProvider, locale, queryID); - if (names == null) { // There may be a case that a standard id has become an // alias. so, check the aliases backward. names = examineAliases(timeZoneNameProvider, locale, - queryID, aliases, aliases.entrySet()); + canonicalID == null ? requestID : canonicalID, aliases); } } } @@ -178,20 +201,18 @@ public final class TimeZoneNameUtility { private static String[] examineAliases(TimeZoneNameProvider tznp, Locale locale, String id, - Map aliases, - Set> aliasesSet) { + Map aliases) { if (aliases.containsValue(id)) { - for (Map.Entry entry : aliasesSet) { + for (Map.Entry entry : aliases.entrySet()) { if (entry.getValue().equals(id)) { String alias = entry.getKey(); String[] names = buildZoneStrings(tznp, locale, alias); if (names != null) { return names; - } else { - names = examineAliases(tznp, locale, alias, aliases, aliasesSet); - if (names != null) { - return names; - } + } + names = examineAliases(tznp, locale, alias, aliases); + if (names != null) { + return names; } } } @@ -201,7 +222,7 @@ public final class TimeZoneNameUtility { } private static String[] buildZoneStrings(TimeZoneNameProvider tznp, - Locale locale, String id) { + Locale locale, String id) { String[] names = new String[5]; for (int i = 1; i <= 4; i ++) { @@ -220,6 +241,77 @@ public final class TimeZoneNameUtility { } } + private static class TimeZoneNameGetter + implements LocaleServiceProviderPool.LocalizedObjectGetter { + private static final TimeZoneNameGetter INSTANCE = + new TimeZoneNameGetter(); + + @Override + public String getObject(TimeZoneNameProvider timeZoneNameProvider, + Locale locale, + String requestID, + Object... params) { + assert params.length == 2; + int style = (int) params[0]; + String tzid = (String) params[1]; + String value = getName(timeZoneNameProvider, locale, requestID, style, tzid); + if (value == null) { + Map aliases = ZoneInfo.getAliasTable(); + if (aliases != null) { + String canonicalID = aliases.get(tzid); + if (canonicalID != null) { + value = getName(timeZoneNameProvider, locale, requestID, style, canonicalID); + } + if (value == null) { + value = examineAliases(timeZoneNameProvider, locale, requestID, + canonicalID != null ? canonicalID : tzid, style, aliases); + } + } + } + + return value; + } + + private static String examineAliases(TimeZoneNameProvider tznp, Locale locale, + String requestID, String tzid, int style, + Map aliases) { + if (aliases.containsValue(tzid)) { + for (Map.Entry entry : aliases.entrySet()) { + if (entry.getValue().equals(tzid)) { + String alias = entry.getKey(); + String name = getName(tznp, locale, requestID, style, alias); + if (name != null) { + return name; + } + name = examineAliases(tznp, locale, requestID, alias, style, aliases); + if (name != null) { + return name; + } + } + } + } + return null; + } + + private static String getName(TimeZoneNameProvider timeZoneNameProvider, + Locale locale, String requestID, int style, String tzid) { + String value = null; + switch (requestID) { + case "std": + value = timeZoneNameProvider.getDisplayName(tzid, false, style, locale); + break; + case "dst": + value = timeZoneNameProvider.getDisplayName(tzid, true, style, locale); + break; + case "generic": + value = timeZoneNameProvider.getGenericDisplayName(tzid, style, locale); + break; + } + return value; + } + } + // No instantiation private TimeZoneNameUtility() { } diff --git a/jdk/src/share/classes/sun/util/resources/LocaleData.java b/jdk/src/share/classes/sun/util/resources/LocaleData.java index 4570406f2a8..9a7a7c40119 100644 --- a/jdk/src/share/classes/sun/util/resources/LocaleData.java +++ b/jdk/src/share/classes/sun/util/resources/LocaleData.java @@ -46,9 +46,9 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.ResourceBundle; +import sun.util.locale.provider.LocaleDataMetaInfo; import sun.util.locale.provider.LocaleProviderAdapter; import static sun.util.locale.provider.LocaleProviderAdapter.Type.JRE; -import sun.util.locale.provider.LocaleDataMetaInfo; /** * Provides information about and access to resource bundles in the @@ -94,8 +94,8 @@ public class LocaleData { * Gets a time zone names resource bundle, using privileges * to allow accessing a sun.* package. */ - public OpenListResourceBundle getTimeZoneNames(Locale locale) { - return (OpenListResourceBundle) getBundle(type.getUtilResourcesPackage() + ".TimeZoneNames", locale); + public TimeZoneNamesBundle getTimeZoneNames(Locale locale) { + return (TimeZoneNamesBundle) getBundle(type.getUtilResourcesPackage() + ".TimeZoneNames", locale); } /** @@ -158,30 +158,33 @@ public class LocaleData { /* Get the locale string list from LocaleDataMetaInfo class. */ String localeString = LocaleDataMetaInfo.getSupportedLocaleString(baseName); - if (localeString == null || localeString.length() == 0) { - return candidates; - } - - for (Iterator l = candidates.iterator(); l.hasNext(); ) { - Locale loc = l.next(); - String lstr; - if (loc.getScript().length() > 0) { - lstr = loc.toLanguageTag().replace('-', '_'); - } else { - lstr = loc.toString(); - int idx = lstr.indexOf("_#"); - if (idx >= 0) { - lstr = lstr.substring(0, idx); + if (localeString != null && localeString.length() != 0) { + for (Iterator l = candidates.iterator(); l.hasNext();) { + Locale loc = l.next(); + String lstr; + if (loc.getScript().length() > 0) { + lstr = loc.toLanguageTag().replace('-', '_'); + } else { + lstr = loc.toString(); + int idx = lstr.indexOf("_#"); + if (idx >= 0) { + lstr = lstr.substring(0, idx); + } + } + /* Every locale string in the locale string list returned from + the above getSupportedLocaleString is enclosed + within two white spaces so that we could check some locale + such as "en". + */ + if (lstr.length() != 0 && localeString.indexOf(" " + lstr + " ") == -1) { + l.remove(); } } - /* Every locale string in the locale string list returned from - the above getSupportedLocaleString is enclosed - within two white spaces so that we could check some locale - such as "en". - */ - if (lstr.length() != 0 && localeString.indexOf(" " + lstr + " ") == -1) { - l.remove(); - } + } + // Force fallback to Locale.ENGLISH for CLDR time zone names support + if (locale.getLanguage() != "en" + && baseName.contains(CLDR) && baseName.endsWith("TimeZoneNames")) { + candidates.add(candidates.size() - 1, Locale.ENGLISH); } return candidates; } diff --git a/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java b/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java index e0551931d19..494e5c89c08 100644 --- a/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java +++ b/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java @@ -67,6 +67,7 @@ public abstract class OpenListResourceBundle extends ResourceBundle { } // Implements java.util.ResourceBundle.handleGetObject; inherits javadoc specification. + @Override public Object handleGetObject(String key) { if (key == null) { throw new NullPointerException(); @@ -79,6 +80,7 @@ public abstract class OpenListResourceBundle extends ResourceBundle { /** * Implementation of ResourceBundle.getKeys. */ + @Override public Enumeration getKeys() { ResourceBundle parent = this.parent; return new ResourceBundleEnumeration(handleGetKeys(), @@ -86,7 +88,8 @@ public abstract class OpenListResourceBundle extends ResourceBundle { } /** - * Returns a set of keys provided in this resource bundle + * Returns a set of keys provided in this resource bundle, + * including no parents. */ public Set handleGetKeys() { loadLookupTablesIfNecessary(); @@ -99,7 +102,7 @@ public abstract class OpenListResourceBundle extends ResourceBundle { if (keyset != null) { return keyset; } - Set ks = new HashSet<>(); + Set ks = createSet(); ks.addAll(handleGetKeys()); if (parent != null) { ks.addAll(parent.keySet()); @@ -112,13 +115,6 @@ public abstract class OpenListResourceBundle extends ResourceBundle { return keyset; } - /** - * Returns the parent bundle - */ - public OpenListResourceBundle getParent() { - return (OpenListResourceBundle)parent; - } - /** * See ListResourceBundle class description. */ @@ -160,10 +156,14 @@ public abstract class OpenListResourceBundle extends ResourceBundle { * Lets subclasses provide specialized Map implementations. * Default uses HashMap. */ - protected Map createMap(int size) { + protected Map createMap(int size) { return new HashMap<>(size); } + protected Set createSet() { + return new HashSet<>(); + } + private volatile Map lookup = null; private volatile Set keyset; } diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java index 5b2931b7b62..59af1d215bf 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java @@ -43,160 +43,238 @@ package sun.util.resources; public final class TimeZoneNames extends TimeZoneNamesBundle { protected final Object[][] getContents() { + // Note: generic names came from CLDR with some adjustments. String ACT[] = new String[] {"Acre Time", "ACT", - "Acre Summer Time", "ACST"}; + "Acre Summer Time", "ACST", + "Acre Time", "ACT"}; String ADELAIDE[] = new String[] {"Central Standard Time (South Australia)", "CST", - "Central Summer Time (South Australia)", "CST"}; + "Central Summer Time (South Australia)", "CST", + "Central Time (South Australia)", "CT"}; String AGT[] = new String[] {"Argentine Time", "ART", - "Argentine Summer Time", "ARST"}; + "Argentine Summer Time", "ARST", + "Argentine Time", "ART"}; String AKST[] = new String[] {"Alaska Standard Time", "AKST", - "Alaska Daylight Time", "AKDT"}; + "Alaska Daylight Time", "AKDT", + "Alaska Time", "AKT"}; String AMT[] = new String[] {"Amazon Time", "AMT", - "Amazon Summer Time", "AMST"}; + "Amazon Summer Time", "AMST", + "Amazon Time", "AMT"}; String ARAST[] = new String[] {"Arabia Standard Time", "AST", - "Arabia Daylight Time", "ADT"}; + "Arabia Daylight Time", "ADT", + "Arabia Time", "AT"}; String ARMT[] = new String[] {"Armenia Time", "AMT", - "Armenia Summer Time", "AMST"}; + "Armenia Summer Time", "AMST", + "Armenia Time", "AMT"}; String AST[] = new String[] {"Atlantic Standard Time", "AST", - "Atlantic Daylight Time", "ADT"}; + "Atlantic Daylight Time", "ADT", + "Atlantic Time", "AT"}; String BDT[] = new String[] {"Bangladesh Time", "BDT", - "Bangladesh Summer Time", "BDST"}; + "Bangladesh Summer Time", "BDST", + "Bangladesh Time", "BDT"}; String BRISBANE[] = new String[] {"Eastern Standard Time (Queensland)", "EST", - "Eastern Summer Time (Queensland)", "EST"}; + "Eastern Summer Time (Queensland)", "EST", + "Eastern Time (Queensland)", "ET"}; String BROKEN_HILL[] = new String[] {"Central Standard Time (South Australia/New South Wales)", "CST", - "Central Summer Time (South Australia/New South Wales)", "CST"}; + "Central Summer Time (South Australia/New South Wales)", "CST", + "Central Time (South Australia/New South Wales)", "CT"}; String BRT[] = new String[] {"Brasilia Time", "BRT", - "Brasilia Summer Time", "BRST"}; + "Brasilia Summer Time", "BRST", + "Brasilia Time", "BRT"}; String BTT[] = new String[] {"Bhutan Time", "BTT", - "Bhutan Summer Time", "BTST"}; + "Bhutan Summer Time", "BTST", + "Bhutan Time", "BTT"}; String CAT[] = new String[] {"Central African Time", "CAT", - "Central African Summer Time", "CAST"}; + "Central African Summer Time", "CAST", + "Central Africa Time", "CAT"}; String CET[] = new String[] {"Central European Time", "CET", - "Central European Summer Time", "CEST"}; + "Central European Summer Time", "CEST", + "Central European Time", "CET"}; String CHAST[] = new String[] {"Chatham Standard Time", "CHAST", - "Chatham Daylight Time", "CHADT"}; + "Chatham Daylight Time", "CHADT", + "Chatham Time", "CHAT"}; String CHUT[] = new String[] {"Chuuk Time", "CHUT", - "Chuuk Summer Time", "CHUST"}; + "Chuuk Summer Time", "CHUST", + "Chuuk Time", "CHUT"}; String CIT[] = new String[] {"Central Indonesia Time", "CIT", - "Central Indonesia Summer Time", "CIST"}; + "Central Indonesia Summer Time", "CIST", + "Central Indonesia Time", "CIT"}; String CLT[] = new String[] {"Chile Time", "CLT", - "Chile Summer Time", "CLST"}; + "Chile Summer Time", "CLST", + "Chile Time", "CLT"}; String CST[] = new String[] {"Central Standard Time", "CST", - "Central Daylight Time", "CDT"}; + "Central Daylight Time", "CDT", + "Central Time", "CT"}; String CTT[] = new String[] {"China Standard Time", "CST", - "China Daylight Time", "CDT"}; + "China Daylight Time", "CDT", + "China Time", "CT"}; String CUBA[] = new String[] {"Cuba Standard Time", "CST", - "Cuba Daylight Time", "CDT"}; + "Cuba Daylight Time", "CDT", + "Cuba Time", "CT"}; String DARWIN[] = new String[] {"Central Standard Time (Northern Territory)", "CST", - "Central Summer Time (Northern Territory)", "CST"}; + "Central Summer Time (Northern Territory)", "CST", + "Central Time (Northern Territory)", "CT"}; String DUBLIN[] = new String[] {"Greenwich Mean Time", "GMT", - "Irish Summer Time", "IST"}; + "Irish Summer Time", "IST", + "Irish Time", "IT"}; String EAT[] = new String[] {"Eastern African Time", "EAT", - "Eastern African Summer Time", "EAST"}; + "Eastern African Summer Time", "EAST", + "Eastern Africa Time", "EAT"}; String EASTER[] = new String[] {"Easter Is. Time", "EAST", - "Easter Is. Summer Time", "EASST"}; + "Easter Is. Summer Time", "EASST", + "Easter Is. Time", "EAST"}; String EET[] = new String[] {"Eastern European Time", "EET", - "Eastern European Summer Time", "EEST"}; + "Eastern European Summer Time", "EEST", + "Eastern European Time", "EET"}; String EGT[] = new String[] {"Eastern Greenland Time", "EGT", - "Eastern Greenland Summer Time", "EGST"}; + "Eastern Greenland Summer Time", "EGST", + "Eastern Greenland Time", "EGT"}; String EST[] = new String[] {"Eastern Standard Time", "EST", - "Eastern Daylight Time", "EDT"}; + "Eastern Daylight Time", "EDT", + "Eastern Time", "ET"}; String EST_NSW[] = new String[] {"Eastern Standard Time (New South Wales)", "EST", - "Eastern Summer Time (New South Wales)", "EST"}; + "Eastern Summer Time (New South Wales)", "EST", + "Eastern Time (New South Wales)", "ET"}; String FET[] = new String[] {"Further-eastern European Time", "FET", - "Further-eastern European Summer Time", "FEST"}; + "Further-eastern European Summer Time", "FEST", + "Further-eastern European Time", "FET"}; String GHMT[] = new String[] {"Ghana Mean Time", "GMT", - "Ghana Summer Time", "GHST"}; + "Ghana Summer Time", "GHST", + "Ghana Mean Time", "GMT"}; String GAMBIER[] = new String[] {"Gambier Time", "GAMT", - "Gambier Summer Time", "GAMST"}; + "Gambier Summer Time", "GAMST", + "Gambier Time", "GAMT"}; String GMT[] = new String[] {"Greenwich Mean Time", "GMT", + "Greenwich Mean Time", "GMT", "Greenwich Mean Time", "GMT"}; String GMTBST[] = new String[] {"Greenwich Mean Time", "GMT", - "British Summer Time", "BST"}; + "British Summer Time", "BST", + "British Time", "BT"}; String GST[] = new String[] {"Gulf Standard Time", "GST", - "Gulf Daylight Time", "GDT"}; + "Gulf Daylight Time", "GDT", + "Gulf Time", "GT"}; String HAST[] = new String[] {"Hawaii-Aleutian Standard Time", "HAST", - "Hawaii-Aleutian Daylight Time", "HADT"}; + "Hawaii-Aleutian Daylight Time", "HADT", + "Hawaii-Aleutian Time", "HAT"}; String HKT[] = new String[] {"Hong Kong Time", "HKT", - "Hong Kong Summer Time", "HKST"}; + "Hong Kong Summer Time", "HKST", + "Hong Kong Time", "HKT"}; String HST[] = new String[] {"Hawaii Standard Time", "HST", - "Hawaii Daylight Time", "HDT"}; + "Hawaii Daylight Time", "HDT", + "Hawaii Time", "HT"}; String ICT[] = new String[] {"Indochina Time", "ICT", - "Indochina Summer Time", "ICST"}; + "Indochina Summer Time", "ICST", + "Indochina Time", "ICT"}; String IRT[] = new String[] {"Iran Standard Time", "IRST", - "Iran Daylight Time", "IRDT"}; + "Iran Daylight Time", "IRDT", + "Iran Time", "IRT"}; String ISRAEL[] = new String[] {"Israel Standard Time", "IST", - "Israel Daylight Time", "IDT"}; + "Israel Daylight Time", "IDT", + "Israel Time", "IT"}; String IST[] = new String[] {"India Standard Time", "IST", - "India Daylight Time", "IDT"}; + "India Daylight Time", "IDT", + "India Time", "IT"}; String JST[] = new String[] {"Japan Standard Time", "JST", - "Japan Daylight Time", "JDT"}; + "Japan Daylight Time", "JDT", + "Japan Time", "JT"}; String KST[] = new String[] {"Korea Standard Time", "KST", - "Korea Daylight Time", "KDT"}; + "Korea Daylight Time", "KDT", + "Korea Time", "KT"}; String LORD_HOWE[] = new String[] {"Lord Howe Standard Time", "LHST", - "Lord Howe Summer Time", "LHST"}; + "Lord Howe Summer Time", "LHST", + "Lord Howe Time", "LHT"}; String MHT[] = new String[] {"Marshall Islands Time", "MHT", - "Marshall Islands Summer Time", "MHST"}; + "Marshall Islands Summer Time", "MHST", + "Marshall Islands Time", "MHT"}; String MSK[] = new String[] {"Moscow Standard Time", "MSK", - "Moscow Daylight Time", "MSD"}; + "Moscow Daylight Time", "MSD", + "Moscow Time", "MT"}; String MST[] = new String[] {"Mountain Standard Time", "MST", - "Mountain Daylight Time", "MDT"}; + "Mountain Daylight Time", "MDT", + "Mountain Time", "MT"}; String MYT[] = new String[] {"Malaysia Time", "MYT", - "Malaysia Summer Time", "MYST"}; + "Malaysia Summer Time", "MYST", + "Malaysia Time", "MYT"}; String NORONHA[] = new String[] {"Fernando de Noronha Time", "FNT", - "Fernando de Noronha Summer Time", "FNST"}; + "Fernando de Noronha Summer Time", "FNST", + "Fernando de Noronha Time", "FNT"}; String NOVT[] = new String[] {"Novosibirsk Time", "NOVT", - "Novosibirsk Summer Time", "NOVST"}; + "Novosibirsk Summer Time", "NOVST", + "Novosibirsk Time", "NOVT"}; String NPT[] = new String[] {"Nepal Time", "NPT", - "Nepal Summer Time", "NPST"}; + "Nepal Summer Time", "NPST", + "Nepal Time", "NPT"}; String NST[] = new String[] {"Newfoundland Standard Time", "NST", - "Newfoundland Daylight Time", "NDT"}; + "Newfoundland Daylight Time", "NDT", + "Newfoundland Time", "NT"}; String NZST[] = new String[] {"New Zealand Standard Time", "NZST", - "New Zealand Daylight Time", "NZDT"}; + "New Zealand Daylight Time", "NZDT", + "New Zealand Time", "NZT"}; String PITCAIRN[] = new String[] {"Pitcairn Standard Time", "PST", - "Pitcairn Daylight Time", "PDT"}; + "Pitcairn Daylight Time", "PDT", + "Pitcairn Time", "PT"}; String PKT[] = new String[] {"Pakistan Time", "PKT", - "Pakistan Summer Time", "PKST"}; + "Pakistan Summer Time", "PKST", + "Pakistan Time", "PKT"}; String PONT[] = new String[] {"Pohnpei Time", "PONT", - "Pohnpei Summer Time", "PONST"}; + "Pohnpei Summer Time", "PONST", + "Ponape Time", "PONT"}; String PST[] = new String[] {"Pacific Standard Time", "PST", - "Pacific Daylight Time", "PDT"}; + "Pacific Daylight Time", "PDT", + "Pacific Time", "PT"}; String SAST[] = new String[] {"South Africa Standard Time", "SAST", - "South Africa Summer Time", "SAST"}; + "South Africa Summer Time", "SAST", + "South Africa Time", "SAT"}; String SBT[] = new String[] {"Solomon Is. Time", "SBT", - "Solomon Is. Summer Time", "SBST"}; + "Solomon Is. Summer Time", "SBST", + "Solomon Is. Time", "SBT"}; String SGT[] = new String[] {"Singapore Time", "SGT", - "Singapore Summer Time", "SGST"}; + "Singapore Summer Time", "SGST", + "Singapore Time", "SGT"}; String SLST[] = new String[] {"Greenwich Mean Time", "GMT", - "Sierra Leone Summer Time", "SLST"}; + "Sierra Leone Summer Time", "SLST", + "Sierra Leone Time", "SLT"}; String TASMANIA[] = new String[] {"Eastern Standard Time (Tasmania)", "EST", - "Eastern Summer Time (Tasmania)", "EST"}; + "Eastern Summer Time (Tasmania)", "EST", + "Eastern Time (Tasmania)", "ET"}; String TMT[] = new String[] {"Turkmenistan Time", "TMT", - "Turkmenistan Summer Time", "TMST"}; + "Turkmenistan Summer Time", "TMST", + "Turkmenistan Time", "TMT"}; String ULAT[]= new String[] {"Ulaanbaatar Time", "ULAT", - "Ulaanbaatar Summer Time", "ULAST"}; + "Ulaanbaatar Summer Time", "ULAST", + "Ulaanbaatar Time", "ULAT"}; String WART[] = new String[] {"Western Argentine Time", "WART", - "Western Argentine Summer Time", "WARST"}; + "Western Argentine Summer Time", "WARST", + "Western Argentine Time", "WART"}; String WAT[] = new String[] {"Western African Time", "WAT", - "Western African Summer Time", "WAST"}; + "Western African Summer Time", "WAST", + "Western African Time", "WAT"}; String WET[] = new String[] {"Western European Time", "WET", - "Western European Summer Time", "WEST"}; + "Western European Summer Time", "WEST", + "Western European Time", "WET"}; String WIT[] = new String[] {"West Indonesia Time", "WIT", - "West Indonesia Summer Time", "WIST"}; + "West Indonesia Summer Time", "WIST", + "West Indonesia Time", "WIT"}; String WST_AUS[] = new String[] {"Western Standard Time (Australia)", "WST", - "Western Summer Time (Australia)", "WST"}; + "Western Summer Time (Australia)", "WST", + "Western Time (Australia)", "WT"}; String SAMOA[] = new String[] {"Samoa Standard Time", "SST", - "Samoa Daylight Time", "SDT"}; + "Samoa Daylight Time", "SDT", + "Samoa Time", "ST"}; String WST_SAMOA[] = new String[] {"West Samoa Time", "WST", - "West Samoa Daylight Time", "WSDT"}; + "West Samoa Daylight Time", "WSDT", + "West Samoa Time", "WST"}; String ChST[] = new String[] {"Chamorro Standard Time", "ChST", - "Chamorro Daylight Time", "ChDT"}; + "Chamorro Daylight Time", "ChDT", + "Chamorro Time", "ChT"}; String VICTORIA[] = new String[] {"Eastern Standard Time (Victoria)", "EST", - "Eastern Summer Time (Victoria)", "EST"}; + "Eastern Summer Time (Victoria)", "EST", + "Eastern Time (Victoria)", "ET"}; String UTC[] = new String[] {"Coordinated Universal Time", "UTC", + "Coordinated Universal Time", "UTC", "Coordinated Universal Time", "UTC"}; String UZT[] = new String[] {"Uzbekistan Time", "UZT", - "Uzbekistan Summer Time", "UZST"}; + "Uzbekistan Summer Time", "UZST", + "Uzbekistan Time", "UZT"}; return new Object[][] { {"America/Los_Angeles", PST}, @@ -309,7 +387,8 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Argentina/Ushuaia", AGT}, {"America/Aruba", AST}, {"America/Asuncion", new String[] {"Paraguay Time", "PYT", - "Paraguay Summer Time", "PYST"}}, + "Paraguay Summer Time", "PYST", + "Paraguay Time", "PYT"}}, {"America/Atikokan", EST}, {"America/Atka", HAST}, {"America/Bahia", BRT}, @@ -320,17 +399,20 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Blanc-Sablon", AST}, {"America/Boa_Vista", AMT}, {"America/Bogota", new String[] {"Colombia Time", "COT", - "Colombia Summer Time", "COST"}}, + "Colombia Summer Time", "COST", + "Colombia Time", "COT"}}, {"America/Boise", MST}, {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, {"America/Cancun", CST}, {"America/Caracas", new String[] {"Venezuela Time", "VET", - "Venezuela Summer Time", "VEST"}}, + "Venezuela Summer Time", "VEST", + "Venezuela Time", "VET"}}, {"America/Catamarca", AGT}, {"America/Cayenne", new String[] {"French Guiana Time", "GFT", - "French Guiana Summer Time", "GFST"}}, + "French Guiana Summer Time", "GFST", + "French Guiana Time", "GFT"}}, {"America/Cayman", EST}, {"America/Chihuahua", MST}, {"America/Creston", MST}, @@ -352,16 +434,19 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, {"America/Godthab", new String[] {"Western Greenland Time", "WGT", - "Western Greenland Summer Time", "WGST"}}, + "Western Greenland Summer Time", "WGST", + "Western Greenland Time", "WGT"}}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, {"America/Guadeloupe", AST}, {"America/Guatemala", CST}, {"America/Guayaquil", new String[] {"Ecuador Time", "ECT", - "Ecuador Summer Time", "ECST"}}, + "Ecuador Summer Time", "ECST", + "Ecuador Time", "ECT"}}, {"America/Guyana", new String[] {"Guyana Time", "GYT", - "Guyana Summer Time", "GYST"}}, + "Guyana Summer Time", "GYST", + "Guyana Time", "GYT"}}, {"America/Havana", CUBA}, {"America/Hermosillo", MST}, {"America/Indiana/Indianapolis", EST}, @@ -382,9 +467,11 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Knox_IN", CST}, {"America/Kralendijk", AST}, {"America/La_Paz", new String[] {"Bolivia Time", "BOT", - "Bolivia Summer Time", "BOST"}}, + "Bolivia Summer Time", "BOST", + "Bolivia Time", "BOT"}}, {"America/Lima", new String[] {"Peru Time", "PET", - "Peru Summer Time", "PEST"}}, + "Peru Summer Time", "PEST", + "Peru Time", "PET"}}, {"America/Louisville", EST}, {"America/Lower_Princes", AST}, {"America/Maceio", BRT}, @@ -398,13 +485,16 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Menominee", CST}, {"America/Merida", CST}, {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", - "Metlakatla Daylight Time", "MeDT"}}, + "Metlakatla Daylight Time", "MeDT", + "Metlakatla Time", "MeT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"Pierre & Miquelon Standard Time", "PMST", - "Pierre & Miquelon Daylight Time", "PMDT"}}, + "Pierre & Miquelon Daylight Time", "PMDT", + "Pierre & Miquelon Time", "PMT"}}, {"America/Moncton", AST}, {"America/Montevideo", new String[] {"Uruguay Time", "UYT", - "Uruguay Summer Time", "UYST"}}, + "Uruguay Summer Time", "UYST", + "Uruguay Time", "UYT"}}, {"America/Monterrey", CST}, {"America/Montreal", EST}, {"America/Montserrat", AST}, @@ -419,7 +509,8 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Panama", EST}, {"America/Pangnirtung", EST}, {"America/Paramaribo", new String[] {"Suriname Time", "SRT", - "Suriname Summer Time", "SRST"}}, + "Suriname Summer Time", "SRST", + "Suriname Time", "SRT"}}, {"America/Port-au-Prince", EST}, {"America/Port_of_Spain", AST}, {"America/Porto_Acre", AMT}, @@ -459,113 +550,143 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Yellowknife", MST}, {"Antarctica/Casey", WST_AUS}, {"Antarctica/Davis", new String[] {"Davis Time", "DAVT", - "Davis Summer Time", "DAVST"}}, + "Davis Summer Time", "DAVST", + "Davis Time", "DAVT"}}, {"Antarctica/DumontDUrville", new String[] {"Dumont-d'Urville Time", "DDUT", - "Dumont-d'Urville Summer Time", "DDUST"}}, + "Dumont-d'Urville Summer Time", "DDUST", + "Dumont-d'Urville Time", "DDUT"}}, {"Antarctica/Macquarie", new String[] {"Macquarie Island Time", "MIST", - "Macquarie Island Summer Time", "MIST"}}, + "Macquarie Island Summer Time", "MIST", + "Macquarie Island Time", "MIST"}}, {"Antarctica/Mawson", new String[] {"Mawson Time", "MAWT", - "Mawson Summer Time", "MAWST"}}, + "Mawson Summer Time", "MAWST", + "Mawson Time", "MAWT"}}, {"Antarctica/McMurdo", NZST}, {"Antarctica/Palmer", CLT}, {"Antarctica/Rothera", new String[] {"Rothera Time", "ROTT", - "Rothera Summer Time", "ROTST"}}, + "Rothera Summer Time", "ROTST", + "Rothera Time", "ROTT"}}, {"Antarctica/South_Pole", NZST}, {"Antarctica/Syowa", new String[] {"Syowa Time", "SYOT", - "Syowa Summer Time", "SYOST"}}, + "Syowa Summer Time", "SYOST", + "Syowa Time", "SYOT"}}, {"Antarctica/Vostok", new String[] {"Vostok Time", "VOST", - "Vostok Summer Time", "VOSST"}}, + "Vostok Summer Time", "VOSST", + "Vostok Time", "VOST"}}, {"Arctic/Longyearbyen", CET}, {"Asia/Aden", ARAST}, {"Asia/Almaty", new String[] {"Alma-Ata Time", "ALMT", - "Alma-Ata Summer Time", "ALMST"}}, + "Alma-Ata Summer Time", "ALMST", + "Alma-Ata Time", "ALMT"}}, {"Asia/Amman", EET}, {"Asia/Anadyr", new String[] {"Anadyr Time", "ANAT", - "Anadyr Summer Time", "ANAST"}}, + "Anadyr Summer Time", "ANAST", + "Anadyr Time", "ANAT"}}, {"Asia/Aqtau", new String[] {"Aqtau Time", "AQTT", - "Aqtau Summer Time", "AQTST"}}, + "Aqtau Summer Time", "AQTST", + "Aqtau Time", "AQTT"}}, {"Asia/Aqtobe", new String[] {"Aqtobe Time", "AQTT", - "Aqtobe Summer Time", "AQTST"}}, + "Aqtobe Summer Time", "AQTST", + "Aqtobe Time", "AQTT"}}, {"Asia/Ashgabat", TMT}, {"Asia/Ashkhabad", TMT}, {"Asia/Baghdad", ARAST}, {"Asia/Bahrain", ARAST}, {"Asia/Baku", new String[] {"Azerbaijan Time", "AZT", - "Azerbaijan Summer Time", "AZST"}}, + "Azerbaijan Summer Time", "AZST", + "Azerbaijan Time", "AZT"}}, {"Asia/Bangkok", ICT}, {"Asia/Beirut", EET}, {"Asia/Bishkek", new String[] {"Kirgizstan Time", "KGT", - "Kirgizstan Summer Time", "KGST"}}, + "Kirgizstan Summer Time", "KGST", + "Kirgizstan Time", "KGT"}}, {"Asia/Brunei", new String[] {"Brunei Time", "BNT", - "Brunei Summer Time", "BNST"}}, + "Brunei Summer Time", "BNST", + "Brunei Time", "BNT"}}, {"Asia/Calcutta", IST}, {"Asia/Choibalsan", new String[] {"Choibalsan Time", "CHOT", - "Choibalsan Summer Time", "CHOST"}}, + "Choibalsan Summer Time", "CHOST", + "Choibalsan Time", "CHOT"}}, {"Asia/Chongqing", CTT}, {"Asia/Chungking", CTT}, {"Asia/Colombo", IST}, {"Asia/Dacca", BDT}, {"Asia/Dhaka", BDT}, {"Asia/Dili", new String[] {"Timor-Leste Time", "TLT", - "Timor-Leste Summer Time", "TLST"}}, + "Timor-Leste Summer Time", "TLST", + "Timor-Leste Time", "TLT"}}, {"Asia/Damascus", EET}, {"Asia/Dubai", GST}, {"Asia/Dushanbe", new String[] {"Tajikistan Time", "TJT", - "Tajikistan Summer Time", "TJST"}}, + "Tajikistan Summer Time", "TJST", + "Tajikistan Time", "TJT"}}, {"Asia/Gaza", EET}, {"Asia/Harbin", CTT}, {"Asia/Hebron", EET}, {"Asia/Ho_Chi_Minh", ICT}, {"Asia/Hong_Kong", HKT}, {"Asia/Hovd", new String[] {"Hovd Time", "HOVT", - "Hovd Summer Time", "HOVST"}}, + "Hovd Summer Time", "HOVST", + "Hovd Time", "HOVT"}}, {"Asia/Irkutsk", new String[] {"Irkutsk Time", "IRKT", - "Irkutsk Summer Time", "IRKST"}}, + "Irkutsk Summer Time", "IRKST", + "Irkutsk Time", "IRKT"}}, {"Asia/Istanbul", EET}, {"Asia/Jakarta", WIT}, {"Asia/Jayapura", new String[] {"East Indonesia Time", "EIT", - "East Indonesia Summer Time", "EIST"}}, + "East Indonesia Summer Time", "EIST", + "East Indonesia Time", "EIT"}}, {"Asia/Kabul", new String[] {"Afghanistan Time", "AFT", - "Afghanistan Summer Time", "AFST"}}, + "Afghanistan Summer Time", "AFST", + "Afghanistan Time", "AFT"}}, {"Asia/Kamchatka", new String[] {"Petropavlovsk-Kamchatski Time", "PETT", - "Petropavlovsk-Kamchatski Summer Time", "PETST"}}, + "Petropavlovsk-Kamchatski Summer Time", "PETST", + "Petropavlovsk-Kamchatski Time", "PETT"}}, {"Asia/Karachi", PKT}, {"Asia/Kashgar", CTT}, {"Asia/Kathmandu", NPT}, {"Asia/Katmandu", NPT}, {"Asia/Kolkata", IST}, {"Asia/Krasnoyarsk", new String[] {"Krasnoyarsk Time", "KRAT", - "Krasnoyarsk Summer Time", "KRAST"}}, + "Krasnoyarsk Summer Time", "KRAST", + "Krasnoyarsk Time", "KRAT"}}, {"Asia/Kuala_Lumpur", MYT}, {"Asia/Kuching", MYT}, {"Asia/Kuwait", ARAST}, {"Asia/Macao", CTT}, {"Asia/Macau", CTT}, {"Asia/Magadan", new String[] {"Magadan Time", "MAGT", - "Magadan Summer Time", "MAGST"}}, + "Magadan Summer Time", "MAGST", + "Magadan Time", "MAGT"}}, {"Asia/Makassar", CIT}, {"Asia/Manila", new String[] {"Philippines Time", "PHT", - "Philippines Summer Time", "PHST"}}, + "Philippines Summer Time", "PHST", + "Philippines Time", "PHT"}}, {"Asia/Muscat", GST}, {"Asia/Nicosia", EET}, {"Asia/Novokuznetsk", NOVT}, {"Asia/Novosibirsk", NOVT}, {"Asia/Oral", new String[] {"Oral Time", "ORAT", - "Oral Summer Time", "ORAST"}}, + "Oral Summer Time", "ORAST", + "Oral Time", "ORAT"}}, {"Asia/Omsk", new String[] {"Omsk Time", "OMST", - "Omsk Summer Time", "OMSST"}}, + "Omsk Summer Time", "OMSST", + "Omsk Time", "OMST"}}, {"Asia/Phnom_Penh", ICT}, {"Asia/Pontianak", WIT}, {"Asia/Pyongyang", KST}, {"Asia/Qatar", ARAST}, {"Asia/Qyzylorda", new String[] {"Qyzylorda Time", "QYZT", - "Qyzylorda Summer Time", "QYZST"}}, + "Qyzylorda Summer Time", "QYZST", + "Qyzylorda Time", "QYZT"}}, {"Asia/Rangoon", new String[] {"Myanmar Time", "MMT", - "Myanmar Summer Time", "MMST"}}, + "Myanmar Summer Time", "MMST", + "Myanmar Time", "MMT"}}, {"Asia/Riyadh", ARAST}, {"Asia/Saigon", ICT}, {"Asia/Sakhalin", new String[] {"Sakhalin Time", "SAKT", - "Sakhalin Summer Time", "SAKST"}}, + "Sakhalin Summer Time", "SAKST", + "Sakhalin Time", "SAKT"}}, {"Asia/Samarkand", UZT}, {"Asia/Seoul", KST}, {"Asia/Singapore", SGT}, @@ -573,7 +694,8 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"Asia/Tel_Aviv", ISRAEL}, {"Asia/Tashkent", UZT}, {"Asia/Tbilisi", new String[] {"Georgia Time", "GET", - "Georgia Summer Time", "GEST"}}, + "Georgia Summer Time", "GEST", + "Georgia Time", "GET"}}, {"Asia/Tehran", IRT}, {"Asia/Thimbu", BTT}, {"Asia/Thimphu", BTT}, @@ -583,28 +705,35 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"Asia/Urumqi", CTT}, {"Asia/Vientiane", ICT}, {"Asia/Vladivostok", new String[] {"Vladivostok Time", "VLAT", - "Vladivostok Summer Time", "VLAST"}}, + "Vladivostok Summer Time", "VLAST", + "Vladivostok Time", "VLAT"}}, {"Asia/Yakutsk", new String[] {"Yakutsk Time", "YAKT", - "Yakutsk Summer Time", "YAKST"}}, + "Yakutsk Summer Time", "YAKST", + "Yakutsk Time", "YAKT"}}, {"Asia/Yekaterinburg", new String[] {"Yekaterinburg Time", "YEKT", - "Yekaterinburg Summer Time", "YEKST"}}, + "Yekaterinburg Summer Time", "YEKST", + "Yekaterinburg Time", "YEKT"}}, {"Asia/Yerevan", ARMT}, {"Atlantic/Azores", new String[] {"Azores Time", "AZOT", - "Azores Summer Time", "AZOST"}}, + "Azores Summer Time", "AZOST", + "Azores Time", "AZOT"}}, {"Atlantic/Bermuda", AST}, {"Atlantic/Canary", WET}, {"Atlantic/Cape_Verde", new String[] {"Cape Verde Time", "CVT", - "Cape Verde Summer Time", "CVST"}}, + "Cape Verde Summer Time", "CVST", + "Cape Verde Time", "CVT"}}, {"Atlantic/Faeroe", WET}, {"Atlantic/Faroe", WET}, {"Atlantic/Jan_Mayen", CET}, {"Atlantic/Madeira", WET}, {"Atlantic/Reykjavik", GMT}, {"Atlantic/South_Georgia", new String[] {"South Georgia Standard Time", "GST", - "South Georgia Daylight Time", "GDT"}}, + "South Georgia Daylight Time", "GDT", + "South Georgia Time", "GT"}}, {"Atlantic/St_Helena", GMT}, {"Atlantic/Stanley", new String[] {"Falkland Is. Time", "FKT", - "Falkland Is. Summer Time", "FKST"}}, + "Falkland Is. Summer Time", "FKST", + "Falkland Is. Time", "FKT"}}, {"Australia/ACT", EST_NSW}, {"Australia/Adelaide", ADELAIDE}, {"Australia/Brisbane", BRISBANE}, @@ -613,7 +742,8 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"Australia/Currie", EST_NSW}, {"Australia/Darwin", DARWIN}, {"Australia/Eucla", new String[] {"Central Western Standard Time (Australia)", "CWST", - "Central Western Summer Time (Australia)", "CWST"}}, + "Central Western Summer Time (Australia)", "CWST", + "Central Western Time (Australia)", "CWT"}}, {"Australia/Hobart", TASMANIA}, {"Australia/LHI", LORD_HOWE}, {"Australia/Lindeman", BRISBANE}, @@ -697,7 +827,8 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"Europe/Riga", EET}, {"Europe/Rome", CET}, {"Europe/Samara", new String[] {"Samara Time", "SAMT", - "Samara Summer Time", "SAMST"}}, + "Samara Summer Time", "SAMST", + "Samara Time", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, {"Europe/Simferopol", EET}, @@ -713,7 +844,8 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"Europe/Vienna", CET}, {"Europe/Vilnius", EET}, {"Europe/Volgograd", new String[] {"Volgograd Time", "VOLT", - "Volgograd Summer Time", "VOLST"}}, + "Volgograd Summer Time", "VOLST", + "Volgograd Time", "VOLT"}}, {"Europe/Warsaw", CET}, {"Europe/Zagreb", CET}, {"Europe/Zaporozhye", EET}, @@ -727,30 +859,39 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"IST", IST}, {"Indian/Antananarivo", EAT}, {"Indian/Chagos", new String[] {"Indian Ocean Territory Time", "IOT", - "Indian Ocean Territory Summer Time", "IOST"}}, + "Indian Ocean Territory Summer Time", "IOST", + "Indian Ocean Territory Time", "IOT"}}, {"Indian/Christmas", new String[] {"Christmas Island Time", "CXT", - "Christmas Island Summer Time", "CXST"}}, + "Christmas Island Summer Time", "CXST", + "Christmas Island Time", "CIT"}}, {"Indian/Cocos", new String[] {"Cocos Islands Time", "CCT", - "Cocos Islands Summer Time", "CCST"}}, + "Cocos Islands Summer Time", "CCST", + "Cocos Islands Time", "CCT"}}, {"Indian/Comoro", EAT}, {"Indian/Kerguelen", new String[] {"French Southern & Antarctic Lands Time", "TFT", - "French Southern & Antarctic Lands Summer Time", "TFST"}}, + "French Southern & Antarctic Lands Summer Time", "TFST", + "French Southern & Antarctic Lands Time", "TFT"}}, {"Indian/Mahe", new String[] {"Seychelles Time", "SCT", - "Seychelles Summer Time", "SCST"}}, + "Seychelles Summer Time", "SCST", + "Seychelles Time", "SCT"}}, {"Indian/Maldives", new String[] {"Maldives Time", "MVT", - "Maldives Summer Time", "MVST"}}, + "Maldives Summer Time", "MVST", + "Maldives Time", "MVT"}}, {"Indian/Mauritius", new String[] {"Mauritius Time", "MUT", - "Mauritius Summer Time", "MUST"}}, + "Mauritius Summer Time", "MUST", + "Mauritius Time", "MUT"}}, {"Indian/Mayotte", EAT}, {"Indian/Reunion", new String[] {"Reunion Time", "RET", - "Reunion Summer Time", "REST"}}, + "Reunion Summer Time", "REST", + "Reunion Time", "RET"}}, {"Israel", ISRAEL}, {"Jamaica", EST}, {"Japan", JST}, {"Kwajalein", MHT}, {"Libya", EET}, {"MET", new String[] {"Middle Europe Time", "MET", - "Middle Europe Summer Time", "MEST"}}, + "Middle Europe Summer Time", "MEST", + "Middle Europe Time", "MET"}}, {"Mexico/BajaNorte", PST}, {"Mexico/BajaSur", MST}, {"Mexico/General", CST}, @@ -770,61 +911,82 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"Pacific/Chuuk", CHUT}, {"Pacific/Easter", EASTER}, {"Pacific/Efate", new String[] {"Vanuatu Time", "VUT", - "Vanuatu Summer Time", "VUST"}}, + "Vanuatu Summer Time", "VUST", + "Vanuatu Time", "VUT"}}, {"Pacific/Enderbury", new String[] {"Phoenix Is. Time", "PHOT", - "Phoenix Is. Summer Time", "PHOST"}}, + "Phoenix Is. Summer Time", "PHOST", + "Phoenix Is. Time", "PHOT"}}, {"Pacific/Fakaofo", new String[] {"Tokelau Time", "TKT", - "Tokelau Summer Time", "TKST"}}, + "Tokelau Summer Time", "TKST", + "Tokelau Time", "TKT"}}, {"Pacific/Fiji", new String[] {"Fiji Time", "FJT", - "Fiji Summer Time", "FJST"}}, + "Fiji Summer Time", "FJST", + "Fiji Time", "FJT"}}, {"Pacific/Funafuti", new String[] {"Tuvalu Time", "TVT", - "Tuvalu Summer Time", "TVST"}}, + "Tuvalu Summer Time", "TVST", + "Tuvalu Time", "TVT"}}, {"Pacific/Galapagos", new String[] {"Galapagos Time", "GALT", - "Galapagos Summer Time", "GALST"}}, + "Galapagos Summer Time", "GALST", + "Galapagos Time", "GALT"}}, {"Pacific/Gambier", GAMBIER}, {"Pacific/Guadalcanal", SBT}, {"Pacific/Guam", ChST}, {"Pacific/Johnston", HST}, {"Pacific/Kiritimati", new String[] {"Line Is. Time", "LINT", - "Line Is. Summer Time", "LINST"}}, + "Line Is. Summer Time", "LINST", + "Line Is. Time", "LINT"}}, {"Pacific/Kosrae", new String[] {"Kosrae Time", "KOST", - "Kosrae Summer Time", "KOSST"}}, + "Kosrae Summer Time", "KOSST", + "Kosrae Time", "KOST"}}, {"Pacific/Kwajalein", MHT}, {"Pacific/Majuro", MHT}, {"Pacific/Marquesas", new String[] {"Marquesas Time", "MART", - "Marquesas Summer Time", "MARST"}}, + "Marquesas Summer Time", "MARST", + "Marquesas Time", "MART"}}, {"Pacific/Midway", SAMOA}, {"Pacific/Nauru", new String[] {"Nauru Time", "NRT", - "Nauru Summer Time", "NRST"}}, + "Nauru Summer Time", "NRST", + "Nauru Time", "NRT"}}, {"Pacific/Niue", new String[] {"Niue Time", "NUT", - "Niue Summer Time", "NUST"}}, + "Niue Summer Time", "NUST", + "Niue Time", "NUT"}}, {"Pacific/Norfolk", new String[] {"Norfolk Time", "NFT", - "Norfolk Summer Time", "NFST"}}, + "Norfolk Summer Time", "NFST", + "Norfolk Time", "NFT"}}, {"Pacific/Noumea", new String[] {"New Caledonia Time", "NCT", - "New Caledonia Summer Time", "NCST"}}, + "New Caledonia Summer Time", "NCST", + "New Caledonia Time", "NCT"}}, {"Pacific/Pago_Pago", SAMOA}, {"Pacific/Palau", new String[] {"Palau Time", "PWT", - "Palau Summer Time", "PWST"}}, + "Palau Summer Time", "PWST", + "Palau Time", "PWT"}}, {"Pacific/Pitcairn", PITCAIRN}, {"Pacific/Pohnpei", PONT}, {"Pacific/Ponape", PONT}, {"Pacific/Port_Moresby", new String[] {"Papua New Guinea Time", "PGT", - "Papua New Guinea Summer Time", "PGST"}}, + "Papua New Guinea Summer Time", "PGST", + "Papua New Guinea Time", "PGT"}}, {"Pacific/Rarotonga", new String[] {"Cook Is. Time", "CKT", - "Cook Is. Summer Time", "CKHST"}}, + "Cook Is. Summer Time", "CKHST", + "Cook Is. Time", "CKT"}}, {"Pacific/Saipan", ChST}, {"Pacific/Samoa", SAMOA}, {"Pacific/Tahiti", new String[] {"Tahiti Time", "TAHT", - "Tahiti Summer Time", "TAHST"}}, + "Tahiti Summer Time", "TAHST", + "Tahiti Time", "TAHT"}}, {"Pacific/Tarawa", new String[] {"Gilbert Is. Time", "GILT", - "Gilbert Is. Summer Time", "GILST"}}, + "Gilbert Is. Summer Time", "GILST", + "Gilbert Is. Time", "GILT"}}, {"Pacific/Tongatapu", new String[] {"Tonga Time", "TOT", - "Tonga Summer Time", "TOST"}}, + "Tonga Summer Time", "TOST", + "Tonga Time", "TOT"}}, {"Pacific/Truk", CHUT}, {"Pacific/Wake", new String[] {"Wake Time", "WAKT", - "Wake Summer Time", "WAKST"}}, + "Wake Summer Time", "WAKST", + "Wake Time", "WAKT"}}, {"Pacific/Wallis", new String[] {"Wallis & Futuna Time", "WFT", - "Wallis & Futuna Summer Time", "WFST"}}, + "Wallis & Futuna Summer Time", "WFST", + "Wallis & Futuna Time", "WFT"}}, {"Pacific/Yap", CHUT}, {"Poland", CET}, {"PRC", CTT}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java index 3757ed121a5..a3c37ecc05e 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java @@ -42,6 +42,9 @@ package sun.util.resources; import java.util.Map; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.MissingResourceException; +import java.util.Set; /** * Subclass of ResourceBundle with special @@ -57,6 +60,26 @@ import java.util.LinkedHashMap; */ public abstract class TimeZoneNamesBundle extends OpenListResourceBundle { + /** + * Returns a String array containing time zone names. The String array has + * at most size elements. + * + * @param key the time zone ID for which names are obtained + * @param size the requested size of array for names + * @return a String array containing names + */ + public String[] getStringArray(String key, int size) { + String[] names = handleGetObject(key, size); + if ((names == null || names.length != size) && parent != null) { + names = ((TimeZoneNamesBundle)parent).getStringArray(key, size); + } + if (names == null) { + throw new MissingResourceException("no time zone names", getClass().getName(), key); + } + return names; + + } + /** * Maps time zone IDs to locale-specific names. * The value returned is an array of five strings: @@ -71,13 +94,17 @@ public abstract class TimeZoneNamesBundle extends OpenListResourceBundle { * getContents implementations, while the time zone * ID is inserted into the returned array by this method. */ + @Override public Object handleGetObject(String key) { + return handleGetObject(key, 5); + } + + private String[] handleGetObject(String key, int n) { String[] contents = (String[]) super.handleGetObject(key); if (contents == null) { return null; } - - int clen = contents.length; + int clen = Math.min(n, contents.length); String[] tmpobj = new String[clen+1]; tmpobj[0] = key; System.arraycopy(contents, 0, tmpobj, 1, clen); @@ -85,13 +112,23 @@ public abstract class TimeZoneNamesBundle extends OpenListResourceBundle { } /** - * Use LinkedHashMap to preserve order of bundle entries. + * Use LinkedHashMap to preserve the order of bundle entries. */ @Override - protected Map createMap(int size) { + protected Map createMap(int size) { return new LinkedHashMap<>(size); } + /** + * Use LinkedHashSet to preserve the key order. + * @param the type of elements + * @return a Set + */ + @Override + protected Set createSet() { + return new LinkedHashSet<>(); + } + /** * Provides key/value mappings for a specific * resource bundle. Each entry of the array diff --git a/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.java b/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.java new file mode 100644 index 00000000000..f2dcbe5cfd5 --- /dev/null +++ b/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.*; +import sun.util.locale.provider.TimeZoneNameUtility; + +public class GenericTimeZoneNamesTest { + private static final String[] PT = { + "America/Los_Angeles", "US/Pacific", "PST" + }; + + private static int errors = 0; + + public static void main(String[] args) { + for (String tag : args) { + Locale locale = Locale.forLanguageTag(tag); + for (String tzid : PT) { + test(tzid, TimeZone.LONG, locale, "Pacific Time"); + test(tzid, TimeZone.SHORT, locale, "PT"); + } + } + + if (errors != 0) { + throw new RuntimeException("test failed"); + } + } + + private static void test(String tzid, int style, Locale locale, String expected) { + // No public API to get generic time zone names (JDK 8) + String got = TimeZoneNameUtility.retrieveGenericDisplayName(tzid, style, locale); + if (!expected.equals(got)) { + System.err.printf("test: tzid=%s, locale=%s, style=%d, got=\"%s\", expected=\"%s\"%n", + tzid, locale, style, got, expected); + errors++; + } + } +} diff --git a/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh b/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh new file mode 100644 index 00000000000..a5491891bbb --- /dev/null +++ b/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh @@ -0,0 +1,47 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# @test +# @bug 8003267 +# @summary Unit test for generic time zone names support +# @compile -XDignore.symbol.file GenericTimeZoneNamesTest.java +# @run shell GenericTimeZoneNamesTest.sh + +# This test is locale data-dependent and assumes that both JRE and CLDR +# have the same geneic time zone names in English. + +STATUS=0 +echo "Locale providers: default" +# TODO: The purpose of ja-JP is to make sure the fallback for generic +# names works. Remove ja-JP when adding generic names to localized +# resources. +if ! ${TESTJAVA}/bin/java -esa -cp "${TESTCLASSES}" GenericTimeZoneNamesTest en-US ja-JP; then + STATUS=1 +fi + +echo "Locale providers: CLDR" +if ! ${TESTJAVA}/bin/java -esa -cp "${TESTCLASSES}" -Djava.locale.providers=CLDR GenericTimeZoneNamesTest en-US; then + STATUS=1 +fi +exit ${STATUS} + diff --git a/jdk/test/java/util/Calendar/NarrowNamesTest.java b/jdk/test/java/util/Calendar/NarrowNamesTest.java new file mode 100644 index 00000000000..7338792abd3 --- /dev/null +++ b/jdk/test/java/util/Calendar/NarrowNamesTest.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.*; +import static java.util.GregorianCalendar.*; + +public class NarrowNamesTest { + private static final Locale US = Locale.US; + private static final Locale JAJPJP = new Locale("ja", "JP", "JP"); + private static final Locale THTH = new Locale("th", "TH"); + + private static final String RESET_INDEX = "RESET_INDEX"; + + private static int errors = 0; + + // This test is locale data-dependent. + public static void main(String[] args) { + test(US, ERA, "B", + ERA, BC, YEAR, 1); + test(US, ERA, "A", + ERA, AD, YEAR, 2012); + test(US, DAY_OF_WEEK, "S", + YEAR, 2012, MONTH, DECEMBER, DAY_OF_MONTH, 23); + test(US, AM_PM, "a", + HOUR_OF_DAY, 10); + test(US, AM_PM, "p", + HOUR_OF_DAY, 23); + test(JAJPJP, DAY_OF_WEEK, "\u65e5", + YEAR, 24, MONTH, DECEMBER, DAY_OF_MONTH, 23); + test(THTH, MONTH, NARROW_STANDALONE, "\u0e18.\u0e04.", + YEAR, 2555, MONTH, DECEMBER, DAY_OF_MONTH, 5); + test(THTH, DAY_OF_WEEK, "\u0e1e", + YEAR, 2555, MONTH, DECEMBER, DAY_OF_MONTH, 5); + + testMap(US, DAY_OF_WEEK, ALL_STYLES, // shouldn't include any narrow names + "", // 1-based indexing for DAY_OF_WEEK + "Sunday", // Sunday + "Monday", // Monday + "Tuesday", // Tuesday + "Wednesday", // Wednesday + "Thursday", // Thursday + "Friday", // Friday + "Saturday", // Saturday + RESET_INDEX, + "", // 1-based indexing for DAY_OF_WEEK + "Sun", // abb Sunday + "Mon", // abb Monday + "Tue", // abb Tuesday + "Wed", // abb Wednesday + "Thu", // abb Thursday + "Fri", // abb Friday + "Sat" // abb Saturday + ); + testMap(US, DAY_OF_WEEK, NARROW_FORMAT); // expect null + testMap(US, AM_PM, ALL_STYLES, + "AM", "PM", + RESET_INDEX, + "a", "p"); + testMap(JAJPJP, DAY_OF_WEEK, NARROW_STANDALONE); // expect null + testMap(JAJPJP, DAY_OF_WEEK, NARROW_FORMAT, + "", // 1-based indexing for DAY_OF_WEEK + "\u65e5", + "\u6708", + "\u706b", + "\u6c34", + "\u6728", + "\u91d1", + "\u571f"); + testMap(THTH, MONTH, NARROW_FORMAT); // expect null + testMap(THTH, MONTH, NARROW_STANDALONE, + "\u0e21.\u0e04.", + "\u0e01.\u0e1e.", + "\u0e21\u0e35.\u0e04.", + "\u0e40\u0e21.\u0e22.", + "\u0e1e.\u0e04.", + "\u0e21\u0e34.\u0e22.", + "\u0e01.\u0e04.", + "\u0e2a.\u0e04.", + "\u0e01.\u0e22.", + "\u0e15.\u0e04.", + "\u0e1e.\u0e22.", + "\u0e18.\u0e04."); + + if (errors != 0) { + throw new RuntimeException("test failed"); + } + } + + private static void test(Locale locale, int field, String expected, int... data) { + test(locale, field, NARROW_FORMAT, expected, data); + } + + private static void test(Locale locale, int field, int style, String expected, int... fieldValuePairs) { + Calendar cal = Calendar.getInstance(locale); + cal.clear(); + for (int i = 0; i < fieldValuePairs.length;) { + int f = fieldValuePairs[i++]; + int v = fieldValuePairs[i++]; + cal.set(f, v); + } + String got = cal.getDisplayName(field, style, locale); + if (!expected.equals(got)) { + System.err.printf("test: locale=%s, field=%d, value=%d, style=%d, got=\"%s\", expected=\"%s\"%n", + locale, field, cal.get(field), style, got, expected); + errors++; + } + } + + private static void testMap(Locale locale, int field, int style, String... expected) { + Map expectedMap = null; + if (expected.length > 0) { + expectedMap = new TreeMap<>(LengthBasedComparator.INSTANCE); + int index = 0; + for (int i = 0; i < expected.length; i++) { + if (expected[i].isEmpty()) { + index++; + continue; + } + if (expected[i] == RESET_INDEX) { + index = 0; + continue; + } + expectedMap.put(expected[i], index++); + } + } + Calendar cal = Calendar.getInstance(locale); + Map got = cal.getDisplayNames(field, style, locale); + if (!(expectedMap == null && got == null) + && !expectedMap.equals(got)) { + System.err.printf("testMap: locale=%s, field=%d, style=%d, expected=%s, got=%s%n", + locale, field, style, expectedMap, got); + errors++; + } + } + + /** + * Comparator implementation for TreeMap which iterates keys from longest + * to shortest. + */ + private static class LengthBasedComparator implements Comparator { + private static final LengthBasedComparator INSTANCE = new LengthBasedComparator(); + + private LengthBasedComparator() { + } + + @Override + public int compare(String o1, String o2) { + int n = o2.length() - o1.length(); + return (n == 0) ? o1.compareTo(o2) : n; + } + } +} diff --git a/jdk/test/java/util/Calendar/NarrowNamesTest.sh b/jdk/test/java/util/Calendar/NarrowNamesTest.sh new file mode 100644 index 00000000000..742e35ac291 --- /dev/null +++ b/jdk/test/java/util/Calendar/NarrowNamesTest.sh @@ -0,0 +1,41 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# @test +# @bug 8000983 +# @summary Unit test for narrow names support +# @build NarrowNamesTest +# @run shell NarrowNamesTest.sh + +# This test is locale data-dependent and assumes that both JRE and CLDR +# have the same narrow names. + +STATUS=0 +for P in "JRE,SPI" "CLDR" +do + echo "Locale providers: $P" + if ! ${TESTJAVA}/bin/java -esa -cp "${TESTCLASSES}" -Djava.locale.providers="${P}" NarrowNamesTest; then + STATUS=1 + fi +done +exit ${STATUS} diff --git a/jdk/test/java/util/PluggableLocale/GenericTest.java b/jdk/test/java/util/PluggableLocale/GenericTest.java index 8be74cdca91..eee0f95ff3a 100644 --- a/jdk/test/java/util/PluggableLocale/GenericTest.java +++ b/jdk/test/java/util/PluggableLocale/GenericTest.java @@ -41,6 +41,7 @@ public class GenericTest { com.bar.CurrencyNameProviderImpl2 currencyNP2 = new com.bar.CurrencyNameProviderImpl2(); com.bar.LocaleNameProviderImpl localeNP = new com.bar.LocaleNameProviderImpl(); com.bar.TimeZoneNameProviderImpl tzNP = new com.bar.TimeZoneNameProviderImpl(); + com.bar.GenericTimeZoneNameProviderImpl tzGenNP = new com.bar.GenericTimeZoneNameProviderImpl(); com.bar.CalendarDataProviderImpl calDataP = new com.bar.CalendarDataProviderImpl(); com.bar.CalendarNameProviderImpl calNameP = new com.bar.CalendarNameProviderImpl(); @@ -73,6 +74,7 @@ public class GenericTest { expected.addAll(Arrays.asList(currencyNP2.getAvailableLocales())); expected.addAll(Arrays.asList(localeNP.getAvailableLocales())); expected.addAll(Arrays.asList(tzNP.getAvailableLocales())); + expected.addAll(Arrays.asList(tzGenNP.getAvailableLocales())); expected.addAll(Arrays.asList(calDataP.getAvailableLocales())); expected.addAll(Arrays.asList(calNameP.getAvailableLocales())); if (!result.equals(expected)) { diff --git a/jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.java b/jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.java index cc71e6c6543..7ed2fc11429 100644 --- a/jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.java +++ b/jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.java @@ -40,6 +40,7 @@ public class TimeZoneNameProviderTest extends ProviderTest { TimeZoneNameProviderTest() { test1(); test2(); + test3(); aliasTest(); } @@ -92,6 +93,7 @@ public class TimeZoneNameProviderTest extends ProviderTest { final String pattern = "z"; final Locale OSAKA = new Locale("ja", "JP", "osaka"); final Locale KYOTO = new Locale("ja", "JP", "kyoto"); + final Locale GENERIC = new Locale("ja", "JP", "generic"); final String[] TIMEZONES = { "GMT", "America/Los_Angeles", "SystemV/PST8", @@ -157,6 +159,29 @@ public class TimeZoneNameProviderTest extends ProviderTest { } } + void test3() { + final String[] TZNAMES = { + LATIME, PST, PST8PDT, US_PACIFIC, + TOKYOTIME, JST, JAPAN, + }; + for (String tzname : TZNAMES) { + TimeZone tz = TimeZone.getTimeZone(tzname); + for (int style : new int[] { TimeZone.LONG, TimeZone.SHORT }) { + String osakaStd = tz.getDisplayName(false, style, OSAKA); + if (osakaStd != null) { + // No API for getting generic time zone names + String generic = TimeZoneNameUtility.retrieveGenericDisplayName(tzname, + style, GENERIC); + String expected = "Generic " + osakaStd; + if (!expected.equals(generic)) { + throw new RuntimeException("Wrong generic name: got=\"" + generic + + "\", expected=\"" + expected + "\""); + } + } + } + } + } + final String LATIME = "America/Los_Angeles"; final String PST = "PST"; final String PST8PDT = "PST8PDT"; diff --git a/jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.sh b/jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.sh index 76a08e6e83e..4e34ae09814 100644 --- a/jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.sh +++ b/jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2012, Oracle and/or its affiliates. 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 @@ -23,6 +23,6 @@ #!/bin/sh # # @test -# @bug 4052440 +# @bug 4052440 8003267 # @summary TimeZoneNameProvider tests # @run shell ExecTest.sh bar TimeZoneNameProviderTest true diff --git a/jdk/test/java/util/PluggableLocale/barprovider.jar b/jdk/test/java/util/PluggableLocale/barprovider.jar index deed5facccbba17157bb62d49f5f82c70e7bbaf6..3a6f37a94588c36bed0fc0c8cc7e29aea3dfb2fb 100644 GIT binary patch delta 7192 zcmaJ`by%Fc(#Kg~aa&x9Ew07g-L1G6iY@M2pt!S0f#SuBQ@j-S;!vPKaVc(vQc6GI z+<|-f64R%_@!6lbow~upX(*!t4#|gKD#F3RDc%1cWOpOBotKkR2ve^S4X|Qja>bobFXA zdsGMG4}FrpQay?V5C7z$uK!NhgYZZ=2g*RHiEuP~LukQGZur3nS`q}T#Fd=dzDmjm zNKuGZoBF&*{ zGFqMOFOkFZ>Z+d$Nl$w@q*t95RP3FmWN3Tvb>U>r0Y7EioQ%}6g?EOu6mlD@+lRO6 zv0Cf?e4ji!G?k*iOo!b&o7~hhK|A0eSNX)_CNGf>eEiB-YBxG5p~S?9=PYVOtagMt z{HCE|^Sd5lg-StiH@ic85ew=IrC=a*-9wGzJblV`a;!|56xEBBz{!Zujnc8_>D7CR zSyOg{n?Y)Id^zExa0r<<5^MM=figl)*eUr4&;;tky5E|qfAKb(gGi?*@J6iUS(Pm* zuyWRVCni%33|jQ4&MDoN!JLj0k{#i8(qGPq4zCR%Hh$Y}&_}vcqvm9`FbIIo12*VQ zAt?3^lo=?-?#G?1UsdH7v_Yg5S^cYD=-XUuLW>UsPx7i2!TuiGqf#Oj^QSCdG|N86 zd^32ax@lGhYpf)n*p-fkO_8VP8?AJ3wp|`nWxBI$uqM%iFzb_GzArN0j592N<)m9g z)rxYQTNbPPi`&!3erG*N?HcFX3)II_NgRx4%lDfB=~Rl8_9Z zSKN#^wCh~oZW3rHHWtyk#cyaY2c8SaFbZDF1E9Zf@)b64%Yxl6`*Any15Fp%%TX`l z<_f8}*FpU_whChwNZ?pYiVdGt-TibUvPk`_-*)NLUemotQ3Eef6qC<;orCAuOspBT zelsIxoEyUnUSlT3{*IO5e+!->w-@aCds7Q?n z2j`FSmyh_%%RKmo1UeF!1Uvwi!$SniLnJ|P0@t@8<{&~%=tlC8KBlZrsKMrXBx^U2 zqK)n}Q0Na(=-W|JYA|Mmq#Bkcz;Zon@`-&pi~yOQxCCl+(Utm+NDhK)tY4GWH1d7& z&z*6fh*_k$RV7^K6zmbpw7+JpM$f9~9-CDUI2fw1V_Vl-)W>1)&6(U}uJjXsLCDXXDl&H}g$yHZ8sCB+H0euZ@Fp`Te)XtcAdaLaNB z|B;rCHECB~{5mW4w52F7o@A(Qr-frDXGi3!;n&^yxjr1sApS{I6496HlVGmVPZuA0jko4$lAoSAGl}P%JLrxC?Ez|~Ee_dAtdIR>&8?fKmPIAX-^9 z3s0CN_)RVjUl{!g{MV8XDO;(dBGs9{p_3z=KEb#Abd#m&qwl}YHj`an48%Ea#x!o( z#hQeBo$YaiZfAiS{7oV(+qG&({DB*)230wLV;EL>hc`_N&vHuZLa2K-p%t0;9-H!% zGE=_%wMrr78n=z^Yjr~u{BeXnBVMw+Q6_o$ee>MsofGO@M66iasTU~RaZ9RT82#^y(M$&E1&1T_tC#cgL00`_F!yS0h(~)|`sR&h|0Sh{N-yBzDp6@~9L*>7&c+gi0a{ zadC*i%+q58M#2dG@~D~o7JgECfborP6~81e)r>utZ4bWgDVOD<4E7{Zng+CVM!CL> z50;;{XAEN8-WbP?cgx?)XyKu5t~9bblZ!m-)_-Zs2rMe@~|UwDXksPriGE9ut~>o{%L%H&A`%v^L3mG$OcG%sxB0H)KV-T^#D zdbQf)h7clTJAwe(Rh_FcKb^d~ia>tMeW>5GUqjV$WT~c8k;Folobi`rt*cT5o;Fq` zow%zRYN8rchemXP zIZ|Q1;Cs6^{<1{2KbM^C;GH6pD*CK7<9(eVII$kZAsU^7(JLlLNoKa=6Yoa}ZD^kB z*)JiC)8>dN6HYpUX zayzt@8~gDli{31UK6SjvBY8m(@U06l#(X^*Iu21YUzxe6oGhIyl*@vNe&AxuF>Mkr zpr2~RCH7%5+sHH(RpJ3471)vli9)v$$n3?zCuD864z|m;FxT>-<1XUswT17E z)P4F{UcXguOjvP06Jgm7=sq22cuT2S)}YfYxKfybT7EMZro3h(Zi4pp4pJ(U6Tc)P zh}*;t%sTiw{$@1l`B3}`(oZdWw#N5WPv%=f#{3!=CZ+nA<_1IGKgTt28-Ks|J16J~ zY{AZ8A9k2!R#*N;p`tE1Nf0`_CEK_u=T{S7#PK2GBI<4g{}=JQG#*`>nVlcR=~dL? z(#6qjHiMOKIi-~?P_XB|?%2i>EyPaJj)?e~jfgz6&X6xj^F@p~laDnpY07-Za(QG; zNp#L$g6F4cITq%k#xN_^io?z~TU9cJfPuKc@27m_%$7VRk`7Zxn!JWa*Qc3;ce$C; zif=KgUozmyac2*=(_$e0fXJGzABy{58UjIU5#%5{G7NW0QVd@tKxQFK&MAAi>p!1<6?BcKr4ygq7|VuJn!{1?T{yFJ^*Z`lvSiz0ZoBVy(u>O3XE!~tKQ&=3A7YN+4=4&~?R7zcU$IYMIftG81%i6@tZTM`~ zcY!;4IV2c=u5nQ4Dqx!+0h#LT=&3F2C>z!H^3}jC^bVr%(DGNS@yG&yfS)dAH^E&VCADTWf_k8)SDe*Bd+vd==7OAGMb) zO+X3er7Z~)ANJwf2>!>LsL5mG0cn+(upXU;>{%E zSeXjb?3G{ZjWp03+Pvnbvbu%zr*oU8>-HDmHM1Dm;u;U78Ah6Q;g2C?jJ(zxZ?I9R z7*GE}w=qHjjXp(DJNK~2Bvg4}y@+1Sw_U<@%FwUR-4Q)4B3)wZIVcuRY8ktRRuH>p zf9@zE?fPSeMUX4TS)7w94gd(&gWzUfBlp? zNag0fq*a4WgEI@b5%M85Qt_>3wv&ceDX)Zqlv}|Cd%zDBQJ$G{N{z+xcyfA^vx+Fk zDS8tJ_9*&H?cJ+6d~-VCN3ZlW(v^P1I;?1N3)%R&ms8+}A&D3}ab1LUJ5_k$3BOMr z2VE@HPS8l}qqjg6hM&Hda<21KZBFf-NUcjf=r7QE7kQ$+u%D?rlUhknuZ|{`I?Hks z2rjg?o%L14LA6sZE+eYLVzVd3Zs40W9wffhJS8CMxz^~n51?MFiX{wSSaT<_U$O!T zCD-QdJE%=s*;b|KV|-t-)ni-C)HL69nG@2U^6*3GfhC;ECFo10n%-h>c#Yl1;9F~F4Dv0-wBiyBDZU+KO=y3uU*6i=U2)?6Dl}Y zJC{Qb&6qXm+H!wi@1N&FD_HOZhRIXQ)#uQ$X6Unqzw_pTqz781XmZ{X@vz$TEa)lu zKWzklNrXVD1aExZVKlG#&XQs++PT9m**4w>m5Ug5F?tzS~soy7K;T=}-HM7yF{8CzhIQ6G_=F)9aO( zCiclg3_*o+jRDSN5#VsE{6_ww>g9`@iI8eWAb_zU$mHD4(#BMUw&Vrc?5 z9K-wyq&&rC2b}SFR8Gm|m`9;&;W2Wdug6zOeNnE|1zNDx{is$vNVHxa=et{DcZjy@ zhTj^Dw@7@ZycKSi!!Xud_df0<+g+gFt?Ft*zL+tWkZ{5Le#A{v-h)dRrgAFM%BggX z5Lnn89dn`XiiT#~&;5(y-8%XQ(f*ov$R?MpqeKYf%<x)I*J=}5)cC6lVw9<>K=j~^U~k0ZR0wUV*XNVGP*HUVcj|Yc zg{u)j@tuUcd-|K=>!c^&yOkg8x|YGTa`ZkntVaEpUDvmRkp2n}9dOj(aq3%eGT@;; zT5_o02X}iUNwRnG%!g_uQ5-o)#4SP3r1((Y$@rNn3-!c6*tT|UlP#oMB0}w#^MpYm z;rDdXT!>84bfxR zR#iz{)|^O=SC$!y zIsHmR8r7dQ>Qh>$t4$Ou!c7=Vd0&boD+ILs5U5@9Og=0nD5!7cIZynu+bmGH$n#@Q zs?he8g%#Mj?-_{-V~I~KOLLid0P`8|02PYfBJh2inKz|10oM5Kun4Rc^&#-4B3 z@f_a}P6+yW{sZGB39N{P1zM9w)(W#aDXYaqvF}@&0tsQX<`XV2*V&4$Z;=`bIeNQ{ zH;}iP>os%A%ywfz`*^AfKXaG#{}@S|=L!Fw+{3~#cb${2)X&>vtzF|RtRFty+&7^& zRe|Dd9OE!%0yJtSPy2}-Z9e2t8QoZpandz#;ZPD*7{czs(j3Q%2#s?=F+}!Gq<@WW z3(@Zq9R)Wh_>y3t6D2*-K~Fo8=#pmT@i2K;oQG{ur$4$p+GwBFl6qR6-7?p#`RQG{ zcSH2FHM3xvvkr;h82&cJr}cPyu2Q zJvV`N+WaZHL1TvnjmJKA@``jl+L=Ec2)aPaFBp3VP#GF!8zLHL)*E=PH>kSA5<4f9 zc~?myCK$d?xc*Yh4_cq~p|_Tw@9g9chewo9Rna+)AV0DDjtS3 z?6?Vi2^0M_X(A?4iED6(bgw`iQs82|+=(FS8z1Odk9R!JdYm0D;vjA}y~+ec9xbZ0 zqSG5_*nin&wkf*Wx0Kg~llB7b5~ z576oV$|%nNMEf6*N(%$>0v_Km+EX%wT71|T9}!ICDaj+rkdF+(p6H%L4m%>lf&JtK z0v^_Q04`wEJVXc(5|{uF?;~sNJ!?JLJ*&W@tbfL&|CIG3B`k-I31-d%d}RFdkozYi zC;h$lkBpBCpx-Z`0lr@V1QX{Yew5?EAHpEKLede}R=~!C2JEWI}C8R@_mJ)=elny~s8bm~CP#PCdKq*0x25IyM z{QmdV@Bg3Ynrr5nxzGJfoHKLgAcAM_5$I{6p_2o!v9SRXex9iWQfN1shLOUzGIq+W z(o&9$GLXwD6+6dzDUZZD6~!tQdnTaS{ovmIJrsbRCKmS5pvNJ39*`X+CGXSWeaq5d=&#j zE$s@~K?mVjb@5k@frfi>XNy>7dgKLH`kQ&$mrON_klZJsYxBY<)@ySoDK>!legd>| zZ&wsdep<7x%Gi$B%4AXc?^3nYYAcno?lfAlQzPZu$DUR7hkJdESh`a9@aoYzvy<0? z%hn%OcJ8o6FiOUX$gNH~a>;t7d~?xd+4uzevQ#^3JLsXIt8zk}R)&PCA+I8A&D=C~ zA^AxcEVE1Zv$8Ms?q~y}^`qWwcFa@Q7c3DwZlMmp2+$c>z2>8i1B@N>jl677o0iVqu~Y4-}dSUc%YAKqh%oIZW~xGI3ia;wYB(SC5%Ywc-^SQ-n~18T$QL2@7~}c1W4;QwbUr zyZB<iBOw>Us3~N$E4pBaKRcMg5$InqeSmtS zB)#Y;tve_HfGQdQ@VCYxyz%r<`S=>U@$%8&_-T%Mkv1CMF6HXqmkMWnQ2Y4cTv4O} zQKZ&r8nYN~^vo8X-^fdr_E-n)$H>r&m-)u+@u;@25)qh%VFgfJE2P|3ruh=(QmLrsyo#^&uLlo z2ceys2rA+VV5lrX1_cHH(2Mii5Pln#__YCeJ+fWO$KMIpcSUybUZj=QzW%tg$Ovtt%k?mqs>b@hhY3;IZJ(koARi z$#t1mzb;QM3IO~|?u@a-+r8YD2TQD$$4gMlR6!2Ac`SiqIx_oQayyOaD%l{x5ucHV z-{Wx3@dx0%0|d#E$-&7vbgdGU63e8XzHAbdl9^%DZ-rDF5dG40ff)IjkJG$Ux=J7h zB6&rDqV+mcYD3dUYTbi8?NURFd6T$LWkwcpV@#>%8~dNW8_yfZ-8A4X&>soaP$}2) z(rJbkKMsFb#TVPD*9JrC*q65)0HgAyDWx2~X)wd7)IXM)3~IO3;?*}2~}!LXm4mPUFGg7ZwOI-BjA`mTrKqiXL-?MNCc@kUBs@vlG;-C6z{B9mM5PD zO6}~B+mA)M^WLnBlTr4>eSDektaa=&8&kylTAzPeZ) z>RQ<)?7TnBlz4VLhBYVczh_Q?N!J!ycV)<);BfMOx1jTKKdYT3qGVXV;@qKTQQoSd z!bA5k9_&{QB41W_1NRt+<-(pdIYZyq5dh&tsU-#C;=o9AR>mPNr&a%QgN1 zNNGiSwG2NNV;=FCC^mY;E{(fcVevUnBde`ol}gAvC7GKf77R48k9`XcjCyP&*{j?< zBtCT1YQK>sCK8}TqSAki5##&(X*`4DiN~_I8|?jhi%+(_1f^T3;rSIf}_UIIeCmueEqh>z&+$+(9-TpTF*8Yk+?I|+Egm< zU*U+0z0#8<>-|J0kL}B6n!Q?#k;D zV4@#Q+wSs{6-&|S>kpC(6ylXc3rxbvO*cUI@?`08Ec=D-6PozMd}e@}4M-ehvxqTu zk!_w_T&+Tneg*hePiWhePS}R7(RE199Tt;A{}#ms(wrqYj|$Vtxj#+~L`-T~fdb&0lfg+4gVP%_7mdicMbQ zm(<=@Qr+q^z1hj!``i{ru6MB)SpRM17g%@Tmb^^GaTv;mT$PR&pSe?thdDd;nyQaPPFb#wgqlPLSq(hkFW7)2lz=2Rcp2p8MfMek@7 z^;6;6v@fBxX2zs^6^*-uLJqaLg8m#j9NGZlw7po(<| zMP%hF#6DFmvzwWh7OV=K(my7TZ8k_~yA!={v9U*M3gXjCX;?6OD}rs_W^&355al@OK!xb*8}TE)49?~|d+7M_rI zZE-7p6pD@uN-8@AmqIOhSTFB$O@<|9DjlUp!E^U&9%3thN>(GdG!b9~=TEOc+b$20 zcW(mv4651Umt?cP4EHH@ovVeCw!U_|x@U^FPjmWfE3MZvb9N-OW9>1^OSP@cxP=4r z0G1yw#2#aeQ9O>aAsIT?l~lj;iIqNeRH)XWA>vC2)r?$^shqI&SF4n`OS~KF88IV) zv0PhEDCU1#j{~m`ihN@u?-LaGtUw7`sKe1xVUms?PMyOn6Ix4F5+fL&uZRZCghl2B zd)`uCTjo7K;i0;s`JS#O&vANug`U?ErE^848_`>SJdPI0Vo0*I)P7VfQ%7Ewo|+(q z{=`E0AR*v^dcS6nc|V9>Ro}sKCEHYA;wO(aVqfZWVVI4v|2g=>Ufz3nKuCy%je`r% z6A_(#vEb#u6Dm9J;69FsjiRElGpmml|3uV3{v+YSW$pp5BnJW8hY+z*jA z35uh5WS)v{@6$Y0HY5r!C~7oXbjRbaJLI9Z=>7^bEs7q~&qW$(XzGBsD)fF-xp(NH zymma`=IU=hx%4a27w)dBCvUZ{!7oD?LI#nguj8yveic;cE8O+6wgRiX zVgS)YYB@3cF^hZZ?VdVisN{|1rap z1aJCa$l07{M<#F9GU8#b@A1#h*JG_?u!D;?rd|NESWVB4a6MrDfQfj^lBl@#Kmdjv zhV;BQGh5NUFMZn4IeDHEMPL{eT-E;-n9Pf7oIOBuD>bfNKO*~%W%pu{iHf#jmoEi?0KO=%{mI38Eh;LaETwtdCh~9^!4`=V2Eywk$ zlB%-HW=e4E`Me3_bF)Fp_YGszV|oAbaAT**3=0LO&0r)sIS8kZQrk#sF_|a6Pt7wDs>!*Uv*_v6Uub)YosuX92 z1&)7HS7~aNO3Yg*8fdC%!h{5ePR^F^en{i1zvGAFd{Rgu5IP=BMG>~q#Wc!w`Y!5) zkBRNhhaL!b(r;HuBE1_hzTlW2%~~u45wzGM~e4AH>zb2AL$u$VZZVTQ8oPJ}LLPDEjvs z)y_HFBSuN~k054`oFbG@EOR;&k7#p;e?D%O{n#1IUiB`%i3bFPKQXkjcJTEq#d0@0 zPYYEm_(uEW+bi4V+zO!**|9fuei&y!A>(;IB~SJk;8Q%|pt@sOap?0wCwvO?wW14) zwIY`H5RvBL?`G+8_PuVeJ~+TC0yz)svI8YE#uG_>`NIr_Dvl>(yelfiWHKnT83#Kj zXkP`mr~0kE%nf6SgZG=}Hg5^xXEw%Prk6mF2sP>YB=DKy$&pS_D?Ra8pl z-Wli-%B|7f)}}@8i1CFI-aoV{d?U)Q_Ve4g+Ch)~v3vD{8aVPrW5_wS-fsA!7ezD7 zVWiAjZ?_uw@H8G1_4`QER<7nYrbpBBM&3#&c}pr}4aIG4{~enln=7e!urA3V?w0HT zg~Vv#CQWXUyLU`~QP5Y%^fS7wrOqU*{-rad^=`Ev=~aL5R$=X=`GEcu=7dj%O@I>tiGheNW8pdTa|-sCy^;Fc9?zc9t56^T2Y&|b+1 zL{LU?a*x%axW_W%uzsD!d>0v)A+gaob9AJ3WFBtV;u@TAKQU6wjmzjI$bw~h^m!Y> z8C7oU2E6i)vy&n0%E2ci@14I<^w!Mtec9C?A>}Dh6~WchFSR1Da#uM>vT7vr3>O1I za+k?cJE6@W{|l(o;LiP|$d1OijXZ5~25u3S@))_%Ac~a-{Z-T_WIIiJl1XEZVGJv} zg0cnPSut<{t_ToiXB|2}A4HFiQK^}it0dMnG25i4N!i>nTd2Sx47{RA{bGa%s(>?} z!Pkgg>+qhpcVI8QQGU&!3<-vDPi-DJ@vR)ZF+Z*-GuNy;o6cJq4IYx-#?ud zjy+E60SQc>=2L0(i}W}k8a<^=+uybIjhjqXVFp?z-W#>{%Xzbvc|nw5JLFfB&{B!F z*EQhhULI2v$?pehd&G;@yi3@CyThU>NHM&aA9;~&ya(_VTBG1)QhiR&3%6JAQsNc% zvl=cdB(j?{9bOo2am{?0vEPvQWV%g%q&h3GDPgLVM>5mX2pBSownjg)oa_pYu6%09 z1j;hSc~C$Dvh>R>sT_3a^CK7txgRpSm^n(IL00KAH$;2))6a7;0`rl9gAe9&d~=UV zNkj|Y2sz1zZrnqWt)}GfK7pTqnt+hRnp`n%4gyEZ+_)+)bLW&{U-qYyBh_L9U23aR z(VvLMoVpz$!@ zPp!fNB3KnoNzE)+g00U^l2pQoVAGx$11i(-l%*Cv(wt0wRv(R@=?a|Lz=A8jZ&Me~ zH4#+Q4qT`9wXPriv{@XB!?(++)hsXS7WA ziRcdfuI_`=Q6H6#V_rF1fTUtu9FD~f7c)sP#c4A0`!?Cr#A+-^0quub1zno+Td(&U zzZFV5Dgcm*{$CoGisZXhI0keuLJTGKpYkizlz++((DH7}?@(UEn0LV)WgStk!W6i?2T=H z4LN46E%HjD{Vw8O~ z1(h7|zhPn&PXwi?1i`iYrSMPm7jaiq^tOMm#A&G}uSK9E=g&M%Os5DgJ#d(GW`#A~@GR zpu+9t9Kj?_f!c?S&|?3G;HK@*s|V-5($}Rmd_4oX`n|4BUS2oLXYA+d;mZ&8u=Dl( zua#E#Q;hV_4*)GcqE3|Qb`T0!57D95jW-%5@)t;xAF(H@cnjJ_=vLePzaV0PYY-1& zUX1z{NC)$X^122V{U5fe8z3tJjz)&i5XZj-gT+G!Y_Ea$uanSq`u8anyaux%E>KAS k0sm. + */ +public class GenericTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl { + static final Locale jaJPGeneric = new Locale("ja", "JP", "generic"); + static final Locale OSAKA = new Locale("ja", "JP", "osaka"); + + static Locale[] avail = { + jaJPGeneric + }; + + @Override + public Locale[] getAvailableLocales() { + return avail; + } + + @Override + public String getGenericDisplayName(String id, int style, Locale locale) { + if (!jaJPGeneric.equals(locale)) { + return null; + } + String std = super.getDisplayName(id, false, style, OSAKA); + return (std != null) ? "Generic " + std : null; + } +} diff --git a/jdk/test/java/util/PluggableLocale/providersrc/Makefile b/jdk/test/java/util/PluggableLocale/providersrc/Makefile index 2af60665a36..916fed91e62 100644 --- a/jdk/test/java/util/PluggableLocale/providersrc/Makefile +++ b/jdk/test/java/util/PluggableLocale/providersrc/Makefile @@ -38,6 +38,7 @@ BARFILES_JAVA = \ CurrencyNameProviderImpl.java \ CurrencyNameProviderImpl2.java \ TimeZoneNameProviderImpl.java \ + GenericTimeZoneNameProviderImpl.java \ LocaleNameProviderImpl.java \ CalendarDataProviderImpl.java \ CalendarNameProviderImpl.java \ diff --git a/jdk/test/java/util/PluggableLocale/providersrc/java.util.spi.TimeZoneNameProvider b/jdk/test/java/util/PluggableLocale/providersrc/java.util.spi.TimeZoneNameProvider index c435e04e133..a72cb416c33 100644 --- a/jdk/test/java/util/PluggableLocale/providersrc/java.util.spi.TimeZoneNameProvider +++ b/jdk/test/java/util/PluggableLocale/providersrc/java.util.spi.TimeZoneNameProvider @@ -5,3 +5,4 @@ # implementation class # com.bar.TimeZoneNameProviderImpl +com.bar.GenericTimeZoneNameProviderImpl diff --git a/jdk/test/sun/text/resources/LocaleData b/jdk/test/sun/text/resources/LocaleData index 2e630767548..8a85b7c9bf5 100644 --- a/jdk/test/sun/text/resources/LocaleData +++ b/jdk/test/sun/text/resources/LocaleData @@ -7074,3 +7074,586 @@ FormatData/sl/DatePatterns/1=dd. MMMM y # bug 7189611 CurrencyNames/es_VE/VEF=Bs.F. + +# rfe 8000983 (narrow names support) +FormatData//DayNarrows/0=S +FormatData//DayNarrows/1=M +FormatData//DayNarrows/2=T +FormatData//DayNarrows/3=W +FormatData//DayNarrows/4=T +FormatData//DayNarrows/5=F +FormatData//DayNarrows/6=S +FormatData//narrow.AmPmMarkers/0=a +FormatData//narrow.AmPmMarkers/1=p +FormatData//narrow.Eras/0=B +FormatData//narrow.Eras/1=A +FormatData//buddhist.narrow.Eras/0=BC +FormatData//buddhist.narrow.Eras/1=B.E. +FormatData//japanese.narrow.Eras/0= +FormatData//japanese.narrow.Eras/1=M +FormatData//japanese.narrow.Eras/2=T +FormatData//japanese.narrow.Eras/3=S +FormatData//japanese.narrow.Eras/4=H + +FormatData/ar/DayNarrows/0=\u062d +FormatData/ar/DayNarrows/1=\u0646 +FormatData/ar/DayNarrows/2=\u062b +FormatData/ar/DayNarrows/3=\u0631 +FormatData/ar/DayNarrows/4=\u062e +FormatData/ar/DayNarrows/5=\u062c +FormatData/ar/DayNarrows/6=\u0633 + +FormatData/be/standalone.MonthNarrows/0=\u0441 +FormatData/be/standalone.MonthNarrows/1=\u043b +FormatData/be/standalone.MonthNarrows/2=\u0441 +FormatData/be/standalone.MonthNarrows/3=\u043a +FormatData/be/standalone.MonthNarrows/4=\u043c +FormatData/be/standalone.MonthNarrows/5=\u0447 +FormatData/be/standalone.MonthNarrows/6=\u043b +FormatData/be/standalone.MonthNarrows/7=\u0436 +FormatData/be/standalone.MonthNarrows/8=\u0432 +FormatData/be/standalone.MonthNarrows/9=\u043a +FormatData/be/standalone.MonthNarrows/10=\u043b +FormatData/be/standalone.MonthNarrows/11=\u0441 +FormatData/be/standalone.MonthNarrows/12= +FormatData/be/DayNarrows/0=\u043d +FormatData/be/DayNarrows/1=\u043f +FormatData/be/DayNarrows/2=\u0430 +FormatData/be/DayNarrows/3=\u0441 +FormatData/be/DayNarrows/4=\u0447 +FormatData/be/DayNarrows/5=\u043f +FormatData/be/DayNarrows/6=\u0441 + +FormatData/bg/DayNarrows/0=\u043d +FormatData/bg/DayNarrows/1=\u043f +FormatData/bg/DayNarrows/2=\u0432 +FormatData/bg/DayNarrows/3=\u0441 +FormatData/bg/DayNarrows/4=\u0447 +FormatData/bg/DayNarrows/5=\u043f +FormatData/bg/DayNarrows/6=\u0441 + +FormatData/ca/standalone.MonthNarrows/0=g +FormatData/ca/standalone.MonthNarrows/1=f +FormatData/ca/standalone.MonthNarrows/2=m +FormatData/ca/standalone.MonthNarrows/3=a +FormatData/ca/standalone.MonthNarrows/4=m +FormatData/ca/standalone.MonthNarrows/5=j +FormatData/ca/standalone.MonthNarrows/6=j +FormatData/ca/standalone.MonthNarrows/7=a +FormatData/ca/standalone.MonthNarrows/8=s +FormatData/ca/standalone.MonthNarrows/9=o +FormatData/ca/standalone.MonthNarrows/10=n +FormatData/ca/standalone.MonthNarrows/11=d +FormatData/ca/standalone.MonthNarrows/12= +FormatData/ca/DayNarrows/0=G +# Note: "L" is a contribued item in CLDR +FormatData/ca/DayNarrows/1=L +FormatData/ca/DayNarrows/2=T +FormatData/ca/DayNarrows/3=C +FormatData/ca/DayNarrows/4=J +FormatData/ca/DayNarrows/5=V +FormatData/ca/DayNarrows/6=S +FormatData/ca/standalone.DayNarrows/0=g +FormatData/ca/standalone.DayNarrows/1=l +FormatData/ca/standalone.DayNarrows/2=t +FormatData/ca/standalone.DayNarrows/3=c +FormatData/ca/standalone.DayNarrows/4=j +FormatData/ca/standalone.DayNarrows/5=v +FormatData/ca/standalone.DayNarrows/6=s + +FormatData/cs/DayNarrows/0=N +FormatData/cs/DayNarrows/1=P +FormatData/cs/DayNarrows/2=\u00da +FormatData/cs/DayNarrows/3=S +FormatData/cs/DayNarrows/4=\u010c +FormatData/cs/DayNarrows/5=P +FormatData/cs/DayNarrows/6=S + +FormatData/da/DayNarrows/0=S +FormatData/da/DayNarrows/1=M +FormatData/da/DayNarrows/2=T +FormatData/da/DayNarrows/3=O +FormatData/da/DayNarrows/4=T +FormatData/da/DayNarrows/5=F +FormatData/da/DayNarrows/6=L + +FormatData/de/DayNarrows/0=S +FormatData/de/DayNarrows/1=M +FormatData/de/DayNarrows/2=D +FormatData/de/DayNarrows/3=M +FormatData/de/DayNarrows/4=D +FormatData/de/DayNarrows/5=F +FormatData/de/DayNarrows/6=S + +FormatData/el/DayNarrows/0=\u039a +FormatData/el/DayNarrows/1=\u0394 +FormatData/el/DayNarrows/2=\u03a4 +FormatData/el/DayNarrows/3=\u03a4 +FormatData/el/DayNarrows/4=\u03a0 +FormatData/el/DayNarrows/5=\u03a0 +FormatData/el/DayNarrows/6=\u03a3 + +FormatData/es/DayNarrows/0=D +FormatData/es/DayNarrows/1=L +FormatData/es/DayNarrows/2=M +FormatData/es/DayNarrows/3=X +FormatData/es/DayNarrows/4=J +FormatData/es/DayNarrows/5=V +FormatData/es/DayNarrows/6=S + +FormatData/et/DayNarrows/0=P +FormatData/et/DayNarrows/1=E +FormatData/et/DayNarrows/2=T +FormatData/et/DayNarrows/3=K +FormatData/et/DayNarrows/4=N +FormatData/et/DayNarrows/5=R +FormatData/et/DayNarrows/6=L + +FormatData/fi/standalone.MonthNarrows/0=T +FormatData/fi/standalone.MonthNarrows/1=H +FormatData/fi/standalone.MonthNarrows/2=M +FormatData/fi/standalone.MonthNarrows/3=H +FormatData/fi/standalone.MonthNarrows/4=T +FormatData/fi/standalone.MonthNarrows/5=K +FormatData/fi/standalone.MonthNarrows/6=H +FormatData/fi/standalone.MonthNarrows/7=E +FormatData/fi/standalone.MonthNarrows/8=S +FormatData/fi/standalone.MonthNarrows/9=L +FormatData/fi/standalone.MonthNarrows/10=M +FormatData/fi/standalone.MonthNarrows/11=J +FormatData/fi/standalone.MonthNarrows/12= +FormatData/fi/DayNarrows/0=S +FormatData/fi/DayNarrows/1=M +FormatData/fi/DayNarrows/2=T +FormatData/fi/DayNarrows/3=K +FormatData/fi/DayNarrows/4=T +FormatData/fi/DayNarrows/5=P +FormatData/fi/DayNarrows/6=L +FormatData/fi/standalone.DayNarrows/0=S +FormatData/fi/standalone.DayNarrows/1=M +FormatData/fi/standalone.DayNarrows/2=T +FormatData/fi/standalone.DayNarrows/3=K +FormatData/fi/standalone.DayNarrows/4=T +FormatData/fi/standalone.DayNarrows/5=P +FormatData/fi/standalone.DayNarrows/6=L +FormatData/fi/narrow.AmPmMarkers/0=ap. +FormatData/fi/narrow.AmPmMarkers/1=ip. + +FormatData/fr/DayNarrows/0=D +FormatData/fr/DayNarrows/1=L +FormatData/fr/DayNarrows/2=M +FormatData/fr/DayNarrows/3=M +FormatData/fr/DayNarrows/4=J +FormatData/fr/DayNarrows/5=V +FormatData/fr/DayNarrows/6=S + +FormatData/hi_IN/DayNarrows/0=\u0930 +FormatData/hi_IN/DayNarrows/1=\u0938\u094b +FormatData/hi_IN/DayNarrows/2=\u092e\u0902 +FormatData/hi_IN/DayNarrows/3=\u092c\u0941 +FormatData/hi_IN/DayNarrows/4=\u0917\u0941 +FormatData/hi_IN/DayNarrows/5=\u0936\u0941 +FormatData/hi_IN/DayNarrows/6=\u0936 + +FormatData/hr/standalone.MonthNarrows/0=1. +FormatData/hr/standalone.MonthNarrows/1=2. +FormatData/hr/standalone.MonthNarrows/2=3. +FormatData/hr/standalone.MonthNarrows/3=4. +FormatData/hr/standalone.MonthNarrows/4=5. +FormatData/hr/standalone.MonthNarrows/5=6. +FormatData/hr/standalone.MonthNarrows/6=7. +FormatData/hr/standalone.MonthNarrows/7=8. +FormatData/hr/standalone.MonthNarrows/8=9. +FormatData/hr/standalone.MonthNarrows/9=10. +FormatData/hr/standalone.MonthNarrows/10=11. +FormatData/hr/standalone.MonthNarrows/11=12. +FormatData/hr/standalone.MonthNarrows/12= +FormatData/hr/DayNarrows/0=N +FormatData/hr/DayNarrows/1=P +FormatData/hr/DayNarrows/2=U +FormatData/hr/DayNarrows/3=S +FormatData/hr/DayNarrows/4=\u010c +FormatData/hr/DayNarrows/5=P +FormatData/hr/DayNarrows/6=S +FormatData/hr/standalone.DayNarrows/0=n +FormatData/hr/standalone.DayNarrows/1=p +FormatData/hr/standalone.DayNarrows/2=u +FormatData/hr/standalone.DayNarrows/3=s +FormatData/hr/standalone.DayNarrows/4=\u010d +FormatData/hr/standalone.DayNarrows/5=p +FormatData/hr/standalone.DayNarrows/6=s + +FormatData/hu/DayNarrows/0=V +FormatData/hu/DayNarrows/1=H +FormatData/hu/DayNarrows/2=K +FormatData/hu/DayNarrows/3=Sz +FormatData/hu/DayNarrows/4=Cs +FormatData/hu/DayNarrows/5=P +FormatData/hu/DayNarrows/6=Sz + +FormatData/is/standalone.MonthNarrows/0=j +FormatData/is/standalone.MonthNarrows/1=f +FormatData/is/standalone.MonthNarrows/2=m +FormatData/is/standalone.MonthNarrows/3=a +FormatData/is/standalone.MonthNarrows/4=m +FormatData/is/standalone.MonthNarrows/5=j +FormatData/is/standalone.MonthNarrows/6=j +FormatData/is/standalone.MonthNarrows/7=\u00e1 +FormatData/is/standalone.MonthNarrows/8=s +FormatData/is/standalone.MonthNarrows/9=o +FormatData/is/standalone.MonthNarrows/10=n +FormatData/is/standalone.MonthNarrows/11=d +FormatData/is/standalone.MonthNarrows/12= +FormatData/is/DayNarrows/0=S +FormatData/is/DayNarrows/1=M +FormatData/is/DayNarrows/2=\u00de +FormatData/is/DayNarrows/3=M +FormatData/is/DayNarrows/4=F +FormatData/is/DayNarrows/5=F +FormatData/is/DayNarrows/6=L +FormatData/is/standalone.DayNarrows/0=s +FormatData/is/standalone.DayNarrows/1=m +FormatData/is/standalone.DayNarrows/2=\u00fe +FormatData/is/standalone.DayNarrows/3=m +FormatData/is/standalone.DayNarrows/4=f +FormatData/is/standalone.DayNarrows/5=f +FormatData/is/standalone.DayNarrows/6=l + +FormatData/it/DayNarrows/0=D +FormatData/it/DayNarrows/1=L +FormatData/it/DayNarrows/2=M +FormatData/it/DayNarrows/3=M +FormatData/it/DayNarrows/4=G +FormatData/it/DayNarrows/5=V +FormatData/it/DayNarrows/6=S + +FormatData/iw/DayNarrows/0=\u05d0 +FormatData/iw/DayNarrows/1=\u05d1 +FormatData/iw/DayNarrows/2=\u05d2 +FormatData/iw/DayNarrows/3=\u05d3 +FormatData/iw/DayNarrows/4=\u05d4 +FormatData/iw/DayNarrows/5=\u05d5 +FormatData/iw/DayNarrows/6=\u05e9 +FormatData/iw/standalone.DayNarrows/0=\u05d0 +FormatData/iw/standalone.DayNarrows/1=\u05d1 +FormatData/iw/standalone.DayNarrows/2=\u05d2 +FormatData/iw/standalone.DayNarrows/3=\u05d3 +FormatData/iw/standalone.DayNarrows/4=\u05d4 +FormatData/iw/standalone.DayNarrows/5=\u05d5 +FormatData/iw/standalone.DayNarrows/6=\u05e9 + +FormatData/ja/DayNarrows/0=\u65e5 +FormatData/ja/DayNarrows/1=\u6708 +FormatData/ja/DayNarrows/2=\u706b +FormatData/ja/DayNarrows/3=\u6c34 +FormatData/ja/DayNarrows/4=\u6728 +FormatData/ja/DayNarrows/5=\u91d1 +FormatData/ja/DayNarrows/6=\u571f + +FormatData/ko/DayNarrows/0=\uc77c +FormatData/ko/DayNarrows/1=\uc6d4 +FormatData/ko/DayNarrows/2=\ud654 +FormatData/ko/DayNarrows/3=\uc218 +FormatData/ko/DayNarrows/4=\ubaa9 +FormatData/ko/DayNarrows/5=\uae08 +FormatData/ko/DayNarrows/6=\ud1a0 + +FormatData/lt/standalone.MonthNarrows/0=S +FormatData/lt/standalone.MonthNarrows/1=V +FormatData/lt/standalone.MonthNarrows/2=K +FormatData/lt/standalone.MonthNarrows/3=B +FormatData/lt/standalone.MonthNarrows/4=G +FormatData/lt/standalone.MonthNarrows/5=B +FormatData/lt/standalone.MonthNarrows/6=L +FormatData/lt/standalone.MonthNarrows/7=R +FormatData/lt/standalone.MonthNarrows/8=R +FormatData/lt/standalone.MonthNarrows/9=S +FormatData/lt/standalone.MonthNarrows/10=L +FormatData/lt/standalone.MonthNarrows/11=G +FormatData/lt/standalone.MonthNarrows/12= + +FormatData/lt/DayNarrows/0=S +FormatData/lt/DayNarrows/1=P +FormatData/lt/DayNarrows/2=A +FormatData/lt/DayNarrows/3=T +FormatData/lt/DayNarrows/4=K +FormatData/lt/DayNarrows/5=P +FormatData/lt/DayNarrows/6=\u0160 +FormatData/lt/standalone.DayNarrows/0=S +FormatData/lt/standalone.DayNarrows/1=P +FormatData/lt/standalone.DayNarrows/2=A +FormatData/lt/standalone.DayNarrows/3=T +FormatData/lt/standalone.DayNarrows/4=K +FormatData/lt/standalone.DayNarrows/5=P +FormatData/lt/standalone.DayNarrows/6=\u0160 + +FormatData/lv/DayNarrows/0=S +FormatData/lv/DayNarrows/1=P +FormatData/lv/DayNarrows/2=O +FormatData/lv/DayNarrows/3=T +FormatData/lv/DayNarrows/4=C +FormatData/lv/DayNarrows/5=P +FormatData/lv/DayNarrows/6=S + +FormatData/mk/DayNarrows/0=\u043d +FormatData/mk/DayNarrows/1=\u043f +FormatData/mk/DayNarrows/2=\u0432 +FormatData/mk/DayNarrows/3=\u0441 +FormatData/mk/DayNarrows/4=\u0447 +FormatData/mk/DayNarrows/5=\u043f +FormatData/mk/DayNarrows/6=\u0441 + +FormatData/ms/standalone.MonthNarrows/0=J +FormatData/ms/standalone.MonthNarrows/1=F +FormatData/ms/standalone.MonthNarrows/2=M +FormatData/ms/standalone.MonthNarrows/3=A +FormatData/ms/standalone.MonthNarrows/4=M +FormatData/ms/standalone.MonthNarrows/5=J +FormatData/ms/standalone.MonthNarrows/6=J +FormatData/ms/standalone.MonthNarrows/7=O +FormatData/ms/standalone.MonthNarrows/8=S +FormatData/ms/standalone.MonthNarrows/9=O +FormatData/ms/standalone.MonthNarrows/10=N +FormatData/ms/standalone.MonthNarrows/11=D +FormatData/ms/standalone.MonthNarrows/12= +FormatData/ms/DayNarrows/0=A +FormatData/ms/DayNarrows/1=I +FormatData/ms/DayNarrows/2=S +FormatData/ms/DayNarrows/3=R +FormatData/ms/DayNarrows/4=K +FormatData/ms/DayNarrows/5=J +FormatData/ms/DayNarrows/6=S +FormatData/ms/standalone.DayNarrows/0=A +FormatData/ms/standalone.DayNarrows/1=I +FormatData/ms/standalone.DayNarrows/2=S +FormatData/ms/standalone.DayNarrows/3=R +FormatData/ms/standalone.DayNarrows/4=K +FormatData/ms/standalone.DayNarrows/5=J +FormatData/ms/standalone.DayNarrows/6=S + +FormatData/mt/DayNarrows/0=\u0126 +FormatData/mt/DayNarrows/1=T +FormatData/mt/DayNarrows/2=T +FormatData/mt/DayNarrows/3=E +FormatData/mt/DayNarrows/4=\u0126 +FormatData/mt/DayNarrows/5=\u0120 +FormatData/mt/DayNarrows/6=S + +FormatData/nl/DayNarrows/0=Z +FormatData/nl/DayNarrows/1=M +FormatData/nl/DayNarrows/2=D +FormatData/nl/DayNarrows/3=W +FormatData/nl/DayNarrows/4=D +FormatData/nl/DayNarrows/5=V +FormatData/nl/DayNarrows/6=Z + +FormatData/pl/DayNarrows/0=N +FormatData/pl/DayNarrows/1=P +FormatData/pl/DayNarrows/2=W +FormatData/pl/DayNarrows/3=\u015a +FormatData/pl/DayNarrows/4=C +FormatData/pl/DayNarrows/5=P +FormatData/pl/DayNarrows/6=S + +FormatData/pt/DayNarrows/0=D +FormatData/pt/DayNarrows/1=S +FormatData/pt/DayNarrows/2=T +FormatData/pt/DayNarrows/3=Q +FormatData/pt/DayNarrows/4=Q +FormatData/pt/DayNarrows/5=S +FormatData/pt/DayNarrows/6=S + +FormatData/ro/standalone.MonthNarrows/0=I +FormatData/ro/standalone.MonthNarrows/1=F +FormatData/ro/standalone.MonthNarrows/2=M +FormatData/ro/standalone.MonthNarrows/3=A +FormatData/ro/standalone.MonthNarrows/4=M +FormatData/ro/standalone.MonthNarrows/5=I +FormatData/ro/standalone.MonthNarrows/6=I +FormatData/ro/standalone.MonthNarrows/7=A +FormatData/ro/standalone.MonthNarrows/8=S +FormatData/ro/standalone.MonthNarrows/9=O +FormatData/ro/standalone.MonthNarrows/10=N +FormatData/ro/standalone.MonthNarrows/11=D +FormatData/ro/standalone.MonthNarrows/12= +# commented out DayNarrows due to mostly undefined +#FormatData/ro/DayNarrows/0=D +#FormatData/ro/DayNarrows/1= +#FormatData/ro/DayNarrows/2= +#FormatData/ro/DayNarrows/3= +#FormatData/ro/DayNarrows/4= +#FormatData/ro/DayNarrows/5= +#FormatData/ro/DayNarrows/6= +FormatData/ro/standalone.DayNarrows/0=D +FormatData/ro/standalone.DayNarrows/1=L +FormatData/ro/standalone.DayNarrows/2=M +FormatData/ro/standalone.DayNarrows/3=M +FormatData/ro/standalone.DayNarrows/4=J +FormatData/ro/standalone.DayNarrows/5=V +FormatData/ro/standalone.DayNarrows/6=S + +FormatData/ru/DayNarrows/0=\u0412 +FormatData/ru/DayNarrows/1=\u041f\u043d +FormatData/ru/DayNarrows/2=\u0412\u0442 +FormatData/ru/DayNarrows/3=\u0421 +FormatData/ru/DayNarrows/4=\u0427 +FormatData/ru/DayNarrows/5=\u041f +# Note: "sat" is an contributed item in CLDR. +FormatData/ru/DayNarrows/6=\u0421 + +FormatData/ru/standalone.DayNarrows/0=\u0412 +FormatData/ru/standalone.DayNarrows/1=\u041f +FormatData/ru/standalone.DayNarrows/2=\u0412 +FormatData/ru/standalone.DayNarrows/3=\u0421 +FormatData/ru/standalone.DayNarrows/4=\u0427 +FormatData/ru/standalone.DayNarrows/5=\u041f +FormatData/ru/standalone.DayNarrows/6=\u0421 + +FormatData/sk/DayNarrows/0=N +FormatData/sk/DayNarrows/1=P +FormatData/sk/DayNarrows/2=U +FormatData/sk/DayNarrows/3=S +FormatData/sk/DayNarrows/4=\u0160 +FormatData/sk/DayNarrows/5=P +FormatData/sk/DayNarrows/6=S + +FormatData/sl/DayNarrows/0=n +FormatData/sl/DayNarrows/1=p +FormatData/sl/DayNarrows/2=t +FormatData/sl/DayNarrows/3=s +FormatData/sl/DayNarrows/4=\u010d +FormatData/sl/DayNarrows/5=p +FormatData/sl/DayNarrows/6=s + +FormatData/sq/DayNarrows/0=D +FormatData/sq/DayNarrows/1=H +FormatData/sq/DayNarrows/2=M +FormatData/sq/DayNarrows/3=M +FormatData/sq/DayNarrows/4=E +FormatData/sq/DayNarrows/5=P +FormatData/sq/DayNarrows/6=S + +FormatData/sr/DayNarrows/0=\u043d +FormatData/sr/DayNarrows/1=\u043f +FormatData/sr/DayNarrows/2=\u0443 +FormatData/sr/DayNarrows/3=\u0441 +FormatData/sr/DayNarrows/4=\u0447 +FormatData/sr/DayNarrows/5=\u043f +FormatData/sr/DayNarrows/6=\u0441 +FormatData/sr/short.Eras/0=\u043f. \u043d. \u0435. +FormatData/sr/short.Eras/1=\u043d. \u0435. +FormatData/sr/narrow.Eras/0=\u043f.\u043d.\u0435. +FormatData/sr/narrow.Eras/1=\u043d.\u0435. + +FormatData/sv/standalone.MonthNarrows/0=J +FormatData/sv/standalone.MonthNarrows/1=F +FormatData/sv/standalone.MonthNarrows/2=M +FormatData/sv/standalone.MonthNarrows/3=A +FormatData/sv/standalone.MonthNarrows/4=M +FormatData/sv/standalone.MonthNarrows/5=J +FormatData/sv/standalone.MonthNarrows/6=J +FormatData/sv/standalone.MonthNarrows/7=A +FormatData/sv/standalone.MonthNarrows/8=S +FormatData/sv/standalone.MonthNarrows/9=O +FormatData/sv/standalone.MonthNarrows/10=N +FormatData/sv/standalone.MonthNarrows/11=D +FormatData/sv/standalone.MonthNarrows/12= +FormatData/sv/DayNarrows/0=S +FormatData/sv/DayNarrows/1=M +FormatData/sv/DayNarrows/2=T +FormatData/sv/DayNarrows/3=O +FormatData/sv/DayNarrows/4=T +FormatData/sv/DayNarrows/5=F +FormatData/sv/DayNarrows/6=L +FormatData/sv/standalone.DayNarrows/0=S +FormatData/sv/standalone.DayNarrows/1=M +FormatData/sv/standalone.DayNarrows/2=T +FormatData/sv/standalone.DayNarrows/3=O +FormatData/sv/standalone.DayNarrows/4=T +FormatData/sv/standalone.DayNarrows/5=F +FormatData/sv/standalone.DayNarrows/6=L +FormatData/sv/narrow.Eras/0=f.Kr. +FormatData/sv/narrow.Eras/1=e.Kr. +FormatData/sv/narrow.AmPmMarkers/0=f +FormatData/sv/narrow.AmPmMarkers/1=e + +FormatData/th/standalone.MonthNarrows/0=\u0e21.\u0e04. +FormatData/th/standalone.MonthNarrows/1=\u0e01.\u0e1e. +FormatData/th/standalone.MonthNarrows/2=\u0e21\u0e35.\u0e04. +FormatData/th/standalone.MonthNarrows/3=\u0e40\u0e21.\u0e22. +FormatData/th/standalone.MonthNarrows/4=\u0e1e.\u0e04. +FormatData/th/standalone.MonthNarrows/5=\u0e21\u0e34.\u0e22. +FormatData/th/standalone.MonthNarrows/6=\u0e01.\u0e04. +FormatData/th/standalone.MonthNarrows/7=\u0e2a.\u0e04. +FormatData/th/standalone.MonthNarrows/8=\u0e01.\u0e22. +FormatData/th/standalone.MonthNarrows/9=\u0e15.\u0e04. +FormatData/th/standalone.MonthNarrows/10=\u0e1e.\u0e22. +FormatData/th/standalone.MonthNarrows/11=\u0e18.\u0e04. +FormatData/th/standalone.MonthNarrows/12= +FormatData/th/DayNarrows/0=\u0e2d +FormatData/th/DayNarrows/1=\u0e08 +FormatData/th/DayNarrows/2=\u0e2d +FormatData/th/DayNarrows/3=\u0e1e +FormatData/th/DayNarrows/4=\u0e1e +FormatData/th/DayNarrows/5=\u0e28 +FormatData/th/DayNarrows/6=\u0e2a +FormatData/th/narrow.Eras/0=\u0e01\u0e48\u0e2d\u0e19 \u0e04.\u0e28. +FormatData/th/narrow.Eras/1=\u0e04.\u0e28. + +FormatData/tr/standalone.MonthNarrows/0=O +FormatData/tr/standalone.MonthNarrows/1=\u015e +FormatData/tr/standalone.MonthNarrows/2=M +FormatData/tr/standalone.MonthNarrows/3=N +FormatData/tr/standalone.MonthNarrows/4=M +FormatData/tr/standalone.MonthNarrows/5=H +FormatData/tr/standalone.MonthNarrows/6=T +FormatData/tr/standalone.MonthNarrows/7=A +FormatData/tr/standalone.MonthNarrows/8=E +FormatData/tr/standalone.MonthNarrows/9=E +FormatData/tr/standalone.MonthNarrows/10=K +FormatData/tr/standalone.MonthNarrows/11=A +FormatData/tr/standalone.MonthNarrows/12= +FormatData/tr/DayNarrows/0=P +FormatData/tr/DayNarrows/1=P +FormatData/tr/DayNarrows/2=S +FormatData/tr/DayNarrows/3=\u00c7 +FormatData/tr/DayNarrows/4=P +FormatData/tr/DayNarrows/5=C +FormatData/tr/DayNarrows/6=C + +FormatData/uk/DayNarrows/0=\u041d +FormatData/uk/DayNarrows/1=\u041f +FormatData/uk/DayNarrows/2=\u0412 +FormatData/uk/DayNarrows/3=\u0421 +FormatData/uk/DayNarrows/4=\u0427 +FormatData/uk/DayNarrows/5=\u041f +FormatData/uk/DayNarrows/6=\u0421 + +FormatData/vi/DayNarrows/0=CN +FormatData/vi/DayNarrows/1=T2 +FormatData/vi/DayNarrows/2=T3 +FormatData/vi/DayNarrows/3=T4 +FormatData/vi/DayNarrows/4=T5 +FormatData/vi/DayNarrows/5=T6 +FormatData/vi/DayNarrows/6=T7 + +FormatData/zh/standalone.MonthNarrows/0=1\u6708 +FormatData/zh/standalone.MonthNarrows/1=2\u6708 +FormatData/zh/standalone.MonthNarrows/2=3\u6708 +FormatData/zh/standalone.MonthNarrows/3=4\u6708 +FormatData/zh/standalone.MonthNarrows/4=5\u6708 +FormatData/zh/standalone.MonthNarrows/5=6\u6708 +FormatData/zh/standalone.MonthNarrows/6=7\u6708 +FormatData/zh/standalone.MonthNarrows/7=8\u6708 +FormatData/zh/standalone.MonthNarrows/8=9\u6708 +FormatData/zh/standalone.MonthNarrows/9=10\u6708 +FormatData/zh/standalone.MonthNarrows/10=11\u6708 +FormatData/zh/standalone.MonthNarrows/11=12\u6708 +FormatData/zh/standalone.MonthNarrows/12= +FormatData/zh/DayNarrows/0=\u65e5 +FormatData/zh/DayNarrows/1=\u4e00 +FormatData/zh/DayNarrows/2=\u4e8c +FormatData/zh/DayNarrows/3=\u4e09 +FormatData/zh/DayNarrows/4=\u56db +FormatData/zh/DayNarrows/5=\u4e94 +FormatData/zh/DayNarrows/6=\u516d diff --git a/jdk/test/sun/text/resources/LocaleDataTest.java b/jdk/test/sun/text/resources/LocaleDataTest.java index 51bf527bce1..837a8aa411e 100644 --- a/jdk/test/sun/text/resources/LocaleDataTest.java +++ b/jdk/test/sun/text/resources/LocaleDataTest.java @@ -34,7 +34,7 @@ * 6509039 6609737 6610748 6645271 6507067 6873931 6450945 6645268 6646611 * 6645405 6650730 6910489 6573250 6870908 6585666 6716626 6914413 6916787 * 6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495 - * 7003124 7085757 7028073 7171028 7189611 + * 7003124 7085757 7028073 7171028 7189611 8000983 * @summary Verify locale data * */ From 5e999034a3c2ea89a80c0656eee07a1aa72c255b Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Mon, 10 Dec 2012 14:56:44 +0000 Subject: [PATCH 86/94] 8003948: NTLM/Negotiate authentication problem Reviewed-by: chegar, weijun --- .../classes/sun/net/www/MessageHeader.java | 37 ++++++++++ .../www/protocol/http/HttpURLConnection.java | 17 +++++ jdk/test/sun/net/www/MessageHeaderTest.java | 74 +++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 jdk/test/sun/net/www/MessageHeaderTest.java diff --git a/jdk/src/share/classes/sun/net/www/MessageHeader.java b/jdk/src/share/classes/sun/net/www/MessageHeader.java index dbb2cfc7c3a..3a46def13b3 100644 --- a/jdk/src/share/classes/sun/net/www/MessageHeader.java +++ b/jdk/src/share/classes/sun/net/www/MessageHeader.java @@ -137,6 +137,43 @@ class MessageHeader { return null; } + /** + * Removes bare Negotiate and Kerberos headers when an "NTLM ..." + * appears. All Performed on headers with key being k. + * @return true if there is a change + */ + public boolean filterNTLMResponses(String k) { + boolean found = false; + for (int i=0; i 5 + && values[i].substring(0, 5).equalsIgnoreCase("NTLM ")) { + found = true; + break; + } + } + if (found) { + int j = 0; + for (int i=0; i { int index = 0; int next = -1; diff --git a/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 87fdaa82bf2..8003b5a5433 100644 --- a/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -1326,6 +1326,16 @@ public class HttpURLConnection extends java.net.HttpURLConnection { if (logger.isLoggable(PlatformLogger.FINE)) { logger.fine(responses.toString()); } + + boolean b1 = responses.filterNTLMResponses("WWW-Authenticate"); + boolean b2 = responses.filterNTLMResponses("Proxy-Authenticate"); + if (b1 || b2) { + if (logger.isLoggable(PlatformLogger.FINE)) { + logger.fine(">>>> Headers are filtered"); + logger.fine(responses.toString()); + } + } + inputStream = http.getInputStream(); respCode = getResponseCode(); @@ -1784,6 +1794,13 @@ public class HttpURLConnection extends java.net.HttpURLConnection { logger.fine(responses.toString()); } + if (responses.filterNTLMResponses("Proxy-Authenticate")) { + if (logger.isLoggable(PlatformLogger.FINE)) { + logger.fine(">>>> Headers are filtered"); + logger.fine(responses.toString()); + } + } + statusLine = responses.getValue(0); StringTokenizer st = new StringTokenizer(statusLine); st.nextToken(); diff --git a/jdk/test/sun/net/www/MessageHeaderTest.java b/jdk/test/sun/net/www/MessageHeaderTest.java new file mode 100644 index 00000000000..aceb635cfae --- /dev/null +++ b/jdk/test/sun/net/www/MessageHeaderTest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8003948 + * @run main MessageHeaderTest + */ +import java.io.*; +import sun.net.www.MessageHeader; + +public class MessageHeaderTest { + public static void main (String[] args) throws Exception { + for (int i=0; i<7; i++) { + ByteArrayInputStream bis = new ByteArrayInputStream(headers[i].getBytes()); + MessageHeader h = new MessageHeader(bis); + String before = h.toString(); + before = before.substring(before.indexOf('{')); + boolean result = h.filterNTLMResponses("WWW-Authenticate"); + String after = h.toString(); + after = after.substring(after.indexOf('{')); + if (!expected[i].equals(after)) { + throw new RuntimeException(Integer.toString(i) + " expected != after"); + } + if (result != expectedResult[i]) { + throw new RuntimeException(Integer.toString(i) + " result != expectedResult"); + } + } + } + + static String expected[] = { + "{null: HTTP/1.1 200 Ok}{Foo: bar}{Bar: foo}{WWW-Authenticate: NTLM sdsds}", + "{null: HTTP/1.1 200 Ok}{Foo: bar}{Bar: foo}{WWW-Authenticate: }", + "{null: HTTP/1.1 200 Ok}{Foo: bar}{Bar: foo}{WWW-Authenticate: NTLM sdsds}", + "{null: HTTP/1.1 200 Ok}{Foo: bar}{Bar: foo}{WWW-Authenticate: NTLM sdsds}", + "{null: HTTP/1.1 200 Ok}{Foo: bar}{Bar: foo}{WWW-Authenticate: NTLM sdsds}{Bar: foo}", + "{null: HTTP/1.1 200 Ok}{WWW-Authenticate: Negotiate}{Foo: bar}{Bar: foo}{WWW-Authenticate: NTLM}{Bar: foo}{WWW-Authenticate: Kerberos}", + "{null: HTTP/1.1 200 Ok}{Foo: foo}{Bar: }{WWW-Authenticate: NTLM blob}{Bar: foo blob}" + }; + + static boolean[] expectedResult = { + false, false, true, true, true, false, false + }; + + static String[] headers = { + "HTTP/1.1 200 Ok\r\nFoo: bar\r\nBar: foo\r\nWWW-Authenticate: NTLM sdsds", + "HTTP/1.1 200 Ok\r\nFoo: bar\r\nBar: foo\r\nWWW-Authenticate:", + "HTTP/1.1 200 Ok\r\nFoo: bar\r\nBar: foo\r\nWWW-Authenticate: NTLM sdsds\r\nWWW-Authenticate: Negotiate", + "HTTP/1.1 200 Ok\r\nFoo: bar\r\nBar: foo\r\nWWW-Authenticate: NTLM sdsds\r\nWWW-Authenticate: Negotiate\r\nWWW-Authenticate: Kerberos", + "HTTP/1.1 200 Ok\r\nWWW-Authenticate: Negotiate\r\nFoo: bar\r\nBar: foo\r\nWWW-Authenticate: NTLM sdsds\r\nBar: foo\r\nWWW-Authenticate: Kerberos", + "HTTP/1.1 200 Ok\r\nWWW-Authenticate: Negotiate\r\nFoo: bar\r\nBar: foo\r\nWWW-Authenticate: NTLM\r\nBar: foo\r\nWWW-Authenticate: Kerberos", + "HTTP/1.1 200 Ok\r\nFoo: foo\r\nBar:\r\nWWW-Authenticate: NTLM blob\r\nBar: foo blob" + }; +} From e4a502d7f5f6c5a875d8a1e0223172fb5144aedc Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Mon, 10 Dec 2012 15:15:57 -0800 Subject: [PATCH 87/94] 4819681: Typo in http://java.sun.com/j2se/1.4.1/docs/api/java/util/logging/LogManager.html Simple capitalization typo in LogManager() description Reviewed-by: darcy, mchung --- jdk/src/share/classes/java/util/logging/LogManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/util/logging/LogManager.java b/jdk/src/share/classes/java/util/logging/LogManager.java index 8d83108b712..ef8158a1366 100644 --- a/jdk/src/share/classes/java/util/logging/LogManager.java +++ b/jdk/src/share/classes/java/util/logging/LogManager.java @@ -243,7 +243,7 @@ public class LogManager { * Protected constructor. This is protected so that container applications * (such as J2EE containers) can subclass the object. It is non-public as * it is intended that there only be one LogManager object, whose value is - * retrieved by calling Logmanager.getLogManager. + * retrieved by calling LogManager.getLogManager. */ protected LogManager() { // Add a shutdown hook to close the global handlers. From 9cb760fd37b68f676c7ad92e5245dfd90ce2b79c Mon Sep 17 00:00:00 2001 From: Frank Ding Date: Tue, 11 Dec 2012 10:42:24 +0800 Subject: [PATCH 88/94] 6512101: Incorrect encoding in NetworkInterface.getDisplayName() Reviewed-by: chegar, dsamersoff --- .../native/java/net/NetworkInterface.c | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/jdk/src/windows/native/java/net/NetworkInterface.c b/jdk/src/windows/native/java/net/NetworkInterface.c index b0f9344db4a..6d144659235 100644 --- a/jdk/src/windows/native/java/net/NetworkInterface.c +++ b/jdk/src/windows/native/java/net/NetworkInterface.c @@ -178,7 +178,7 @@ int enumInterfaces(JNIEnv *env, netif **netifPP) int count; netif *netifP; DWORD i; - int lo=0, eth=0, tr=0, fddi=0, ppp=0, sl=0, wlan=0, net=0; + int lo=0, eth=0, tr=0, fddi=0, ppp=0, sl=0, wlan=0, net=0, wlen=0; /* * Ask the IP Helper library to enumerate the adapters @@ -260,8 +260,17 @@ int enumInterfaces(JNIEnv *env, netif **netifPP) */ curr = (netif *)calloc(1, sizeof(netif)); if (curr != NULL) { + wlen = MultiByteToWideChar(CP_OEMCP, 0, ifrowP->bDescr, + ifrowP->dwDescrLen, NULL, 0); + if(wlen == 0) { + // MultiByteToWideChar should not fail + // But in rare case it fails, we allow 'char' to be displayed + curr->displayName = (char *)malloc(ifrowP->dwDescrLen + 1); + } else { + curr->displayName = (wchar_t *)malloc(wlen*(sizeof(wchar_t))+1); + } + curr->name = (char *)malloc(strlen(dev_name) + 1); - curr->displayName = (char *)malloc(ifrowP->dwDescrLen + 1); if (curr->name == NULL || curr->displayName == NULL) { if (curr->name) free(curr->name); @@ -282,8 +291,29 @@ int enumInterfaces(JNIEnv *env, netif **netifPP) * 32-bit numbers as index values. */ strcpy(curr->name, dev_name); - strncpy(curr->displayName, ifrowP->bDescr, ifrowP->dwDescrLen); - curr->displayName[ifrowP->dwDescrLen] = '\0'; + if (wlen == 0) { + // display char type in case of MultiByteToWideChar failure + strncpy(curr->displayName, ifrowP->bDescr, ifrowP->dwDescrLen); + curr->displayName[ifrowP->dwDescrLen] = '\0'; + } else { + // call MultiByteToWideChar again to fill curr->displayName + // it should not fail, because we have called it once before + if (MultiByteToWideChar(CP_OEMCP, 0, ifrowP->bDescr, + ifrowP->dwDescrLen, curr->displayName, wlen) == 0) { + JNU_ThrowByName(env, "java/lang/Error", + "Cannot get multibyte char for interface display name"); + free_netif(netifP); + free(tableP); + free(curr->name); + free(curr->displayName); + free(curr); + return -1; + } else { + curr->displayName[wlen*(sizeof(wchar_t))] = '\0'; + curr->dNameIsUnicode = TRUE; + } + } + curr->dwIndex = ifrowP->dwIndex; curr->ifType = ifrowP->dwType; curr->index = GetFriendlyIfIndex(ifrowP->dwIndex); From 2be2f20b659fdb22fc1121cfbe7f91c4a00b60c3 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Tue, 11 Dec 2012 13:14:56 +0800 Subject: [PATCH 89/94] 8004488: wrong permissions checked in krb5 Reviewed-by: xuelei --- .../security/auth/module/Krb5LoginModule.java | 4 -- .../sun/security/jgss/krb5/Krb5Util.java | 62 ++++--------------- .../security/krb5/auto/KeyPermissions.java | 56 +++++++++++++++++ .../sun/security/krb5/auto/KeyTabCompat.java | 18 +----- 4 files changed, 72 insertions(+), 68 deletions(-) create mode 100644 jdk/test/sun/security/krb5/auto/KeyPermissions.java diff --git a/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java b/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java index 5779da791e5..3d1744ba172 100644 --- a/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java +++ b/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java @@ -1067,10 +1067,6 @@ public class Krb5LoginModule implements LoginModule { if (ktab != null) { if (!privCredSet.contains(ktab)) { privCredSet.add(ktab); - // Compatibility; also add keys to privCredSet - for (KerberosKey key: ktab.getKeys(kerbClientPrinc)) { - privCredSet.add(new Krb5Util.KeysFromKeyTab(key)); - } } } else { succeeded = false; diff --git a/jdk/src/share/classes/sun/security/jgss/krb5/Krb5Util.java b/jdk/src/share/classes/sun/security/jgss/krb5/Krb5Util.java index 97f1a12447c..ec5bc9ca43b 100644 --- a/jdk/src/share/classes/sun/security/jgss/krb5/Krb5Util.java +++ b/jdk/src/share/classes/sun/security/jgss/krb5/Krb5Util.java @@ -40,10 +40,7 @@ import sun.security.krb5.EncryptionKey; import sun.security.krb5.KrbException; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; -import java.util.Objects; -import java.util.Set; import sun.security.krb5.KerberosSecrets; import sun.security.krb5.PrincipalName; /** @@ -189,18 +186,6 @@ public class Krb5Util { return subject; } - // A special KerberosKey, used as keys read from a KeyTab object. - // Each time new keys are read from KeyTab objects in the private - // credentials set, old ones are removed and new ones added. - public static class KeysFromKeyTab extends KerberosKey { - private static final long serialVersionUID = 8238092170252746927L; - - public KeysFromKeyTab(KerberosKey key) { - super(key.getPrincipal(), key.getEncoded(), - key.getKeyType(), key.getVersionNumber()); - } - } - /** * Credentials of a service, the private secret to authenticate its * identity, which can be: @@ -239,7 +224,7 @@ public class Krb5Util { // Compatibility with old behavior: even when there is no // KerberosPrincipal, we can find one from KerberosKeys List keys = SubjectComber.findMany( - subj, null, null, KerberosKey.class); + subj, serverPrincipal, null, KerberosKey.class); if (!keys.isEmpty()) { sc.kp = keys.get(0).getPrincipal(); serverPrincipal = sc.kp.getName(); @@ -255,9 +240,9 @@ public class Krb5Util { subj, null, null, KeyTab.class); sc.kk = SubjectComber.findMany( subj, serverPrincipal, null, KerberosKey.class); - sc.tgt = SubjectComber.find(subj, null, null, KerberosTicket.class); - - if (sc.ktabs.isEmpty() && sc.kk.isEmpty()) { + sc.tgt = SubjectComber.find( + subj, null, serverPrincipal, KerberosTicket.class); + if (sc.ktabs.isEmpty() && sc.kk.isEmpty() && sc.tgt == null) { return null; } return sc; @@ -268,37 +253,16 @@ public class Krb5Util { } public KerberosKey[] getKKeys() { - if (ktabs.isEmpty()) { - return kk.toArray(new KerberosKey[kk.size()]); - } else { - List keys = new ArrayList<>(); - for (KeyTab ktab: ktabs) { - for (KerberosKey k: ktab.getKeys(kp)) { - keys.add(k); - } - } - // Compatibility: also add keys to privCredSet. Remove old - // ones first, only remove those from keytab. - if (!subj.isReadOnly()) { - Set pcs = subj.getPrivateCredentials(); - synchronized (pcs) { - Iterator iterator = pcs.iterator(); - while (iterator.hasNext()) { - Object obj = iterator.next(); - if (obj instanceof KeysFromKeyTab) { - KerberosKey key = (KerberosKey)obj; - if (Objects.equals(key.getPrincipal(), kp)) { - iterator.remove(); - } - } - } - } - for (KerberosKey key: keys) { - subj.getPrivateCredentials().add(new KeysFromKeyTab(key)); - } - } - return keys.toArray(new KerberosKey[keys.size()]); + List keys = new ArrayList<>(); + for (KerberosKey k: kk) { + keys.add(k); } + for (KeyTab ktab: ktabs) { + for (KerberosKey k: ktab.getKeys(kp)) { + keys.add(k); + } + } + return keys.toArray(new KerberosKey[keys.size()]); } public EncryptionKey[] getEKeys() { diff --git a/jdk/test/sun/security/krb5/auto/KeyPermissions.java b/jdk/test/sun/security/krb5/auto/KeyPermissions.java new file mode 100644 index 00000000000..78f0eafc6c5 --- /dev/null +++ b/jdk/test/sun/security/krb5/auto/KeyPermissions.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8004488 + * @summary wrong permissions checked in krb5 + * @compile -XDignore.symbol.file KeyPermissions.java + * @run main/othervm KeyPermissions + */ + +import java.security.AccessControlException; +import java.security.Permission; +import javax.security.auth.PrivateCredentialPermission; +import sun.security.jgss.GSSUtil; + +public class KeyPermissions extends SecurityManager { + + @Override + public void checkPermission(Permission perm) { + if (perm instanceof PrivateCredentialPermission) { + if (!perm.getName().startsWith("javax.security.auth.kerberos.")) { + throw new AccessControlException( + "I don't like this", perm); + } + } + } + + public static void main(String[] args) throws Exception { + System.setSecurityManager(new KeyPermissions()); + new OneKDC(null).writeJAASConf(); + Context s = Context.fromJAAS("server"); + s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); + } +} + diff --git a/jdk/test/sun/security/krb5/auto/KeyTabCompat.java b/jdk/test/sun/security/krb5/auto/KeyTabCompat.java index f6763510fd2..87a3e7e9c78 100644 --- a/jdk/test/sun/security/krb5/auto/KeyTabCompat.java +++ b/jdk/test/sun/security/krb5/auto/KeyTabCompat.java @@ -24,6 +24,7 @@ /* * @test * @bug 6894072 + * @bug 8004488 * @compile -XDignore.symbol.file KeyTabCompat.java * @run main/othervm KeyTabCompat * @summary always refresh keytab @@ -70,21 +71,8 @@ public class KeyTabCompat { s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); s.status(); - if (s.s().getPrivateCredentials(KerberosKey.class).size() != 1) { - throw new Exception("There should be one KerberosKey"); + if (s.s().getPrivateCredentials(KerberosKey.class).size() != 0) { + throw new Exception("There should be no KerberosKey"); } - - Thread.sleep(2000); // make sure ktab timestamp is different - - kdc.addPrincipal(OneKDC.SERVER, "pass2".toCharArray()); - kdc.writeKtab(OneKDC.KTAB); - - Context.handshake(c, s); - s.status(); - - if (s.s().getPrivateCredentials(KerberosKey.class).size() != 1) { - throw new Exception("There should be only one KerberosKey"); - } - } } From ee1832fd74511934ce991f4a350d8461a1816cf9 Mon Sep 17 00:00:00 2001 From: Akhil Arora Date: Tue, 11 Dec 2012 15:33:16 -0800 Subject: [PATCH 90/94] 8003246: Add InitialValue Supplier to ThreadLocal Reviewed-by: mduigou, forax, dl, chegar, briangoetz --- .../share/classes/java/lang/ThreadLocal.java | 54 ++++++-- .../ThreadLocal/ThreadLocalSupplierTest.java | 127 ++++++++++++++++++ 2 files changed, 171 insertions(+), 10 deletions(-) create mode 100644 jdk/test/java/lang/ThreadLocal/ThreadLocalSupplierTest.java diff --git a/jdk/src/share/classes/java/lang/ThreadLocal.java b/jdk/src/share/classes/java/lang/ThreadLocal.java index ac2254f88dc..b337fc5f2e6 100644 --- a/jdk/src/share/classes/java/lang/ThreadLocal.java +++ b/jdk/src/share/classes/java/lang/ThreadLocal.java @@ -25,19 +25,21 @@ package java.lang; import java.lang.ref.*; +import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Supplier; /** * This class provides thread-local variables. These variables differ from * their normal counterparts in that each thread that accesses one (via its - * get or set method) has its own, independently initialized - * copy of the variable. ThreadLocal instances are typically private + * {@code get} or {@code set} method) has its own, independently initialized + * copy of the variable. {@code ThreadLocal} instances are typically private * static fields in classes that wish to associate state with a thread (e.g., * a user ID or Transaction ID). * *

For example, the class below generates unique identifiers local to each * thread. - * A thread's id is assigned the first time it invokes ThreadId.get() + * A thread's id is assigned the first time it invokes {@code ThreadId.get()} * and remains unchanged on subsequent calls. *

  * import java.util.concurrent.atomic.AtomicInteger;
@@ -61,7 +63,7 @@ import java.util.concurrent.atomic.AtomicInteger;
  * }
  * 
*

Each thread holds an implicit reference to its copy of a thread-local - * variable as long as the thread is alive and the ThreadLocal + * variable as long as the thread is alive and the {@code ThreadLocal} * instance is accessible; after a thread goes away, all of its copies of * thread-local instances are subject to garbage collection (unless other * references to these copies exist). @@ -108,14 +110,14 @@ public class ThreadLocal { * thread-local variable. This method will be invoked the first * time a thread accesses the variable with the {@link #get} * method, unless the thread previously invoked the {@link #set} - * method, in which case the initialValue method will not + * method, in which case the {@code initialValue} method will not * be invoked for the thread. Normally, this method is invoked at * most once per thread, but it may be invoked again in case of * subsequent invocations of {@link #remove} followed by {@link #get}. * - *

This implementation simply returns null; if the + *

This implementation simply returns {@code null}; if the * programmer desires thread-local variables to have an initial - * value other than null, ThreadLocal must be + * value other than {@code null}, {@code ThreadLocal} must be * subclassed, and this method overridden. Typically, an * anonymous inner class will be used. * @@ -125,8 +127,22 @@ public class ThreadLocal { return null; } + /** + * Creates a thread local variable. The initial value of the variable is + * determined by invoking the {@code get} method on the {@code Supplier}. + * + * @param supplier the supplier to be used to determine the initial value + * @return a new thread local variable + * @throws NullPointerException if the specified supplier is null + * @since 1.8 + */ + public static ThreadLocal withInitial(Supplier supplier) { + return new SuppliedThreadLocal<>(supplier); + } + /** * Creates a thread local variable. + * @see #withInitial(java.util.function.Supplier) */ public ThreadLocal() { } @@ -195,7 +211,7 @@ public class ThreadLocal { * reinitialized by invoking its {@link #initialValue} method, * unless its value is {@linkplain #set set} by the current thread * in the interim. This may result in multiple invocations of the - * initialValue method in the current thread. + * {@code initialValue} method in the current thread. * * @since 1.5 */ @@ -250,6 +266,24 @@ public class ThreadLocal { throw new UnsupportedOperationException(); } + /** + * An extension of ThreadLocal that obtains its initial value from + * the specified {@code Supplier}. + */ + static final class SuppliedThreadLocal extends ThreadLocal { + + private final Supplier supplier; + + SuppliedThreadLocal(Supplier supplier) { + this.supplier = Objects.requireNonNull(supplier); + } + + @Override + protected T initialValue() { + return supplier.get(); + } + } + /** * ThreadLocalMap is a customized hash map suitable only for * maintaining thread local values. No operations are exported @@ -599,9 +633,9 @@ public class ThreadLocal { * @param i a position known NOT to hold a stale entry. The * scan starts at the element after i. * - * @param n scan control: log2(n) cells are scanned, + * @param n scan control: {@code log2(n)} cells are scanned, * unless a stale entry is found, in which case - * log2(table.length)-1 additional cells are scanned. + * {@code log2(table.length)-1} additional cells are scanned. * When called from insertions, this parameter is the number * of elements, but when from replaceStaleEntry, it is the * table length. (Note: all this could be changed to be either diff --git a/jdk/test/java/lang/ThreadLocal/ThreadLocalSupplierTest.java b/jdk/test/java/lang/ThreadLocal/ThreadLocalSupplierTest.java new file mode 100644 index 00000000000..6d4bfdbb986 --- /dev/null +++ b/jdk/test/java/lang/ThreadLocal/ThreadLocalSupplierTest.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Supplier; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * @test + * @run testng ThreadLocalSupplierTest + * @summary tests ThreadLocal.withInitial(). + * Adapted from java.lang.Basic functional test of ThreadLocal + * + * @author Jim Gish + */ +@Test +public class ThreadLocalSupplierTest { + + static final class IntegerSupplier implements Supplier { + + private final AtomicInteger supply = new AtomicInteger(0); + + @Override + public Integer get() { + return supply.getAndIncrement(); + } + + public int numCalls() { + return supply.intValue(); + } + } + + static IntegerSupplier theSupply = new IntegerSupplier(); + + static final class MyThreadLocal extends ThreadLocal { + + private final ThreadLocal delegate; + + public volatile boolean everCalled; + + public MyThreadLocal(Supplier supplier) { + delegate = ThreadLocal.withInitial(supplier); + } + + @Override + public Integer get() { + return delegate.get(); + } + + @Override + protected synchronized Integer initialValue() { + // this should never be called since we are using the factory instead + everCalled = true; + return null; + } + } + + /** + * Our one and only ThreadLocal from which we get thread ids using a + * supplier which simply increments a counter on each call of get(). + */ + static MyThreadLocal threadLocal = new MyThreadLocal(theSupply); + + public void testMultiThread() throws Exception { + final int threadCount = 500; + final Thread th[] = new Thread[threadCount]; + final boolean visited[] = new boolean[threadCount]; + + // Create and start the threads + for (int i = 0; i < threadCount; i++) { + th[i] = new Thread() { + @Override + public void run() { + final int threadId = threadLocal.get(); + assertFalse(visited[threadId], "visited[" + threadId + "]=" + visited[threadId]); + visited[threadId] = true; + // check the get() again + final int secondCheckThreadId = threadLocal.get(); + assertEquals(secondCheckThreadId, threadId); + } + }; + th[i].start(); + } + + // Wait for the threads to finish + for (int i = 0; i < threadCount; i++) { + th[i].join(); + } + + assertEquals(theSupply.numCalls(), threadCount); + // make sure the provided initialValue() has not been called + assertFalse(threadLocal.everCalled); + // Check results + for (int i = 0; i < threadCount; i++) { + assertTrue(visited[i], "visited[" + i + "]=" + visited[i]); + } + } + + public void testSimple() { + final String expected = "OneWithEverything"; + final ThreadLocal threadLocal = ThreadLocal.withInitial(() -> expected); + assertEquals(expected, threadLocal.get()); + } +} From 20d79bf44082218d38ef835ab6af816e3454da70 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Tue, 11 Dec 2012 20:49:44 -0800 Subject: [PATCH 91/94] 8004905: Correct license of test to remove classpath exception Reviewed-by: akhil --- jdk/test/java/lang/ThreadLocal/ThreadLocalSupplierTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jdk/test/java/lang/ThreadLocal/ThreadLocalSupplierTest.java b/jdk/test/java/lang/ThreadLocal/ThreadLocalSupplierTest.java index 6d4bfdbb986..5601ac50bc4 100644 --- a/jdk/test/java/lang/ThreadLocal/ThreadLocalSupplierTest.java +++ b/jdk/test/java/lang/ThreadLocal/ThreadLocalSupplierTest.java @@ -4,9 +4,7 @@ * * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 From c740727efc3547ac17dddd25457ed0f2521ce9f2 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 12 Dec 2012 18:39:34 +0800 Subject: [PATCH 92/94] 8004904: Makefile for ntlm Reviewed-by: erikj, chegar --- jdk/make/com/sun/security/Makefile | 2 +- jdk/make/com/sun/security/ntlm/Makefile | 39 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 jdk/make/com/sun/security/ntlm/Makefile diff --git a/jdk/make/com/sun/security/Makefile b/jdk/make/com/sun/security/Makefile index 3a6ae4386e2..85a919b1824 100644 --- a/jdk/make/com/sun/security/Makefile +++ b/jdk/make/com/sun/security/Makefile @@ -35,7 +35,7 @@ SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true include $(BUILDDIR)/common/Defs.gmk SUBDIRS = auth -SUBDIRS_misc = jgss sasl auth/module +SUBDIRS_misc = jgss sasl auth/module ntlm include $(BUILDDIR)/common/Subdirs.gmk all build clean clobber:: diff --git a/jdk/make/com/sun/security/ntlm/Makefile b/jdk/make/com/sun/security/ntlm/Makefile new file mode 100644 index 00000000000..547092b7a61 --- /dev/null +++ b/jdk/make/com/sun/security/ntlm/Makefile @@ -0,0 +1,39 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +BUILDDIR = ../../../.. +PACKAGE = com.sun.security.ntlm +PRODUCT = sun +include $(BUILDDIR)/common/Defs.gmk + +# +# Files +# +AUTO_FILES_JAVA_DIRS = com/sun/security/ntlm + +# +# Rules +# +include $(BUILDDIR)/common/Classes.gmk From 2f710eebba81e622e76a237ffdb88956e8ec239f Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 12 Dec 2012 11:35:18 +0000 Subject: [PATCH 93/94] 8004921: Trivial javadoc warnings in Base64 Reviewed-by: darcy --- jdk/src/share/classes/java/util/Base64.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/jdk/src/share/classes/java/util/Base64.java b/jdk/src/share/classes/java/util/Base64.java index a44c5d0c5a9..f5ff211f8d4 100644 --- a/jdk/src/share/classes/java/util/Base64.java +++ b/jdk/src/share/classes/java/util/Base64.java @@ -289,8 +289,8 @@ public class Base64 { * *

This method first encodes all input bytes into a base64 encoded * byte array and then constructs a new String by using the encoded byte - * array and the {@link java.nio.charset.StandardCharsets.ISO_8859_1 ISO-8859-1} - * charset. + * array and the {@link java.nio.charset.StandardCharsets#ISO_8859_1 + * ISO-8859-1} charset. * *

In other words, an invocation of this method has exactly the same * effect as invoking @@ -358,9 +358,9 @@ public class Base64 { * to encode any more input bytes. The encoding operation can be * continued, if there is more bytes in input buffer to be encoded, * by invoking this method again with an output buffer that has more - * {@linkplain Buffer#remaining remaining} bytes. This is typically - * done by draining any encoded bytes from the output buffer. The - * value returned from last invocation needs to be passed in as the + * {@linkplain java.nio.Buffer#remaining remaining} bytes. This is + * typically done by draining any encoded bytes from the output buffer. + * The value returned from last invocation needs to be passed in as the * third parameter {@code bytesOut} if it is to continue an unfinished * encoding, 0 otherwise. * @@ -806,9 +806,9 @@ public class Base64 { * buffer has insufficient space to decode any more input bytes. * The decoding operation can be continued, if there is more bytes * in input buffer to be decoded, by invoking this method again with - * an output buffer that has more {@linkplain Buffer#remaining remaining} - * bytes.This is typically done by draining any decoded bytes from the - * output buffer. + * an output buffer that has more {@linkplain java.nio.Buffer#remaining + * remaining} bytes. This is typically done by draining any decoded + * bytes from the output buffer. * *

Recommended Usage Example *


From 64b0adf837142918dc58a5463fca6877a43c5c5e Mon Sep 17 00:00:00 2001
From: Alan Bateman 
Date: Wed, 12 Dec 2012 13:03:05 +0000
Subject: [PATCH 94/94] 8004874: Reduce dependency on java.beans to only
 add/removePropertyChangeListener

Reviewed-by: ksrini, mchung, dholmes
---
 .../com/sun/java/util/jar/pack/PropMap.java   | 142 +++++++++++++++---
 .../classes/java/util/logging/LogManager.java | 116 ++++++++++++--
 2 files changed, 231 insertions(+), 27 deletions(-)

diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java
index e1a385546c9..6199c77b51d 100644
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java
@@ -25,8 +25,6 @@
 
 package com.sun.java.util.jar.pack;
 
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
@@ -42,40 +40,39 @@ import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.jar.Pack200;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 /**
  * Control block for publishing Pack200 options to the other classes.
  */
 
 final class PropMap implements SortedMap  {
     private final TreeMap theMap = new TreeMap<>();;
-    private final List listenerList = new ArrayList<>(1);
 
-    void addListener(PropertyChangeListener listener) {
+    // type is erased, elements are of type java.beans.PropertyChangeListener
+    private final List listenerList = new ArrayList<>(1);
+
+    void addListener(Object listener) {
+        assert Beans.isPropertyChangeListener(listener);
         listenerList.add(listener);
     }
 
-    void removeListener(PropertyChangeListener listener) {
+    void removeListener(Object listener) {
+        assert Beans.isPropertyChangeListener(listener);
         listenerList.remove(listener);
     }
 
-    void addListeners(ArrayList listeners) {
-        listenerList.addAll(listeners);
-    }
-
-    void removeListeners(ArrayList listeners) {
-        listenerList.removeAll(listeners);
-    }
-
     // Override:
     public String put(String key, String value) {
         String oldValue = theMap.put(key, value);
         if (value != oldValue && !listenerList.isEmpty()) {
+            assert Beans.isBeansPresent();
             // Post the property change event.
-            PropertyChangeEvent event =
-                new PropertyChangeEvent(this, key,
-                                        oldValue, value);
-            for (PropertyChangeListener listener : listenerList) {
-                listener.propertyChange(event);
+            Object event = Beans.newPropertyChangeEvent(this, key, oldValue, value);
+            for (Object listener : listenerList) {
+                Beans.invokePropertyChange(listener, event);
             }
         }
         return oldValue;
@@ -339,4 +336,113 @@ final class PropMap implements SortedMap  {
     public String lastKey() {
        return theMap.lastKey();
     }
+
+    /**
+     * A class that provides access to the java.beans.PropertyChangeListener
+     * and java.beans.PropertyChangeEvent without creating a static dependency
+     * on java.beans. This class can be removed once the addPropertyChangeListener
+     * and removePropertyChangeListener methods are removed from Packer and
+     * Unpacker.
+     */
+    private static class Beans {
+        private static final Class propertyChangeListenerClass =
+            getClass("java.beans.PropertyChangeListener");
+
+        private static final Class propertyChangeEventClass =
+            getClass("java.beans.PropertyChangeEvent");
+
+        private static final Method propertyChangeMethod =
+            getMethod(propertyChangeListenerClass,
+                      "propertyChange",
+                      propertyChangeEventClass);
+
+        private static final Constructor propertyEventCtor =
+            getConstructor(propertyChangeEventClass,
+                           Object.class,
+                           String.class,
+                           Object.class,
+                           Object.class);
+
+        private static Class getClass(String name) {
+            try {
+                return Class.forName(name, true, Beans.class.getClassLoader());
+            } catch (ClassNotFoundException e) {
+                return null;
+            }
+        }
+        private static Constructor getConstructor(Class c, Class... types) {
+            try {
+                return (c == null) ? null : c.getDeclaredConstructor(types);
+            } catch (NoSuchMethodException x) {
+                throw new AssertionError(x);
+            }
+        }
+
+        private static Method getMethod(Class c, String name, Class... types) {
+            try {
+                return (c == null) ? null : c.getMethod(name, types);
+            } catch (NoSuchMethodException e) {
+                throw new AssertionError(e);
+            }
+        }
+
+        /**
+         * Returns {@code true} if java.beans is present.
+         */
+        static boolean isBeansPresent() {
+            return propertyChangeListenerClass != null &&
+                   propertyChangeEventClass != null;
+        }
+
+        /**
+         * Returns {@code true} if the given object is a PropertyChangeListener
+         */
+        static boolean isPropertyChangeListener(Object obj) {
+            if (propertyChangeListenerClass == null) {
+                return false;
+            } else {
+                return propertyChangeListenerClass.isInstance(obj);
+            }
+        }
+
+        /**
+         * Returns a new PropertyChangeEvent with the given source, property
+         * name, old and new values.
+         */
+        static Object newPropertyChangeEvent(Object source, String prop,
+                                             Object oldValue, Object newValue)
+        {
+            try {
+                return propertyEventCtor.newInstance(source, prop, oldValue, newValue);
+            } catch (InstantiationException | IllegalAccessException x) {
+                throw new AssertionError(x);
+            } catch (InvocationTargetException x) {
+                Throwable cause = x.getCause();
+                if (cause instanceof Error)
+                    throw (Error)cause;
+                if (cause instanceof RuntimeException)
+                    throw (RuntimeException)cause;
+                throw new AssertionError(x);
+            }
+        }
+
+        /**
+         * Invokes the given PropertyChangeListener's propertyChange method
+         * with the given event.
+         */
+        static void invokePropertyChange(Object listener, Object ev) {
+            try {
+                propertyChangeMethod.invoke(listener, ev);
+            } catch (IllegalAccessException x) {
+                throw new AssertionError(x);
+            } catch (InvocationTargetException x) {
+                Throwable cause = x.getCause();
+                if (cause instanceof Error)
+                    throw (Error)cause;
+                if (cause instanceof RuntimeException)
+                    throw (RuntimeException)cause;
+                throw new AssertionError(x);
+            }
+        }
+    }
 }
diff --git a/jdk/src/share/classes/java/util/logging/LogManager.java b/jdk/src/share/classes/java/util/logging/LogManager.java
index ef8158a1366..e3a8bf27885 100644
--- a/jdk/src/share/classes/java/util/logging/LogManager.java
+++ b/jdk/src/share/classes/java/util/logging/LogManager.java
@@ -31,10 +31,10 @@ import java.util.*;
 import java.security.*;
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.WeakReference;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-import java.net.URL;
-import sun.security.action.GetPropertyAction;
 
 /**
  * There is a single global LogManager object that is used to
@@ -150,7 +150,7 @@ public class LogManager {
 
     // The map of the registered listeners. The map value is the registration
     // count to allow for cases where the same listener is registered many times.
-    private final Map listenerMap = new HashMap<>();
+    private final Map listenerMap = new HashMap<>();
 
     // Table of named Loggers that maps names to Loggers.
     private Hashtable namedLoggers = new Hashtable<>();
@@ -971,22 +971,24 @@ public class LogManager {
         // Notify any interested parties that our properties have changed.
         // We first take a copy of the listener map so that we aren't holding any
         // locks when calling the listeners.
-        Map listeners = null;
+        Map listeners = null;
         synchronized (listenerMap) {
             if (!listenerMap.isEmpty())
                 listeners = new HashMap<>(listenerMap);
         }
         if (listeners != null) {
-            PropertyChangeEvent ev = new PropertyChangeEvent(LogManager.class, null, null, null);
-            for (Map.Entry entry : listeners.entrySet()) {
-                PropertyChangeListener listener = entry.getKey();
+            assert Beans.isBeansPresent();
+            Object ev = Beans.newPropertyChangeEvent(LogManager.class, null, null, null);
+            for (Map.Entry entry : listeners.entrySet()) {
+                Object listener = entry.getKey();
                 int count = entry.getValue().intValue();
                 for (int i = 0; i < count; i++) {
-                    listener.propertyChange(ev);
+                    Beans.invokePropertyChange(listener, ev);
                 }
             }
         }
 
+
         // Note that we need to reinitialize global handles when
         // they are first referenced.
         synchronized (this) {
@@ -1269,4 +1271,100 @@ public class LogManager {
         return loggingMXBean;
     }
 
+    /**
+     * A class that provides access to the java.beans.PropertyChangeListener
+     * and java.beans.PropertyChangeEvent without creating a static dependency
+     * on java.beans. This class can be removed once the addPropertyChangeListener
+     * and removePropertyChangeListener methods are removed.
+     */
+    private static class Beans {
+        private static final Class propertyChangeListenerClass =
+            getClass("java.beans.PropertyChangeListener");
+
+        private static final Class propertyChangeEventClass =
+            getClass("java.beans.PropertyChangeEvent");
+
+        private static final Method propertyChangeMethod =
+            getMethod(propertyChangeListenerClass,
+                      "propertyChange",
+                      propertyChangeEventClass);
+
+        private static final Constructor propertyEventCtor =
+            getConstructor(propertyChangeEventClass,
+                           Object.class,
+                           String.class,
+                           Object.class,
+                           Object.class);
+
+        private static Class getClass(String name) {
+            try {
+                return Class.forName(name, true, Beans.class.getClassLoader());
+            } catch (ClassNotFoundException e) {
+                return null;
+            }
+        }
+        private static Constructor getConstructor(Class c, Class... types) {
+            try {
+                return (c == null) ? null : c.getDeclaredConstructor(types);
+            } catch (NoSuchMethodException x) {
+                throw new AssertionError(x);
+            }
+        }
+
+        private static Method getMethod(Class c, String name, Class... types) {
+            try {
+                return (c == null) ? null : c.getMethod(name, types);
+            } catch (NoSuchMethodException e) {
+                throw new AssertionError(e);
+            }
+        }
+
+        /**
+         * Returns {@code true} if java.beans is present.
+         */
+        static boolean isBeansPresent() {
+            return propertyChangeListenerClass != null &&
+                   propertyChangeEventClass != null;
+        }
+
+        /**
+         * Returns a new PropertyChangeEvent with the given source, property
+         * name, old and new values.
+         */
+        static Object newPropertyChangeEvent(Object source, String prop,
+                                             Object oldValue, Object newValue)
+        {
+            try {
+                return propertyEventCtor.newInstance(source, prop, oldValue, newValue);
+            } catch (InstantiationException | IllegalAccessException x) {
+                throw new AssertionError(x);
+            } catch (InvocationTargetException x) {
+                Throwable cause = x.getCause();
+                if (cause instanceof Error)
+                    throw (Error)cause;
+                if (cause instanceof RuntimeException)
+                    throw (RuntimeException)cause;
+                throw new AssertionError(x);
+            }
+        }
+
+        /**
+         * Invokes the given PropertyChangeListener's propertyChange method
+         * with the given event.
+         */
+        static void invokePropertyChange(Object listener, Object ev) {
+            try {
+                propertyChangeMethod.invoke(listener, ev);
+            } catch (IllegalAccessException x) {
+                throw new AssertionError(x);
+            } catch (InvocationTargetException x) {
+                Throwable cause = x.getCause();
+                if (cause instanceof Error)
+                    throw (Error)cause;
+                if (cause instanceof RuntimeException)
+                    throw (RuntimeException)cause;
+                throw new AssertionError(x);
+            }
+        }
+    }
 }