• R/O
  • SSH
  • HTTPS

mergedoc: Commit


Commit MetaInfo

Revision2741 (tree)
Time2021-07-15 18:12:17
Authorcypher256

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/Pleiades.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/Pleiades.java (revision 2741)
@@ -16,7 +16,8 @@
1616 import jp.sourceforge.mergedoc.pleiades.runtime.LauncherTransformer;
1717
1818 /**
19- * Pleiades AOP を起動するためのエージェントです。
19+ * Pleiades AOP を起動するためのエージェントです。<br>
20+ * このクラスは javaagent で指定される jar の manifest に Premain-Class として設定されています。
2021 * @author cypher256
2122 */
2223 public class Pleiades {
@@ -34,7 +35,7 @@
3435 private static File pleiadesTempDir;
3536
3637 /**
37- * 起動エントリー・ポイントとなると premain メソッドです。<br>
38+ * 対象 Java アプリケーションの main メソッドの前に呼び出されるメソッドです。<br>
3839 * 起動時の main スレッドから呼び出されるため、時間がかかる処理は非同期で行います。
3940 * @param agentArg -javaagent 引数
4041 * @param inst トランスフォーマー登録・削除用 Instrumentation
@@ -42,7 +43,7 @@
4243 public static void premain(final String agentArg, final Instrumentation inst) {
4344
4445 try {
45- // Eclipse ファイル > 再開 で premain が 2 回呼び出される問題に対応
46+ // Eclipse メニューの ファイル > 再開 で premain が 2 回呼び出される問題に対応
4647 if (instrumentation != null) {
4748 Logger log = Logger.getLogger(Pleiades.class);
4849 log.info("instrumentation がすでに存在するため premain 処理を実行しません。");
@@ -88,8 +89,8 @@
8889 }
8990
9091 /**
91- * バイトコード変換トランスフォーマーを登録・削除するための Instrumentation を取得します。
92- * @return トランスフォーマー登録・削除用 Instrumentation (not null)
92+ * AOP バイトコード変換トランスフォーマーを登録・削除するための Instrumentation を取得します。
93+ * @return AOP トランスフォーマー登録・削除用 Instrumentation (not null)
9394 */
9495 public static Instrumentation getInstrumentation() {
9596 return instrumentation;
@@ -118,6 +119,6 @@
118119 * @return ファイル。JUnit やツールからの実行時は null。
119120 */
120121 public static File temp(String... path) {
121- return Filez.concatPath(pleiadesTempDir, path);
122+ return Filez.joinPath(pleiadesTempDir, path);
122123 }
123124 }
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/PleiadesContext.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/PleiadesContext.java (revision 2741)
@@ -12,7 +12,7 @@
1212 import jp.sourceforge.mergedoc.pleiades.log.Logger.LogLevel;
1313
1414 /**
15- * Pleiades 全体から参照するコンテキスト情報です。
15+ * Pleiades 実行時に全体から参照されるコンテキスト情報です。
1616 * @author cypher256
1717 */
1818 public class PleiadesContext {
@@ -78,7 +78,7 @@
7878 * -javaagent:plugins/jp.sourceforge.mergedoc.pleiades/pleiades.jar=debug
7979 * -javaagent:plugins/jp.sourceforge.mergedoc.pleiades/pleiades.jar=debug,no.clean.message
8080 * </pre>
81- * @param agentArg -javaagent 引数 (未指定の場合は null)
81+ * @param agentArg -javaagent 引数 (未指定の場合は null)
8282 */
8383 PleiadesContext(String agentArg) {
8484
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/log/FileLogger.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/log/FileLogger.java (revision 2741)
@@ -8,7 +8,6 @@
88
99 import java.io.File;
1010 import java.io.PrintStream;
11-import java.util.Collection;
1211 import java.util.HashMap;
1312 import java.util.Map;
1413
@@ -26,16 +25,6 @@
2625 /** ファイル PrintStream マップ <ログファイル名, プリントストリーム> */
2726 private static Map<String, PrintStream> fileOutMap = new HashMap<>();
2827
29- /**
30- * 開かれている出力ストリームをクローズします。
31- */
32- public static void close() { // 厳密には getOut() と同期が必要
33-
34- Collection<PrintStream> printStreams = fileOutMap.values();
35- fileOutMap = null;
36- printStreams.forEach(Filez::closeQuietly);
37- }
38-
3928 //-------------------------------------------------------------------------
4029
4130 /** ログ・ファイル名 */
@@ -62,17 +51,22 @@
6251 logFile.delete();
6352 PrintStream out = Filez.newPrintStream(logFile);
6453 fileOutMap.put(logFileName, out);
54+
55+ // エラー時の System.exit に対応するためにシャットダウンフックでクローズ
56+ Runtime.getRuntime().addShutdownHook(new Thread(() -> {
57+ debug("シャットダウンフックによるクローズ: %s", logFile.getName());
58+ fileOutMap.remove(logFileName); // close 後の getOut 対応
59+ Filez.closeQuietly(out);
60+ }));
6561 }
6662
6763 /**
68- * ファイル PrintStream を取得します。
64+ * ログ出力先となるファイル PrintStream を取得します。
6965 */
7066 @Override
7167 protected PrintStream getOut() {
72- if (fileOutMap == null) {
73- return System.err; // close 済みの場合は、代わりにエラー出力を使用する
74- }
75- return fileOutMap.get(logFileName);
68+ // null (close 済み) の場合は、代わりにエラー出力を使用する
69+ return fileOutMap.getOrDefault(logFileName, System.err);
7670 }
7771
7872 /**
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/resource/Filez.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/resource/Filez.java (revision 2741)
@@ -40,7 +40,7 @@
4040 String markResource = "/.marker";
4141 URL url = Filez.class.getResource(markResource);
4242 if (url == null) {
43-
43+
4444 // 注)ログの出力先は、これを元に解決されるため、この時点ではロガーは使用できない
4545 String msg = "conf の場所を決定するためのファイルがクラスパス上に見つかりません。" + markResource;
4646 Exception e = new FileNotFoundException(msg);
@@ -76,7 +76,7 @@
7676
7777 /**
7878 * 相対パスを指定して AOP 定義や辞書として読み取るファイルを取得します。<br>
79- * 基準となるパスは .marker ファイルがあるディレクトリです。
79+ * 基準となるパスはクラスパス上の .marker ファイルがあるディレクトリです。
8080 * <ul>
8181 * <li>javaagent 実行時: plugins/jp.sourceforge.mergedoc.pleiades/conf
8282 * <li>JUnit など実行時: src/main/resources
@@ -85,7 +85,7 @@
8585 * @return リソース File オブジェクト
8686 */
8787 public static File conf(String... path) {
88- return concatPath(conf, path);
88+ return joinPath(conf, path);
8989 }
9090
9191 /**
@@ -94,7 +94,7 @@
9494 * @param path 基準ディレクトリからの相対パス (可変長引数)
9595 * @return 連結後の File オブジェクト (baseDir が null の場合は null)
9696 */
97- public static File concatPath(File baseDir, String... path) {
97+ public static File joinPath(File baseDir, String... path) {
9898 if (baseDir == null) {
9999 return null;
100100 }
@@ -151,8 +151,8 @@
151151 if (closeable != null) {
152152 closeable.close();
153153 }
154- } catch (final IOException ioe) {
155- throw new IllegalStateException(ioe);
154+ } catch (final IOException e) {
155+ throw new IllegalStateException(e);
156156 }
157157 }
158158
@@ -168,7 +168,7 @@
168168 String folderPath = folder.getCanonicalPath();
169169 String filePath = file.getCanonicalPath();
170170 return filePath.replace(folderPath, "");
171-
171+
172172 } catch (IOException e) {
173173 throw new IllegalArgumentException(folder + ", " + file, e);
174174 }
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/resource/PropertySet.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/resource/PropertySet.java (revision 2741)
@@ -91,7 +91,7 @@
9191 * @param props Java 標準プロパティー
9292 */
9393 public PropertySet(Properties... props) {
94-
94+
9595 for (Properties prop : props) {
9696 for (Entry<Object, Object> entry : prop.entrySet()) {
9797 put((String) entry.getKey(), (String) entry.getValue());
@@ -104,7 +104,7 @@
104104 * @param props プロパティー・セット
105105 */
106106 public PropertySet(PropertySet... props) {
107-
107+
108108 for (PropertySet prop : props) {
109109 putAll(prop);
110110 }
@@ -125,7 +125,7 @@
125125 * @return このインスタンス
126126 */
127127 public PropertySet load(String... paths) {
128-
128+
129129 for (String path : paths) {
130130 File file = Filez.conf(path);
131131 load(file);
@@ -141,19 +141,19 @@
141141 * @return このインスタンス
142142 */
143143 public PropertySet load(File... files) {
144-
144+
145145 for (File file : files) {
146-
146+
147147 // ディレクトリーの場合
148148 if (file.isDirectory()) {
149-
149+
150150 for (File f : listPropertiesFiles(file)) {
151- loadFile(f);
151+ loadFileWithLog(f);
152152 }
153153 }
154154 // ファイルの場合
155155 else {
156- loadFile(file);
156+ loadFileWithLog(file);
157157 }
158158 }
159159 return this;
@@ -166,11 +166,11 @@
166166 * @return プロパティー・ファイル・リスト
167167 */
168168 public static File[] listPropertiesFiles(File dir) {
169-
169+
170170 File[] fs = Filez.listFiles(dir);
171171 Arrays.sort(fs); // 昇順
172172 List<File> list = new ArrayList<>();
173-
173+
174174 for (File f : fs) {
175175 String name = f.getName();
176176 if (name.endsWith(PROP_EXTENSION) || name.endsWith(PROP_EXTENSION + ZIP_EXTENSION)) {
@@ -186,10 +186,10 @@
186186 * @param is 入力ストリーム
187187 */
188188 public void load(InputStream is) {
189-
189+
190190 try {
191191 loadUTF8(is);
192-
192+
193193 } catch (IOException e) {
194194 throw new IllegalArgumentException(e);
195195 }
@@ -201,12 +201,12 @@
201201 * @param dirs ディレクトリー
202202 */
203203 public void loadRecursive(File... dirs) {
204-
204+
205205 for (File dir : dirs) {
206-
206+
207207 File[] fs = dir.listFiles();
208208 Arrays.sort(fs); // 昇順
209-
209+
210210 for (File f : fs) {
211211 if (f.isDirectory()) {
212212 loadRecursive(f); // 再帰
@@ -233,7 +233,7 @@
233233 */
234234 @Override
235235 public void putAll(Map<? extends String, ? extends String> m) {
236-
236+
237237 for (Entry<? extends String, ? extends String> entry : m.entrySet()) {
238238 put(entry.getKey(), entry.getValue());
239239 }
@@ -246,7 +246,7 @@
246246 * @return 保存されたキーのリスト (ソート済み)。保存されなかった場合は null。
247247 */
248248 public List<String> store(String path, String comment) {
249-
249+
250250 File resourceFile = Filez.conf(path);
251251 return store(resourceFile, comment);
252252 }
@@ -258,20 +258,20 @@
258258 * @return 保存されたキーのリスト (ソート済み)。保存されなかった場合は null。
259259 */
260260 public List<String> store(File file, String comment) {
261-
261+
262262 long startTime = System.nanoTime();
263263 String fileName = file.getName();
264-
264+
265265 // 既存ファイルと内容が同じであれば保存しない (コメントの日付更新抑止)
266266 if (file.exists() && fileName.endsWith(PROP_EXTENSION)) {
267267 PropertySet old = new PropertySet();
268- old.loadFileWithoutLog(file);
268+ old.loadFile(file);
269269 if (old.equals(this)) {
270270 log.info("store 更新なし %6d エントリー %-34s", size(), fileName);
271271 return null;
272272 }
273273 }
274-
274+
275275 // ヘッダーの作成
276276 List<String> headerList = new ArrayList<>();
277277 headerList.add(saveConvertComment("このファイルは Pleiades により生成されました。" + size() + " エントリー。"));
@@ -283,11 +283,11 @@
283283 headerList.add("# ");
284284 headerList.add("####################################################################################################");
285285 String header = StringUtils.join(headerList, "\n");
286-
286+
287287 OutputStream os = null;
288288 try {
289289 os = Filez.newBufferedOutputStream(file);
290-
290+
291291 // 拡張子が .properties.zip の場合、ZipOutputStream でラップ
292292 if (fileName.endsWith(PROP_EXTENSION + ZIP_EXTENSION)) {
293293 ZipOutputStream zos = new ZipOutputStream(os);
@@ -296,15 +296,15 @@
296296 os = zos;
297297 }
298298 List<String> keyList = store(os, header);
299-
299+
300300 log.info("store %4.3f 秒 - %6d エントリー %s", (System.nanoTime() - startTime) / 1e9, size(), fileName);
301301 return keyList;
302-
302+
303303 } catch (IOException e) {
304304 throw new IllegalArgumentException(file.toString(), e);
305-
305+
306306 } finally {
307- Filez.closeQuietly(os);
307+ Filez.closeQuietly(os); // zos ラップのため try-with- は使用できない
308308 }
309309 }
310310
@@ -315,22 +315,22 @@
315315 */
316316 @Override
317317 public Iterator<Property> iterator() {
318-
318+
319319 final Iterator<Entry<String, String>> it = entrySet().iterator();
320-
320+
321321 return new Iterator<>() {
322-
322+
323323 @Override
324324 public boolean hasNext() {
325325 return it.hasNext();
326326 }
327-
327+
328328 @Override
329329 public Property next() {
330330 Entry<String, String> entry = it.next();
331331 return new Property(entry.getKey(), entry.getValue());
332332 }
333-
333+
334334 @Override
335335 public void remove() {
336336 throw new UnsupportedOperationException();
@@ -345,10 +345,10 @@
345345 private int loadCount;
346346
347347 protected InputStream getInputStream(File file) throws IOException {
348-
348+
349349 // 拡張子 .properties
350350 InputStream is = Filez.newBufferedInputStream(file);
351-
351+
352352 // 拡張子 .properties.zip
353353 if (file.getName().endsWith(PROP_EXTENSION + ZIP_EXTENSION)) {
354354 ZipInputStream zis = new ZipInputStream(is);
@@ -358,24 +358,22 @@
358358 return is;
359359 }
360360
361- private void loadFile(File file) {
362-
361+ private void loadFileWithLog(File file) {
362+
363363 long startTime = System.nanoTime();
364-
365- loadFileWithoutLog(file);
366-
364+ loadFile(file);
367365 log.debug("load %4.3f 秒 - %6d エントリー %s", (System.nanoTime() - startTime) / 1e9, loadCount, file.getName());
368366 loadCount = 0;
369367 }
370368
371- private void loadFileWithoutLog(File file) {
372-
369+ private void loadFile(File file) {
370+
373371 try (InputStream is = getInputStream(file)) {
374372 if (is == null) {
375373 return;
376374 }
377- loadUTF8(is);
378-
375+ loadUTF8(is);
376+
379377 } catch (IOException e) {
380378 throw new IllegalArgumentException(e);
381379 }
@@ -382,7 +380,7 @@
382380 }
383381
384382 private void loadUTF8(InputStream is) throws IOException {
385- load0(new LineReader(new InputStreamReader(is, StandardCharsets.UTF_8)));
383+ load0(new LineReader(new InputStreamReader(is, StandardCharsets.UTF_8)));
386384 }
387385
388386 private void load0(LineReader lr) throws IOException {
@@ -393,13 +391,13 @@
393391 char c;
394392 boolean hasSep;
395393 boolean precedingBackslash;
396-
394+
397395 while ((limit = lr.readLine()) >= 0) {
398396 c = 0;
399397 keyLen = 0;
400398 valueStart = limit;
401399 hasSep = false;
402-
400+
403401 // System.out.println("line=<" + new String(lineBuf, 0, limit) + ">");
404402 precedingBackslash = false;
405403 while (keyLen < limit) {
@@ -440,13 +438,13 @@
440438
441439 @SuppressWarnings("unchecked")
442440 private List<String> store(OutputStream out, String comments) throws IOException {
443-
441+
444442 BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8));
445443 if (comments != null) {
446444 writeln(writer, "#" + comments);
447445 }
448446 writeln(writer, "#" + new Date().toString());
449-
447+
450448 // ConcurrentModificationException 低減のため clone
451449 HashMap<String, String> c = null;
452450 try {
@@ -460,11 +458,11 @@
460458 return null;
461459 }
462460 }
463-
461+
464462 // キーでソート
465463 List<String> keyList = new ArrayList<>(c.keySet());
466464 keyList.sort(String.CASE_INSENSITIVE_ORDER);
467-
465+
468466 for (String key : keyList) {
469467 String val = get(key);
470468 key = saveConvert(key, true);
@@ -472,17 +470,17 @@
472470 writeln(writer, key + "=" + val);
473471 }
474472 writer.flush();
475-
473+
476474 return keyList;
477475 }
478476
479477 class LineReader {
480-
478+
481479 public LineReader(Reader reader) {
482480 this.reader = reader;
483481 inCharBuf = new char[8192];
484482 }
485-
483+
486484 byte[] inByteBuf;
487485 char[] inCharBuf;
488486 char[] lineBuf = new char[1024];
@@ -489,11 +487,11 @@
489487 int inLimit = 0;
490488 int inOff = 0;
491489 Reader reader;
492-
490+
493491 int readLine() throws IOException {
494492 int len = 0;
495493 char c = 0;
496-
494+
497495 boolean skipWhiteSpace = true;
498496 boolean isCommentLine = false;
499497 boolean isNewLine = true;
@@ -500,7 +498,7 @@
500498 boolean appendedLineBegin = false;
501499 boolean precedingBackslash = false;
502500 boolean skipLF = false;
503-
501+
504502 while (true) {
505503 if (inOff >= inLimit) {
506504 inLimit = reader.read(inCharBuf);
@@ -536,7 +534,7 @@
536534 continue;
537535 }
538536 }
539-
537+
540538 if (c != '\n' && c != '\r') {
541539 lineBuf[len++] = c;
542540 if (len == lineBuf.length) {
@@ -600,7 +598,7 @@
600598 char[] out = convtBuf;
601599 int outLen = 0;
602600 int end = off + len;
603-
601+
604602 while (off < end) {
605603 aChar = in[off++];
606604 if (aChar == '\\') {
@@ -664,13 +662,13 @@
664662 }
665663
666664 private String saveConvertComment(String theString) {
667-
665+
668666 String space = theString.replaceFirst("(\\s*).*", "$1");
669667 return space + saveConvert(theString.trim(), false);
670668 }
671669
672670 private String saveConvert(String theString, boolean escapeSpace) {
673-
671+
674672 int len = theString.length();
675673 int bufLen = len * 2;
676674 if (bufLen < 0) {
@@ -677,7 +675,7 @@
677675 bufLen = Integer.MAX_VALUE;
678676 }
679677 StringBuilder outBuffer = new StringBuilder(bufLen);
680-
678+
681679 for (int x = 0; x < len; x++) {
682680 char aChar = theString.charAt(x);
683681 if ((aChar > 61) && (aChar < 127)) {
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/resource/TranslationNotFoundProperties.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/resource/TranslationNotFoundProperties.java (revision 2741)
@@ -30,7 +30,7 @@
3030 private static final Logger log = Logger.getLogger(TranslationNotFoundProperties.class);
3131
3232 /** 訳無しプロパティー出力ファイル名 */
33- private static final File NOT_FOUND_LOG_FILE = Pleiades.temp("translation-notfound.properties");
33+ private static final File NOTFOUND_PROP_FILE = Pleiades.temp("translation-notfound.properties");
3434
3535 /** 訳無しプロパティー出力から除外する要素をリストしたファイル名 */
3636 private static final File NOTFOUND_EXCLUDE_FILE = Filez.conf("translation-notfound-exclud.list");
@@ -82,13 +82,13 @@
8282 */
8383 // Java 11 以降で private だと AOP エラーになる
8484 protected void init() {
85-
85+
8686 excludSet = new HashSet<>();
8787 excludPatternSet = new HashSet<>();
8888 loggedSet = Collections.synchronizedSet(new HashSet<>());
89-
89+
9090 try (BufferedReader in = new BufferedReader(new FileReader(NOTFOUND_EXCLUDE_FILE))) {
91-
91+
9292 for (String line; (line = in.readLine()) != null;) {
9393 if (!line.startsWith("#")) {
9494 String str = line.replace("\\n", "\n");
@@ -106,12 +106,12 @@
106106 log.fatal(msg);
107107 throw new IllegalStateException(msg, e);
108108 }
109-
110- out = Filez.newPrintStream(NOT_FOUND_LOG_FILE);
111-
109+
110+ out = Filez.newPrintStream(NOTFOUND_PROP_FILE);
111+
112112 // VM シャットダウン・フックに PrintStream のクローズを登録
113113 Runtime.getRuntime().addShutdownHook(new Thread(() -> {
114- // ここではすでにログはクローズ済みのため、出力できない
114+ log.debug("シャットダウンフックによるクローズ: %s", NOTFOUND_PROP_FILE.getName());
115115 Filez.closeQuietly(out);
116116 }));
117117 log.debug("訳無しプロパティーを生成しました。");
@@ -126,10 +126,10 @@
126126 * @param enTs 英語文字列
127127 */
128128 public void put(TranslationString enTs) {
129-
129+
130130 // trimForce された状態を元に戻す
131131 enTs.init();
132-
132+
133133 println(enTs.toString().trim());
134134 println(enTs.trim());
135135 println(enTs.trimForce());
@@ -140,7 +140,7 @@
140140 * @param en ニーモニックを含まない英語リソース文字列
141141 */
142142 protected void println(String en) {
143-
143+
144144 if (loggedSet.contains(en)) {
145145 return;
146146 }
@@ -153,10 +153,10 @@
153153 }
154154 }
155155 loggedSet.add(en);
156-
156+
157157 String key = Property.escapeKey(en);
158158 String value = Property.escapeValue(en);
159-
159+
160160 // 翻訳しやすいように右辺の改行文字は空白に置換
161161 value = value.replace("\\r", " ");
162162 value = value.replace("\\n", " ");
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/Analyses.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/Analyses.java (revision 2741)
@@ -53,8 +53,8 @@
5353 try {
5454 return super.computeIfAbsent(key, mappingFunction);
5555 } catch (ConcurrentModificationException e) {
56- // ほぼ発生しないが 1 回だけリトライ (debug 時のみだが目立つように warn レベル)
57- getLog().warn(e, "計測記録リトライ %s", key);
56+ // 数百万回に 1 回程度しか発生しないが 1 回だけリトライ (このクラスの処理は debug 時のみ)
57+ getLog().debug(e, "計測記録リトライ computeIfAbsent %s", key);
5858 return super.computeIfAbsent(key, mappingFunction);
5959 }
6060 }
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/Applicationz.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/Applicationz.java (revision 2741)
@@ -243,7 +243,7 @@
243243 * @return Eclipse ホーム・ディレクトリー。Eclipse javaagent からの起動ではない場合 (IDEA など) は null。
244244 */
245245 public static File eclipseHome(String... path) {
246- return Filez.concatPath(eclipseHome, path);
246+ return Filez.joinPath(eclipseHome, path);
247247 }
248248
249249 /**
@@ -253,6 +253,6 @@
253253 * @return Eclipse OSGi ホーム・ディレクトリー。Eclipse javaagent からの起動ではない場合 (IDEA など) は null。
254254 */
255255 public static File osgiHome(String... path) {
256- return Filez.concatPath(osgiHome, path);
256+ return Filez.joinPath(osgiHome, path);
257257 }
258258 }
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/LauncherTransformer.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/LauncherTransformer.java (revision 2741)
@@ -18,7 +18,6 @@
1818 import javassist.CtMethod;
1919 import javassist.NotFoundException;
2020 import jp.sourceforge.mergedoc.pleiades.Pleiades;
21-import jp.sourceforge.mergedoc.pleiades.log.FileLogger;
2221 import jp.sourceforge.mergedoc.pleiades.log.Logger;
2322 import jp.sourceforge.mergedoc.pleiades.resource.PropertySet;
2423 import jp.sourceforge.mergedoc.pleiades.runtime.advice.PleiadesConfig;
@@ -382,9 +381,6 @@
382381
383382 // プロセス間排他ロック解除
384383 ProcessLockz.release();
385-
386- // ログファイルのクローズ
387- FileLogger.close();
388384 }
389385 }
390386 }
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/ProcessLockz.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/ProcessLockz.java (revision 2741)
@@ -28,7 +28,7 @@
2828 private static final Logger log = Logger.getLogger(ProcessLockz.class);
2929
3030 /** ロック・ファイル */
31- private static final File lockFile = Pleiades.temp(".lock");
31+ private static final File LOCK_FILE = Pleiades.temp(".lock");
3232
3333 /** ロック・ファイル・チャンネル */
3434 private static volatile FileChannel fileChannel;
@@ -35,7 +35,7 @@
3535
3636 static {
3737 try {
38- lockFile.createNewFile();
38+ LOCK_FILE.createNewFile();
3939 } catch (IOException e) {
4040 log.error(e, "プロセス間排他ロック・ファイルの作成に失敗しました。");
4141 }
@@ -56,7 +56,7 @@
5656 }
5757 log.debug("プロセス間排他ロックします。");
5858
59- try (RandomAccessFile raf = new RandomAccessFile(lockFile.getPath(), "rw")) {
59+ try (RandomAccessFile raf = new RandomAccessFile(LOCK_FILE.getPath(), "rw")) {
6060 fileChannel = raf.getChannel();
6161
6262 FileLock lock = fileChannel.tryLock();
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/UpdateDetector.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/UpdateDetector.java (revision 2741)
@@ -28,10 +28,11 @@
2828 * @return 1 つでも更新されている場合は true
2929 */
3030 public boolean isUpdated(File... targetDirs) throws IOException {
31-
31+
3232 if (targetDirs.length == 0) {
3333 throw new IllegalStateException("ターゲットディレクトリが指定されていません。");
3434 }
35+
3536 long start = System.nanoTime();
3637 File pluginModifiedFile = Pleiades.temp(".plugin-modified");
3738 long prevLastModified = pluginModifiedFile.lastModified();
@@ -57,6 +58,7 @@
5758 pluginModifiedFile.setLastModified(lastModified);
5859 isUpdated = true;
5960 }
61+
6062 Analyses.end(Applicationz.class, "isUpdated", start);
6163 return isUpdated;
6264 }
@@ -73,14 +75,17 @@
7375 boolean isParentPluginsDir = parent.equals("plugins") || parent.equals("lib"/* IDEA */);
7476
7577 for (File file : parentDir.listFiles()) {
78+ String name = file.getName();
7679
77- String name = file.getName();
7880 if (name.equals("features") || name.startsWith(".")) {
7981 // チェックしない
82+
8083 } else if (isParentPluginsDir) {
8184 // 親がプラグインディレクトリの場合は再帰しないで自身のみチェック (ファイルの場合もあり)
8285 latest = max(file, latest);
86+
8387 } else if (file.isFile()) {
88+
8489 if (name.endsWith(".xml") || name.endsWith(".properties")) {
8590 // conf 配下の設定ファイル (画像などを除く)
8691 latest = max(file, latest);
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/resource/ExcludeClassNameCache.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/resource/ExcludeClassNameCache.java (revision 2741)
@@ -29,7 +29,7 @@
2929 private static final Logger log = Logger.getLogger(ExcludeClassNameCache.class);
3030
3131 /** 変換除外クラス名キャッシュ・ファイル */
32- public static final File cacheFile = Pleiades.temp(CacheFilez.EXCLUDE_CLASS_LIST);
32+ public static final File EXCLUDE_CACHE_FILE = Pleiades.temp(CacheFilez.EXCLUDE_CLASS_LIST);
3333
3434 /** このクラスのシングルトン・インスタンス */
3535 private static final ExcludeClassNameCache singleton = new ExcludeClassNameCache();
@@ -66,20 +66,20 @@
6666 long start = System.nanoTime();
6767 Set<String> set = new HashSet<>();
6868
69- if (!cacheFile.exists()) {
70- log.info(cacheFile.getName() + " が存在しません。");
69+ if (!EXCLUDE_CACHE_FILE.exists()) {
70+ log.info(EXCLUDE_CACHE_FILE.getName() + " が存在しません。");
7171
7272 } else {
7373
7474 try {
75- set.addAll(FileUtils.readLines(cacheFile, StandardCharsets.UTF_8));
76- log.info("load %6d エントリー %s", set.size(), cacheFile.getName());
75+ set.addAll(FileUtils.readLines(EXCLUDE_CACHE_FILE, StandardCharsets.UTF_8));
76+ log.info("load %6d エントリー %s", set.size(), EXCLUDE_CACHE_FILE.getName());
7777
7878 } catch (Exception e) {
7979
8080 // キャッシュ破損、自己復元
81- log.warn("除外クラス名キャッシュ %s の破損を検出。復元中... - %s", cacheFile, e.toString());
82- cacheFile.delete();
81+ log.warn("除外クラス名キャッシュ %s の破損を検出。復元中... - %s", EXCLUDE_CACHE_FILE, e.toString());
82+ EXCLUDE_CACHE_FILE.delete();
8383 set.clear();
8484 }
8585 }
@@ -105,11 +105,11 @@
105105 storeSet = null;
106106 diskSet.addAll(newSet);
107107
108- FileUtils.writeLines(cacheFile, null, diskSet);
109- log.info("store %6d エントリー %s", diskSet.size(), cacheFile.getName());
108+ FileUtils.writeLines(EXCLUDE_CACHE_FILE, null, diskSet);
109+ log.info("store %6d エントリー %s", diskSet.size(), EXCLUDE_CACHE_FILE.getName());
110110
111111 } catch (IOException e) {
112- log.error(e, cacheFile.getName() + " の保存に失敗しました。");
112+ log.error(e, EXCLUDE_CACHE_FILE.getName() + " の保存に失敗しました。");
113113 }
114114 }
115115
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/resource/TransformedClassCache.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/resource/TransformedClassCache.java (revision 2741)
@@ -31,6 +31,9 @@
3131 /** ロガー */
3232 private static final Logger log = Logger.getLogger(TransformedClassCache.class);
3333
34+ /** クラス・キャッシュ・ファイル */
35+ private static final File CLASS_CACHE_FILE = Pleiades.temp(CacheFilez.TRANSFORMED_CLASS_CACHE);
36+
3437 /** このクラスのシングルトン・インスタンス */
3538 private static final TransformedClassCache singleton = new TransformedClassCache();
3639
@@ -44,9 +47,6 @@
4447
4548 //-------------------------------------------------------------------------
4649
47- /** クラス・キャッシュ・ファイル */
48- private final File cacheFile = Pleiades.temp(CacheFilez.TRANSFORMED_CLASS_CACHE);
49-
5050 /** ロードされたクラス・マップ */
5151 private Map<String, byte[]> loadedMap = new HashMap<>();
5252
@@ -69,12 +69,12 @@
6969 long start = System.nanoTime();
7070 Map<String, byte[]> map = new HashMap<>();
7171
72- if (!cacheFile.exists()) {
73- log.info(cacheFile.getName() + " が存在しません。");
72+ if (!CLASS_CACHE_FILE.exists()) {
73+ log.info(CLASS_CACHE_FILE.getName() + " が存在しません。");
7474
7575 } else {
7676
77- try (ZipInputStream zis = new ZipInputStream(Filez.newBufferedInputStream(cacheFile))) {
77+ try (ZipInputStream zis = new ZipInputStream(Filez.newBufferedInputStream(CLASS_CACHE_FILE))) {
7878 for (ZipEntry zipEntry; (zipEntry = zis.getNextEntry()) != null;) {
7979
8080 String classId = zipEntry.getName();
@@ -81,12 +81,12 @@
8181 byte[] bytecode = zis.readAllBytes();
8282 map.put(classId, bytecode);
8383 }
84- log.info("load %6d エントリー %s", map.size(), cacheFile.getName());
84+ log.info("load %6d エントリー %s", map.size(), CLASS_CACHE_FILE.getName());
8585
8686 } catch (Exception e) {
8787
88- log.warn("変換済みクラス・キャッシュ %s 破損検出によるクリア - %s", cacheFile, e.toString());
89- cacheFile.delete();
88+ log.warn("変換済みクラス・キャッシュ %s 破損検出によるクリア - %s", CLASS_CACHE_FILE, e.toString());
89+ CLASS_CACHE_FILE.delete();
9090 map.clear();
9191 }
9292 }
@@ -106,7 +106,7 @@
106106 return;
107107 }
108108 Map<String, byte[]> map = load();
109- try (ZipOutputStream out = new ZipOutputStream(Filez.newBufferedOutputStream(cacheFile))) {
109+ try (ZipOutputStream out = new ZipOutputStream(Filez.newBufferedOutputStream(CLASS_CACHE_FILE))) {
110110 out.setLevel(Deflater.BEST_SPEED);
111111
112112 // ConcurrentModificationException 防止
@@ -120,10 +120,10 @@
120120 out.putNextEntry(new ZipEntry(classId));
121121 out.write(bytecode);
122122 }
123- log.info("store %6d エントリー %s", map.size(), cacheFile.getName());
123+ log.info("store %6d エントリー %s", map.size(), CLASS_CACHE_FILE.getName());
124124
125125 } catch (IOException e) {
126- log.error(e, cacheFile.getName() + "の保存に失敗しました。");
126+ log.error(e, CLASS_CACHE_FILE.getName() + "の保存に失敗しました。");
127127 }
128128 }
129129
--- trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/resource/TranslationDictionary.java (revision 2740)
+++ trunk/Pleiades/src/main/java/jp/sourceforge/mergedoc/pleiades/runtime/resource/TranslationDictionary.java (revision 2741)
@@ -44,10 +44,10 @@
4444 private static final Logger log = Logger.getLogger(TranslationDictionary.class);
4545
4646 /** 翻訳キャッシュ・プロパティー・ファイル */
47- private static final File transCacheFile = Pleiades.temp(CacheFilez.TRANS_CACHE_PROP);
47+ private static final File TRANS_CACHE_FILE = Pleiades.temp(CacheFilez.TRANS_CACHE_PROP);
4848
4949 /** ニーモニック変換キャッシュ・プロパティー・ファイル */
50- private static final File mnemonicCacheFile = Pleiades.temp(CacheFilez.MNEMONIC_CACHE_PROP);
50+ private static final File MNEMONIC_CACHE_FILE = Pleiades.temp(CacheFilez.MNEMONIC_CACHE_PROP);
5151
5252 /** 正規表現キープレフィックス */
5353 private static final String REGEX_KEY_PREFIX = "%REGEX%";
@@ -145,24 +145,24 @@
145145 mnemonicCacheProp = new CachePropertySet(5000, "ニーモニック変換キャッシュ・プロパティー");
146146
147147 // キャッシュファイルがある場合 (2 回目以降の起動) : JUnit 起動時は null
148- if (transCacheFile != null && transCacheFile.exists()) {
148+ if (TRANS_CACHE_FILE != null && TRANS_CACHE_FILE.exists()) {
149149
150150 // 翻訳キャッシュをロード (後で必要になったときに原本を load)
151151 try {
152- transCacheProp.load(transCacheFile);
153- if (mnemonicCacheFile.exists()) {
154- mnemonicCacheProp.load(mnemonicCacheFile);
152+ transCacheProp.load(TRANS_CACHE_FILE);
153+ if (MNEMONIC_CACHE_FILE.exists()) {
154+ mnemonicCacheProp.load(MNEMONIC_CACHE_FILE);
155155 }
156156
157157 } catch (RuntimeException e) {
158158
159159 // キャッシュ破損、自己復元
160- log.warn("翻訳キャッシュ %s の破損を検出。復元中... - %s", transCacheFile, e.toString());
161- transCacheFile.delete();
160+ log.warn("翻訳キャッシュ %s の破損を検出。復元中... - %s", TRANS_CACHE_FILE, e.toString());
161+ TRANS_CACHE_FILE.delete();
162162 transCacheProp.clear();
163163 transCacheProp.load(validateExists(FileNamez.TRANS_FIRST_PROP));
164164
165- mnemonicCacheFile.delete();
165+ MNEMONIC_CACHE_FILE.delete();
166166 mnemonicCacheProp.clear();
167167 }
168168 }
@@ -205,7 +205,7 @@
205205 File additionsDir = Filez.conf(TRANS_ADDITIONS_DIR);
206206 if (additionsDir.exists()) {
207207
208- new PropertySet(additionsDir){
208+ new PropertySet(additionsDir) {
209209 @Override
210210 public String put(String en, String ja) {
211211
@@ -276,7 +276,7 @@
276276 public void shutdown() {
277277
278278 isLoadedDefault = true;
279- mnemonicCacheProp.store(mnemonicCacheFile);
279+ mnemonicCacheProp.store(MNEMONIC_CACHE_FILE);
280280
281281 // 安全のためキャッシュが大きくなりすぎている場合はクリア (通常は発生しない想定)
282282 if (transCacheProp.size() > 50 * 10000) {
@@ -283,11 +283,11 @@
283283 log.warn("翻訳キャッシュが大きくなりすぎているためクリアしました。" + transCacheProp.size());
284284 transCacheProp.clear();
285285 }
286- transCacheProp.store(transCacheFile);
286+ transCacheProp.store(TRANS_CACHE_FILE);
287287
288288 // デバッグ時は zip でない形式でも保存
289289 if (pleiadesContext.enabledNotFoundLog) {
290- transCacheProp.store(new File(transCacheFile.getPath().replaceFirst("\\.zip$", "")));
290+ transCacheProp.store(new File(TRANS_CACHE_FILE.getPath().replaceFirst("\\.zip$", "")));
291291 }
292292 }
293293
Show on old repository browser