author | coleenp |
Wed, 13 Nov 2019 08:23:23 -0500 | |
changeset 59056 | 15936b142f86 |
parent 54257 | 21702e87efdf |
permissions | -rw-r--r-- |
1 | 1 |
/* |
54257
21702e87efdf
8220095: Assertion failure when symlink (with different name) is used for lib/modules file
iklam
parents:
54042
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/classFileStream.hpp" |
|
42650 | 27 |
#include "classfile/classLoader.hpp" |
28 |
#include "classfile/dictionary.hpp" |
|
7397 | 29 |
#include "classfile/vmSymbols.hpp" |
37248 | 30 |
#include "memory/resourceArea.hpp" |
1 | 31 |
|
34666 | 32 |
const bool ClassFileStream::verify = true; |
33 |
||
34 |
void ClassFileStream::truncated_file_error(TRAPS) const { |
|
1 | 35 |
THROW_MSG(vmSymbols::java_lang_ClassFormatError(), "Truncated class file"); |
36 |
} |
|
37 |
||
34666 | 38 |
ClassFileStream::ClassFileStream(const u1* buffer, |
39 |
int length, |
|
40 |
const char* source, |
|
54257
21702e87efdf
8220095: Assertion failure when symlink (with different name) is used for lib/modules file
iklam
parents:
54042
diff
changeset
|
41 |
bool verify_stream, |
21702e87efdf
8220095: Assertion failure when symlink (with different name) is used for lib/modules file
iklam
parents:
54042
diff
changeset
|
42 |
bool from_boot_loader_modules_image) : |
34666 | 43 |
_buffer_start(buffer), |
44 |
_buffer_end(buffer + length), |
|
45 |
_current(buffer), |
|
46 |
_source(source), |
|
54257
21702e87efdf
8220095: Assertion failure when symlink (with different name) is used for lib/modules file
iklam
parents:
54042
diff
changeset
|
47 |
_need_verify(verify_stream), |
21702e87efdf
8220095: Assertion failure when symlink (with different name) is used for lib/modules file
iklam
parents:
54042
diff
changeset
|
48 |
_from_boot_loader_modules_image(from_boot_loader_modules_image) {} |
34666 | 49 |
|
50 |
const u1* ClassFileStream::clone_buffer() const { |
|
51 |
u1* const new_buffer_start = NEW_RESOURCE_ARRAY(u1, length()); |
|
52 |
memcpy(new_buffer_start, _buffer_start, length()); |
|
53 |
return new_buffer_start; |
|
1 | 54 |
} |
55 |
||
34666 | 56 |
const char* const ClassFileStream::clone_source() const { |
57 |
const char* const src = source(); |
|
58 |
char* source_copy = NULL; |
|
59 |
if (src != NULL) { |
|
60 |
size_t source_len = strlen(src); |
|
61 |
source_copy = NEW_RESOURCE_ARRAY(char, source_len + 1); |
|
62 |
strncpy(source_copy, src, source_len + 1); |
|
63 |
} |
|
64 |
return source_copy; |
|
65 |
} |
|
66 |
||
67 |
// Caller responsible for ResourceMark |
|
68 |
// clone stream with a rewound position |
|
69 |
const ClassFileStream* ClassFileStream::clone() const { |
|
70 |
const u1* const new_buffer_start = clone_buffer(); |
|
71 |
return new ClassFileStream(new_buffer_start, |
|
72 |
length(), |
|
73 |
clone_source(), |
|
54257
21702e87efdf
8220095: Assertion failure when symlink (with different name) is used for lib/modules file
iklam
parents:
54042
diff
changeset
|
74 |
need_verify(), |
21702e87efdf
8220095: Assertion failure when symlink (with different name) is used for lib/modules file
iklam
parents:
54042
diff
changeset
|
75 |
from_boot_loader_modules_image()); |
34666 | 76 |
} |
77 |
||
42650 | 78 |
uint64_t ClassFileStream::compute_fingerprint() const { |
79 |
int classfile_size = length(); |
|
80 |
int classfile_crc = ClassLoader::crc32(0, (const char*)buffer(), length()); |
|
81 |
uint64_t fingerprint = (uint64_t(classfile_size) << 32) | uint64_t(uint32_t(classfile_crc)); |
|
82 |
assert(fingerprint != 0, "must not be zero"); |
|
83 |
||
84 |
return fingerprint; |
|
85 |
} |