1 |
/* CoderResult.java -- |
/* CoderResult.java -- |
2 |
Copyright (C) 2002 Free Software Foundation, Inc. |
Copyright (C) 2002, 2004 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
82 |
private final int type; |
private final int type; |
83 |
private final int length; |
private final int length; |
84 |
|
|
85 |
private CoderResult (int type, int length) |
// Package-private to avoid a trampoline constructor. |
86 |
|
CoderResult (int type, int length) |
87 |
{ |
{ |
88 |
this.type = type; |
this.type = type; |
89 |
this.length = length; |
this.length = length; |
158 |
{ |
{ |
159 |
private final HashMap cache; |
private final HashMap cache; |
160 |
|
|
161 |
private Cache () |
// Package-private to avoid a trampoline constructor. |
162 |
|
Cache () |
163 |
{ |
{ |
164 |
// If we didn't synchronize on this, then cache would be initialized |
cache = new HashMap (); |
|
// without holding a lock. Undefined behavior would occur if the |
|
|
// first thread to call get(int) was not the same as the one that |
|
|
// called the constructor. |
|
|
synchronized (this) |
|
|
{ |
|
|
cache = new HashMap (); |
|
|
} |
|
165 |
} |
} |
166 |
|
|
167 |
private synchronized CoderResult get (int length) |
// Package-private to avoid a trampoline. |
168 |
|
synchronized CoderResult get (int length) |
169 |
{ |
{ |
170 |
if (length <= 0) |
if (length <= 0) |
171 |
throw new IllegalArgumentException ("Non-positive length"); |
throw new IllegalArgumentException ("Non-positive length"); |