mirror of
https://github.com/darlinghq/darling-openjdk.git
synced 2025-03-02 13:06:48 +00:00
Merge
This commit is contained in:
commit
f3883b4d54
@ -149,8 +149,8 @@ strip_prop_options_clean:
|
|||||||
# Strip the properties files
|
# Strip the properties files
|
||||||
strip_all_props: $(STRIPPROPERTIES_JARFILE) $(STRIP_PROP_options)
|
strip_all_props: $(STRIPPROPERTIES_JARFILE) $(STRIP_PROP_options)
|
||||||
@if [ -s $(STRIP_PROP_options) ] ; then \
|
@if [ -s $(STRIP_PROP_options) ] ; then \
|
||||||
$(ECHO) "$(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) -optionsfile $(STRIP_PROP_options)" ; \
|
$(ECHO) "$(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) @$(STRIP_PROP_options)" ; \
|
||||||
$(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) -optionsfile $(STRIP_PROP_options) ; \
|
$(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) @$(STRIP_PROP_options) ; \
|
||||||
fi
|
fi
|
||||||
@$(java-vm-cleanup)
|
@$(java-vm-cleanup)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -36,6 +36,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ import java.util.Properties;
|
|||||||
* Reads a properties file from standard input and writes an equivalent
|
* Reads a properties file from standard input and writes an equivalent
|
||||||
* properties file without comments to standard output.
|
* properties file without comments to standard output.
|
||||||
*/
|
*/
|
||||||
public class StripProperties {
|
public class StripPropertiesCorba {
|
||||||
|
|
||||||
private static void error(String msg, Exception e) {
|
private static void error(String msg, Exception e) {
|
||||||
System.err.println("ERROR: stripproperties: " + msg);
|
System.err.println("ERROR: stripproperties: " + msg);
|
||||||
@ -53,82 +54,89 @@ public class StripProperties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> parseOptions(String args[]) {
|
private static List<String> infiles = new ArrayList<String>();
|
||||||
List<String> files = new ArrayList<String>();
|
private static List<String> outfiles = new ArrayList<String>();
|
||||||
|
|
||||||
|
private static boolean parseOptions(String args[]) {
|
||||||
|
boolean ok = true;
|
||||||
|
|
||||||
for ( int i = 0; i < args.length ; i++ ) {
|
for ( int i = 0; i < args.length ; i++ ) {
|
||||||
if ( "-optionsfile".equals(args[i]) && i+1 < args.length ) {
|
if ( "-clean".equals(args[i]) && i+2 < args.length ) {
|
||||||
String filename = args[++i];
|
infiles.add(args[++i]);
|
||||||
|
outfiles.add(args[++i]);
|
||||||
|
} else if ( args[i].charAt(0)=='@') {
|
||||||
|
String filename = args[i].substring(1);
|
||||||
FileInputStream finput = null;
|
FileInputStream finput = null;
|
||||||
byte contents[] = null;
|
byte contents[] = null;
|
||||||
try {
|
try {
|
||||||
finput = new FileInputStream(filename);
|
finput = new FileInputStream(filename);
|
||||||
int byteCount = finput.available();
|
int byteCount = finput.available();
|
||||||
if ( byteCount <= 0 ) {
|
if ( byteCount <= 0 ) {
|
||||||
error("The -optionsfile file is empty", null);
|
error("The @file is empty", null);
|
||||||
files = null;
|
ok = false;
|
||||||
} else {
|
} else {
|
||||||
contents = new byte[byteCount];
|
contents = new byte[byteCount];
|
||||||
int bytesRead = finput.read(contents);
|
int bytesRead = finput.read(contents);
|
||||||
if ( byteCount != bytesRead ) {
|
if ( byteCount != bytesRead ) {
|
||||||
error("Cannot read all of -optionsfile file", null);
|
error("Cannot read all of @file", null);
|
||||||
files = null;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch ( IOException e ) {
|
} catch ( IOException e ) {
|
||||||
error("cannot open " + filename, e);
|
error("cannot open " + filename, e);
|
||||||
files = null;
|
ok = false;
|
||||||
}
|
}
|
||||||
if ( finput != null ) {
|
if ( finput != null ) {
|
||||||
try {
|
try {
|
||||||
finput.close();
|
finput.close();
|
||||||
} catch ( IOException e ) {
|
} catch ( IOException e ) {
|
||||||
files = null;
|
ok = false;
|
||||||
error("cannot close " + filename, e);
|
error("cannot close " + filename, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( files != null && contents != null ) {
|
if ( ok && contents != null ) {
|
||||||
String tokens[] = (new String(contents)).split("\\s+");
|
String tokens[] = (new String(contents)).split("\\s+");
|
||||||
if ( tokens.length > 0 ) {
|
if ( tokens.length > 0 ) {
|
||||||
List<String> ofiles = parseOptions(tokens);
|
ok = parseOptions(tokens);
|
||||||
if ( ofiles != null ) {
|
|
||||||
files.addAll(ofiles);
|
|
||||||
} else {
|
|
||||||
error("No files found in file", null);
|
|
||||||
files = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if ( !ok ) {
|
||||||
if ( files == null ) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
files.add(args[i]);
|
infiles.add(args[i]);
|
||||||
|
outfiles.add(args[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return files;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean stripFiles(List<String> files) {
|
private static boolean stripFiles(List<String> infiles, List<String> outfiles) {
|
||||||
boolean ok = true;
|
boolean ok = true;
|
||||||
for ( String file : files ) {
|
Iterator<String> inIter = infiles.iterator();
|
||||||
|
Iterator<String> outIter = outfiles.iterator();
|
||||||
|
|
||||||
|
for (; inIter.hasNext(); ) {
|
||||||
|
String infile = inIter.next();
|
||||||
|
String outfile = outIter.next();
|
||||||
|
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
try {
|
try {
|
||||||
in = new BufferedInputStream(new FileInputStream(file));
|
in = new BufferedInputStream(new FileInputStream(infile));
|
||||||
prop.load(in);
|
prop.load(in);
|
||||||
} catch ( FileNotFoundException e ) {
|
} catch ( FileNotFoundException e ) {
|
||||||
error("Cannot access file " + file, e);
|
error("Cannot access file " + infile, e);
|
||||||
ok = false;
|
ok = false;
|
||||||
} catch ( IOException e ) {
|
} catch ( IOException e ) {
|
||||||
error("IO exception processing file " + file, e);
|
error("IO exception processing file " + infile, e);
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
if ( in != null ) {
|
if ( in != null ) {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
} catch ( IOException e ) {
|
} catch ( IOException e ) {
|
||||||
error("IO exception closing file " + file, e);
|
error("IO exception closing file " + infile, e);
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,18 +146,18 @@ public class StripProperties {
|
|||||||
|
|
||||||
OutputStream out = null;
|
OutputStream out = null;
|
||||||
try {
|
try {
|
||||||
out = new FileOutputStream(file);
|
out = new FileOutputStream(outfile);
|
||||||
storeProperties(prop, out);
|
storeProperties(prop, out);
|
||||||
out.flush();
|
out.flush();
|
||||||
} catch ( IOException e ) {
|
} catch ( IOException e ) {
|
||||||
error("IO exception processing file " + file, e);
|
error("IO exception processing file " + outfile, e);
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
if ( out != null ) {
|
if ( out != null ) {
|
||||||
try {
|
try {
|
||||||
out.close();
|
out.close();
|
||||||
} catch ( IOException e ) {
|
} catch ( IOException e ) {
|
||||||
error("IO exception closing file " + file, e);
|
error("IO exception closing file " + outfile, e);
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,8 +174,8 @@ public class StripProperties {
|
|||||||
* @param args Names of properties files to process and replace contents
|
* @param args Names of properties files to process and replace contents
|
||||||
*/
|
*/
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
List<String> files = parseOptions(args);
|
boolean ok = parseOptions(args);
|
||||||
if ( files == null || !stripFiles(files) ) {
|
if ( !ok || !stripFiles(infiles, outfiles) ) {
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,7 +254,7 @@ public class StripProperties {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
BufferedWriter awriter;
|
BufferedWriter awriter;
|
||||||
awriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1"));
|
awriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1"));
|
||||||
for (Enumeration e = properties.keys(); e.hasMoreElements();) {
|
for (Enumeration<Object> e = properties.keys(); e.hasMoreElements();) {
|
||||||
String key = (String)e.nextElement();
|
String key = (String)e.nextElement();
|
||||||
String val = (String)properties.get(key);
|
String val = (String)properties.get(key);
|
||||||
key = saveConvert(key, true);
|
key = saveConvert(key, true);
|
@ -34,7 +34,7 @@ PROGRAM = stripproperties
|
|||||||
include $(BUILDDIR)/common/Defs.gmk
|
include $(BUILDDIR)/common/Defs.gmk
|
||||||
|
|
||||||
BUILDTOOL_SOURCE_ROOT = $(BUILDDIR)/tools/src
|
BUILDTOOL_SOURCE_ROOT = $(BUILDDIR)/tools/src
|
||||||
BUILDTOOL_MAIN = $(PKGDIR)/StripProperties.java
|
BUILDTOOL_MAIN = $(PKGDIR)/StripPropertiesCorba.java
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build tool jar rules.
|
# Build tool jar rules.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user