Browse Source

Shorten fully-qualified names (cherry-pick 5c6e9ac)

master
Gintas Grigelionis 7 years ago
parent
commit
f979b44443
3 changed files with 36 additions and 38 deletions
  1. +3
    -2
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java
  2. +9
    -14
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
  3. +24
    -22
      src/main/org/apache/tools/ant/types/Permissions.java

+ 3
- 2
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -23,6 +23,7 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.HashMap; import java.util.HashMap;
@@ -226,7 +227,7 @@ public class ProjectHelper2 extends ProjectHelper {
try { try {
context.setBuildFile((File) null); context.setBuildFile((File) null);
context.setBuildFile(url); context.setBuildFile(url);
} catch (java.net.MalformedURLException ex) {
} catch (MalformedURLException ex) {
throw new BuildException(ex); throw new BuildException(ex);
} }
buildFileName = url.toString(); buildFileName = url.toString();
@@ -773,7 +774,7 @@ public class ProjectHelper2 extends ProjectHelper {
if (MagicNames.ANT_FILE_TYPE_URL.equals(dupType)) { if (MagicNames.ANT_FILE_TYPE_URL.equals(dupType)) {
try { try {
dupFile = new URL(dup); dupFile = new URL(dup);
} catch (java.net.MalformedURLException mue) {
} catch (MalformedURLException mue) {
throw new BuildException("failed to parse " throw new BuildException("failed to parse "
+ dup + " as URL while looking" + dup + " as URL while looking"
+ " at a duplicate project" + " at a duplicate project"


+ 9
- 14
src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java View File

@@ -23,6 +23,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.Hashtable; import java.util.Hashtable;


@@ -168,7 +169,7 @@ public class DescriptorHandler extends HandlerBase {
URL urldtd = new URL(location); URL urldtd = new URL(location);
urlDTDs.put(publicId, urldtd); urlDTDs.put(publicId, urldtd);
} }
} catch (java.net.MalformedURLException e) {
} catch (MalformedURLException e) {
//ignored //ignored
} }


@@ -262,7 +263,6 @@ public class DescriptorHandler extends HandlerBase {
inEJBRef = false; inEJBRef = false;
} }



/** /**
* SAX parser call-back method that is invoked when a new element is entered * SAX parser call-back method that is invoked when a new element is entered
* into. Used to store the context (attribute name) in the currentAttribute * into. Used to store the context (attribute name) in the currentAttribute
@@ -290,7 +290,6 @@ public class DescriptorHandler extends HandlerBase {
} }
} }



/** /**
* SAX parser call-back method that is invoked when an element is exited. * SAX parser call-back method that is invoked when an element is exited.
* Used to blank out (set to the empty string, not nullify) the name of * Used to blank out (set to the empty string, not nullify) the name of
@@ -338,11 +337,9 @@ public class DescriptorHandler extends HandlerBase {
*/ */
public void characters(char[] ch, int start, int length) public void characters(char[] ch, int start, int length)
throws SAXException { throws SAXException {

currentText += new String(ch, start, length); currentText += new String(ch, start, length);
} }



/** /**
* Called when an endelement is seen. * Called when an endelement is seen.
* This may be overridden in derived classes. * This may be overridden in derived classes.
@@ -357,15 +354,14 @@ public class DescriptorHandler extends HandlerBase {
return; return;
} }


if (currentElement.equals(HOME_INTERFACE)
|| currentElement.equals(REMOTE_INTERFACE)
|| currentElement.equals(LOCAL_INTERFACE)
|| currentElement.equals(LOCAL_HOME_INTERFACE)
|| currentElement.equals(BEAN_CLASS)
|| currentElement.equals(PK_CLASS)) {
if (HOME_INTERFACE.equals(currentElement)
|| REMOTE_INTERFACE.equals(currentElement)
|| LOCAL_INTERFACE.equals(currentElement)
|| LOCAL_HOME_INTERFACE.equals(currentElement)
|| BEAN_CLASS.equals(currentElement)
|| PK_CLASS.equals(currentElement)) {


// Get the filename into a String object // Get the filename into a String object
File classFile = null;
String className = currentText.trim(); String className = currentText.trim();


// If it's a primitive wrapper then we shouldn't try and put // If it's a primitive wrapper then we shouldn't try and put
@@ -376,8 +372,7 @@ public class DescriptorHandler extends HandlerBase {
// name, create the File object and add it to the Hashtable. // name, create the File object and add it to the Hashtable.
className = className.replace('.', File.separatorChar); className = className.replace('.', File.separatorChar);
className += ".class"; className += ".class";
classFile = new File(srcDir, className);
ejbFiles.put(className, classFile);
ejbFiles.put(className, new File(srcDir, className));
} }
} }




+ 24
- 22
src/main/org/apache/tools/ant/types/Permissions.java View File

@@ -19,10 +19,12 @@
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.net.SocketPermission;
import java.security.UnresolvedPermission; import java.security.UnresolvedPermission;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.PropertyPermission;
import java.util.Set; import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;


@@ -122,27 +124,27 @@ public class Permissions {
} }
} }
// Add base set of permissions // Add base set of permissions
granted.add(new java.net.SocketPermission("localhost:1024-", "listen"));
granted.add(new java.util.PropertyPermission("java.version", "read"));
granted.add(new java.util.PropertyPermission("java.vendor", "read"));
granted.add(new java.util.PropertyPermission("java.vendor.url", "read"));
granted.add(new java.util.PropertyPermission("java.class.version", "read"));
granted.add(new java.util.PropertyPermission("os.name", "read"));
granted.add(new java.util.PropertyPermission("os.version", "read"));
granted.add(new java.util.PropertyPermission("os.arch", "read"));
granted.add(new java.util.PropertyPermission("file.encoding", "read"));
granted.add(new java.util.PropertyPermission("file.separator", "read"));
granted.add(new java.util.PropertyPermission("path.separator", "read"));
granted.add(new java.util.PropertyPermission("line.separator", "read"));
granted.add(new java.util.PropertyPermission("java.specification.version", "read"));
granted.add(new java.util.PropertyPermission("java.specification.vendor", "read"));
granted.add(new java.util.PropertyPermission("java.specification.name", "read"));
granted.add(new java.util.PropertyPermission("java.vm.specification.version", "read"));
granted.add(new java.util.PropertyPermission("java.vm.specification.vendor", "read"));
granted.add(new java.util.PropertyPermission("java.vm.specification.name", "read"));
granted.add(new java.util.PropertyPermission("java.vm.version", "read"));
granted.add(new java.util.PropertyPermission("java.vm.vendor", "read"));
granted.add(new java.util.PropertyPermission("java.vm.name", "read"));
granted.add(new SocketPermission("localhost:1024-", "listen"));
granted.add(new PropertyPermission("java.version", "read"));
granted.add(new PropertyPermission("java.vendor", "read"));
granted.add(new PropertyPermission("java.vendor.url", "read"));
granted.add(new PropertyPermission("java.class.version", "read"));
granted.add(new PropertyPermission("os.name", "read"));
granted.add(new PropertyPermission("os.version", "read"));
granted.add(new PropertyPermission("os.arch", "read"));
granted.add(new PropertyPermission("file.encoding", "read"));
granted.add(new PropertyPermission("file.separator", "read"));
granted.add(new PropertyPermission("path.separator", "read"));
granted.add(new PropertyPermission("line.separator", "read"));
granted.add(new PropertyPermission("java.specification.version", "read"));
granted.add(new PropertyPermission("java.specification.vendor", "read"));
granted.add(new PropertyPermission("java.specification.name", "read"));
granted.add(new PropertyPermission("java.vm.specification.version", "read"));
granted.add(new PropertyPermission("java.vm.specification.vendor", "read"));
granted.add(new PropertyPermission("java.vm.specification.name", "read"));
granted.add(new PropertyPermission("java.vm.version", "read"));
granted.add(new PropertyPermission("java.vm.vendor", "read"));
granted.add(new PropertyPermission("java.vm.name", "read"));
} }


private java.security.Permission createPermission( private java.security.Permission createPermission(
@@ -187,7 +189,7 @@ public class Permissions {
*/ */
@Override @Override
public void checkExit(final int status) { public void checkExit(final int status) {
final java.security.Permission perm = new java.lang.RuntimePermission("exitVM", null);
final java.security.Permission perm = new RuntimePermission("exitVM", null);
try { try {
checkPermission(perm); checkPermission(perm);
} catch (final SecurityException e) { } catch (final SecurityException e) {


Loading…
Cancel
Save