Compare commits
107 Commits
branch_1_1
...
master
Author | SHA1 | Date |
---|---|---|
hoenicke | e5c8e18a43 | 11 years ago |
hoenicke | 33504d1840 | 11 years ago |
hoenicke | 7a96e31c81 | 12 years ago |
hoenicke | 0277d99ebb | 12 years ago |
hoenicke | accfa1271e | 12 years ago |
hoenicke | 744346bbcb | 12 years ago |
hoenicke | 3c76f52d03 | 12 years ago |
hoenicke | 5815ab3a08 | 12 years ago |
hoenicke | 977e4a6e8d | 18 years ago |
asal | 0526241d2f | 18 years ago |
asal | 2610837e4e | 18 years ago |
asal | 08ca574741 | 18 years ago |
hoenicke | a69e8b35b6 | 18 years ago |
hoenicke | 39775ca4ee | 18 years ago |
hoenicke | f7d5e15584 | 19 years ago |
hoenicke | 000cbe01e8 | 19 years ago |
hoenicke | 4ff081adef | 19 years ago |
hoenicke | 183db2f66c | 20 years ago |
hoenicke | 4ec17554de | 20 years ago |
hoenicke | 7a700a7a5b | 20 years ago |
hoenicke | 9e663e0b65 | 20 years ago |
hoenicke | 7442ded059 | 20 years ago |
hoenicke | 487a4b49d9 | 20 years ago |
hoenicke | 033d9d57e5 | 20 years ago |
hoenicke | ec129979e1 | 20 years ago |
hoenicke | ae5ffbf3f8 | 20 years ago |
hoenicke | bf472df5c0 | 21 years ago |
hoenicke | 338feb1f61 | 21 years ago |
seeksthemoon | 2872b22195 | 21 years ago |
seeksthemoon | c53a8d1acf | 21 years ago |
hoenicke | 0c1d7a4b7c | 22 years ago |
hoenicke | 66dc0880ab | 22 years ago |
hoenicke | 48d511532d | 22 years ago |
hoenicke | d6462acefc | 22 years ago |
hoenicke | f43b317ae8 | 22 years ago |
hoenicke | 375a002248 | 23 years ago |
hoenicke | b33f6d1045 | 23 years ago |
hoenicke | c11b2426df | 23 years ago |
hoenicke | d7567a6b06 | 23 years ago |
hoenicke | 06f647eb1c | 23 years ago |
hoenicke | c0bd096c0d | 23 years ago |
hoenicke | d04992725b | 23 years ago |
hoenicke | d3f133999f | 23 years ago |
hoenicke | 25339761a8 | 23 years ago |
hoenicke | 0243eb4f23 | 23 years ago |
hoenicke | 9e5dca11ad | 23 years ago |
hoenicke | d5a0591d1f | 23 years ago |
hoenicke | 2d1bb14f08 | 23 years ago |
hoenicke | 14b4dd94f8 | 23 years ago |
hoenicke | 7714d5d503 | 23 years ago |
hoenicke | 6acf9d8d7a | 23 years ago |
hoenicke | dab92b2d4d | 23 years ago |
hoenicke | 4352b285ab | 23 years ago |
hoenicke | 1ce57d3614 | 23 years ago |
hoenicke | 804d4f7912 | 23 years ago |
hoenicke | 743e08ea39 | 23 years ago |
hoenicke | 31ebef4f9c | 23 years ago |
hoenicke | a2006f63d4 | 23 years ago |
hoenicke | f2d8663e9f | 23 years ago |
hoenicke | e78e8b0472 | 23 years ago |
hoenicke | 676e21257f | 23 years ago |
hoenicke | c30ac484c5 | 23 years ago |
hoenicke | 9f97289a90 | 23 years ago |
hoenicke | 472188e7ff | 24 years ago |
hoenicke | 14943a8451 | 24 years ago |
hoenicke | 9cbbe3b6ea | 24 years ago |
hoenicke | 51ad83c9c9 | 24 years ago |
hoenicke | 2ae9fec86a | 24 years ago |
hoenicke | 5a22174883 | 24 years ago |
hoenicke | e3e58de150 | 24 years ago |
hoenicke | 389f642dd5 | 24 years ago |
hoenicke | 342283c03a | 24 years ago |
hoenicke | 9470aef606 | 24 years ago |
hoenicke | 03a84b8f4f | 24 years ago |
hoenicke | 31b99cc4f0 | 24 years ago |
hoenicke | 8c85a88d39 | 24 years ago |
hoenicke | 854a466d67 | 24 years ago |
hoenicke | 0e32c28865 | 24 years ago |
hoenicke | 00448cfcbc | 24 years ago |
hoenicke | 8f00154e64 | 24 years ago |
hoenicke | 712f5d03dd | 24 years ago |
hoenicke | b14a4f5e86 | 24 years ago |
hoenicke | e4b704ca70 | 24 years ago |
hoenicke | 571bb071fe | 24 years ago |
hoenicke | 1a0fc97111 | 24 years ago |
hoenicke | 4a63627c87 | 24 years ago |
hoenicke | 5e6af53990 | 24 years ago |
hoenicke | ca386721b2 | 24 years ago |
hoenicke | af97d8da6d | 24 years ago |
hoenicke | 7ff611fe09 | 24 years ago |
hoenicke | bde4f7f48c | 24 years ago |
hoenicke | e154dfdc1b | 24 years ago |
hoenicke | 0b2f10fddf | 24 years ago |
hoenicke | bf597fea43 | 24 years ago |
hoenicke | aca625aa34 | 24 years ago |
hoenicke | 34081d2e06 | 24 years ago |
hoenicke | 96ef935ccc | 24 years ago |
hoenicke | 46f4102cec | 24 years ago |
hoenicke | ff73414ef3 | 24 years ago |
hoenicke | b99c87a98d | 24 years ago |
hoenicke | f85c46fd44 | 24 years ago |
hoenicke | 39d1fbb31b | 24 years ago |
hoenicke | 3378492cd3 | 24 years ago |
hoenicke | a34a837696 | 24 years ago |
hoenicke | b53430f5c5 | 24 years ago |
hoenicke | 723088e8be | 24 years ago |
hoenicke | 9c9de3b561 | 24 years ago |
@ -0,0 +1,14 @@ |
|||||||
|
# The "checkoutlist" file is used to support additional version controlled |
||||||
|
# administrative files in $CVSROOT/CVSROOT, such as template files. |
||||||
|
# |
||||||
|
# The first entry on a line is a filename which will be checked out from |
||||||
|
# the corresponding RCS file in the $CVSROOT/CVSROOT directory. |
||||||
|
# The remainder of the line is an error message to use if the file cannot |
||||||
|
# be checked out. |
||||||
|
# |
||||||
|
# File format: |
||||||
|
# |
||||||
|
# [<whitespace>]<filename><whitespace><error message><end-of-line> |
||||||
|
# |
||||||
|
# comment lines begin with '#' |
||||||
|
syncmail |
@ -0,0 +1,15 @@ |
|||||||
|
# The "commitinfo" file is used to control pre-commit checks. |
||||||
|
# The filter on the right is invoked with the repository and a list |
||||||
|
# of files to check. A non-zero exit of the filter program will |
||||||
|
# cause the commit to be aborted. |
||||||
|
# |
||||||
|
# The first entry on a line is a regular expression which is tested |
||||||
|
# against the directory that the change is being committed to, relative |
||||||
|
# to the $CVSROOT. For the first match that is found, then the remainder |
||||||
|
# of the line is the name of the filter to run. |
||||||
|
# |
||||||
|
# If the repository name does not match any of the regular expressions in this |
||||||
|
# file, the "DEFAULT" line is used, if it is specified. |
||||||
|
# |
||||||
|
# If the name "ALL" appears as a regular expression it is always used |
||||||
|
# in addition to the first matching regex or "DEFAULT". |
@ -0,0 +1,11 @@ |
|||||||
|
# Set this to "no" if pserver shouldn't check system users/passwords |
||||||
|
#SystemAuth=no |
||||||
|
|
||||||
|
# Set `PreservePermissions' to `yes' to save file status information |
||||||
|
# in the repository. |
||||||
|
#PreservePermissions=no |
||||||
|
|
||||||
|
# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top |
||||||
|
# level of the new working directory when using the `cvs checkout' |
||||||
|
# command. |
||||||
|
#TopLevelAdmin=no |
@ -0,0 +1 @@ |
|||||||
|
*.class |
@ -0,0 +1,24 @@ |
|||||||
|
# This file affects handling of files based on their names. |
||||||
|
# |
||||||
|
# The -t/-f options allow one to treat directories of files |
||||||
|
# as a single file, or to transform a file in other ways on |
||||||
|
# its way in and out of CVS. |
||||||
|
# |
||||||
|
# The -m option specifies whether CVS attempts to merge files. |
||||||
|
# |
||||||
|
# The -k option specifies keyword expansion (e.g. -kb for binary). |
||||||
|
# |
||||||
|
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers) |
||||||
|
# |
||||||
|
# wildcard [option value][option value]... |
||||||
|
# |
||||||
|
# where option is one of |
||||||
|
# -f from cvs filter value: path to filter |
||||||
|
# -t to cvs filter value: path to filter |
||||||
|
# -m update methodology value: MERGE or COPY |
||||||
|
# -k expansion mode value: b, o, kkv, &c |
||||||
|
# |
||||||
|
# and value is a single-quote delimited value. |
||||||
|
# For example: |
||||||
|
*.gif -k 'b' |
||||||
|
*.xcf -k 'b' |
@ -0,0 +1,21 @@ |
|||||||
|
# The "editinfo" file is used to allow verification of logging |
||||||
|
# information. It works best when a template (as specified in the |
||||||
|
# rcsinfo file) is provided for the logging procedure. Given a |
||||||
|
# template with locations for, a bug-id number, a list of people who |
||||||
|
# reviewed the code before it can be checked in, and an external |
||||||
|
# process to catalog the differences that were code reviewed, the |
||||||
|
# following test can be applied to the code: |
||||||
|
# |
||||||
|
# Making sure that the entered bug-id number is correct. |
||||||
|
# Validating that the code that was reviewed is indeed the code being |
||||||
|
# checked in (using the bug-id number or a seperate review |
||||||
|
# number to identify this particular code set.). |
||||||
|
# |
||||||
|
# If any of the above test failed, then the commit would be aborted. |
||||||
|
# |
||||||
|
# Actions such as mailing a copy of the report to each reviewer are |
||||||
|
# better handled by an entry in the loginfo file. |
||||||
|
# |
||||||
|
# One thing that should be noted is the the ALL keyword is not |
||||||
|
# supported. There can be only one entry that matches a given |
||||||
|
# repository. |
@ -0,0 +1,27 @@ |
|||||||
|
# The "loginfo" file controls where "cvs commit" log information |
||||||
|
# is sent. The first entry on a line is a regular expression which must match |
||||||
|
# the directory that the change is being made to, relative to the |
||||||
|
# $CVSROOT. If a match is found, then the remainder of the line is a filter |
||||||
|
# program that should expect log information on its standard input. |
||||||
|
# |
||||||
|
# If the repository name does not match any of the regular expressions in this |
||||||
|
# file, the "DEFAULT" line is used, if it is specified. |
||||||
|
# |
||||||
|
# If the name ALL appears as a regular expression it is always used |
||||||
|
# in addition to the first matching regex or DEFAULT. |
||||||
|
# |
||||||
|
# You may specify a format string as part of the |
||||||
|
# filter. The string is composed of a `%' followed |
||||||
|
# by a single format character, or followed by a set of format |
||||||
|
# characters surrounded by `{' and `}' as separators. The format |
||||||
|
# characters are: |
||||||
|
# |
||||||
|
# s = file name |
||||||
|
# V = old version number (pre-checkin) |
||||||
|
# v = new version number (post-checkin) |
||||||
|
# |
||||||
|
# For example: |
||||||
|
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog |
||||||
|
# or |
||||||
|
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog |
||||||
|
DEFAULT $CVSROOT/CVSROOT/syncmail %{sVv} jode-commit@lists.sourceforge.net |
@ -0,0 +1 @@ |
|||||||
|
jode jode |
@ -0,0 +1,12 @@ |
|||||||
|
# The "notify" file controls where notifications from watches set by |
||||||
|
# "cvs watch add" or "cvs edit" are sent. The first entry on a line is |
||||||
|
# a regular expression which is tested against the directory that the |
||||||
|
# change is being made to, relative to the $CVSROOT. If it matches, |
||||||
|
# then the remainder of the line is a filter program that should contain |
||||||
|
# one occurrence of %s for the user to notify, and information on its |
||||||
|
# standard input. |
||||||
|
# |
||||||
|
# "ALL" or "DEFAULT" can be used in place of the regular expression. |
||||||
|
# |
||||||
|
# For example: |
||||||
|
#ALL mail %s -s "CVS notification" |
@ -0,0 +1,13 @@ |
|||||||
|
# The "rcsinfo" file is used to control templates with which the editor |
||||||
|
# is invoked on commit and import. |
||||||
|
# |
||||||
|
# The first entry on a line is a regular expression which is tested |
||||||
|
# against the directory that the change is being made to, relative to the |
||||||
|
# $CVSROOT. For the first match that is found, then the remainder of the |
||||||
|
# line is the name of the file that contains the template. |
||||||
|
# |
||||||
|
# If the repository name does not match any of the regular expressions in this |
||||||
|
# file, the "DEFAULT" line is used, if it is specified. |
||||||
|
# |
||||||
|
# If the name "ALL" appears as a regular expression it is always used |
||||||
|
# in addition to the first matching regex or "DEFAULT". |
@ -0,0 +1,20 @@ |
|||||||
|
# The "taginfo" file is used to control pre-tag checks. |
||||||
|
# The filter on the right is invoked with the following arguments: |
||||||
|
# |
||||||
|
# $1 -- tagname |
||||||
|
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d |
||||||
|
# $3 -- repository |
||||||
|
# $4-> file revision [file revision ...] |
||||||
|
# |
||||||
|
# A non-zero exit of the filter program will cause the tag to be aborted. |
||||||
|
# |
||||||
|
# The first entry on a line is a regular expression which is tested |
||||||
|
# against the directory that the change is being committed to, relative |
||||||
|
# to the $CVSROOT. For the first match that is found, then the remainder |
||||||
|
# of the line is the name of the filter to run. |
||||||
|
# |
||||||
|
# If the repository name does not match any of the regular expressions in this |
||||||
|
# file, the "DEFAULT" line is used, if it is specified. |
||||||
|
# |
||||||
|
# If the name "ALL" appears as a regular expression it is always used |
||||||
|
# in addition to the first matching regex or "DEFAULT". |
@ -0,0 +1,21 @@ |
|||||||
|
# The "verifymsg" file is used to allow verification of logging |
||||||
|
# information. It works best when a template (as specified in the |
||||||
|
# rcsinfo file) is provided for the logging procedure. Given a |
||||||
|
# template with locations for, a bug-id number, a list of people who |
||||||
|
# reviewed the code before it can be checked in, and an external |
||||||
|
# process to catalog the differences that were code reviewed, the |
||||||
|
# following test can be applied to the code: |
||||||
|
# |
||||||
|
# Making sure that the entered bug-id number is correct. |
||||||
|
# Validating that the code that was reviewed is indeed the code being |
||||||
|
# checked in (using the bug-id number or a seperate review |
||||||
|
# number to identify this particular code set.). |
||||||
|
# |
||||||
|
# If any of the above test failed, then the commit would be aborted. |
||||||
|
# |
||||||
|
# Actions such as mailing a copy of the report to each reviewer are |
||||||
|
# better handled by an entry in the loginfo file. |
||||||
|
# |
||||||
|
# One thing that should be noted is the the ALL keyword is not |
||||||
|
# supported. There can be only one entry that matches a given |
||||||
|
# repository. |
@ -0,0 +1,7 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<classpath> |
||||||
|
<classpathentry excluding="net/sf/jode/obfuscator/modules/LocalOptimizer.java|net/sf/jode/obfuscator/modules/LocalizeFieldTransformer.java|net/sf/jode/obfuscator/modules/RemovePopAnalyzer.java" kind="src" output="build" path="src"/> |
||||||
|
<classpathentry kind="lib" path="lib/java-getopt-1.0.8.jar"/> |
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
||||||
|
<classpathentry kind="output" path="build"/> |
||||||
|
</classpath> |
@ -0,0 +1,17 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<projectDescription> |
||||||
|
<name>jode</name> |
||||||
|
<comment></comment> |
||||||
|
<projects> |
||||||
|
</projects> |
||||||
|
<buildSpec> |
||||||
|
<buildCommand> |
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name> |
||||||
|
<arguments> |
||||||
|
</arguments> |
||||||
|
</buildCommand> |
||||||
|
</buildSpec> |
||||||
|
<natures> |
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature> |
||||||
|
</natures> |
||||||
|
</projectDescription> |
@ -0,0 +1,353 @@ |
|||||||
|
#Thu Mar 01 23:39:18 CET 2012 |
||||||
|
eclipse.preferences.version=1 |
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 |
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve |
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.4 |
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate |
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate |
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate |
||||||
|
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.deadCode=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.deprecation=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error |
||||||
|
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.nullReference=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedImport=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning |
||||||
|
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning |
||||||
|
org.eclipse.jdt.core.compiler.source=1.3 |
||||||
|
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_assignment=0 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 |
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_after_package=1 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_field=0 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_method=1 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_package=0 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 |
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line |
||||||
|
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false |
||||||
|
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false |
||||||
|
org.eclipse.jdt.core.formatter.comment.format_block_comments=true |
||||||
|
org.eclipse.jdt.core.formatter.comment.format_header=false |
||||||
|
org.eclipse.jdt.core.formatter.comment.format_html=true |
||||||
|
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true |
||||||
|
org.eclipse.jdt.core.formatter.comment.format_line_comments=true |
||||||
|
org.eclipse.jdt.core.formatter.comment.format_source_code=true |
||||||
|
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true |
||||||
|
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true |
||||||
|
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert |
||||||
|
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert |
||||||
|
org.eclipse.jdt.core.formatter.comment.line_length=80 |
||||||
|
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true |
||||||
|
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true |
||||||
|
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false |
||||||
|
org.eclipse.jdt.core.formatter.compact_else_if=true |
||||||
|
org.eclipse.jdt.core.formatter.continuation_indentation=2 |
||||||
|
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 |
||||||
|
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off |
||||||
|
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on |
||||||
|
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false |
||||||
|
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true |
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true |
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true |
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true |
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true |
||||||
|
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true |
||||||
|
org.eclipse.jdt.core.formatter.indent_empty_lines=false |
||||||
|
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true |
||||||
|
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true |
||||||
|
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true |
||||||
|
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false |
||||||
|
org.eclipse.jdt.core.formatter.indentation.size=4 |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert |
||||||
|
org.eclipse.jdt.core.formatter.join_lines_in_comments=true |
||||||
|
org.eclipse.jdt.core.formatter.join_wrapped_lines=true |
||||||
|
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false |
||||||
|
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false |
||||||
|
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false |
||||||
|
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false |
||||||
|
org.eclipse.jdt.core.formatter.lineSplit=80 |
||||||
|
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false |
||||||
|
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false |
||||||
|
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 |
||||||
|
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 |
||||||
|
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true |
||||||
|
org.eclipse.jdt.core.formatter.tabulation.char=mixed |
||||||
|
org.eclipse.jdt.core.formatter.tabulation.size=8 |
||||||
|
org.eclipse.jdt.core.formatter.use_on_off_tags=false |
||||||
|
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false |
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true |
||||||
|
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true |
@ -0,0 +1,4 @@ |
|||||||
|
#Thu Mar 01 22:21:28 CET 2012 |
||||||
|
eclipse.preferences.version=1 |
||||||
|
formatter_profile=org.eclipse.jdt.ui.default.sun_profile |
||||||
|
formatter_settings_version=12 |
@ -0,0 +1,3 @@ |
|||||||
|
#Thu Mar 01 22:15:48 CET 2012 |
||||||
|
eclipse.preferences.version=1 |
||||||
|
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false |
@ -1,45 +1,23 @@ |
|||||||
Before installing, make sure you have at least version 1.1 of the java |
Before installing, make sure you have at least version 1.1 of the java |
||||||
developement kit installed. If you want to run this program you only |
developement kit installed. If you want to run this program you only |
||||||
need the java runtime environment. Version 1.1 is quite old, I |
need the java runtime environment. Version 1.1 is quite old, I |
||||||
recommend using Java 2 (jdk1.2 or above). |
recommend using Java 2 (jdk1.2 or above). You need perl if you want |
||||||
|
to compile a 1.1 version. |
||||||
This package was designed to use the GNU standard for configuration |
|
||||||
and makefiles. To build and install do the following: |
This package was designed to use the ANT from the jakarta.apache.org |
||||||
|
tools. I assume you have installed it correctly. |
||||||
0). If you have downloaded the code from the CVS repository create |
|
||||||
configure and Makefile.in with autoconf-2.13 and automake-1.4. Type |
Take some time to edit config.props. There are a few options you need |
||||||
"aclocal; automake -a; autoconf". |
to take care of. (Unfortunately ant can't test for executables). |
||||||
|
|
||||||
1). You need a java development kit (at least version 1.1), some unix |
Now you are ready to invoke ant. There are many possible targets, here |
||||||
tools and some java packages. Make sure that you have all java |
are the most useful ones: |
||||||
packages that are needed in your classpath. This are gnu.getopt, and |
|
||||||
if you have JDK 1.1 you also need the collection classes and swing for |
all builds class files and documentation. |
||||||
1.1. These packages are accessible from the following urls: |
build builds class files only (autodetects java version). |
||||||
|
build-1.1 builds JDK1.1 class files. |
||||||
CYGWIN (unix tools for win95/NT): |
doc builds documentation. |
||||||
http://sourceware.cygnus.com/cygwin/ |
dist creates all release files. |
||||||
|
test does some self tests. You need to have junit installed for this. |
||||||
JDK 1.1: |
clean cleans everything that doesn't belong to the source distribution. |
||||||
http://java.sun.com/products/jdk/1.1/index.htm |
cvsclean cleans everything that doesn't belong into the cvs repository. |
||||||
|
|
||||||
Collection classes and Swing for JDK 1.1: |
|
||||||
http://java.sun.com/beans/infobus/#DOWNLOAD_COLLECTIONS |
|
||||||
http://java.sun.com/products/jfc/index.html#download-swing |
|
||||||
|
|
||||||
JDK 1.2: |
|
||||||
http://java.sun.com/products/jdk/1.2/index.html |
|
||||||
|
|
||||||
Getopt: |
|
||||||
http://www.urbanophile.com/arenn/hacking/download.html#getopt |
|
||||||
|
|
||||||
2). Run the "configure" script to configure the package. There are |
|
||||||
various options you might want to pass to configure to control how the |
|
||||||
package is built. "configure --help" will give a complete list. |
|
||||||
|
|
||||||
Use the --with-jdk option to specify the install directory of the jdk. |
|
||||||
|
|
||||||
If you have jikes, you should specify it with --with-jikes. You can |
|
||||||
give a path to the directory where it resides, otherwise it is |
|
||||||
searched in the path. |
|
||||||
|
|
||||||
3). Type "make" to build the package. |
|
||||||
|
@ -0,0 +1,3 @@ |
|||||||
|
Manifest-Version: 1.0 |
||||||
|
Main-Class: net.sf.jode.swingui.Main |
||||||
|
Created-By: SeeksTheMoon |
@ -1,5 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
SUBDIRS = bin doc jode test
|
|
||||||
|
|
||||||
EXTRA_DIST = jcpp
|
|
@ -1,44 +0,0 @@ |
|||||||
dnl |
|
||||||
dnl Add macros |
|
||||||
dnl JODE_CHECK_JAVA |
|
||||||
dnl |
|
||||||
|
|
||||||
dnl JODE_CHECK_JAVA(path) |
|
||||||
AC_DEFUN(JODE_CHECK_JAVA, |
|
||||||
[ |
|
||||||
AC_PATH_PROG(JAVA, java, "", $1/bin:$1/jre/bin:$PATH) |
|
||||||
AC_PATH_PROG(JAVAC, javac, "", $1/bin:$PATH) |
|
||||||
AC_PATH_PROG(JAR, jar, "", $1/bin:$PATH) |
|
||||||
for path in $1/lib $1/jre/lib $1/shared; do |
|
||||||
for classlib in classes.zip rt.jar; do |
|
||||||
AC_CHECK_FILES($path/$classlib, |
|
||||||
[ CLASSLIB=$path/$classlib |
|
||||||
break 3 |
|
||||||
], [ true ]) |
|
||||||
done |
|
||||||
done |
|
||||||
AC_SUBST(CLASSPATH) |
|
||||||
AC_SUBST(CLASSLIB) |
|
||||||
]) |
|
||||||
|
|
||||||
AC_DEFUN(JODE_CHECK_CLASS, |
|
||||||
[ |
|
||||||
if (IFS=":" |
|
||||||
clazz=`echo $1 | sed -e 's/\./\//g' -e 's/\(.*\)/\1.class/'` |
|
||||||
myclasspath=$2; |
|
||||||
for path in $myclasspath; do |
|
||||||
if test -d $path; then |
|
||||||
if test -f $path/$clazz; then |
|
||||||
exit 0 |
|
||||||
fi |
|
||||||
elif CLASS_CHECK $path $clazz ; then |
|
||||||
exit 0 |
|
||||||
fi |
|
||||||
done; |
|
||||||
exit 1) |
|
||||||
then |
|
||||||
$3 |
|
||||||
else |
|
||||||
$4 |
|
||||||
fi |
|
||||||
]) |
|
@ -0,0 +1,380 @@ |
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?> |
||||||
|
<!-- Jakarta-Ant build file for jode, Copyright (C) 1999-2004 Jochen Hoenicke. |
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation; either version 2, or (at your option) |
||||||
|
any later version. |
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with this program; see the file COPYING. If not, write to |
||||||
|
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
||||||
|
|
||||||
|
$Id$ |
||||||
|
--> |
||||||
|
|
||||||
|
<!DOCTYPE project PUBLIC "-//ANT//DTD project//EN" "project.dtd"> |
||||||
|
<project name="jode" default="test" basedir="."> |
||||||
|
<!-- set global properties for this build --> |
||||||
|
<property name="version" value="1.90-CVS"/> |
||||||
|
|
||||||
|
<property name="build" value="${basedir}/build"/> |
||||||
|
<property name="props" value="${basedir}/props"/> |
||||||
|
<property name="doc" value="${basedir}/doc"/> |
||||||
|
<property name="lib" value="${basedir}/lib"/> |
||||||
|
<property name="src" value="${basedir}/src"/> |
||||||
|
<property name="release" value="${basedir}/release"/> |
||||||
|
<property name="distdir" value="${release}/jode-${version}"/> |
||||||
|
<property name="scripts" value="${basedir}/scripts"/> |
||||||
|
|
||||||
|
<property name="api.doc" value="${doc}/api"/> |
||||||
|
|
||||||
|
<property name="test" value="${basedir}/test"/> |
||||||
|
<property name="test.src" value="${test}/src"/> |
||||||
|
<property name="test.build" value="${test}/build"/> |
||||||
|
<property name="test.log" value="${test}/log"/> |
||||||
|
|
||||||
|
<property name="jcpp" value="${scripts}/jcpp.pl"/> |
||||||
|
|
||||||
|
<property name="versionfile" value="${src}/jode/GlobalOptions.java"/> |
||||||
|
|
||||||
|
<property file="config.props"/> |
||||||
|
|
||||||
|
<path id="project.classpath"> |
||||||
|
<pathelement path="${classpath}"/> |
||||||
|
<fileset dir="lib" includes="*.jar"/> |
||||||
|
</path> |
||||||
|
|
||||||
|
<!-- ********* General targets ******* --> |
||||||
|
|
||||||
|
<!-- compiles jode and creates its javadoc-files --> |
||||||
|
<target name="all" depends="build,doc"/> |
||||||
|
|
||||||
|
<!-- clean all --> |
||||||
|
<target name="clean" depends="clean-jcpp,clean-build,clean-doc,clean-test"/> |
||||||
|
<target name="cvsclean" depends="clean,clean-html,clean-release"/> |
||||||
|
|
||||||
|
<!-- ********* jcpp targets ******* --> |
||||||
|
|
||||||
|
<target name="check-jcpp" unless="perl.present"> |
||||||
|
<fail message="need perl to configure for JDK 1.1"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="run-jcpp" depends="check-packages,check-jcpp"> |
||||||
|
<apply dir="." executable="perl" parallel="true"> |
||||||
|
<arg file="${jcpp}"/> |
||||||
|
<arg value="-DJDK11"/> |
||||||
|
<arg value="-DCOLLECTIONS=${collections.package}"/> |
||||||
|
<arg value="-DCOLLECTIONEXTRA=${collections.package}"/> |
||||||
|
<arg value="-DJAVAX_SWING=${swing.package}"/> |
||||||
|
<fileset dir="${src}" includes="**/*.java"/> |
||||||
|
</apply> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="clean-jcpp" if="perl.present"> |
||||||
|
<apply dir="." executable="perl" parallel="true"> |
||||||
|
<arg file="${jcpp}"/> |
||||||
|
<arg value="-DJDK12"/> |
||||||
|
<arg value="-DCOLLECTIONS=java.util"/> |
||||||
|
<arg value="-DCOLLECTIONEXTRA=java.lang"/> |
||||||
|
<arg value="-DJAVAX_SWING=javax.swing"/> |
||||||
|
<fileset dir="${src}" includes="**/*.java"/> |
||||||
|
</apply> |
||||||
|
</target> |
||||||
|
|
||||||
|
<!-- ********* Check Environment ******* --> |
||||||
|
|
||||||
|
<target name="check-jdk" unless="jdk1.1.forced"> |
||||||
|
<available property="jdk1.2+" classname="java.lang.ThreadLocal" /> |
||||||
|
<available property="jdk1.3+" classname="java.lang.StrictMath" /> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="fail-getopt" unless="getopt.present"> |
||||||
|
<fail message="Package gnu.getopt not found!"/> |
||||||
|
</target> |
||||||
|
<target name="check-getopt"> |
||||||
|
<available property="getopt.present" |
||||||
|
classname="gnu.getopt.Getopt" |
||||||
|
classpathref="project.classpath" /> |
||||||
|
<antcall target="fail-getopt"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="check-packages"> |
||||||
|
<available property="collections.package" |
||||||
|
value="gnu.java.util.collections" |
||||||
|
classname="gnu.java.util.collections.Set" |
||||||
|
classpathref="project.classpath" /> |
||||||
|
<available property="collections.package" |
||||||
|
value="org.gnu.java.util.collections" |
||||||
|
classname="org.gnu.java.util.collections.Set" |
||||||
|
classpathref="project.classpath" /> |
||||||
|
<available property="collections.package" |
||||||
|
value="com.sun.java.util.collections" |
||||||
|
classname="com.sun.java.util.collections.Set" |
||||||
|
classpathref="project.classpath" /> |
||||||
|
<available property="swing.package" value="com.sun.java.swing" |
||||||
|
classname="com.sun.java.swing.JFrame" |
||||||
|
classpathref="project.classpath" /> |
||||||
|
<available property="swing.package" value="javax.swing" |
||||||
|
classname="javax.swing.JFrame" |
||||||
|
classpathref="project.classpath" /> |
||||||
|
</target> |
||||||
|
|
||||||
|
<!-- ********* Build targets ******* --> |
||||||
|
|
||||||
|
<target name="preconfig" depends="check-jdk,check-getopt,preconfig.11"/> |
||||||
|
<target name="preconfig.11" unless="jdk1.2+"> |
||||||
|
<antcall target="run-jcpp"/> |
||||||
|
</target> |
||||||
|
<target name="preconfig.12" if="jdk1.2+"> |
||||||
|
<antcall target="clean-jcpp"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="build-1.1"> |
||||||
|
<antcall target="build"> |
||||||
|
<param name="jdk1.1.forced" value="on"/> |
||||||
|
</antcall> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="build" depends="check-jdk,preconfig"> |
||||||
|
<mkdir dir="${build}"/> |
||||||
|
<javac srcdir="${src}" |
||||||
|
destdir="${build}" |
||||||
|
debug="true" |
||||||
|
classpathref="project.classpath" |
||||||
|
deprecation="on"> |
||||||
|
<exclude name="net/sf/jode/obfuscator/modules/RemovePopAnalyzer.java"/> |
||||||
|
<exclude name="net/sf/jode/obfuscator/modules/LocalOptimizer.java"/> |
||||||
|
<exclude name="net/sf/jode/obfuscator/modules/LocalizeFieldTransformer.java"/> |
||||||
|
<!-- |
||||||
|
<exclude name="net/sf/jode/bytecode/*Subroutine*" /> |
||||||
|
--> |
||||||
|
</javac> |
||||||
|
</target> |
||||||
|
|
||||||
|
<!-- clean the class files --> |
||||||
|
<target name="clean-build"> |
||||||
|
<delete dir="${build}"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<!-- ********* Create Release files ******* --> |
||||||
|
|
||||||
|
<target name="release" depends="release-bin,release-bin11,release-src,release-javadoc"/> |
||||||
|
|
||||||
|
<target name="release-bindist" depends="build"> |
||||||
|
<jar jarfile="${distdir}/jode.jar" compress="true" manifest="${basedir}/MANIFEST.MF"> |
||||||
|
<fileset dir="${build}" includes="**/*.class"/> |
||||||
|
<fileset dir="${props}" includes="**/*.properties"/> |
||||||
|
</jar> |
||||||
|
<copy todir="${distdir}"> |
||||||
|
<fileset dir="${lib}"> |
||||||
|
<include name="*getopt*.jar" /> |
||||||
|
<include name="*collection*.jar" unless="jdk1.2+" /> |
||||||
|
</fileset> |
||||||
|
<fileset dir="${basedir}" |
||||||
|
includes="AUTHORS,COPYING,NEWS,README,THANKS,TODO"> |
||||||
|
<include name="doc/*.html" /> |
||||||
|
<include name="doc/*.gif" /> |
||||||
|
<include name="doc/*.jos" /> |
||||||
|
<include name="doc/*.perl" /> |
||||||
|
</fileset> |
||||||
|
</copy> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="release-bin" depends="doc-html"> |
||||||
|
<antcall target="clean"/> |
||||||
|
<mkdir dir="${release}"/> |
||||||
|
<mkdir dir="${distdir}"/> |
||||||
|
<antcall target="release-bindist"/> |
||||||
|
<jar jarfile="${release}/jode-${version}.jar" |
||||||
|
basedir="${release}" includes="jode-${version}/**"/> |
||||||
|
<delete dir="${distdir}"/> |
||||||
|
<antcall target="clean"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="release-bin11" depends="doc-html"> |
||||||
|
<antcall target="clean"/> |
||||||
|
<mkdir dir="${release}"/> |
||||||
|
<mkdir dir="${distdir}"/> |
||||||
|
<antcall target="release-bindist"> |
||||||
|
<param name="jdk1.1.forced" value="on"/> |
||||||
|
</antcall> |
||||||
|
<jar jarfile="${release}/jode-${version}-JDK1.1.jar" |
||||||
|
basedir="${release}" includes="jode-${version}/**"/> |
||||||
|
<delete dir="${distdir}"/> |
||||||
|
<antcall target="clean"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="release-src" depends="doc-html"> |
||||||
|
<antcall target="clean"/> |
||||||
|
<mkdir dir="${release}"/> |
||||||
|
<mkdir dir="${distdir}"/> |
||||||
|
<copy todir="${distdir}"> |
||||||
|
<fileset dir="${basedir}" |
||||||
|
includes="AUTHORS,COPYING,INSTALL,NEWS,README,THANKS,TODO,ChangeLog"> |
||||||
|
<include name="build.xml,config.props,project*.dtd"/> |
||||||
|
<include name="doc/**"/> |
||||||
|
<include name="scripts/**"/> |
||||||
|
<include name="src/**"/> |
||||||
|
<include name="test/*.java"/> |
||||||
|
<include name="test/*.j"/> |
||||||
|
<include name="test/src/**"/> |
||||||
|
<include name="props/**"/> |
||||||
|
<include name="lib/**"/> |
||||||
|
</fileset> |
||||||
|
</copy> |
||||||
|
<jar jarfile="${release}/jode-${version}-src.jar" |
||||||
|
basedir="${release}" includes="jode-${version}/**"/> |
||||||
|
<delete dir="${distdir}"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="release-javadoc"> |
||||||
|
<antcall target="doc-javadoc"/> |
||||||
|
<mkdir dir="${release}"/> |
||||||
|
<jar jarfile="${release}/jode-${version}-API.jar" |
||||||
|
basedir="${doc}" includes="api/**"/> |
||||||
|
<antcall target="clean-doc"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="clean-release"> |
||||||
|
<delete dir="${release}"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<!-- ********* Javadoc targets ********** --> |
||||||
|
|
||||||
|
<target name="doc" depends="doc-javadoc,doc-html"/> |
||||||
|
|
||||||
|
<target name="doc-html" if="htp.present"> |
||||||
|
<apply executable="htp" dir="${doc}" dest="${doc}" parallel="false" relative="yes"> |
||||||
|
<arg value="-NODEPEND" /> |
||||||
|
<srcfile /> |
||||||
|
<targetfile /> |
||||||
|
<fileset dir="${doc}" includes="*.htp"/> |
||||||
|
<mapper type="glob" from="*.htp" to="*.html"/> |
||||||
|
</apply> |
||||||
|
</target> |
||||||
|
<target name="doc-javadoc"> |
||||||
|
<tstamp> |
||||||
|
<format property="date" pattern="MMM d, yyyy"/> |
||||||
|
</tstamp> |
||||||
|
<mkdir dir="${api.doc}"/> |
||||||
|
<javadoc packagenames="net.sf.jode.*" |
||||||
|
windowtitle="Jode ${version} API Specification" |
||||||
|
header='<b><a href="http://jode.sourceforge.net/">Jode</a> ${version}</b><br><font size="-2">Build ${date}</font>' |
||||||
|
overview="${src}/net/sf/jode/overview.html" |
||||||
|
bottom='Copyright &copy; 1998-2004 by Jochen Hoenicke.' |
||||||
|
sourcepath="${src}" |
||||||
|
destdir="${api.doc}" |
||||||
|
use="yes"> |
||||||
|
<link offline="${javadoc.offline}" |
||||||
|
href="${javadoc.href}" |
||||||
|
packagelistLoc="${javadoc.packagelistLoc}"/> |
||||||
|
</javadoc> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="clean-doc"> |
||||||
|
<delete dir="${api.doc}"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="clean-html"> |
||||||
|
<delete> |
||||||
|
<fileset dir="${doc}" includes="*.html"/> |
||||||
|
</delete> |
||||||
|
</target> |
||||||
|
|
||||||
|
<!-- ********* test targets ************* --> |
||||||
|
|
||||||
|
<target name="build-test" depends="build"> |
||||||
|
<mkdir dir="${test.build}"/> |
||||||
|
<javac srcdir="${test.src}" |
||||||
|
destdir="${test.build}" |
||||||
|
debug="true" |
||||||
|
classpathref="project.classpath" |
||||||
|
classpath="${build}" |
||||||
|
deprecation="on"> |
||||||
|
</javac> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="test" depends="build-test"> |
||||||
|
<mkdir dir="${test.log}"/> |
||||||
|
<junit printsummary="yes" fork="yes" haltonfailure="yes"> |
||||||
|
<classpath> |
||||||
|
<pathelement path="${test.build}"/> |
||||||
|
<pathelement path="${build}"/> |
||||||
|
<path refid="project.classpath"/> |
||||||
|
</classpath> |
||||||
|
<formatter type="plain" /> |
||||||
|
<batchtest fork="no" todir="${test.log}"> |
||||||
|
<fileset dir="${test.src}"> |
||||||
|
<include name="**/*.java"/> |
||||||
|
</fileset> |
||||||
|
</batchtest> |
||||||
|
</junit> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="test-cvs" depends="build-test"> |
||||||
|
<mkdir dir="${test.log}"/> |
||||||
|
<junit printsummary="yes" fork="yes" haltonfailure="yes"> |
||||||
|
<classpath> |
||||||
|
<pathelement path="${test.build}"/> |
||||||
|
<pathelement path="${build}"/> |
||||||
|
<fileset dir="lib" includes="*.jar"/> |
||||||
|
<fileset dir="/usr/local/ant/lib" includes="*.jar"/> |
||||||
|
</classpath> |
||||||
|
<formatter type="plain" /> |
||||||
|
<batchtest fork="no" todir="${test.log}"> |
||||||
|
<fileset dir="${test.src}"> |
||||||
|
<include name="**/*.java"/> |
||||||
|
</fileset> |
||||||
|
</batchtest> |
||||||
|
</junit> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="clean-test"> |
||||||
|
<delete dir="${test.build}"/> |
||||||
|
<delete dir="${test.log}"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<!-- ********* version targets ************* --> |
||||||
|
|
||||||
|
<target name="setversion" if="version"> |
||||||
|
<echo message="updating version in ${versionfile} ..."/> |
||||||
|
<exec executable="perl"> |
||||||
|
<arg value="-i"/> |
||||||
|
<arg value="-pe"/> |
||||||
|
<arg value='s/(String\s*version\s*=\s*")[^"]*/$1${version}/' /> |
||||||
|
<arg value="${versionfile}"/> |
||||||
|
</exec> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="commit" depends="setversion,test-cvs" if="version"> |
||||||
|
<antcall target="cvsclean"/> |
||||||
|
<echo message="---------------------------------------------------"/> |
||||||
|
<echo message=' Commiting new Jode version: ${version} !!!'/> |
||||||
|
<echo message="==================================================="/> |
||||||
|
<!-- |
||||||
|
search the old version information and replace it with the new version |
||||||
|
we will search the $(mainclass) for 'String VERSION = "..."' and |
||||||
|
replace the contents of the String with the new version. |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- commit the new $(VERSIONFILE) to the CVS |
||||||
|
<echo message="commiting updated file to CVS..."/> |
||||||
|
<cvs command='ci -m"new version ${version}" ${versionfile}'/> |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- commit the new $(VERSIONFILE) to the CVS |
||||||
|
<echo message="tagging files in CVS..."/> |
||||||
|
<property |
||||||
|
<cvs command="tag ${cvstag}"/> |
||||||
|
--> |
||||||
|
|
||||||
|
<echo message="...done!"/> |
||||||
|
<echo message="---------------------------------------------------"/> |
||||||
|
</target> |
||||||
|
</project> |
@ -0,0 +1,28 @@ |
|||||||
|
# Do you have online access for generating javadoc? |
||||||
|
# If not, where are your local files. |
||||||
|
javadoc.offline=false |
||||||
|
javadoc.packagelistLoc= |
||||||
|
javadoc.href=http://java.sun.com/products/jdk/1.2/docs/api/ |
||||||
|
#javadoc.href=file:/usr/doc/inet/java/jdk1.2/docs/api |
||||||
|
|
||||||
|
#javadoc.offline=true |
||||||
|
#javadoc.packagelistLoc=/usr/doc/inet/java/jdk1.2/docs/api |
||||||
|
|
||||||
|
# Is Perl installed on your system? |
||||||
|
# |
||||||
|
# perl is needed to reconfigure Jode for JDK-1.1. If you haven't |
||||||
|
# installed it you can only configure for JDK-1.2 and you should |
||||||
|
# comment out the next line. |
||||||
|
# |
||||||
|
# perl is also used for things that are relevant for the maintainer. |
||||||
|
# |
||||||
|
# Remove the next line if perl is not installed. |
||||||
|
perl.present=true |
||||||
|
|
||||||
|
# Is HTP installed on your system? |
||||||
|
# |
||||||
|
# htp is needed to generate html files from htp files. |
||||||
|
# see http://htp.sourceforge.net/ |
||||||
|
# |
||||||
|
# Remove the next line if either htp is not installed. |
||||||
|
htp.present=true |
@ -1,244 +0,0 @@ |
|||||||
dnl Process this file with autoconf to produce a configure script. |
|
||||||
AC_INIT() |
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE(jode, 1.1.2) |
|
||||||
|
|
||||||
dnl Checks for programs. |
|
||||||
AC_PROG_MAKE_SET |
|
||||||
AC_PATH_PROG(PERL, perl) |
|
||||||
AC_PATH_PROG(CYGPATH, cygpath) |
|
||||||
|
|
||||||
dnl Checks for libraries. |
|
||||||
|
|
||||||
dnl Checks for header files. |
|
||||||
|
|
||||||
dnl Checks for typedefs, structures, and compiler characteristics. |
|
||||||
|
|
||||||
dnl Checks for library functions. |
|
||||||
|
|
||||||
dnl hack to quote Makefile lines |
|
||||||
QUOTE="" |
|
||||||
AC_SUBST(QUOTE) |
|
||||||
|
|
||||||
AC_SUBST(SHELL) |
|
||||||
|
|
||||||
if test -n "$CYGPATH"; then |
|
||||||
# Extra check if java take windows path? |
|
||||||
CLASSPATH=`$CYGPATH --unix --path $CLASSPATH` |
|
||||||
SUBSTCP="$CYGPATH --windows --path" |
|
||||||
else |
|
||||||
SUBSTCP="echo" |
|
||||||
fi |
|
||||||
|
|
||||||
AC_SUBST(SUBSTCP) |
|
||||||
|
|
||||||
AC_ARG_WITH(java, |
|
||||||
[ --with-java specify path to a java-like program ], |
|
||||||
[ |
|
||||||
if test ${withval} != "" || test ${withval} != "yes" || test ${withval} != "no"; then |
|
||||||
# set javac to user input value |
|
||||||
JODE_CHECK_JAVA(${withval}) |
|
||||||
else |
|
||||||
JODE_CHECK_JAVA(/usr/lib/java) |
|
||||||
fi |
|
||||||
], |
|
||||||
[ |
|
||||||
JODE_CHECK_JAVA(/usr/lib/java) |
|
||||||
]) |
|
||||||
|
|
||||||
dnl jikes can also handle dependancies. |
|
||||||
AC_ARG_WITH(jikes, |
|
||||||
[ --with-jikes specify location of jikes ], |
|
||||||
[ |
|
||||||
USER_SPECIFIED_JIKES=true |
|
||||||
if test "${withval}" = "yes" || test "${withval}" = ""; then |
|
||||||
AC_PATH_PROG(JIKES, jikes, "", $PATH) |
|
||||||
else |
|
||||||
echo "searching jikes in ${withval}:$PATH" |
|
||||||
AC_PATH_PROG(JIKES, jikes, "", ${withval}:$PATH) |
|
||||||
fi |
|
||||||
if test -n "$JIKES"; then |
|
||||||
JAVAC=$JIKES |
|
||||||
fi |
|
||||||
], |
|
||||||
[ |
|
||||||
USER_SPECIFIED_JIKES= |
|
||||||
AC_PATH_PROG(JIKES, jikes, "", $PATH) |
|
||||||
]) |
|
||||||
AM_CONDITIONAL(HAVE_JIKES, test x"$JIKES" != x) |
|
||||||
|
|
||||||
AC_ARG_WITH(javac, |
|
||||||
[ --with-javac specify location of javac ], |
|
||||||
[ |
|
||||||
if test x$USER_SPECIFIED_JIKES = xtrue; then |
|
||||||
AC_MSG_ERROR(You must only give one option --with-javac or --with-jikes) |
|
||||||
fi |
|
||||||
if test ${withval} != "" || test ${withval} != "yes" || test ${withval} != "no"; then |
|
||||||
AC_CHECK_FILES(${withval}, |
|
||||||
[ JAVAC=${withval} ], |
|
||||||
[ AC_MSG_ERROR(${withval} does not exists) ]) |
|
||||||
fi |
|
||||||
], [ |
|
||||||
dnl use jikes as default, if javac option not given. |
|
||||||
if test -n "$JIKES"; then |
|
||||||
JAVAC=$JIKES |
|
||||||
fi |
|
||||||
]) |
|
||||||
|
|
||||||
AC_PATH_PROG(UNZIP, unzip) |
|
||||||
if test -n "$UNZIP"; then |
|
||||||
CLASS_CHECK () { |
|
||||||
$UNZIP -v -C `$SUBSTCP $1` $2 >/dev/null 2>&1 |
|
||||||
} |
|
||||||
else |
|
||||||
if test -n "$JAR"; then |
|
||||||
CLASS_CHECK () { |
|
||||||
$JAR -tf `$SUBSTCP $1` 2>&1 | grep $2 >/dev/null |
|
||||||
} |
|
||||||
else |
|
||||||
AC_MSG_ERROR(You need either unzip or jar.) |
|
||||||
fi |
|
||||||
fi |
|
||||||
|
|
||||||
AC_MSG_CHECKING(for java.lang.Object) |
|
||||||
JODE_CHECK_CLASS(java.lang.Object, $CLASSLIB, |
|
||||||
[ AC_MSG_RESULT(yes) ], |
|
||||||
[ AC_MSG_RESULT(no) |
|
||||||
AC_MSG_ERROR(Please specify location of core java class library) ]) |
|
||||||
|
|
||||||
AC_MSG_CHECKING(for java.lang.ref.WeakReference) |
|
||||||
JODE_CHECK_CLASS(java.lang.ref.WeakReference, $CLASSLIB, |
|
||||||
[ AC_MSG_RESULT(yes) |
|
||||||
JCPPFLAGS="-DJDK12" ], |
|
||||||
[ AC_MSG_RESULT(no) |
|
||||||
JCPPFLAGS="-DJDK11" ]) |
|
||||||
|
|
||||||
AC_MSG_CHECKING(for collection classes) |
|
||||||
JODE_CHECK_CLASS(java.util.Set, $CLASSPATH:$CLASSLIB, |
|
||||||
[ COLLECTIONS="java.util" |
|
||||||
COLLECTIONEXTRA="java.lang" ], |
|
||||||
[ JODE_CHECK_CLASS(gnu.java.util.collections.Set, $CLASSPATH:$CLASSLIB, |
|
||||||
[ COLLECTIONS="gnu.java.util.collections" |
|
||||||
COLLECTIONEXTRA="gnu.java.util.collections" ], |
|
||||||
[ JODE_CHECK_CLASS(com.sun.java.util.collections.Set, $CLASSPATH:$CLASSLIB, |
|
||||||
[ COLLECTIONS="com.sun.java.util.collections" |
|
||||||
COLLECTIONEXTRA="com.sun.java.util.collections" ], |
|
||||||
[ AC_MSG_RESULT(no) |
|
||||||
AC_MSG_ERROR(You need the Java 1.2 collection classes in your classpath) |
|
||||||
]) |
|
||||||
]) |
|
||||||
]) |
|
||||||
AC_MSG_RESULT($COLLECTIONS) |
|
||||||
AC_SUBST(COLLECTIONS) |
|
||||||
AC_SUBST(COLLECTIONEXTRA) |
|
||||||
|
|
||||||
AC_MSG_CHECKING(for gnu.getopt) |
|
||||||
JODE_CHECK_CLASS(gnu.getopt.Getopt, $CLASSPATH:$CLASSLIB, |
|
||||||
[ AC_MSG_RESULT(yes) ], |
|
||||||
[ AC_MSG_RESULT(no) |
|
||||||
AC_MSG_ERROR(You need gnu getopt for java.) ]) |
|
||||||
|
|
||||||
AC_MSG_CHECKING(for swing) |
|
||||||
JODE_CHECK_CLASS(javax.swing.JFrame, $CLASSPATH:$CLASSLIB, |
|
||||||
[ JAVAX_SWING="javax.swing" ], |
|
||||||
[ JODE_CHECK_CLASS(com.sun.java.swing.JFrame, $CLASSPATH:$CLASSLIB, |
|
||||||
[ JAVAX_SWING="com.sun.java.swing" ], |
|
||||||
[ JAVAX_SWING="no" ]) ] ) |
|
||||||
AC_MSG_RESULT($JAVAX_SWING) |
|
||||||
AC_SUBST(JAVAX_SWING) |
|
||||||
if test "$JAVAX_SWING" != "no"; then |
|
||||||
SWINGUI="swingui" |
|
||||||
else |
|
||||||
AC_MSG_WARN(Swing is not in classpath ... skipping swingui) |
|
||||||
SWINGUI="" |
|
||||||
fi |
|
||||||
AC_SUBST(SWINGUI) |
|
||||||
|
|
||||||
AC_SUBST(CLASSPATH) |
|
||||||
AC_SUBST(JAVAC) |
|
||||||
|
|
||||||
AC_OUTPUT(Makefile |
|
||||||
javaDependencies.pl |
|
||||||
jode/Makefile |
|
||||||
jode/bytecode/Makefile |
|
||||||
jode/decompiler/Makefile |
|
||||||
jode/expr/Makefile |
|
||||||
jode/flow/Makefile |
|
||||||
jode/jvm/Makefile |
|
||||||
jode/obfuscator/Makefile |
|
||||||
jode/obfuscator/modules/Makefile |
|
||||||
jode/swingui/Makefile |
|
||||||
jode/type/Makefile |
|
||||||
jode/util/Makefile |
|
||||||
jode/bytecode/BinaryInfo.java |
|
||||||
jode/bytecode/BytecodeInfo.java |
|
||||||
jode/bytecode/ClassInfo.java |
|
||||||
jode/bytecode/Reference.java |
|
||||||
jode/decompiler/ImportHandler.java |
|
||||||
jode/decompiler/ClassAnalyzer.java |
|
||||||
jode/decompiler/FieldAnalyzer.java |
|
||||||
jode/decompiler/MethodAnalyzer.java |
|
||||||
jode/decompiler/DeadCodeAnalysis.java |
|
||||||
jode/expr/Expression.java |
|
||||||
jode/expr/FieldOperator.java |
|
||||||
jode/expr/InvokeOperator.java |
|
||||||
jode/expr/LocalVarOperator.java |
|
||||||
jode/expr/Operator.java |
|
||||||
jode/expr/CheckNullOperator.java |
|
||||||
jode/flow/RetBlock.java |
|
||||||
jode/flow/InstructionContainer.java |
|
||||||
jode/flow/LoopBlock.java |
|
||||||
jode/flow/SequentialBlock.java |
|
||||||
jode/flow/SlotSet.java |
|
||||||
jode/flow/StructuredBlock.java |
|
||||||
jode/flow/SynchronizedBlock.java |
|
||||||
jode/flow/VariableSet.java |
|
||||||
jode/flow/CatchBlock.java |
|
||||||
jode/flow/IfThenElseBlock.java |
|
||||||
jode/flow/InstructionBlock.java |
|
||||||
jode/flow/FlowBlock.java |
|
||||||
jode/flow/TransformExceptionHandlers.java |
|
||||||
jode/jvm/CodeVerifier.java |
|
||||||
jode/jvm/Interpreter.java |
|
||||||
jode/jvm/SyntheticAnalyzer.java |
|
||||||
jode/obfuscator/ClassBundle.java |
|
||||||
jode/obfuscator/ClassIdentifier.java |
|
||||||
jode/obfuscator/ConstantRuntimeEnvironment.java |
|
||||||
jode/obfuscator/FieldIdentifier.java |
|
||||||
jode/obfuscator/Identifier.java |
|
||||||
jode/obfuscator/LocalIdentifier.java |
|
||||||
jode/obfuscator/Main.java |
|
||||||
jode/obfuscator/MethodIdentifier.java |
|
||||||
jode/obfuscator/OptionHandler.java |
|
||||||
jode/obfuscator/PackageIdentifier.java |
|
||||||
jode/obfuscator/Renamer.java |
|
||||||
jode/obfuscator/ScriptParser.java |
|
||||||
jode/obfuscator/TranslationTable.java |
|
||||||
jode/obfuscator/modules/ConstantAnalyzer.java |
|
||||||
jode/obfuscator/modules/KeywordRenamer.java |
|
||||||
jode/obfuscator/modules/LocalOptimizer.java |
|
||||||
jode/obfuscator/modules/LocalizeFieldTransformer.java |
|
||||||
jode/obfuscator/modules/ModifierMatcher.java |
|
||||||
jode/obfuscator/modules/MultiIdentifierMatcher.java |
|
||||||
jode/obfuscator/modules/NameSwapper.java |
|
||||||
jode/obfuscator/modules/RemovePopAnalyzer.java |
|
||||||
jode/obfuscator/modules/SerializePreserver.java |
|
||||||
jode/obfuscator/modules/SimpleAnalyzer.java |
|
||||||
jode/obfuscator/modules/StrongRenamer.java |
|
||||||
jode/obfuscator/modules/UniqueRenamer.java |
|
||||||
jode/obfuscator/modules/WildCard.java |
|
||||||
jode/swingui/Main.java |
|
||||||
jode/swingui/PackagesTreeModel.java |
|
||||||
jode/swingui/HierarchyTreeModel.java |
|
||||||
jode/type/Type.java |
|
||||||
jode/util/SimpleSet.java |
|
||||||
jode/util/SimpleMap.java |
|
||||||
jode/util/UnifyHash.java |
|
||||||
jode/GlobalOptions.java |
|
||||||
bin/Makefile |
|
||||||
bin/jode |
|
||||||
bin/jode.bat |
|
||||||
doc/Makefile |
|
||||||
test/Makefile, |
|
||||||
[chmod 755 javaDependencies.pl bin/jode], |
|
||||||
[$PERL $srcdir/jcpp $JCPPFLAGS \`ls \$CONFIG_FILES | grep '.java\$'\`]) |
|
@ -1,46 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
PHP_FILES = \
|
|
||||||
applet.php \ |
|
||||||
bluesky.php \ |
|
||||||
download.php \ |
|
||||||
faq.php \ |
|
||||||
feedback.php \ |
|
||||||
history.php \ |
|
||||||
index.php \ |
|
||||||
license.php \ |
|
||||||
links.php \ |
|
||||||
usage.php |
|
||||||
|
|
||||||
HTML_FILES = $(PHP_FILES:%.php=$(srcdir)/%.html)
|
|
||||||
# noinst_DATA = $(HTML_FILES)
|
|
||||||
|
|
||||||
EXTRA_DIST = $(PHP_FILES) $(notdir $(HTML_FILES)) \
|
|
||||||
header.inc \ |
|
||||||
menu.inc \ |
|
||||||
footer.inc \ |
|
||||||
a-logo.gif \ |
|
||||||
myproject.jos \ |
|
||||||
dasm_to_java.perl \ |
|
||||||
gimp/jode-logo.xcf \ |
|
||||||
jode-logo.gif |
|
||||||
|
|
||||||
.PHONY: public_html_symlink |
|
||||||
|
|
||||||
# The following rules require that you have an apache with php on
|
|
||||||
# localhost with standard user public_html directories and
|
|
||||||
# FollowSymLink enabled.
|
|
||||||
|
|
||||||
PUBLIC_HTML=$(HOME)/public_html
|
|
||||||
JODE_PHP_DIR=jode_php
|
|
||||||
|
|
||||||
public_html_symlink: |
|
||||||
rm -f $(PUBLIC_HTML)/$(JODE_PHP_DIR)
|
|
||||||
@RELDIR=`pwd | sed s!^$(HOME)!..!`; \
|
|
||||||
ln -sf $$RELDIR/$(srcdir) $(PUBLIC_HTML)/$(JODE_PHP_DIR); \
|
|
||||||
echo Created symlink to $$RELDIR/$(srcdir).
|
|
||||||
|
|
||||||
footer.inc: public_html_symlink |
|
||||||
|
|
||||||
$(srcdir)/%.html: %.php footer.inc header.inc menu.inc |
|
||||||
lynx -source http://localhost/~$(LOGNAME)/$(JODE_PHP_DIR)/$(notdir $<)?extension=html > $@
|
|
Before Width: | Height: | Size: 894 B |
@ -0,0 +1,25 @@ |
|||||||
|
<section title="The <i>JODE</i> Applet"> |
||||||
|
|
||||||
|
<p>Please be patience, loading the applet may take some time.</p> |
||||||
|
|
||||||
|
<center> |
||||||
|
<applet code="jode/Applet.class" archive="jode-applet.jar" width=540 height=400> |
||||||
|
<param name=pagecolor value="ffffff"> |
||||||
|
<param name=classpath value="http://jode.sourceforge.net/plasma.jar"> |
||||||
|
<param name=class value="PlasmaApplet"> |
||||||
|
<p>Sorry you need a java enabled browser to test a java applet ;-)</p> |
||||||
|
<p>Don't read the rest, it only contains information about the applet.</p> |
||||||
|
</applet> |
||||||
|
</center><br> |
||||||
|
|
||||||
|
<p> Press the start button to decompile <a |
||||||
|
href="http://www.informatik.uni-oldenburg.de/~mw/plasma.html">Michael's |
||||||
|
Plasma applet</a> (and give the decompiler some time to download the |
||||||
|
jar file). </p> |
||||||
|
|
||||||
|
<p>You may change the classpath to point to a zip or jar file of your |
||||||
|
choice. Unfortunately, your browser will most likely forbid URL's that |
||||||
|
aren't located on jode.sourceforge.net. |
||||||
|
Save probably doesn't work, because it is forbidden by your browser.</p> |
||||||
|
|
||||||
|
</section> |
@ -1,38 +0,0 @@ |
|||||||
<?php require("header.inc"); ?> |
|
||||||
<h1>The <i>JODE</i> Applet</h1> |
|
||||||
|
|
||||||
<p>Please be patience, loading the applet may take some time.</p> |
|
||||||
|
|
||||||
<center> |
|
||||||
<applet code="jode/Applet.class" archive="jode-applet.jar" width=540 height=400> |
|
||||||
<param name=pagecolor value="ffffff"> |
|
||||||
<param name=classpath value="http://jode.sourceforge.net/http/www.informatik.uni-oldenburg.de/~mw/plasma.jar"> |
|
||||||
<param name=class value="PlasmaApplet"> |
|
||||||
<p>Sorry you need a java enabled browser to test a java applet ;-)</p> |
|
||||||
<p>Don't read the rest, it only contains information about the applet.</p> |
|
||||||
</applet> |
|
||||||
</center><br> |
|
||||||
|
|
||||||
<p> Press the start button to decompile <a |
|
||||||
href="http://www.informatik.uni-oldenburg.de/~mw/plasma.html">Michael's |
|
||||||
Plasma applet</a> (and give the decompiler some time to download the |
|
||||||
jar file). </p> |
|
||||||
|
|
||||||
You may change the classpath to point to a zip or jar file of your |
|
||||||
choice, using a similar syntax. Only http and ftp addresses are supported. |
|
||||||
The file must be available from the world wide web. In fact you download it |
|
||||||
from Sourceforge and Sourceforge gets it from the given address. This hack |
|
||||||
is necessary, because Java's security policy doesn't allow applets to contact |
|
||||||
a different server. You can also point the classpath to a directory containing |
|
||||||
the class-files (include a slash `/' at the end in this case), but |
|
||||||
this is not recommended, since it is <i>very</i> slow. You may give |
|
||||||
multiple entries in the class path field separated by a comma.<br><br> |
|
||||||
|
|
||||||
You can't use this applet for local files. You can try to give |
|
||||||
local filenames directly without going through Sourceforge, but that is |
|
||||||
probably forbidden by your browser. Most browser only allow loading |
|
||||||
files from the same server as the applet, and this is the reason why |
|
||||||
you have to use such a weird URL.<br><br> |
|
||||||
|
|
||||||
Save probably doesn't work, because it is forbidden by your browser.<br><br> |
|
||||||
<?php require("footer.inc"); ?> |
|
@ -0,0 +1,39 @@ |
|||||||
|
<section title="Download"> |
||||||
|
|
||||||
|
<p>Jode is available in the <sflink |
||||||
|
href="project/showfiles.php">download area</a> in source or binary |
||||||
|
form. For compiling the source code, you need several other packages, |
||||||
|
check the <a href="links.html">links page</a>. You need a unix like |
||||||
|
environment for compilation.</p> |
||||||
|
|
||||||
|
<p>The simplest way to get it, especially for non unix users, is in |
||||||
|
precompiled form, though. There are two jar archives in the download |
||||||
|
area:</P> |
||||||
|
|
||||||
|
<ul> <li>jode-1.1-JDK1.1.jar is for JDK 1.1. If you want to use |
||||||
|
the swing interface, you have to download swing separately, all other |
||||||
|
packages are already included in the archive. </li> |
||||||
|
|
||||||
|
<li>jode-1.1.jar is for JDK 1.2 or better. It should run |
||||||
|
without any other package.</li> </ul> |
||||||
|
</section> |
||||||
|
|
||||||
|
<section title="Subversion Repository"> |
||||||
|
|
||||||
|
<p>You can get the latest sources from the <a |
||||||
|
href="http://sourceforge.net/svn/?group_id=3790">SVN repository</a>. |
||||||
|
Follow the instruction on that page; use |
||||||
|
<code>/svnroot/jode/trunk/jode</code> as last part of the URL. If you |
||||||
|
want to checkout a specific version you can checkout the URL |
||||||
|
<code>.../svnroot/jode/tags/xxx/jode</code>:</p> |
||||||
|
|
||||||
|
<ul> |
||||||
|
<li><code>../jode/tags/jode_1_0_93/jode</code>: checks out the version 1.0.93</li> |
||||||
|
<li><code>../jode/branches/branch_1_1/jode</code>: checks out the latest version in the |
||||||
|
1.1 series.</li> </ul> |
||||||
|
|
||||||
|
<p>To build the sources from latest SVN change to the main directory and invoke ant.</p> |
||||||
|
<p>To build the 1.1 versions of jode change to the main directory and run |
||||||
|
<pre>aclocal && automake -a && autoconf</pre> |
||||||
|
<p>Afterwards follow the instruction in the INSTALL file. </p> |
||||||
|
</section> |
@ -1,40 +0,0 @@ |
|||||||
<?php require("header.inc"); ?> |
|
||||||
<h1>Download</h1> |
|
||||||
|
|
||||||
<p>Jode is available in the <? |
|
||||||
sflink("project/showfiles.php")?>download area</a> in source or |
|
||||||
binary form. For compiling the source code, you need several other |
|
||||||
packages, check the <?php selflink("links") ?>links page</a>. You
|
|
||||||
need a unix like environment for compilation.</p> |
|
||||||
|
|
||||||
<p>The simplest way to get it, especially for non unix users, is in |
|
||||||
precompiled form, though. There are two jar archives in the download |
|
||||||
area:</P> |
|
||||||
|
|
||||||
<ul> <li>jode-1.1-JDK1.1.jar is for JDK 1.1. If you want to use |
|
||||||
the swing interface, you have to download swing separately, all other |
|
||||||
packages are already included in the archive. </li> |
|
||||||
|
|
||||||
<li>jode-1.1.jar is for JDK 1.2 or better. It should run |
|
||||||
without any other package.</li> </ul> </p> |
|
||||||
|
|
||||||
<h1>CVS Repository</h1> |
|
||||||
|
|
||||||
<p>You can get the latest sources from the <?php sflink("cvs/") ?> CVS
|
|
||||||
repository</a>. Follow the instruction on that page; use |
|
||||||
<code>jode</code> as <i>modulename</i>. If you want to checkout a |
|
||||||
specific version you can use the <code>-r</code> option:</p> |
|
||||||
|
|
||||||
<ul> |
|
||||||
<li><code>-r jode_1_0_93</code>: checks out the version 1.0.93</li> |
|
||||||
<li><code>-r branch_1_1</code>: checks out the latest version in the |
|
||||||
1.1 series.</li> </ul> |
|
||||||
|
|
||||||
<p>To build the sources from CVS change to the main directory where |
|
||||||
the <code>configure.in</code> file resides and run |
|
||||||
|
|
||||||
<pre>aclocal && automake -a && autoconf</pre> |
|
||||||
|
|
||||||
Afterwards follow the instruction in the INSTALL file. </p> |
|
||||||
<?php require("footer.inc"); ?> |
|
||||||
|
|
@ -0,0 +1,106 @@ |
|||||||
|
/* XPM */ |
||||||
|
static char * favicon_xpm[] = { |
||||||
|
"16 16 87 1", |
||||||
|
" c None", |
||||||
|
". c #C2C2C2", |
||||||
|
"+ c #A1A1A1", |
||||||
|
"@ c #BBBBBB", |
||||||
|
"# c #D9D9D9", |
||||||
|
"$ c #BABABA", |
||||||
|
"% c #C1C1C1", |
||||||
|
"& c #ECECEC", |
||||||
|
"* c #A7A7A7", |
||||||
|
"= c #636363", |
||||||
|
"- c #989898", |
||||||
|
"; c #C3C3C3", |
||||||
|
"> c #C5C5C5", |
||||||
|
", c #A6A6A6", |
||||||
|
"' c #747474", |
||||||
|
") c #646464", |
||||||
|
"! c #6D6D6D", |
||||||
|
"~ c #8C8C8C", |
||||||
|
"{ c #ABABAB", |
||||||
|
"] c #A5A5A5", |
||||||
|
"^ c #787878", |
||||||
|
"/ c #A8A8A8", |
||||||
|
"( c #606060", |
||||||
|
"_ c #FFFFFF", |
||||||
|
": c #626262", |
||||||
|
"< c #7A7A7A", |
||||||
|
"[ c #FEFEFE", |
||||||
|
"} c #949494", |
||||||
|
"| c #535353", |
||||||
|
"1 c #919191", |
||||||
|
"2 c #F0F0F0", |
||||||
|
"3 c #5B5B5B", |
||||||
|
"4 c #B3B3B3", |
||||||
|
"5 c #5A5A5A", |
||||||
|
"6 c #3E3E3E", |
||||||
|
"7 c #4C4C4C", |
||||||
|
"8 c #666666", |
||||||
|
"9 c #616161", |
||||||
|
"0 c #939393", |
||||||
|
"a c #F8F8F8", |
||||||
|
"b c #1C1C1C", |
||||||
|
"c c #999999", |
||||||
|
"d c #DFDFDF", |
||||||
|
"e c #0D0D0D", |
||||||
|
"f c #B1B1B1", |
||||||
|
"g c #343434", |
||||||
|
"h c #5D5D5D", |
||||||
|
"i c #676767", |
||||||
|
"j c #6F6F6F", |
||||||
|
"k c #9E9E9E", |
||||||
|
"l c #4F4F4F", |
||||||
|
"m c #F7F7F7", |
||||||
|
"n c #1B1B1B", |
||||||
|
"o c #E7E7E7", |
||||||
|
"p c #1D1D1D", |
||||||
|
"q c #7C7C7C", |
||||||
|
"r c #9B9B9B", |
||||||
|
"s c #525252", |
||||||
|
"t c #EFEFEF", |
||||||
|
"u c #9C9C9C", |
||||||
|
"v c #434343", |
||||||
|
"w c #414141", |
||||||
|
"x c #3D3D3D", |
||||||
|
"y c #3F3F3F", |
||||||
|
"z c #BFBFBF", |
||||||
|
"A c #3A3A3A", |
||||||
|
"B c #686868", |
||||||
|
"C c #6B6B6B", |
||||||
|
"D c #C4C4C4", |
||||||
|
"E c #F4F4F4", |
||||||
|
"F c #FAFAFA", |
||||||
|
"G c #D7D7D7", |
||||||
|
"H c #AFAFAF", |
||||||
|
"I c #828282", |
||||||
|
"J c #737373", |
||||||
|
"K c #818181", |
||||||
|
"L c #DEDEDE", |
||||||
|
"M c #E9E9E9", |
||||||
|
"N c #696969", |
||||||
|
"O c #9F9F9F", |
||||||
|
"P c #A2A2A2", |
||||||
|
"Q c #717171", |
||||||
|
"R c #B4B4B4", |
||||||
|
"S c #E8E8E8", |
||||||
|
"T c #898989", |
||||||
|
"U c #767676", |
||||||
|
"V c #DBDBDB", |
||||||
|
" ", |
||||||
|
" ", |
||||||
|
" ", |
||||||
|
" ", |
||||||
|
" .++@ #$%& ", |
||||||
|
"*=-;>,')!~{]^)/ ", |
||||||
|
"(_:<[}|123:42567", |
||||||
|
"8_,90=abc|defg*h", |
||||||
|
"i_jklfmnj1opq(r=", |
||||||
|
"9sgtugvuwxyzwAB:", |
||||||
|
"}CDEFGHIJK{L[MNO", |
||||||
|
" #PQCKRd S@TiUV ", |
||||||
|
" ", |
||||||
|
" ", |
||||||
|
" ", |
||||||
|
" "}; |
Binary file not shown.
@ -0,0 +1,52 @@ |
|||||||
|
<opt quiet> |
||||||
|
<file template="jode.htt"> |
||||||
|
<set version="1.1"> |
||||||
|
<set sfgroup="3790"> |
||||||
|
<def name="sflink" option="href"> |
||||||
|
<a href="http://sourceforge.net/${href}?group_id=${sfgroup}"> |
||||||
|
</def> |
||||||
|
<def name="entry" option="name type href"> |
||||||
|
<if type="sflink"> |
||||||
|
<sflink href="$href"><use name></a> |
||||||
|
<else> |
||||||
|
<if _htpfile_out="${href}.html"> |
||||||
|
<use name> |
||||||
|
<elseif $href="index"> |
||||||
|
<a href="."><use name></a> |
||||||
|
<else> |
||||||
|
<a href="${href}.html"><use name></a> |
||||||
|
</if> |
||||||
|
</if> |
||||||
|
</def> |
||||||
|
|
||||||
|
<block name=menu> |
||||||
|
<entry name="<B>Home</B>" href="index"> |
||||||
|
<entry type=sflink name="Project page" href="project/"> |
||||||
|
<entry name="Applet" href="applet"> |
||||||
|
<entry name="Download" href="download"> |
||||||
|
<entry name="FAQ" href="faq"> |
||||||
|
<entry name="Feedback" href="feedback"> |
||||||
|
<entry name="Documentation" href="usage"> |
||||||
|
<entry name="License" href="license"> |
||||||
|
<entry name="History" href="history"> |
||||||
|
<entry name="Links" href="links"> |
||||||
|
<entry name="Blue Sky" href="bluesky"> |
||||||
|
</block> |
||||||
|
|
||||||
|
<blockdef name=section option="title"> |
||||||
|
<if not sect_ctr><set sect_ctr="0" global></if> |
||||||
|
<inc sect_ctr global> |
||||||
|
<set title${sect_ctr}="$title" global> |
||||||
|
<block name=section${sect_ctr} global expand> |
||||||
|
<use block noexpand> |
||||||
|
</block> |
||||||
|
</blockdef> |
||||||
|
|
||||||
|
<block name=everything> |
||||||
|
<set i=1> |
||||||
|
<while section$i> |
||||||
|
<h1><use title$i></h1> |
||||||
|
<use section$i> |
||||||
|
<inc i> |
||||||
|
</while> |
||||||
|
</block> |
Before Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
@ -0,0 +1,67 @@ |
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<title>Java Optimize and Decompile Environment (JODE)</title> |
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
||||||
|
<meta name="date" content="2001-05-29"> |
||||||
|
<meta name="description" content="JODE - Java Optimize and Decompile Environment."> |
||||||
|
<meta name="author" content="Jochen Hoenicke"> |
||||||
|
<meta name="keywords" content="jode, java, decompiler, obfuscator, deobfuscator, reverse engineering, free, GPL"> |
||||||
|
<style type="text/css"> |
||||||
|
<!-- |
||||||
|
body { color:#000000; background-color: #FFFFFF; } |
||||||
|
.nav { font-family: Helvetica, Arial, sans-serif; font-weight: bold; |
||||||
|
color:#000000; background-color: #EEEEF8; } |
||||||
|
.footer { color:#FFFFFF; background-color: #737B9C; } |
||||||
|
.boldlink { font-weight:bold; text-decoration: none; color:#FFFFFF; } |
||||||
|
//--> |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
|
||||||
|
<body text="#000000" bgcolor="#FFFFFF"> |
||||||
|
|
||||||
|
<table cellpadding=4 cellspacing=1 width="100%" |
||||||
|
><tr |
||||||
|
><td align="left" |
||||||
|
><img src="jode-logo.png" alt="JODE" |
||||||
|
></td |
||||||
|
><td align="right" |
||||||
|
>Powered by <a href="http://sourceforge.net"><img |
||||||
|
src="http://sourceforge.net/sflogo.php?group_id=3790&type=1" |
||||||
|
border=0 width=88 height=31 alt="SourceForge"></a><br |
||||||
|
>HTML coding <a href="http://htp.sourceforge.net"><img |
||||||
|
src="poweredbyhtp.png" border=0 alt="Powered by htp"></a><br |
||||||
|
>Best viewed with <a |
||||||
|
href="http://www.anybrowser.org/campaign/"><img |
||||||
|
src="w3c_ab.png" border=0 alt="Any Browser"></a><br |
||||||
|
></td |
||||||
|
></tr |
||||||
|
></table> |
||||||
|
|
||||||
|
<table cellspacing=0 cellpadding=3 border=0 bgcolor="#EEEEF8" class="nav"> |
||||||
|
<tr><td class="nav"> |
||||||
|
<use menu> |
||||||
|
</td></tr> |
||||||
|
</table><br> |
||||||
|
|
||||||
|
<use everything> |
||||||
|
|
||||||
|
<if _htpfile_out="index.html"> |
||||||
|
<set pageref=""> |
||||||
|
<else> |
||||||
|
<set pageref="$_htpfile_out"> |
||||||
|
</if> |
||||||
|
|
||||||
|
<TABLE class=footer width="100%" border="0" cellspacing="0" cellpadding="2"> |
||||||
|
<TR> |
||||||
|
<TD align="center"><SPAN class=footer> |
||||||
|
All trademarks and copyrights on this page are properties of their respective owners. <br> |
||||||
|
Last updated on <file date>, |
||||||
|
Copyright © 1998-2004 by Jochen Hoenicke. |
||||||
|
Canonic URL is <a class=boldlink href="http://jode.sourceforge.net/$pageref">http://jode.sourceforge.net/<use pageref></a></SPAN> |
||||||
|
</TD> |
||||||
|
</TR> |
||||||
|
</TABLE> |
||||||
|
|
||||||
|
</BODY> |
||||||
|
</HTML> |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.0 KiB |
@ -1,4 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
||||||
.java.deps |
|
||||||
jode.jar |
|
@ -1,29 +0,0 @@ |
|||||||
/* AssertError Copyright (C) 1998-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode; |
|
||||||
|
|
||||||
public class AssertError extends Error { |
|
||||||
public AssertError() { |
|
||||||
} |
|
||||||
|
|
||||||
public AssertError(String detail) { |
|
||||||
super(detail); |
|
||||||
} |
|
||||||
} |
|
@ -1,41 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
SUBDIRS = util bytecode type jvm expr flow decompiler obfuscator @SWINGUI@
|
|
||||||
|
|
||||||
JAR = @JAR@
|
|
||||||
JAVAC = @JAVAC@
|
|
||||||
JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\
|
|
||||||
-dependdir=$(top_builddir) -classpath=$(top_builddir):$(top_srcdir) \
|
|
||||||
-depfile=Makefile.dep
|
|
||||||
CLASSPATH = @CLASSPATH@
|
|
||||||
CLASSLIB = @CLASSLIB@
|
|
||||||
SUBSTCP = @SUBSTCP@
|
|
||||||
FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB))
|
|
||||||
|
|
||||||
MY_JAVA_FILES = \
|
|
||||||
AssertError.java \
|
|
||||||
GlobalOptions.java
|
|
||||||
|
|
||||||
noinst_DATA = $(MY_JAVA_FILES:.java=.class)
|
|
||||||
EXTRA_DIST = $(MY_JAVA_FILES)
|
|
||||||
|
|
||||||
|
|
||||||
JARFILE = jode-@VERSION@.jar
|
|
||||||
#data_DATA = $(JARFILE)
|
|
||||||
|
|
||||||
@QUOTE@-include Makefile.dep |
|
||||||
|
|
||||||
%.class: %.java |
|
||||||
$(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $<
|
|
||||||
|
|
||||||
Makefile.dep: $(MY_JAVA_FILES:.java=.class) |
|
||||||
$(JAVADEP) $^
|
|
||||||
|
|
||||||
clean-local: |
|
||||||
@rm -f *.class
|
|
||||||
@rm -f *.dep
|
|
||||||
|
|
||||||
$(JARFILE): $(noinst_DATA) |
|
||||||
CLASSPATH=$(top_builddir):$(CLASSPATH) $(JAVA) -mx80m \
|
|
||||||
jode.obfuscator.Main --classpath=$(top_builddir) \
|
|
||||||
--dest=$(JARFILE) -v -v $(srcdir)/jode.jodescript
|
|
@ -1,2 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
@ -1,229 +0,0 @@ |
|||||||
/* BinaryInfo Copyright (C) 1998-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.bytecode; |
|
||||||
import java.io.DataInputStream; |
|
||||||
import java.io.DataOutputStream; |
|
||||||
import java.io.EOFException; |
|
||||||
import java.io.FilterInputStream; |
|
||||||
import java.io.IOException; |
|
||||||
import java.io.InputStream; |
|
||||||
import jode.util.SimpleMap; |
|
||||||
|
|
||||||
import @COLLECTIONS@.Map; |
|
||||||
import @COLLECTIONS@.Collections; |
|
||||||
import @COLLECTIONS@.Iterator; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author Jochen Hoenicke |
|
||||||
*/ |
|
||||||
public class BinaryInfo { |
|
||||||
public static final int HIERARCHY = 0x01; |
|
||||||
public static final int FIELDS = 0x02; |
|
||||||
public static final int METHODS = 0x04; |
|
||||||
public static final int CONSTANTS = 0x08; |
|
||||||
public static final int KNOWNATTRIBS = 0x10; |
|
||||||
public static final int INNERCLASSES = 0x20; |
|
||||||
public static final int OUTERCLASSES = 0x40; |
|
||||||
public static final int UNKNOWNATTRIBS = 0x80; |
|
||||||
public static final int FULLINFO = 0xff; |
|
||||||
public static final int MOSTINFO = 0x7f; |
|
||||||
public static final int REFLECTINFO = 0x6f; |
|
||||||
|
|
||||||
private Map unknownAttributes = null; |
|
||||||
|
|
||||||
protected void skipAttributes(DataInputStream input) throws IOException { |
|
||||||
int count = input.readUnsignedShort(); |
|
||||||
for (int i=0; i< count; i++) { |
|
||||||
input.readUnsignedShort(); // the name index
|
|
||||||
long length = input.readInt(); |
|
||||||
while (length > 0) { |
|
||||||
long skipped = input.skip(length); |
|
||||||
if (skipped == 0) |
|
||||||
throw new EOFException("Can't skip. EOF?"); |
|
||||||
length -= skipped; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected int getKnownAttributeCount() { |
|
||||||
return 0; |
|
||||||
} |
|
||||||
|
|
||||||
protected void readAttribute(String name, int length, |
|
||||||
ConstantPool constantPool, |
|
||||||
DataInputStream input, |
|
||||||
int howMuch) throws IOException { |
|
||||||
byte[] data = new byte[length]; |
|
||||||
input.readFully(data); |
|
||||||
if ((howMuch & UNKNOWNATTRIBS) != 0) { |
|
||||||
if (unknownAttributes == null) |
|
||||||
unknownAttributes = new SimpleMap(); |
|
||||||
unknownAttributes.put(name, data); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static class ConstrainedInputStream extends FilterInputStream { |
|
||||||
int length; |
|
||||||
|
|
||||||
public ConstrainedInputStream(int attrLength, InputStream input) { |
|
||||||
super(input); |
|
||||||
length = attrLength; |
|
||||||
} |
|
||||||
|
|
||||||
public int read() throws IOException { |
|
||||||
if (length > 0) { |
|
||||||
int data = super.read(); |
|
||||||
length--; |
|
||||||
return data; |
|
||||||
} |
|
||||||
throw new EOFException(); |
|
||||||
} |
|
||||||
|
|
||||||
public int read(byte[] b, int off, int len) throws IOException { |
|
||||||
if (length < len) { |
|
||||||
len = length; |
|
||||||
} |
|
||||||
if (len == 0) |
|
||||||
return -1; |
|
||||||
int count = super.read(b, off, len); |
|
||||||
length -= count; |
|
||||||
return count; |
|
||||||
} |
|
||||||
|
|
||||||
public int read(byte[] b) throws IOException { |
|
||||||
return read(b, 0, b.length); |
|
||||||
} |
|
||||||
|
|
||||||
public long skip(long count) throws IOException { |
|
||||||
if (length < count) { |
|
||||||
count = length; |
|
||||||
} |
|
||||||
count = super.skip(count); |
|
||||||
length -= (int) count; |
|
||||||
return count; |
|
||||||
} |
|
||||||
|
|
||||||
public void skipRemaining() throws IOException { |
|
||||||
while (length > 0) { |
|
||||||
int skipped = (int) skip(length); |
|
||||||
if (skipped == 0) |
|
||||||
throw new EOFException(); |
|
||||||
length -= skipped; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected void readAttributes(ConstantPool constantPool, |
|
||||||
DataInputStream input, |
|
||||||
int howMuch) throws IOException { |
|
||||||
int count = input.readUnsignedShort(); |
|
||||||
unknownAttributes = null; |
|
||||||
for (int i=0; i< count; i++) { |
|
||||||
String attrName = |
|
||||||
constantPool.getUTF8(input.readUnsignedShort()); |
|
||||||
final int attrLength = input.readInt(); |
|
||||||
ConstrainedInputStream constrInput = |
|
||||||
new ConstrainedInputStream(attrLength, input); |
|
||||||
readAttribute(attrName, attrLength, |
|
||||||
constantPool, new DataInputStream(constrInput), |
|
||||||
howMuch); |
|
||||||
constrInput.skipRemaining(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void dropInfo(int howMuch) { |
|
||||||
if ((howMuch & UNKNOWNATTRIBS) != 0) |
|
||||||
unknownAttributes = null; |
|
||||||
} |
|
||||||
|
|
||||||
protected void prepareAttributes(GrowableConstantPool gcp) { |
|
||||||
if (unknownAttributes == null) |
|
||||||
return; |
|
||||||
Iterator i = unknownAttributes.keySet().iterator(); |
|
||||||
while (i.hasNext()) |
|
||||||
gcp.putUTF8((String) i.next()); |
|
||||||
} |
|
||||||
|
|
||||||
protected void writeKnownAttributes |
|
||||||
(GrowableConstantPool constantPool, |
|
||||||
DataOutputStream output) throws IOException { |
|
||||||
} |
|
||||||
|
|
||||||
protected void writeAttributes |
|
||||||
(GrowableConstantPool constantPool, |
|
||||||
DataOutputStream output) throws IOException { |
|
||||||
int count = getKnownAttributeCount(); |
|
||||||
if (unknownAttributes != null) |
|
||||||
count += unknownAttributes.size(); |
|
||||||
output.writeShort(count); |
|
||||||
writeKnownAttributes(constantPool, output); |
|
||||||
if (unknownAttributes != null) { |
|
||||||
Iterator i = unknownAttributes.entrySet().iterator(); |
|
||||||
while (i.hasNext()) { |
|
||||||
Map.Entry e = (Map.Entry) i.next(); |
|
||||||
String name = (String) e.getKey(); |
|
||||||
byte[] data = (byte[]) e.getValue(); |
|
||||||
output.writeShort(constantPool.putUTF8(name)); |
|
||||||
output.writeInt(data.length); |
|
||||||
output.write(data); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public int getAttributeSize() { |
|
||||||
int size = 2; /* attribute count */ |
|
||||||
if (unknownAttributes != null) { |
|
||||||
Iterator i = unknownAttributes.values().iterator(); |
|
||||||
while (i.hasNext()) |
|
||||||
size += 2 + 4 + ((byte[]) i.next()).length; |
|
||||||
} |
|
||||||
return size; |
|
||||||
} |
|
||||||
|
|
||||||
public byte[] findAttribute(String name) { |
|
||||||
if (unknownAttributes != null) |
|
||||||
return (byte[]) unknownAttributes.get(name); |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public Iterator getAttributes() { |
|
||||||
if (unknownAttributes != null) |
|
||||||
return unknownAttributes.values().iterator(); |
|
||||||
return Collections.EMPTY_SET.iterator(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setAttribute(String name, byte[] content) { |
|
||||||
if (unknownAttributes == null) |
|
||||||
unknownAttributes = new SimpleMap(); |
|
||||||
unknownAttributes.put(name, content); |
|
||||||
} |
|
||||||
|
|
||||||
public byte[] removeAttribute(String name) { |
|
||||||
if (unknownAttributes != null) |
|
||||||
return (byte[]) unknownAttributes.remove(name); |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public void removeAllAttributes() { |
|
||||||
unknownAttributes = null; |
|
||||||
} |
|
||||||
} |
|
File diff suppressed because it is too large
Load Diff
@ -1,903 +0,0 @@ |
|||||||
/* ClassInfo Copyright (C) 1998-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.bytecode; |
|
||||||
import jode.GlobalOptions; |
|
||||||
import jode.util.UnifyHash; |
|
||||||
|
|
||||||
import java.io.DataInputStream; |
|
||||||
import java.io.BufferedInputStream; |
|
||||||
import java.io.DataOutputStream; |
|
||||||
import java.io.IOException; |
|
||||||
import java.util.Enumeration; |
|
||||||
import @COLLECTIONS@.Iterator; |
|
||||||
|
|
||||||
import java.lang.reflect.Constructor; |
|
||||||
import java.lang.reflect.Field; |
|
||||||
import java.lang.reflect.Method; |
|
||||||
import java.lang.reflect.Modifier; |
|
||||||
|
|
||||||
/** |
|
||||||
* This class does represent a class similar to java.lang.Class. You |
|
||||||
* can get the super class and the interfaces. <br> |
|
||||||
* |
|
||||||
* The main difference to java.lang.Class is, that the objects are builded |
|
||||||
* from a stream containing the .class file, and that it uses the |
|
||||||
* <code>Type</code> to represent types instead of Class itself. <br> |
|
||||||
* |
|
||||||
* <h2>The InnerClasses attribute</h2> |
|
||||||
* |
|
||||||
* The InnerClasses attribute is transformed in a special way by this |
|
||||||
* class so we want to taker a closer look. According to the <a |
|
||||||
* href="http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814">inner |
|
||||||
* class specification</a> there must be an InnerClass attribute for |
|
||||||
* every non top-level class that is referenced somewhere in the |
|
||||||
* bytecode. This implies that if this is an inner class, it must |
|
||||||
* contain a inner class attribute for itself. Before a class is |
|
||||||
* referenced as outer class in an InnerClass attribute, it must be |
|
||||||
* described by another InnerClass attribute. <br> |
|
||||||
* |
|
||||||
* Since every class references itself, there must be informations |
|
||||||
* about the outer class for each class scoped class. If that outer |
|
||||||
* class is an outer class again, there must be information about it, |
|
||||||
* too. This particular chain of InnerClassInfos is returned by the |
|
||||||
* getOuterClasses() method; for convenience in reverse order, i.e. |
|
||||||
* current class first, then the outer classes from innermost to |
|
||||||
* outermost. <br> |
|
||||||
* |
|
||||||
* A valid bytecode must also contain InnerClass infos for each inner |
|
||||||
* classes it declares. These information are returned by the |
|
||||||
* getInnerClasses() method. The order of these classes is the same |
|
||||||
* as in the bytecode attribute. |
|
||||||
* |
|
||||||
* All remaining attributes are returned by getExtraClasses() in the |
|
||||||
* same order as in the bytecode attribute. |
|
||||||
* |
|
||||||
* @author Jochen Hoenicke |
|
||||||
*/ |
|
||||||
public class ClassInfo extends BinaryInfo { |
|
||||||
|
|
||||||
private static SearchPath classpath; |
|
||||||
|
|
||||||
private static final UnifyHash classes = new UnifyHash(); |
|
||||||
|
|
||||||
private int status = 0; |
|
||||||
|
|
||||||
private boolean modified = false; |
|
||||||
|
|
||||||
private int modifiers = -1; |
|
||||||
private boolean deprecatedFlag; |
|
||||||
private String name; |
|
||||||
private ClassInfo superclass; |
|
||||||
private ClassInfo[] interfaces; |
|
||||||
private FieldInfo[] fields; |
|
||||||
private MethodInfo[] methods; |
|
||||||
private InnerClassInfo[] outerClasses; |
|
||||||
private InnerClassInfo[] innerClasses; |
|
||||||
private InnerClassInfo[] extraClasses; |
|
||||||
private String sourceFile; |
|
||||||
|
|
||||||
public final static ClassInfo javaLangObject = forName("java.lang.Object"); |
|
||||||
|
|
||||||
public static void setClassPath(String path) { |
|
||||||
setClassPath(new SearchPath(path)); |
|
||||||
} |
|
||||||
|
|
||||||
public static void setClassPath(SearchPath path) { |
|
||||||
if (classpath != path) { |
|
||||||
classpath = path; |
|
||||||
Iterator i = classes.iterator(); |
|
||||||
while (i.hasNext()) { |
|
||||||
ClassInfo ci = (ClassInfo) i.next(); |
|
||||||
ci.status = 0; |
|
||||||
ci.superclass = null; |
|
||||||
ci.fields = null; |
|
||||||
ci.interfaces = null; |
|
||||||
ci.methods = null; |
|
||||||
ci.removeAllAttributes(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static boolean exists(String name) { |
|
||||||
return classpath.exists(name.replace('.', '/') + ".class"); |
|
||||||
} |
|
||||||
|
|
||||||
public static boolean isPackage(String name) { |
|
||||||
return classpath.isDirectory(name.replace('.', '/')); |
|
||||||
} |
|
||||||
|
|
||||||
public static Enumeration getClassesAndPackages(final String packageName) { |
|
||||||
final Enumeration enumeration = |
|
||||||
classpath.listFiles(packageName.replace('.','/')); |
|
||||||
return new Enumeration() { |
|
||||||
public boolean hasMoreElements() { |
|
||||||
return enumeration.hasMoreElements(); |
|
||||||
} |
|
||||||
public Object nextElement() { |
|
||||||
String name = (String) enumeration.nextElement(); |
|
||||||
if (!name.endsWith(".class")) |
|
||||||
// This is a package
|
|
||||||
return name; |
|
||||||
return name.substring(0, name.length()-6); |
|
||||||
|
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
public static ClassInfo forName(String name) { |
|
||||||
if (name == null |
|
||||||
|| name.indexOf(';') != -1 |
|
||||||
|| name.indexOf('[') != -1 |
|
||||||
|| name.indexOf('/') != -1) |
|
||||||
throw new IllegalArgumentException("Illegal class name: "+name); |
|
||||||
|
|
||||||
int hash = name.hashCode(); |
|
||||||
Iterator iter = classes.iterateHashCode(hash); |
|
||||||
while (iter.hasNext()) { |
|
||||||
ClassInfo clazz = (ClassInfo) iter.next(); |
|
||||||
if (clazz.name.equals(name)) |
|
||||||
return clazz; |
|
||||||
} |
|
||||||
ClassInfo clazz = new ClassInfo(name); |
|
||||||
classes.put(hash, clazz); |
|
||||||
return clazz; |
|
||||||
} |
|
||||||
|
|
||||||
private ClassInfo(String name) { |
|
||||||
this.name = name; |
|
||||||
} |
|
||||||
|
|
||||||
protected void readAttribute(String name, int length, |
|
||||||
ConstantPool cp, |
|
||||||
DataInputStream input, |
|
||||||
int howMuch) throws IOException { |
|
||||||
if (name.equals("SourceFile")) { |
|
||||||
if ((howMuch & KNOWNATTRIBS) != 0) { |
|
||||||
if (length != 2) |
|
||||||
throw new ClassFormatException("SourceFile attribute" |
|
||||||
+ " has wrong length"); |
|
||||||
sourceFile = cp.getUTF8(input.readUnsignedShort()); |
|
||||||
} else |
|
||||||
input.readFully(new byte[length]); |
|
||||||
} else if (name.equals("InnerClasses")) { |
|
||||||
if ((howMuch & (OUTERCLASSES | INNERCLASSES)) != 0) { |
|
||||||
int count = input.readUnsignedShort(); |
|
||||||
if (length != 2 + 8 * count) |
|
||||||
throw new ClassFormatException |
|
||||||
("InnerClasses attribute has wrong length"); |
|
||||||
int innerCount = 0, outerCount = 0, extraCount = 0; |
|
||||||
InnerClassInfo[] innerClassInfo = new InnerClassInfo[count]; |
|
||||||
for (int i=0; i< count; i++) { |
|
||||||
int innerIndex = input.readUnsignedShort(); |
|
||||||
int outerIndex = input.readUnsignedShort(); |
|
||||||
int nameIndex = input.readUnsignedShort(); |
|
||||||
String inner = cp.getClassName(innerIndex); |
|
||||||
String outer = |
|
||||||
outerIndex != 0 ? cp.getClassName(outerIndex) : null; |
|
||||||
String innername = |
|
||||||
nameIndex != 0 ? cp.getUTF8(nameIndex) : null; |
|
||||||
int access = input.readUnsignedShort(); |
|
||||||
if (innername != null && innername.length() == 0) |
|
||||||
innername = null; |
|
||||||
|
|
||||||
/* Some compilers give method scope classes a valid |
|
||||||
* outer field, but we mustn't handle them as inner |
|
||||||
* classes. The best way to distinguish this case |
|
||||||
* is by the class name. |
|
||||||
*/ |
|
||||||
if (outer != null && innername != null |
|
||||||
&& inner.length() > outer.length() + 2 + innername.length() |
|
||||||
&& inner.startsWith(outer+"$") |
|
||||||
&& inner.endsWith("$"+innername) |
|
||||||
&& Character.isDigit(inner.charAt(outer.length() + 1))) |
|
||||||
outer = null; |
|
||||||
|
|
||||||
InnerClassInfo ici = new InnerClassInfo |
|
||||||
(inner, outer, innername, access); |
|
||||||
|
|
||||||
if (outer != null && outer.equals(getName()) |
|
||||||
&& innername != null) |
|
||||||
innerClassInfo[innerCount++] = ici; |
|
||||||
else |
|
||||||
innerClassInfo[count - (++extraCount)] = ici; |
|
||||||
} |
|
||||||
/* Now innerClasses are at the front of innerClassInfo array |
|
||||||
* in correct order. The other InnerClassInfos are in reverse |
|
||||||
* order in the rest of the innerClassInfo array. |
|
||||||
*/ |
|
||||||
|
|
||||||
/* We now count the outerClasses. The reverse order is the |
|
||||||
* right thing for us. |
|
||||||
*/ |
|
||||||
{ |
|
||||||
String lastOuterName = getName(); |
|
||||||
for (int i = count - extraCount; |
|
||||||
i < count && lastOuterName != null; i++) { |
|
||||||
InnerClassInfo ici = innerClassInfo[i]; |
|
||||||
if (ici.inner.equals(lastOuterName)) { |
|
||||||
outerCount++; |
|
||||||
extraCount--; |
|
||||||
lastOuterName = ici.outer; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
if (innerCount > 0) { |
|
||||||
innerClasses = new InnerClassInfo[innerCount]; |
|
||||||
System.arraycopy(innerClassInfo, 0, |
|
||||||
innerClasses, 0, innerCount); |
|
||||||
} else |
|
||||||
innerClasses = null; |
|
||||||
|
|
||||||
if (outerCount > 0) { |
|
||||||
outerClasses = new InnerClassInfo[outerCount]; |
|
||||||
} else |
|
||||||
outerClasses = null; |
|
||||||
|
|
||||||
if (extraCount > 0) { |
|
||||||
extraClasses = new InnerClassInfo[extraCount]; |
|
||||||
} else |
|
||||||
extraClasses = null; |
|
||||||
|
|
||||||
/* The last part: We split between outer and extra classes. |
|
||||||
* In this step we will also revert the order of the extra |
|
||||||
* classes. |
|
||||||
*/ |
|
||||||
{ |
|
||||||
int outerPtr = 0; |
|
||||||
String lastOuterName = getName(); |
|
||||||
for (int i = count - extraCount - outerCount; |
|
||||||
i < count; i++) { |
|
||||||
InnerClassInfo ici = innerClassInfo[i]; |
|
||||||
|
|
||||||
/* If we counted correctly there is no NullPointer |
|
||||||
* or ArrayIndexOutOfBoundsException here |
|
||||||
*/ |
|
||||||
if (ici.inner.equals(lastOuterName)) { |
|
||||||
outerClasses[outerPtr++] = ici; |
|
||||||
lastOuterName = ici.outer; |
|
||||||
} else |
|
||||||
extraClasses[--extraCount] = ici; |
|
||||||
} |
|
||||||
} |
|
||||||
} else |
|
||||||
input.readFully(new byte[length]); |
|
||||||
} else if (name.equals("Deprecated")) { |
|
||||||
deprecatedFlag = true; |
|
||||||
if (length != 0) |
|
||||||
throw new ClassFormatException |
|
||||||
("Deprecated attribute has wrong length"); |
|
||||||
} else |
|
||||||
super.readAttribute(name, length, cp, input, howMuch); |
|
||||||
} |
|
||||||
|
|
||||||
public void read(DataInputStream input, int howMuch) throws IOException { |
|
||||||
/* Since we have to read the whole class anyway, we load all |
|
||||||
* info, that we may need later and that does not take much memory. |
|
||||||
*/ |
|
||||||
howMuch |= HIERARCHY | INNERCLASSES | OUTERCLASSES; |
|
||||||
howMuch &= ~status; |
|
||||||
/* header */ |
|
||||||
if (input.readInt() != 0xcafebabe) |
|
||||||
throw new ClassFormatException("Wrong magic"); |
|
||||||
int version = input.readUnsignedShort(); |
|
||||||
version |= input.readUnsignedShort() << 16; |
|
||||||
if (version < (45 << 16 | 0)) |
|
||||||
throw new ClassFormatException("Wrong class version"); |
|
||||||
|
|
||||||
/* constant pool */ |
|
||||||
ConstantPool cpool = new ConstantPool(); |
|
||||||
cpool.read(input); |
|
||||||
|
|
||||||
/* always read modifiers, name, super, ifaces */ |
|
||||||
{ |
|
||||||
modifiers = input.readUnsignedShort(); |
|
||||||
String className = cpool.getClassName(input.readUnsignedShort()); |
|
||||||
if (!name.equals(className)) |
|
||||||
throw new ClassFormatException("wrong name " + className); |
|
||||||
String superName = cpool.getClassName(input.readUnsignedShort()); |
|
||||||
superclass = superName != null ? ClassInfo.forName(superName) : null; |
|
||||||
int count = input.readUnsignedShort(); |
|
||||||
interfaces = new ClassInfo[count]; |
|
||||||
for (int i=0; i< count; i++) { |
|
||||||
interfaces[i] = ClassInfo.forName |
|
||||||
(cpool.getClassName(input.readUnsignedShort())); |
|
||||||
} |
|
||||||
status |= HIERARCHY; |
|
||||||
} |
|
||||||
|
|
||||||
/* fields */ |
|
||||||
if ((howMuch & (FIELDS | KNOWNATTRIBS | UNKNOWNATTRIBS)) != 0) { |
|
||||||
int count = input.readUnsignedShort(); |
|
||||||
if ((status & FIELDS) == 0) |
|
||||||
fields = new FieldInfo[count]; |
|
||||||
for (int i=0; i< count; i++) { |
|
||||||
if ((status & FIELDS) == 0) |
|
||||||
fields[i] = new FieldInfo(this); |
|
||||||
fields[i].read(cpool, input, howMuch); |
|
||||||
} |
|
||||||
} else { |
|
||||||
byte[] skipBuf = new byte[6]; |
|
||||||
int count = input.readUnsignedShort(); |
|
||||||
for (int i=0; i< count; i++) { |
|
||||||
input.readFully(skipBuf); // modifier, name, type
|
|
||||||
skipAttributes(input); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* methods */ |
|
||||||
if ((howMuch & (METHODS | KNOWNATTRIBS | UNKNOWNATTRIBS)) != 0) { |
|
||||||
int count = input.readUnsignedShort(); |
|
||||||
if ((status & METHODS) == 0) |
|
||||||
methods = new MethodInfo[count]; |
|
||||||
for (int i=0; i< count; i++) { |
|
||||||
if ((status & METHODS) == 0) |
|
||||||
methods[i] = new MethodInfo(this); |
|
||||||
methods[i].read(cpool, input, howMuch); |
|
||||||
} |
|
||||||
} else { |
|
||||||
byte[] skipBuf = new byte[6]; |
|
||||||
int count = input.readUnsignedShort(); |
|
||||||
for (int i=0; i< count; i++) { |
|
||||||
input.readFully(skipBuf); // modifier, name, type
|
|
||||||
skipAttributes(input); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* attributes */ |
|
||||||
readAttributes(cpool, input, howMuch); |
|
||||||
status |= howMuch; |
|
||||||
} |
|
||||||
|
|
||||||
public void reserveSmallConstants(GrowableConstantPool gcp) { |
|
||||||
for (int i=0; i < fields.length; i++) |
|
||||||
fields[i].reserveSmallConstants(gcp); |
|
||||||
|
|
||||||
for (int i=0; i < methods.length; i++) |
|
||||||
methods[i].reserveSmallConstants(gcp); |
|
||||||
} |
|
||||||
|
|
||||||
public void prepareWriting(GrowableConstantPool gcp) { |
|
||||||
gcp.putClassName(name); |
|
||||||
gcp.putClassName(superclass.getName()); |
|
||||||
for (int i=0; i < interfaces.length; i++) |
|
||||||
gcp.putClassName(interfaces[i].getName()); |
|
||||||
|
|
||||||
for (int i=0; i < fields.length; i++) |
|
||||||
fields[i].prepareWriting(gcp); |
|
||||||
|
|
||||||
for (int i=0; i < methods.length; i++) |
|
||||||
methods[i].prepareWriting(gcp); |
|
||||||
|
|
||||||
if (sourceFile != null) { |
|
||||||
gcp.putUTF8("SourceFile"); |
|
||||||
gcp.putUTF8(sourceFile); |
|
||||||
} |
|
||||||
if (outerClasses != null || innerClasses != null |
|
||||||
|| extraClasses != null) { |
|
||||||
gcp.putUTF8("InnerClasses"); |
|
||||||
int outerCount = outerClasses != null ? outerClasses.length : 0; |
|
||||||
for (int i=outerCount; i-- > 0;) { |
|
||||||
gcp.putClassName(outerClasses[i].inner); |
|
||||||
if (outerClasses[i].outer != null) |
|
||||||
gcp.putClassName(outerClasses[i].outer); |
|
||||||
if (outerClasses[i].name != null) |
|
||||||
gcp.putUTF8(outerClasses[i].name); |
|
||||||
} |
|
||||||
int innerCount = innerClasses != null ? innerClasses.length : 0; |
|
||||||
for (int i=0; i< innerCount; i++) { |
|
||||||
gcp.putClassName(innerClasses[i].inner); |
|
||||||
if (innerClasses[i].outer != null) |
|
||||||
gcp.putClassName(innerClasses[i].outer); |
|
||||||
if (innerClasses[i].name != null) |
|
||||||
gcp.putUTF8(innerClasses[i].name); |
|
||||||
} |
|
||||||
int extraCount = extraClasses != null ? extraClasses.length : 0; |
|
||||||
for (int i=0; i< extraCount; i++) { |
|
||||||
gcp.putClassName(extraClasses[i].inner); |
|
||||||
if (extraClasses[i].outer != null) |
|
||||||
gcp.putClassName(extraClasses[i].outer); |
|
||||||
if (extraClasses[i].name != null) |
|
||||||
gcp.putUTF8(extraClasses[i].name); |
|
||||||
} |
|
||||||
} |
|
||||||
if (deprecatedFlag) |
|
||||||
gcp.putUTF8("Deprecated"); |
|
||||||
prepareAttributes(gcp); |
|
||||||
} |
|
||||||
|
|
||||||
protected int getKnownAttributeCount() { |
|
||||||
int count = 0; |
|
||||||
if (sourceFile != null) |
|
||||||
count++; |
|
||||||
if (innerClasses != null || outerClasses != null |
|
||||||
|| extraClasses != null) |
|
||||||
count++; |
|
||||||
return count; |
|
||||||
} |
|
||||||
|
|
||||||
public void writeKnownAttributes(GrowableConstantPool gcp, |
|
||||||
DataOutputStream output) |
|
||||||
throws IOException { |
|
||||||
if (sourceFile != null) { |
|
||||||
output.writeShort(gcp.putUTF8("SourceFile")); |
|
||||||
output.writeInt(2); |
|
||||||
output.writeShort(gcp.putUTF8(sourceFile)); |
|
||||||
} |
|
||||||
if (outerClasses != null || innerClasses != null |
|
||||||
|| extraClasses != null) { |
|
||||||
output.writeShort(gcp.putUTF8("InnerClasses")); |
|
||||||
int outerCount = (outerClasses != null) ? outerClasses.length : 0; |
|
||||||
int innerCount = (innerClasses != null) ? innerClasses.length : 0; |
|
||||||
int extraCount = (extraClasses != null) ? extraClasses.length : 0; |
|
||||||
int count = outerCount + innerCount + extraCount; |
|
||||||
output.writeInt(2 + count * 8); |
|
||||||
output.writeShort(count); |
|
||||||
for (int i=outerCount; i-- > 0; ) { |
|
||||||
output.writeShort(gcp.putClassName(outerClasses[i].inner)); |
|
||||||
output.writeShort(outerClasses[i].outer != null ? |
|
||||||
gcp.putClassName(outerClasses[i].outer) : 0); |
|
||||||
output.writeShort(outerClasses[i].name != null ? |
|
||||||
gcp.putUTF8(outerClasses[i].name) : 0); |
|
||||||
output.writeShort(outerClasses[i].modifiers); |
|
||||||
} |
|
||||||
for (int i=0; i< innerCount; i++) { |
|
||||||
output.writeShort(gcp.putClassName(innerClasses[i].inner)); |
|
||||||
output.writeShort(innerClasses[i].outer != null ? |
|
||||||
gcp.putClassName(innerClasses[i].outer) : 0); |
|
||||||
output.writeShort(innerClasses[i].name != null ? |
|
||||||
gcp.putUTF8(innerClasses[i].name) : 0); |
|
||||||
output.writeShort(innerClasses[i].modifiers); |
|
||||||
} |
|
||||||
for (int i=0; i< extraCount; i++) { |
|
||||||
output.writeShort(gcp.putClassName(extraClasses[i].inner)); |
|
||||||
output.writeShort(extraClasses[i].outer != null ? |
|
||||||
gcp.putClassName(extraClasses[i].outer) : 0); |
|
||||||
output.writeShort(extraClasses[i].name != null ? |
|
||||||
gcp.putUTF8(extraClasses[i].name) : 0); |
|
||||||
output.writeShort(extraClasses[i].modifiers); |
|
||||||
} |
|
||||||
} |
|
||||||
if (deprecatedFlag) { |
|
||||||
output.writeShort(gcp.putUTF8("Deprecated")); |
|
||||||
output.writeInt(0); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void write(DataOutputStream out) throws IOException { |
|
||||||
GrowableConstantPool gcp = new GrowableConstantPool(); |
|
||||||
reserveSmallConstants(gcp); |
|
||||||
prepareWriting(gcp); |
|
||||||
|
|
||||||
out.writeInt(0xcafebabe); |
|
||||||
out.writeShort(3); |
|
||||||
out.writeShort(45); |
|
||||||
gcp.write(out); |
|
||||||
|
|
||||||
out.writeShort(modifiers); |
|
||||||
out.writeShort(gcp.putClassName(name)); |
|
||||||
out.writeShort(gcp.putClassName(superclass.getName())); |
|
||||||
out.writeShort(interfaces.length); |
|
||||||
for (int i=0; i < interfaces.length; i++) |
|
||||||
out.writeShort(gcp.putClassName(interfaces[i].getName())); |
|
||||||
|
|
||||||
out.writeShort(fields.length); |
|
||||||
for (int i=0; i < fields.length; i++) |
|
||||||
fields[i].write(gcp, out); |
|
||||||
|
|
||||||
out.writeShort(methods.length); |
|
||||||
for (int i=0; i < methods.length; i++) |
|
||||||
methods[i].write(gcp, out); |
|
||||||
|
|
||||||
writeAttributes(gcp, out); |
|
||||||
} |
|
||||||
|
|
||||||
public void loadInfoReflection(Class clazz, int howMuch) |
|
||||||
throws SecurityException { |
|
||||||
if ((howMuch & HIERARCHY) != 0) { |
|
||||||
modifiers = clazz.getModifiers(); |
|
||||||
if (clazz.getSuperclass() == null) |
|
||||||
superclass = clazz == Object.class ? null : javaLangObject; |
|
||||||
else |
|
||||||
superclass = ClassInfo.forName |
|
||||||
(clazz.getSuperclass().getName()); |
|
||||||
Class[] ifaces = clazz.getInterfaces(); |
|
||||||
interfaces = new ClassInfo[ifaces.length]; |
|
||||||
for (int i=0; i<ifaces.length; i++) |
|
||||||
interfaces[i] = ClassInfo.forName(ifaces[i].getName()); |
|
||||||
status |= HIERARCHY; |
|
||||||
} |
|
||||||
if ((howMuch & FIELDS) != 0 && fields == null) { |
|
||||||
Field[] fs; |
|
||||||
try { |
|
||||||
fs = clazz.getDeclaredFields(); |
|
||||||
} catch (SecurityException ex) { |
|
||||||
fs = clazz.getFields(); |
|
||||||
GlobalOptions.err.println |
|
||||||
("Could only get public fields of class " |
|
||||||
+ name + "."); |
|
||||||
} |
|
||||||
fields = new FieldInfo[fs.length]; |
|
||||||
for (int i = fs.length; --i >= 0; ) { |
|
||||||
String type = TypeSignature.getSignature(fs[i].getType()); |
|
||||||
fields[i] = new FieldInfo |
|
||||||
(this, fs[i].getName(), type, fs[i].getModifiers()); |
|
||||||
} |
|
||||||
} |
|
||||||
if ((howMuch & METHODS) != 0 && methods == null) { |
|
||||||
Constructor[] cs; |
|
||||||
Method[] ms; |
|
||||||
try { |
|
||||||
cs = clazz.getDeclaredConstructors(); |
|
||||||
ms = clazz.getDeclaredMethods(); |
|
||||||
} catch (SecurityException ex) { |
|
||||||
cs = clazz.getConstructors(); |
|
||||||
ms = clazz.getMethods(); |
|
||||||
GlobalOptions.err.println |
|
||||||
("Could only get public methods of class " |
|
||||||
+ name + "."); |
|
||||||
} |
|
||||||
methods = new MethodInfo[cs.length + ms.length]; |
|
||||||
for (int i = cs.length; --i >= 0; ) { |
|
||||||
String type = TypeSignature.getSignature |
|
||||||
(cs[i].getParameterTypes(), void.class); |
|
||||||
methods[i] = new MethodInfo |
|
||||||
(this, "<init>", type, cs[i].getModifiers()); |
|
||||||
} |
|
||||||
for (int i = ms.length; --i >= 0; ) { |
|
||||||
String type = TypeSignature.getSignature |
|
||||||
(ms[i].getParameterTypes(), ms[i].getReturnType()); |
|
||||||
methods[cs.length+i] = new MethodInfo |
|
||||||
(this, ms[i].getName(), type, ms[i].getModifiers()); |
|
||||||
} |
|
||||||
} |
|
||||||
if ((howMuch & INNERCLASSES) != 0 && innerClasses == null) { |
|
||||||
Class[] is; |
|
||||||
try { |
|
||||||
is = clazz.getDeclaredClasses(); |
|
||||||
} catch (SecurityException ex) { |
|
||||||
is = clazz.getClasses(); |
|
||||||
GlobalOptions.err.println |
|
||||||
("Could only get public inner classes of class " |
|
||||||
+ name + "."); |
|
||||||
} |
|
||||||
if (is.length > 0) { |
|
||||||
innerClasses = new InnerClassInfo[is.length]; |
|
||||||
for (int i = is.length; --i >= 0; ) { |
|
||||||
String inner = is[i].getName(); |
|
||||||
int dollar = inner.lastIndexOf('$'); |
|
||||||
String name = inner.substring(dollar+1); |
|
||||||
innerClasses[i] = new InnerClassInfo |
|
||||||
(inner, getName(), name, is[i].getModifiers()); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
if ((howMuch & OUTERCLASSES) != 0 && outerClasses == null) { |
|
||||||
int count = 0; |
|
||||||
Class declarer = clazz.getDeclaringClass(); |
|
||||||
while (declarer != null) { |
|
||||||
count++; |
|
||||||
declarer = declarer.getDeclaringClass(); |
|
||||||
} |
|
||||||
if (count > 0) { |
|
||||||
outerClasses = new InnerClassInfo[count]; |
|
||||||
Class current = clazz; |
|
||||||
for (int i = 0; i < count; i++) { |
|
||||||
declarer = current.getDeclaringClass(); |
|
||||||
String name = current.getName(); |
|
||||||
int dollar = name.lastIndexOf('$'); |
|
||||||
outerClasses[i] = new InnerClassInfo |
|
||||||
(name, declarer.getName(), |
|
||||||
name.substring(dollar+1), current.getModifiers()); |
|
||||||
current = declarer; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
status |= howMuch; |
|
||||||
} |
|
||||||
|
|
||||||
public void loadInfo(int howMuch) { |
|
||||||
if ((status & howMuch) == howMuch) |
|
||||||
return; |
|
||||||
if (modified) { |
|
||||||
System.err.println("Allocating info 0x" |
|
||||||
+ Integer.toHexString(howMuch) |
|
||||||
+ " (status 0x" + Integer.toHexString(status) |
|
||||||
+ ") in class " + this); |
|
||||||
Thread.dumpStack(); |
|
||||||
return; |
|
||||||
} |
|
||||||
try { |
|
||||||
DataInputStream input = new DataInputStream |
|
||||||
(new BufferedInputStream |
|
||||||
(classpath.getFile(name.replace('.', '/') + ".class"))); |
|
||||||
read(input, howMuch); |
|
||||||
|
|
||||||
} catch (IOException ex) { |
|
||||||
String message = ex.getMessage(); |
|
||||||
if ((howMuch & ~(FIELDS|METHODS|HIERARCHY |
|
||||||
|INNERCLASSES|OUTERCLASSES)) != 0) { |
|
||||||
throw new NoClassDefFoundError(name); |
|
||||||
} |
|
||||||
// Try getting the info through the reflection interface
|
|
||||||
// instead.
|
|
||||||
Class clazz = null; |
|
||||||
try { |
|
||||||
clazz = Class.forName(name); |
|
||||||
} catch (ClassNotFoundException ex2) { |
|
||||||
} catch (NoClassDefFoundError ex2) { |
|
||||||
} |
|
||||||
try { |
|
||||||
if (clazz != null) { |
|
||||||
loadInfoReflection(clazz, howMuch); |
|
||||||
return; |
|
||||||
} |
|
||||||
} catch (SecurityException ex2) { |
|
||||||
GlobalOptions.err.println |
|
||||||
(ex2+" while collecting info about class " + name + "."); |
|
||||||
} |
|
||||||
|
|
||||||
// Give a warning and ``guess'' the hierarchie, methods etc.
|
|
||||||
GlobalOptions.err.println |
|
||||||
("Can't read class " + name + ", types may be incorrect. (" |
|
||||||
+ ex.getClass().getName() |
|
||||||
+ (message != null ? ": " + message : "") + ")"); |
|
||||||
ex.printStackTrace(GlobalOptions.err); |
|
||||||
|
|
||||||
if ((howMuch & HIERARCHY) != 0) { |
|
||||||
modifiers = Modifier.PUBLIC; |
|
||||||
if (name.equals("java.lang.Object")) |
|
||||||
superclass = null; |
|
||||||
else |
|
||||||
superclass = javaLangObject; |
|
||||||
interfaces = new ClassInfo[0]; |
|
||||||
} |
|
||||||
if ((howMuch & METHODS) != 0) |
|
||||||
methods = new MethodInfo[0]; |
|
||||||
if ((howMuch & FIELDS) != 0) |
|
||||||
fields = new FieldInfo[0]; |
|
||||||
status |= howMuch; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* This is the counter part to loadInfo. It will drop all info specified |
|
||||||
* in howMuch and clean up the memory. |
|
||||||
* @param howMuch tells how much info we should drop |
|
||||||
*/ |
|
||||||
public void dropInfo(int howMuch) { |
|
||||||
if ((status & howMuch) == 0) |
|
||||||
return; |
|
||||||
if (modified) { |
|
||||||
System.err.println("Dropping info 0x" |
|
||||||
+ Integer.toHexString(howMuch) |
|
||||||
+ " (status 0x" + Integer.toHexString(status) |
|
||||||
+ ") in class " + this); |
|
||||||
Thread.dumpStack(); |
|
||||||
return; |
|
||||||
} |
|
||||||
howMuch &= status; |
|
||||||
|
|
||||||
if ((howMuch & FIELDS) != 0) { |
|
||||||
fields = null; |
|
||||||
} else if ((status & FIELDS) != 0 |
|
||||||
&& (howMuch & (KNOWNATTRIBS | UNKNOWNATTRIBS)) != 0) { |
|
||||||
for (int i=0; i < fields.length; i++) |
|
||||||
fields[i].dropInfo(howMuch); |
|
||||||
} |
|
||||||
|
|
||||||
if ((howMuch & METHODS) != 0) { |
|
||||||
methods = null; |
|
||||||
} else if ((status & METHODS) != 0 |
|
||||||
&& (howMuch & (KNOWNATTRIBS | UNKNOWNATTRIBS)) != 0) { |
|
||||||
for (int i=0; i < methods.length; i++) |
|
||||||
methods[i].dropInfo(howMuch); |
|
||||||
} |
|
||||||
if ((howMuch & KNOWNATTRIBS) != 0) |
|
||||||
sourceFile = null; |
|
||||||
if ((howMuch & OUTERCLASSES) != 0) |
|
||||||
outerClasses = null; |
|
||||||
if ((howMuch & INNERCLASSES) != 0) { |
|
||||||
innerClasses = null; |
|
||||||
extraClasses = null; |
|
||||||
} |
|
||||||
super.dropInfo(howMuch); |
|
||||||
status &= ~howMuch; |
|
||||||
} |
|
||||||
|
|
||||||
public String getName() { |
|
||||||
return name; |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaName() { |
|
||||||
/* Don't load attributes for class names not containing a |
|
||||||
* dollar sign. |
|
||||||
*/ |
|
||||||
if (name.indexOf('$') == -1) |
|
||||||
return getName(); |
|
||||||
if (getOuterClasses() != null) { |
|
||||||
int last = outerClasses.length-1; |
|
||||||
StringBuffer sb = |
|
||||||
new StringBuffer(outerClasses[last].outer != null |
|
||||||
? outerClasses[last].outer : "METHOD"); |
|
||||||
for (int i=last; i >= 0; i--) |
|
||||||
sb.append(".").append(outerClasses[i].name != null |
|
||||||
? outerClasses[i].name : "ANONYMOUS"); |
|
||||||
return sb.toString(); |
|
||||||
} |
|
||||||
return getName(); |
|
||||||
} |
|
||||||
|
|
||||||
public ClassInfo getSuperclass() { |
|
||||||
if ((status & HIERARCHY) == 0) |
|
||||||
loadInfo(HIERARCHY); |
|
||||||
return superclass; |
|
||||||
} |
|
||||||
|
|
||||||
public ClassInfo[] getInterfaces() { |
|
||||||
if ((status & HIERARCHY) == 0) |
|
||||||
loadInfo(HIERARCHY); |
|
||||||
return interfaces; |
|
||||||
} |
|
||||||
|
|
||||||
public int getModifiers() { |
|
||||||
if ((status & HIERARCHY) == 0) |
|
||||||
loadInfo(HIERARCHY); |
|
||||||
return modifiers; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isInterface() { |
|
||||||
return Modifier.isInterface(getModifiers()); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isDeprecated() { |
|
||||||
return deprecatedFlag; |
|
||||||
} |
|
||||||
|
|
||||||
public FieldInfo findField(String name, String typeSig) { |
|
||||||
if ((status & FIELDS) == 0) |
|
||||||
loadInfo(FIELDS); |
|
||||||
for (int i=0; i< fields.length; i++) |
|
||||||
if (fields[i].getName().equals(name) |
|
||||||
&& fields[i].getType().equals(typeSig)) |
|
||||||
return fields[i]; |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public MethodInfo findMethod(String name, String typeSig) { |
|
||||||
if ((status & METHODS) == 0) |
|
||||||
loadInfo(METHODS); |
|
||||||
for (int i=0; i< methods.length; i++) |
|
||||||
if (methods[i].getName().equals(name) |
|
||||||
&& methods[i].getType().equals(typeSig)) |
|
||||||
return methods[i]; |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public MethodInfo[] getMethods() { |
|
||||||
if ((status & METHODS) == 0) |
|
||||||
loadInfo(METHODS); |
|
||||||
return methods; |
|
||||||
} |
|
||||||
|
|
||||||
public FieldInfo[] getFields() { |
|
||||||
if ((status & FIELDS) == 0) |
|
||||||
loadInfo(FIELDS); |
|
||||||
return fields; |
|
||||||
} |
|
||||||
|
|
||||||
public InnerClassInfo[] getOuterClasses() { |
|
||||||
if ((status & OUTERCLASSES) == 0) |
|
||||||
loadInfo(OUTERCLASSES); |
|
||||||
return outerClasses; |
|
||||||
} |
|
||||||
|
|
||||||
public InnerClassInfo[] getInnerClasses() { |
|
||||||
if ((status & INNERCLASSES) == 0) |
|
||||||
loadInfo(INNERCLASSES); |
|
||||||
return innerClasses; |
|
||||||
} |
|
||||||
|
|
||||||
public InnerClassInfo[] getExtraClasses() { |
|
||||||
if ((status & INNERCLASSES) == 0) |
|
||||||
loadInfo(INNERCLASSES); |
|
||||||
return extraClasses; |
|
||||||
} |
|
||||||
|
|
||||||
public String getSourceFile() { |
|
||||||
return sourceFile; |
|
||||||
} |
|
||||||
|
|
||||||
public void setName(String newName) { |
|
||||||
name = newName; |
|
||||||
modified = true; |
|
||||||
} |
|
||||||
|
|
||||||
public void setSuperclass(ClassInfo newSuper) { |
|
||||||
superclass = newSuper; |
|
||||||
modified = true; |
|
||||||
} |
|
||||||
|
|
||||||
public void setInterfaces(ClassInfo[] newIfaces) { |
|
||||||
interfaces = newIfaces; |
|
||||||
modified = true; |
|
||||||
} |
|
||||||
|
|
||||||
public void setModifiers(int newModifiers) { |
|
||||||
modifiers = newModifiers; |
|
||||||
modified = true; |
|
||||||
} |
|
||||||
|
|
||||||
public void setDeprecated(boolean flag) { |
|
||||||
deprecatedFlag = flag; |
|
||||||
} |
|
||||||
|
|
||||||
public void setMethods(MethodInfo[] mi) { |
|
||||||
methods = mi; |
|
||||||
modified = true; |
|
||||||
} |
|
||||||
|
|
||||||
public void setFields(FieldInfo[] fi) { |
|
||||||
fields = fi; |
|
||||||
modified = true; |
|
||||||
} |
|
||||||
|
|
||||||
public void setOuterClasses(InnerClassInfo[] oc) { |
|
||||||
outerClasses = oc; |
|
||||||
modified = true; |
|
||||||
} |
|
||||||
|
|
||||||
public void setInnerClasses(InnerClassInfo[] ic) { |
|
||||||
innerClasses = ic; |
|
||||||
modified = true; |
|
||||||
} |
|
||||||
|
|
||||||
public void setExtraClasses(InnerClassInfo[] ec) { |
|
||||||
extraClasses = ec; |
|
||||||
modified = true; |
|
||||||
} |
|
||||||
|
|
||||||
public void setSourceFile(String newSource) { |
|
||||||
sourceFile = newSource; |
|
||||||
modified = true; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean superClassOf(ClassInfo son) { |
|
||||||
while (son != this && son != null) { |
|
||||||
son = son.getSuperclass(); |
|
||||||
} |
|
||||||
return son == this; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean implementedBy(ClassInfo clazz) { |
|
||||||
while (clazz != this && clazz != null) { |
|
||||||
ClassInfo[] ifaces = clazz.getInterfaces(); |
|
||||||
for (int i=0; i< ifaces.length; i++) { |
|
||||||
if (implementedBy(ifaces[i])) |
|
||||||
return true; |
|
||||||
} |
|
||||||
clazz = clazz.getSuperclass(); |
|
||||||
} |
|
||||||
return clazz == this; |
|
||||||
} |
|
||||||
|
|
||||||
public String toString() { |
|
||||||
return name; |
|
||||||
} |
|
||||||
} |
|
@ -1,206 +0,0 @@ |
|||||||
/* FieldInfo Copyright (C) 1998-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.bytecode; |
|
||||||
import java.io.DataInputStream; |
|
||||||
import java.io.DataOutputStream; |
|
||||||
import java.io.IOException; |
|
||||||
import java.lang.reflect.Modifier; |
|
||||||
|
|
||||||
public class FieldInfo extends BinaryInfo { |
|
||||||
ClassInfo clazzInfo; |
|
||||||
|
|
||||||
int modifier; |
|
||||||
String name; |
|
||||||
String typeSig; |
|
||||||
|
|
||||||
Object constant; |
|
||||||
boolean syntheticFlag; |
|
||||||
boolean deprecatedFlag; |
|
||||||
|
|
||||||
public FieldInfo(ClassInfo ci) { |
|
||||||
this.clazzInfo = ci; |
|
||||||
} |
|
||||||
|
|
||||||
public FieldInfo(ClassInfo ci, String name, String typeSig, int modifier) { |
|
||||||
this.clazzInfo = ci; |
|
||||||
this.name = name; |
|
||||||
this.typeSig = typeSig; |
|
||||||
this.modifier = modifier; |
|
||||||
} |
|
||||||
|
|
||||||
protected void readAttribute(String name, int length, |
|
||||||
ConstantPool cp, |
|
||||||
DataInputStream input, |
|
||||||
int howMuch) throws IOException { |
|
||||||
if (name.equals("ConstantValue")) { |
|
||||||
if ((howMuch & KNOWNATTRIBS) != 0) { |
|
||||||
if (length != 2) |
|
||||||
throw new ClassFormatException("ConstantValue attribute" |
|
||||||
+ " has wrong length"); |
|
||||||
int index = input.readUnsignedShort(); |
|
||||||
constant = cp.getConstant(index); |
|
||||||
} else |
|
||||||
input.readFully(new byte[length]); |
|
||||||
} else if (name.equals("Synthetic")) { |
|
||||||
syntheticFlag = true; |
|
||||||
if (length != 0) |
|
||||||
throw new ClassFormatException |
|
||||||
("Synthetic attribute has wrong length"); |
|
||||||
} else if (name.equals("Deprecated")) { |
|
||||||
deprecatedFlag = true; |
|
||||||
if (length != 0) |
|
||||||
throw new ClassFormatException |
|
||||||
("Deprecated attribute has wrong length"); |
|
||||||
} else |
|
||||||
super.readAttribute(name, length, cp, input, howMuch); |
|
||||||
} |
|
||||||
|
|
||||||
public void read(ConstantPool constantPool, |
|
||||||
DataInputStream input, int howMuch) throws IOException { |
|
||||||
modifier = input.readUnsignedShort(); |
|
||||||
name = constantPool.getUTF8(input.readUnsignedShort()); |
|
||||||
typeSig = constantPool.getUTF8(input.readUnsignedShort()); |
|
||||||
readAttributes(constantPool, input, howMuch); |
|
||||||
} |
|
||||||
|
|
||||||
public void reserveSmallConstants(GrowableConstantPool gcp) { |
|
||||||
} |
|
||||||
|
|
||||||
public void prepareWriting(GrowableConstantPool gcp) { |
|
||||||
gcp.putUTF8(name); |
|
||||||
gcp.putUTF8(typeSig); |
|
||||||
if (constant != null) { |
|
||||||
gcp.putUTF8("ConstantValue"); |
|
||||||
if (typeSig.charAt(0) == 'J' || typeSig.charAt(0) == 'D') |
|
||||||
gcp.putLongConstant(constant); |
|
||||||
else |
|
||||||
gcp.putConstant(constant); |
|
||||||
} |
|
||||||
if (syntheticFlag) |
|
||||||
gcp.putUTF8("Synthetic"); |
|
||||||
if (deprecatedFlag) |
|
||||||
gcp.putUTF8("Deprecated"); |
|
||||||
prepareAttributes(gcp); |
|
||||||
} |
|
||||||
|
|
||||||
protected int getKnownAttributeCount() { |
|
||||||
int count = 0; |
|
||||||
if (constant != null) |
|
||||||
count++; |
|
||||||
if (syntheticFlag) |
|
||||||
count++; |
|
||||||
if (deprecatedFlag) |
|
||||||
count++; |
|
||||||
return count; |
|
||||||
} |
|
||||||
|
|
||||||
public void writeKnownAttributes(GrowableConstantPool gcp, |
|
||||||
DataOutputStream output) |
|
||||||
throws IOException { |
|
||||||
if (constant != null) { |
|
||||||
output.writeShort(gcp.putUTF8("ConstantValue")); |
|
||||||
output.writeInt(2); |
|
||||||
int index; |
|
||||||
if (typeSig.charAt(0) == 'J' |
|
||||||
|| typeSig.charAt(0) == 'D') |
|
||||||
index = gcp.putLongConstant(constant); |
|
||||||
else |
|
||||||
index = gcp.putConstant(constant); |
|
||||||
output.writeShort(index); |
|
||||||
} |
|
||||||
if (syntheticFlag) { |
|
||||||
output.writeShort(gcp.putUTF8("Synthetic")); |
|
||||||
output.writeInt(0); |
|
||||||
} |
|
||||||
if (deprecatedFlag) { |
|
||||||
output.writeShort(gcp.putUTF8("Deprecated")); |
|
||||||
output.writeInt(0); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void write(GrowableConstantPool constantPool, |
|
||||||
DataOutputStream output) throws IOException { |
|
||||||
output.writeShort(modifier); |
|
||||||
output.writeShort(constantPool.putUTF8(name)); |
|
||||||
output.writeShort(constantPool.putUTF8(typeSig)); |
|
||||||
writeAttributes(constantPool, output); |
|
||||||
} |
|
||||||
|
|
||||||
public void dropInfo(int howMuch) { |
|
||||||
if ((howMuch & KNOWNATTRIBS) != 0) |
|
||||||
constant = null; |
|
||||||
super.dropInfo(howMuch); |
|
||||||
} |
|
||||||
|
|
||||||
public String getName() { |
|
||||||
return name; |
|
||||||
} |
|
||||||
|
|
||||||
public String getType() { |
|
||||||
return typeSig; |
|
||||||
} |
|
||||||
|
|
||||||
public int getModifiers() { |
|
||||||
return modifier; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isSynthetic() { |
|
||||||
return syntheticFlag; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isDeprecated() { |
|
||||||
return deprecatedFlag; |
|
||||||
} |
|
||||||
|
|
||||||
public Object getConstant() { |
|
||||||
clazzInfo.loadInfo(KNOWNATTRIBS); |
|
||||||
return constant; |
|
||||||
} |
|
||||||
|
|
||||||
public void setName(String newName) { |
|
||||||
name = newName; |
|
||||||
} |
|
||||||
|
|
||||||
public void setType(String newType) { |
|
||||||
typeSig = newType; |
|
||||||
} |
|
||||||
|
|
||||||
public void setModifiers(int newModifier) { |
|
||||||
modifier = newModifier; |
|
||||||
} |
|
||||||
|
|
||||||
public void setSynthetic(boolean flag) { |
|
||||||
syntheticFlag = flag; |
|
||||||
} |
|
||||||
|
|
||||||
public void setDeprecated(boolean flag) { |
|
||||||
deprecatedFlag = flag; |
|
||||||
} |
|
||||||
|
|
||||||
public void setConstant(Object newConstant) { |
|
||||||
constant = newConstant; |
|
||||||
} |
|
||||||
|
|
||||||
public String toString() { |
|
||||||
return "Field "+Modifier.toString(modifier)+" "+ |
|
||||||
typeSig+" "+name; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
@ -1,29 +0,0 @@ |
|||||||
/* Handler Copyright (C) 1999-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.bytecode; |
|
||||||
|
|
||||||
/** |
|
||||||
* A simple class containing the info about an exception handler |
|
||||||
*/ |
|
||||||
public class Handler { |
|
||||||
public Instruction start, end, catcher; |
|
||||||
public String type; |
|
||||||
} |
|
||||||
|
|
@ -1,830 +0,0 @@ |
|||||||
/* Instruction Copyright (C) 1999-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.bytecode; |
|
||||||
|
|
||||||
/** |
|
||||||
* This class represents an instruction in the byte code. |
|
||||||
* |
|
||||||
*/ |
|
||||||
public final class Instruction implements Opcodes{ |
|
||||||
/** |
|
||||||
* The opcode of the instruction. We map some opcodes, e.g. |
|
||||||
* <pre> |
|
||||||
* iload_[0-3] -> iload, ldc_w -> ldc, wide iinc -> iinc. |
|
||||||
* </pre> |
|
||||||
*/ |
|
||||||
// a byte would be enough, but then we would need an unsigned convert.
|
|
||||||
private int opcode; |
|
||||||
/** |
|
||||||
* If this opcode uses a local this gives the slot. For multianewarray |
|
||||||
* this gives the dimension. |
|
||||||
*/ |
|
||||||
private int shortData; |
|
||||||
/** |
|
||||||
* The address of this opcode. |
|
||||||
*/ |
|
||||||
private int addr; |
|
||||||
/** |
|
||||||
* Optional object data for this opcode. There are four different |
|
||||||
* usages of this field: |
|
||||||
* <dl> |
|
||||||
* <dt>opc_ldc / opc_ldc2_w</dt> |
|
||||||
* <dd>The constant of type Integer/Long/Float/Double/String. </dd> |
|
||||||
* <dt>opc_invokexxx / opc_xxxfield / opc_xxxstatic</dt> |
|
||||||
* <dd>The field/method Reference</dd> |
|
||||||
* <dt>opc_new / opc_checkcast / opc_instanceof / opc_multianewarray</dt> |
|
||||||
* <dd>The typesignature of the class/array</dd> |
|
||||||
* <dt>opc_lookupswitch</dt> |
|
||||||
* <dd>The array of values of type int[]</dd> |
|
||||||
* </dl> |
|
||||||
*/ |
|
||||||
private Object objData; |
|
||||||
/** |
|
||||||
* The successors of this opcodes, where flow may lead to |
|
||||||
* (except that nextByAddr is implicit if !alwaysJump). The |
|
||||||
* value null means no successor, if there is one succesor, this |
|
||||||
* is of type Instruction, otherwise, this is an array of Instruction. |
|
||||||
*/ |
|
||||||
private Object succs; |
|
||||||
/** |
|
||||||
* The predecessors of this opcode, orthogonal to the succs array. |
|
||||||
* This must be null or a non empty array. |
|
||||||
*/ |
|
||||||
private Instruction[] preds; |
|
||||||
/** |
|
||||||
* The next instruction in code order. |
|
||||||
*/ |
|
||||||
Instruction nextByAddr; |
|
||||||
/** |
|
||||||
* The previous instruction in code order, useful when changing |
|
||||||
* the order. |
|
||||||
*/ |
|
||||||
Instruction prevByAddr; |
|
||||||
|
|
||||||
/** |
|
||||||
* You can use this field to add some info to each instruction. |
|
||||||
* After using, you must set it to null again. |
|
||||||
* @XXX Do we really need this. Every field here can quickly take |
|
||||||
* half a megabyte! |
|
||||||
*/ |
|
||||||
private Object tmpInfo; |
|
||||||
|
|
||||||
public Instruction(int opcode) { |
|
||||||
this.opcode = opcode; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the opcode of the instruction. We map some opcodes: |
|
||||||
* <pre> |
|
||||||
* [iflda]load_x -> [iflda]load |
|
||||||
* [iflda]store_x -> [iflda]store |
|
||||||
* [ifa]const_xx, ldc_w -> ldc |
|
||||||
* [dl]const_xx -> ldc2_w |
|
||||||
* wide opcode -> opcode |
|
||||||
* tableswitch -> lookupswitch |
|
||||||
* [a]newarray -> multianewarray |
|
||||||
* </pre> |
|
||||||
*/ |
|
||||||
public final int getOpcode() { |
|
||||||
return opcode; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the address of this opcode. As long as you don't remove |
|
||||||
* or insert instructions, you can be sure, that the addresses of the |
|
||||||
* opcodes are unique, and that |
|
||||||
* <pre> |
|
||||||
* instr.getAddr() + instr.getLength() == instr.getNextByAddr().getAddr() |
|
||||||
* <pre> |
|
||||||
* |
|
||||||
* If you insert/remove Instructions, you should be aware that the |
|
||||||
* above property is not guaranteed anymore. |
|
||||||
*/ |
|
||||||
public final int getAddr() { |
|
||||||
return addr; |
|
||||||
} |
|
||||||
|
|
||||||
public final int getNextAddr() { |
|
||||||
return nextByAddr.addr; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the length of this opcode. See getAddr() for some |
|
||||||
* notes. Note that the length doesn't necessarily reflect the |
|
||||||
* real length, when this bytecode is written again, since the |
|
||||||
* length of an ldc instruction depends on the number of entries |
|
||||||
* in constant pool, and the order they are allocated. |
|
||||||
*/ |
|
||||||
public final int getLength() { |
|
||||||
return getNextAddr() - addr; |
|
||||||
} |
|
||||||
|
|
||||||
final void setAddr(int addr) { |
|
||||||
this.addr = addr; |
|
||||||
} |
|
||||||
|
|
||||||
public final boolean hasLocalSlot() { |
|
||||||
return opcode == opc_iinc || opcode == opc_ret |
|
||||||
|| opcode >= opc_iload && opcode <= opc_aload |
|
||||||
|| opcode >= opc_istore && opcode <= opc_astore; |
|
||||||
} |
|
||||||
|
|
||||||
public final int getLocalSlot() |
|
||||||
/*{ require { hasLocalSlot() |
|
||||||
:: "Instruction has no slot" } }*/ |
|
||||||
{ |
|
||||||
return shortData; |
|
||||||
} |
|
||||||
|
|
||||||
public final void setLocalSlot(int slot) |
|
||||||
/*{ require { hasLocalSlot() |
|
||||||
:: "Instruction has no slot" } }*/ |
|
||||||
{ |
|
||||||
shortData = slot; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Optional integer data for this opcode. There are various uses |
|
||||||
* for this: |
|
||||||
* <dl> |
|
||||||
* <dt>opc_iinc</dt> |
|
||||||
* <dd>The value by which the constant is increased/decreased. (short)</dd> |
|
||||||
* <dt>opc_multianewarray</dt> |
|
||||||
* <dd>The number of dimensions (1..255)</dd> |
|
||||||
* </dl> |
|
||||||
*/ |
|
||||||
public final int getIncrement() |
|
||||||
/*{ require { opcode == opc_iinc || opcode == opc_multianewarray |
|
||||||
|| opcode == opc_tableswitch |
|
||||||
:: "Instruction has no int data" } }*/ |
|
||||||
{ |
|
||||||
/* shortData already used for local slot */ |
|
||||||
return ((Short) objData).shortValue(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Optional integer data for this opcode. There are various uses |
|
||||||
* for this: |
|
||||||
* <dl> |
|
||||||
* <dt>opc_iinc</dt> |
|
||||||
* <dd>The value by which the constant is increased/decreased. (short)</dd> |
|
||||||
* <dt>opc_multianewarray</dt> |
|
||||||
* <dd>The number of dimensions (1..255)</dd> |
|
||||||
* </dl> |
|
||||||
*/ |
|
||||||
public final void setIncrement(int incr) |
|
||||||
/*{ require { opcode == opc_iinc || opcode == opc_multianewarray |
|
||||||
:: "Instruction has no int data" } }*/ |
|
||||||
{ |
|
||||||
/* shortData already used for local slot */ |
|
||||||
objData = new Short((short) incr); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
*/ |
|
||||||
public final int getDimensions() |
|
||||||
/*{ require { opcode == opc_multianewarray |
|
||||||
:: "Instruction has no dimensions" } }*/ |
|
||||||
{ |
|
||||||
return shortData; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
*/ |
|
||||||
public final void setDimensions(int dims) |
|
||||||
/*{ require { opcode == opc_multianewarray |
|
||||||
:: "Instruction has no dimensions" } }*/ |
|
||||||
{ |
|
||||||
shortData = dims; |
|
||||||
} |
|
||||||
|
|
||||||
public final Object getConstant() |
|
||||||
/*{ require { opcode == opc_ldc || opcode == opc_ldc2_w |
|
||||||
:: "Instruction has no constant" } }*/ |
|
||||||
{ |
|
||||||
return objData; |
|
||||||
} |
|
||||||
|
|
||||||
public final void setConstant(Object constant) |
|
||||||
/*{ require { opcode == opc_ldc || opcode == opc_ldc2_w |
|
||||||
:: "Instruction has no constant" } }*/ |
|
||||||
{ |
|
||||||
objData = constant; |
|
||||||
} |
|
||||||
|
|
||||||
public final Reference getReference() |
|
||||||
/*{ require { opcode >= opc_getstatic && opcode <= opc_invokeinterface |
|
||||||
:: "Instruction has no reference" } }*/ |
|
||||||
{ |
|
||||||
return (Reference) objData; |
|
||||||
} |
|
||||||
|
|
||||||
public final void setReference(Reference ref) |
|
||||||
/*{ require { opcode >= opc_getstatic && opcode <= opc_invokeinterface |
|
||||||
:: "Instruction has no reference" } }*/ |
|
||||||
{ |
|
||||||
objData = ref; |
|
||||||
} |
|
||||||
|
|
||||||
public final String getClazzType() |
|
||||||
/*{ require { opcode == opc_new |
|
||||||
|| opcode == opc_checkcast |
|
||||||
|| opcode == opc_instanceof |
|
||||||
|| opcode == opc_multianewarray |
|
||||||
:: "Instruction has no typesig" } }*/ |
|
||||||
{ |
|
||||||
return (String) objData; |
|
||||||
} |
|
||||||
|
|
||||||
public final void setClazzType(String type) |
|
||||||
/*{ require { opcode == opc_new |
|
||||||
|| opcode == opc_checkcast |
|
||||||
|| opcode == opc_instanceof |
|
||||||
|| opcode == opc_multianewarray |
|
||||||
:: "Instruction has no typesig" } }*/ |
|
||||||
{ |
|
||||||
objData = type; |
|
||||||
} |
|
||||||
|
|
||||||
public final int[] getValues() |
|
||||||
/*{ require { opcode == opc_lookupswitch |
|
||||||
:: "Instruction has no values" } }*/ |
|
||||||
{ |
|
||||||
return (int[]) objData; |
|
||||||
} |
|
||||||
|
|
||||||
public final void setValues(int[] values) |
|
||||||
/*{ require { opcode == opc_lookupswitch |
|
||||||
:: "Instruction has no values" } }*/ |
|
||||||
{ |
|
||||||
objData = values; |
|
||||||
} |
|
||||||
|
|
||||||
public final boolean doesAlwaysJump() { |
|
||||||
switch (opcode) { |
|
||||||
case opc_ret: |
|
||||||
case opc_goto: |
|
||||||
case opc_jsr: |
|
||||||
case opc_tableswitch: |
|
||||||
case opc_lookupswitch: |
|
||||||
case opc_ireturn: |
|
||||||
case opc_lreturn: |
|
||||||
case opc_freturn: |
|
||||||
case opc_dreturn: |
|
||||||
case opc_areturn: |
|
||||||
case opc_return: |
|
||||||
case opc_athrow: |
|
||||||
return true; |
|
||||||
default: |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public final Instruction[] getPreds() { |
|
||||||
return preds; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns true if this opcode has successors, other than the implicit |
|
||||||
* getNextByAddr(). |
|
||||||
*/ |
|
||||||
public boolean hasSuccs() { |
|
||||||
return succs != null; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the successors of this opcodes, where flow may lead to |
|
||||||
* (except that nextByAddr is implicit if !alwaysJump). The |
|
||||||
* value null means that there is no successor. |
|
||||||
*/ |
|
||||||
public final Instruction[] getSuccs() { |
|
||||||
if (succs instanceof Instruction) |
|
||||||
return new Instruction[] { (Instruction) succs }; |
|
||||||
return (Instruction[]) succs; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the single successor of this opcodes. This gives the |
|
||||||
* target of a goto, jsr, or if opcode. |
|
||||||
* @return null if there is no successor, otherwise the successor. |
|
||||||
* @exception ClassCastException if this has more than one succ. |
|
||||||
*/ |
|
||||||
public final Instruction getSingleSucc() { |
|
||||||
return (Instruction) succs; |
|
||||||
} |
|
||||||
|
|
||||||
public final Instruction getPrevByAddr() { |
|
||||||
if (prevByAddr.opcode == opc_impdep1) |
|
||||||
return null; |
|
||||||
return prevByAddr; |
|
||||||
} |
|
||||||
|
|
||||||
public final Instruction getNextByAddr() { |
|
||||||
if (nextByAddr.opcode == opc_impdep1) |
|
||||||
return null; |
|
||||||
return nextByAddr; |
|
||||||
} |
|
||||||
|
|
||||||
public final Object getTmpInfo() { |
|
||||||
return tmpInfo; |
|
||||||
} |
|
||||||
|
|
||||||
public final void setTmpInfo(Object info) { |
|
||||||
tmpInfo = info; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
// INTERNAL FUNCTIONS TO KEEP PREDS AND SUCCS CONSISTENT
|
|
||||||
|
|
||||||
final void removeSuccs() { |
|
||||||
if (succs == null) |
|
||||||
return; |
|
||||||
if (succs instanceof Instruction[]) { |
|
||||||
Instruction[] ss = (Instruction[]) succs; |
|
||||||
for (int i = 0; i < ss.length; i++) |
|
||||||
if (ss[i] != null) |
|
||||||
ss[i].removePredecessor(this); |
|
||||||
} else |
|
||||||
((Instruction) succs).removePredecessor(this); |
|
||||||
succs = null; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param to may be null |
|
||||||
*/ |
|
||||||
private final void promoteSuccs(Instruction from, Instruction to) { |
|
||||||
if (succs == from) |
|
||||||
succs = to; |
|
||||||
else if (succs instanceof Instruction[]) { |
|
||||||
Instruction[] ss = (Instruction[]) succs; |
|
||||||
for (int i = 0; i < ss.length; i++) |
|
||||||
if (ss[i] == from) |
|
||||||
ss[i] = to; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @exception ClassCastException if newSuccs is neither an Instruction |
|
||||||
* nor an array of instructions. |
|
||||||
*/ |
|
||||||
public final void setSuccs(Object newSuccs) { |
|
||||||
if (succs == newSuccs) |
|
||||||
return; |
|
||||||
removeSuccs(); |
|
||||||
if (newSuccs == null) |
|
||||||
return; |
|
||||||
if (newSuccs instanceof Instruction[]) { |
|
||||||
Instruction[] ns = (Instruction[]) newSuccs; |
|
||||||
switch (ns.length) { |
|
||||||
case 0: |
|
||||||
break; |
|
||||||
case 1: |
|
||||||
succs = ns[0]; |
|
||||||
ns[0].addPredecessor(this); |
|
||||||
break; |
|
||||||
default: |
|
||||||
succs = ns; |
|
||||||
for (int i = 0; i < ns.length; i++) |
|
||||||
ns[i].addPredecessor(this); |
|
||||||
break; |
|
||||||
} |
|
||||||
} else { |
|
||||||
succs = newSuccs; |
|
||||||
((Instruction) newSuccs).addPredecessor(this); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void addPredecessor(Instruction pred) { |
|
||||||
if (preds == null) { |
|
||||||
preds = new Instruction[] { pred }; |
|
||||||
return; |
|
||||||
} |
|
||||||
int predsLength = preds.length; |
|
||||||
Instruction[] newPreds = new Instruction[predsLength+1]; |
|
||||||
System.arraycopy(preds, 0, newPreds, 0, predsLength); |
|
||||||
newPreds[predsLength] = pred; |
|
||||||
preds = newPreds; |
|
||||||
} |
|
||||||
|
|
||||||
void removePredecessor(Instruction pred) { |
|
||||||
/* Hopefully it doesn't matter if this is slow */ |
|
||||||
int predLength = preds.length; |
|
||||||
if (predLength == 1) { |
|
||||||
if (preds[0] != pred) |
|
||||||
throw new jode.AssertError |
|
||||||
("removing not existing predecessor"); |
|
||||||
preds = null; |
|
||||||
} else { |
|
||||||
Instruction[] newPreds = new Instruction[predLength-1]; |
|
||||||
int j; |
|
||||||
for (j = 0; preds[j] != pred; j++) |
|
||||||
newPreds[j] = preds[j]; |
|
||||||
System.arraycopy(preds, j+1, newPreds, j, predLength - j - 1); |
|
||||||
preds = newPreds; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// ADDING, REMOVING AND REPLACING INSTRUCTIONS
|
|
||||||
|
|
||||||
/** |
|
||||||
* Replaces the opcode of this instruction. You should only use the |
|
||||||
* mapped opcodes: |
|
||||||
* <pre> |
|
||||||
* [iflda]load_x -> [iflda]load |
|
||||||
* [iflda]store_x -> [iflda]store |
|
||||||
* [ifa]const_xx, ldc_w -> ldc |
|
||||||
* [dl]const_xx -> ldc2_w |
|
||||||
* wide opcode -> opcode |
|
||||||
* tableswitch -> lookupswitch |
|
||||||
* [a]newarray -> multianewarray |
|
||||||
* </pre> |
|
||||||
*/ |
|
||||||
public final void replaceInstruction(Instruction newInstr, |
|
||||||
BytecodeInfo codeinfo) { |
|
||||||
/* remove predecessors of successors */ |
|
||||||
removeSuccs(); |
|
||||||
|
|
||||||
newInstr.addr = addr; |
|
||||||
nextByAddr.prevByAddr = newInstr; |
|
||||||
newInstr.nextByAddr = nextByAddr; |
|
||||||
prevByAddr.nextByAddr = newInstr; |
|
||||||
newInstr.prevByAddr = prevByAddr; |
|
||||||
prevByAddr = null; |
|
||||||
nextByAddr = null; |
|
||||||
|
|
||||||
/* promote the successors of the predecessors to newInstr */ |
|
||||||
if (preds != null) { |
|
||||||
for (int j=0; j < preds.length; j++) |
|
||||||
preds[j].promoteSuccs(this, newInstr); |
|
||||||
newInstr.preds = preds; |
|
||||||
preds = null; |
|
||||||
} |
|
||||||
|
|
||||||
/* adjust exception handlers */ |
|
||||||
Handler[] handlers = codeinfo.getExceptionHandlers(); |
|
||||||
for (int i=0; i< handlers.length; i++) { |
|
||||||
if (handlers[i].start == this) |
|
||||||
handlers[i].start = newInstr; |
|
||||||
if (handlers[i].end == this) |
|
||||||
handlers[i].end = newInstr; |
|
||||||
if (handlers[i].catcher == this) |
|
||||||
handlers[i].catcher = newInstr; |
|
||||||
} |
|
||||||
|
|
||||||
/* adjust local variable table and line number table */ |
|
||||||
LocalVariableInfo[] lvt = codeinfo.getLocalVariableTable(); |
|
||||||
if (lvt != null) { |
|
||||||
for (int i=0; i< lvt.length; i++) { |
|
||||||
if (lvt[i].start == this) |
|
||||||
lvt[i].start = newInstr; |
|
||||||
if (lvt[i].end == this) |
|
||||||
lvt[i].end = newInstr; |
|
||||||
} |
|
||||||
} |
|
||||||
LineNumber[] lnt = codeinfo.getLineNumberTable(); |
|
||||||
if (lnt != null) { |
|
||||||
for (int i=0; i< lnt.length; i++) { |
|
||||||
if (lnt[i].start == this) |
|
||||||
lnt[i].start = newInstr; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void appendInstruction(Instruction newInstr, BytecodeInfo codeinfo) { |
|
||||||
newInstr.addr = nextByAddr.addr; |
|
||||||
|
|
||||||
newInstr.nextByAddr = nextByAddr; |
|
||||||
nextByAddr.prevByAddr = newInstr; |
|
||||||
newInstr.prevByAddr = this; |
|
||||||
nextByAddr = newInstr; |
|
||||||
|
|
||||||
/* adjust exception handlers end */ |
|
||||||
Handler[] handlers = codeinfo.getExceptionHandlers(); |
|
||||||
if (handlers != null) { |
|
||||||
for (int i=0; i< handlers.length; i++) { |
|
||||||
if (handlers[i].end == this) |
|
||||||
handlers[i].end = newInstr; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Removes this instruction (as if it would be replaced by a nop). |
|
||||||
*/ |
|
||||||
void removeInstruction(BytecodeInfo codeinfo) { |
|
||||||
|
|
||||||
/* remove from chained list and adjust addr / length */ |
|
||||||
prevByAddr.nextByAddr = nextByAddr; |
|
||||||
nextByAddr.prevByAddr = prevByAddr; |
|
||||||
|
|
||||||
/* remove predecessors of successors */ |
|
||||||
removeSuccs(); |
|
||||||
|
|
||||||
/* promote the predecessors to next instruction */ |
|
||||||
if (preds != null) { |
|
||||||
for (int j=0; j < preds.length; j++) |
|
||||||
preds[j].promoteSuccs(this, nextByAddr); |
|
||||||
if (nextByAddr.preds == null) |
|
||||||
nextByAddr.preds = preds; |
|
||||||
else { |
|
||||||
Instruction[] newPreds = new Instruction |
|
||||||
[nextByAddr.preds.length + preds.length]; |
|
||||||
System.arraycopy(nextByAddr.preds, 0, newPreds, 0, |
|
||||||
nextByAddr.preds.length); |
|
||||||
System.arraycopy(preds, 0, newPreds, nextByAddr.preds.length, |
|
||||||
preds.length); |
|
||||||
nextByAddr.preds = newPreds; |
|
||||||
} |
|
||||||
preds = null; |
|
||||||
} |
|
||||||
|
|
||||||
/* adjust exception handlers */ |
|
||||||
Handler[] handlers = codeinfo.getExceptionHandlers(); |
|
||||||
for (int i=0; i< handlers.length; i++) { |
|
||||||
if (handlers[i].start == this && handlers[i].end == this) { |
|
||||||
/* Remove the handler. |
|
||||||
* This is very seldom, so we can make it slow */ |
|
||||||
Handler[] newHandlers = new Handler[handlers.length - 1]; |
|
||||||
System.arraycopy(handlers, 0, newHandlers, 0, i); |
|
||||||
System.arraycopy(handlers, i+1, newHandlers, i, |
|
||||||
handlers.length - (i+1)); |
|
||||||
handlers = newHandlers; |
|
||||||
codeinfo.setExceptionHandlers(newHandlers); |
|
||||||
i--; |
|
||||||
} else { |
|
||||||
if (handlers[i].start == this) |
|
||||||
handlers[i].start = nextByAddr; |
|
||||||
if (handlers[i].end == this) |
|
||||||
handlers[i].end = prevByAddr; |
|
||||||
if (handlers[i].catcher == this) |
|
||||||
handlers[i].catcher = nextByAddr; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* adjust local variable table and line number table */ |
|
||||||
LocalVariableInfo[] lvt = codeinfo.getLocalVariableTable(); |
|
||||||
if (lvt != null) { |
|
||||||
for (int i=0; i< lvt.length; i++) { |
|
||||||
if (lvt[i].start == this && lvt[i].end == this) { |
|
||||||
/* Remove the local variable info. |
|
||||||
* This is very seldom, so we can make it slow |
|
||||||
*/ |
|
||||||
LocalVariableInfo[] newLVT = |
|
||||||
new LocalVariableInfo[lvt.length - 1]; |
|
||||||
System.arraycopy(lvt, 0, newLVT, 0, i); |
|
||||||
System.arraycopy(lvt, i+1, newLVT, i, |
|
||||||
newLVT.length - i); |
|
||||||
lvt = newLVT; |
|
||||||
codeinfo.setLocalVariableTable(newLVT); |
|
||||||
i--; |
|
||||||
} else { |
|
||||||
if (lvt[i].start == this) |
|
||||||
lvt[i].start = nextByAddr; |
|
||||||
if (lvt[i].end == this) |
|
||||||
lvt[i].end = prevByAddr; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
LineNumber[] lnt = codeinfo.getLineNumberTable(); |
|
||||||
if (lnt != null) { |
|
||||||
for (int i=0; i< lnt.length; i++) { |
|
||||||
if (lnt[i].start == this) { |
|
||||||
if (nextByAddr.opcode == opc_impdep1 |
|
||||||
|| (i+1 < lnt.length |
|
||||||
&& lnt[i+1].start == nextByAddr)) { |
|
||||||
/* Remove the line number. |
|
||||||
* This is very seldom, so we can make it slow */ |
|
||||||
LineNumber[] newLNT = |
|
||||||
new LineNumber[lnt.length - 1]; |
|
||||||
System.arraycopy(lnt, 0, newLNT, 0, i); |
|
||||||
System.arraycopy(lnt, i+1, newLNT, i, |
|
||||||
newLNT.length - i); |
|
||||||
lnt = newLNT; |
|
||||||
codeinfo.setLineNumberTable(newLNT); |
|
||||||
i--; |
|
||||||
} else |
|
||||||
lnt[i].start = nextByAddr; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
prevByAddr = null; |
|
||||||
nextByAddr = null; |
|
||||||
} |
|
||||||
|
|
||||||
public int compareTo(Instruction instr) { |
|
||||||
if (addr != instr.addr) |
|
||||||
return addr - instr.addr; |
|
||||||
if (this == instr) |
|
||||||
return 0; |
|
||||||
do { |
|
||||||
instr = instr.nextByAddr; |
|
||||||
if (instr.addr > addr) |
|
||||||
return -1; |
|
||||||
} while (instr != this); |
|
||||||
return 1; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* This returns the number of stack entries this instruction |
|
||||||
* pushes and pops from the stack. The result fills the given |
|
||||||
* array. |
|
||||||
* |
|
||||||
* @param poppush an array of two ints. The first element will |
|
||||||
* get the number of pops, the second the number of pushes. |
|
||||||
*/ |
|
||||||
public void getStackPopPush(int[] poppush) |
|
||||||
/*{ require { poppush != null && poppush.length == 2 |
|
||||||
:: "poppush must be an array of two ints" } } */ |
|
||||||
{ |
|
||||||
byte delta = (byte) stackDelta.charAt(opcode); |
|
||||||
if (delta < 0x40) { |
|
||||||
poppush[0] = delta & 7; |
|
||||||
poppush[1] = delta >> 3; |
|
||||||
} else { |
|
||||||
switch (opcode) { |
|
||||||
case opc_invokevirtual: |
|
||||||
case opc_invokespecial: |
|
||||||
case opc_invokestatic: |
|
||||||
case opc_invokeinterface: { |
|
||||||
Reference ref = getReference(); |
|
||||||
String typeSig = ref.getType(); |
|
||||||
poppush[0] = opcode != opc_invokestatic ? 1 : 0; |
|
||||||
poppush[0] += TypeSignature.getArgumentSize(typeSig); |
|
||||||
poppush[1] = TypeSignature.getReturnSize(typeSig); |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
case opc_putfield: |
|
||||||
case opc_putstatic: { |
|
||||||
Reference ref = getReference(); |
|
||||||
poppush[1] = 0; |
|
||||||
poppush[0] = TypeSignature.getTypeSize(ref.getType()); |
|
||||||
if (opcode == opc_putfield) |
|
||||||
poppush[0]++; |
|
||||||
break; |
|
||||||
} |
|
||||||
case opc_getstatic: |
|
||||||
case opc_getfield: { |
|
||||||
Reference ref = getReference(); |
|
||||||
poppush[1] = TypeSignature.getTypeSize(ref.getType()); |
|
||||||
poppush[0] = opcode == opc_getfield ? 1 : 0; |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
case opc_multianewarray: { |
|
||||||
poppush[1] = 1; |
|
||||||
poppush[0] = getDimensions(); |
|
||||||
break; |
|
||||||
} |
|
||||||
default: |
|
||||||
throw new jode.AssertError("Unknown Opcode: "+opcode); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Instruction findMatchingPop() { |
|
||||||
int poppush[] = new int[2]; |
|
||||||
getStackPopPush(poppush); |
|
||||||
|
|
||||||
int count = poppush[1]; |
|
||||||
Instruction instr = this; |
|
||||||
while (true) { |
|
||||||
if (instr.succs != null || instr.doesAlwaysJump()) |
|
||||||
return null; |
|
||||||
instr = instr.nextByAddr; |
|
||||||
if (instr.preds != null) |
|
||||||
return null; |
|
||||||
|
|
||||||
instr.getStackPopPush(poppush); |
|
||||||
if (count == poppush[0]) |
|
||||||
return instr; |
|
||||||
count += poppush[1] - poppush[0]; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Instruction findMatchingPush() { |
|
||||||
int count = 0; |
|
||||||
Instruction instr = this; |
|
||||||
int poppush[] = new int[2]; |
|
||||||
while (true) { |
|
||||||
if (instr.preds != null) |
|
||||||
return null; |
|
||||||
instr = instr.prevByAddr; |
|
||||||
if (instr == null || instr.succs != null || instr.doesAlwaysJump()) |
|
||||||
return null; |
|
||||||
|
|
||||||
instr.getStackPopPush(poppush); |
|
||||||
if (count < poppush[1]) { |
|
||||||
return count == 0 ? instr : null; |
|
||||||
} |
|
||||||
count += poppush[0] - poppush[1]; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public String getDescription() { |
|
||||||
StringBuffer result = new StringBuffer(String.valueOf(addr)) |
|
||||||
.append('_').append(Integer.toHexString(hashCode())) |
|
||||||
.append(": ").append(opcodeString[opcode]); |
|
||||||
if (opcode != opc_lookupswitch) { |
|
||||||
if (hasLocalSlot()) |
|
||||||
result.append(' ').append(getLocalSlot()); |
|
||||||
if (succs != null) |
|
||||||
result.append(' ').append(((Instruction) succs).addr); |
|
||||||
if (objData != null) |
|
||||||
result.append(' ').append(objData); |
|
||||||
if (opcode == opc_multianewarray) |
|
||||||
result.append(' ').append(getDimensions()); |
|
||||||
} else { |
|
||||||
int[] values = getValues(); |
|
||||||
Instruction[] succs = getSuccs(); |
|
||||||
for (int i=0; i < values.length; i++) { |
|
||||||
result.append(' ').append(values[i]).append("->") |
|
||||||
.append(((Instruction) succs[i]).addr); |
|
||||||
} |
|
||||||
result.append(' ').append("default: ") |
|
||||||
.append(((Instruction) succs[values.length]).addr); |
|
||||||
} |
|
||||||
return result.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
public String toString() { |
|
||||||
return "" + addr + "_" + Integer.toHexString(hashCode()); |
|
||||||
} |
|
||||||
|
|
||||||
private final static String stackDelta = |
|
||||||
"\000\010\010\010\010\010\010\010\010\020\020\010\010\010\020\020\010\010\010\010\020\010\020\010\020\010\010\010\010\010\020\020\020\020\010\010\010\010\020\020\020\020\010\010\010\010\012\022\012\022\012\012\012\012\001\002\001\002\001\001\001\001\001\002\002\002\002\001\001\001\001\002\002\002\002\001\001\001\001\003\004\003\004\003\003\003\003\001\002\021\032\043\042\053\064\022\012\024\012\024\012\024\012\024\012\024\012\024\012\024\012\024\012\024\012\024\011\022\011\022\012\023\012\023\012\023\012\024\012\024\012\024\000\021\011\021\012\012\022\011\021\021\012\022\012\011\011\011\014\012\012\014\014\001\001\001\001\001\001\002\002\002\002\002\002\002\002\000\010\000\001\001\001\002\001\002\001\000\100\100\100\100\100\100\100\100\177\010\011\011\011\001\011\011\001\001\177\100\001\001\000\010"; |
|
||||||
|
|
||||||
/* stackDelta contains \100 if stack count of opcode is variable |
|
||||||
* \177 if opcode is illegal, or 8*stack_push + stack_pop otherwise |
|
||||||
* The above values are extracted from following list with: |
|
||||||
* perl -ne'/"(.*)"/ and print $1' |
|
||||||
* |
|
||||||
* "\000" // nop
|
|
||||||
* "\010\010\010\010\010\010\010\010" // aconst_null, iconst_m?[0-5]
|
|
||||||
* "\020\020\010\010\010\020\020" // [lfd]const_[0-2]
|
|
||||||
* "\010\010\010\010\020" // sipush bipush ldcx
|
|
||||||
* "\010\020\010\020\010" // [ilfda]load
|
|
||||||
* "\010\010\010\010" |
|
||||||
* "\020\020\020\020" |
|
||||||
* "\010\010\010\010" |
|
||||||
* "\020\020\020\020" |
|
||||||
* "\010\010\010\010" |
|
||||||
* "\012\022\012\022\012\012\012\012" // [ilfdabcs]aload
|
|
||||||
* "\001\002\001\002\001" // [ilfda]store
|
|
||||||
* "\001\001\001\001" |
|
||||||
* "\002\002\002\002" |
|
||||||
* "\001\001\001\001" |
|
||||||
* "\002\002\002\002" |
|
||||||
* "\001\001\001\001" |
|
||||||
* "\003\004\003\004\003\003\003\003" // [ilfdabcs]astore
|
|
||||||
* "\001\002" // pop
|
|
||||||
* "\021\032\043\042\053\064" // dup2?(_x[12])?
|
|
||||||
* "\022" // swap
|
|
||||||
* "\012\024\012\024" // [ilfd]add
|
|
||||||
* "\012\024\012\024" // [ilfd]sub
|
|
||||||
* "\012\024\012\024" // [ilfd]mul
|
|
||||||
* "\012\024\012\024" // [ilfd]div
|
|
||||||
* "\012\024\012\024" // [ilfd]rem
|
|
||||||
* "\011\022\011\022" // [ilfd]neg
|
|
||||||
* "\012\023\012\023\012\023" // [il]u?sh[lr]
|
|
||||||
* "\012\024\012\024\012\024" // [il](and|or|xor)
|
|
||||||
* "\000" // opc_iinc
|
|
||||||
* "\021\011\021" // i2[lfd]
|
|
||||||
* "\012\012\022" // l2[ifd]
|
|
||||||
* "\011\021\021" // f2[ild]
|
|
||||||
* "\012\022\012" // d2[ilf]
|
|
||||||
* "\011\011\011" // i2[bcs]
|
|
||||||
* "\014\012\012\014\014" // [lfd]cmp.?
|
|
||||||
* "\001\001\001\001\001\001" // if..
|
|
||||||
* "\002\002\002\002\002\002" // if_icmp..
|
|
||||||
* "\002\002" // if_acmp..
|
|
||||||
* "\000\010\000\001\001" // goto,jsr,ret, .*switch
|
|
||||||
* "\001\002\001\002\001\000" // [ilfda]?return
|
|
||||||
* "\100\100\100\100" // (get/put)(static|field)
|
|
||||||
* "\100\100\100\100" // invoke.*
|
|
||||||
* "\177\010\011\011\011" // 186 - 190
|
|
||||||
* "\001\011\011\001\001" // 191 - 195
|
|
||||||
* "\177\100\001\001" // 196 - 199
|
|
||||||
* "\000\010" // goto_w, jsr_w
|
|
||||||
*/ |
|
||||||
} |
|
@ -1,29 +0,0 @@ |
|||||||
/* LineNumber Copyright (C) 1999-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.bytecode; |
|
||||||
|
|
||||||
/** |
|
||||||
* A simple class containing the info of the LineNumberTable |
|
||||||
*/ |
|
||||||
public class LineNumber { |
|
||||||
public Instruction start; |
|
||||||
public int linenr; |
|
||||||
} |
|
||||||
|
|
@ -1,30 +0,0 @@ |
|||||||
/* LocalVariableInfo Copyright (C) 1999-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.bytecode; |
|
||||||
|
|
||||||
/** |
|
||||||
* A simple class containing the info of the LocalVariableTable |
|
||||||
*/ |
|
||||||
public class LocalVariableInfo { |
|
||||||
public Instruction start, end; |
|
||||||
public String name, type; |
|
||||||
public int slot; |
|
||||||
} |
|
||||||
|
|
@ -1,45 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
JAR = @JAR@
|
|
||||||
JAVAC = @JAVAC@
|
|
||||||
JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\
|
|
||||||
-dependdir=$(top_builddir) -classpath=$(top_builddir):$(top_srcdir) \
|
|
||||||
-depfile=Makefile.dep
|
|
||||||
CLASSPATH = @CLASSPATH@
|
|
||||||
CLASSLIB = @CLASSLIB@
|
|
||||||
SUBSTCP = @SUBSTCP@
|
|
||||||
FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB))
|
|
||||||
|
|
||||||
MY_JAVA_FILES = \
|
|
||||||
BinaryInfo.java \
|
|
||||||
BytecodeInfo.java \
|
|
||||||
ClassFormatException.java \
|
|
||||||
ClassInfo.java \
|
|
||||||
ConstantPool.java \
|
|
||||||
FieldInfo.java \
|
|
||||||
GrowableConstantPool.java \
|
|
||||||
Handler.java \
|
|
||||||
InnerClassInfo.java \
|
|
||||||
Instruction.java \
|
|
||||||
LineNumber.java \
|
|
||||||
LocalVariableInfo.java \
|
|
||||||
MethodInfo.java \
|
|
||||||
Opcodes.java \
|
|
||||||
Reference.java \
|
|
||||||
SearchPath.java \
|
|
||||||
TypeSignature.java
|
|
||||||
|
|
||||||
noinst_DATA = $(MY_JAVA_FILES:.java=.class)
|
|
||||||
EXTRA_DIST = $(MY_JAVA_FILES)
|
|
||||||
|
|
||||||
@QUOTE@-include Makefile.dep |
|
||||||
|
|
||||||
%.class: %.java |
|
||||||
$(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $<
|
|
||||||
|
|
||||||
Makefile.dep: $(MY_JAVA_FILES:.java=.class) |
|
||||||
$(JAVADEP) $^
|
|
||||||
|
|
||||||
clean-local: |
|
||||||
@rm -f *.class
|
|
||||||
@rm -f *.dep
|
|
@ -1,241 +0,0 @@ |
|||||||
/* MethodInfo Copyright (C) 1998-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.bytecode; |
|
||||||
import java.io.DataInputStream; |
|
||||||
import java.io.DataOutputStream; |
|
||||||
import java.io.IOException; |
|
||||||
import java.lang.reflect.Modifier; |
|
||||||
|
|
||||||
public class MethodInfo extends BinaryInfo { |
|
||||||
|
|
||||||
ClassInfo clazzInfo; |
|
||||||
|
|
||||||
int modifier; |
|
||||||
String name; |
|
||||||
String typeSig; |
|
||||||
|
|
||||||
BytecodeInfo bytecode; |
|
||||||
String[] exceptions; |
|
||||||
boolean syntheticFlag; |
|
||||||
boolean deprecatedFlag; |
|
||||||
|
|
||||||
public MethodInfo(ClassInfo ci) { |
|
||||||
clazzInfo = ci; |
|
||||||
} |
|
||||||
|
|
||||||
public MethodInfo(ClassInfo ci, |
|
||||||
String name, String typeSig, int modifier) { |
|
||||||
this.clazzInfo = ci; |
|
||||||
this.name = name; |
|
||||||
this.typeSig = typeSig; |
|
||||||
this.modifier = modifier; |
|
||||||
} |
|
||||||
|
|
||||||
protected void readAttribute(String name, int length, ConstantPool cp, |
|
||||||
DataInputStream input, |
|
||||||
int howMuch) throws IOException { |
|
||||||
if (name.equals("Code")) { |
|
||||||
if ((howMuch & KNOWNATTRIBS) != 0) { |
|
||||||
bytecode = new BytecodeInfo(this); |
|
||||||
bytecode.read(cp, input); |
|
||||||
} else |
|
||||||
input.readFully(new byte[length]); |
|
||||||
} else if (name.equals("Exceptions")) { |
|
||||||
int count = input.readUnsignedShort(); |
|
||||||
exceptions = new String[count]; |
|
||||||
for (int i=0; i< count; i++) |
|
||||||
exceptions[i] = cp.getClassName(input.readUnsignedShort()); |
|
||||||
if (length != 2 * (count + 1)) |
|
||||||
throw new ClassFormatException |
|
||||||
("Exceptions attribute has wrong length"); |
|
||||||
} else if (name.equals("Synthetic")) { |
|
||||||
syntheticFlag = true; |
|
||||||
if (length != 0) |
|
||||||
throw new ClassFormatException |
|
||||||
("Synthetic attribute has wrong length"); |
|
||||||
} else if (name.equals("Deprecated")) { |
|
||||||
deprecatedFlag = true; |
|
||||||
if (length != 0) |
|
||||||
throw new ClassFormatException |
|
||||||
("Deprecated attribute has wrong length"); |
|
||||||
} else |
|
||||||
super.readAttribute(name, length, cp, input, howMuch); |
|
||||||
} |
|
||||||
|
|
||||||
public void read(ConstantPool constantPool, |
|
||||||
DataInputStream input, int howMuch) throws IOException { |
|
||||||
modifier = input.readUnsignedShort(); |
|
||||||
name = constantPool.getUTF8(input.readUnsignedShort()); |
|
||||||
typeSig = constantPool.getUTF8(input.readUnsignedShort()); |
|
||||||
readAttributes(constantPool, input, howMuch); |
|
||||||
} |
|
||||||
|
|
||||||
public void reserveSmallConstants(GrowableConstantPool gcp) { |
|
||||||
if (bytecode != null) |
|
||||||
bytecode.reserveSmallConstants(gcp); |
|
||||||
} |
|
||||||
|
|
||||||
public void prepareWriting(GrowableConstantPool gcp) { |
|
||||||
gcp.putUTF8(name); |
|
||||||
gcp.putUTF8(typeSig); |
|
||||||
if (bytecode != null) { |
|
||||||
gcp.putUTF8("Code"); |
|
||||||
bytecode.prepareWriting(gcp); |
|
||||||
} |
|
||||||
if (exceptions != null) { |
|
||||||
gcp.putUTF8("Exceptions"); |
|
||||||
for (int i=0; i< exceptions.length; i++) |
|
||||||
gcp.putClassName(exceptions[i]); |
|
||||||
} |
|
||||||
if (syntheticFlag) |
|
||||||
gcp.putUTF8("Synthetic"); |
|
||||||
if (deprecatedFlag) |
|
||||||
gcp.putUTF8("Deprecated"); |
|
||||||
prepareAttributes(gcp); |
|
||||||
} |
|
||||||
|
|
||||||
protected int getKnownAttributeCount() { |
|
||||||
int count = 0; |
|
||||||
if (bytecode != null) |
|
||||||
count++; |
|
||||||
if (exceptions != null) |
|
||||||
count++; |
|
||||||
if (syntheticFlag) |
|
||||||
count++; |
|
||||||
if (deprecatedFlag) |
|
||||||
count++; |
|
||||||
return count; |
|
||||||
} |
|
||||||
|
|
||||||
public void writeKnownAttributes(GrowableConstantPool gcp, |
|
||||||
DataOutputStream output) |
|
||||||
throws IOException { |
|
||||||
if (bytecode != null) { |
|
||||||
output.writeShort(gcp.putUTF8("Code")); |
|
||||||
output.writeInt(bytecode.getSize()); |
|
||||||
bytecode.write(gcp, output); |
|
||||||
} |
|
||||||
if (exceptions != null) { |
|
||||||
int count = exceptions.length; |
|
||||||
output.writeShort(gcp.putUTF8("Exceptions")); |
|
||||||
output.writeInt(2 + count * 2); |
|
||||||
output.writeShort(count); |
|
||||||
for (int i=0; i< count; i++) |
|
||||||
output.writeShort(gcp.putClassName(exceptions[i])); |
|
||||||
} |
|
||||||
if (syntheticFlag) { |
|
||||||
output.writeShort(gcp.putUTF8("Synthetic")); |
|
||||||
output.writeInt(0); |
|
||||||
} |
|
||||||
if (deprecatedFlag) { |
|
||||||
output.writeShort(gcp.putUTF8("Deprecated")); |
|
||||||
output.writeInt(0); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void write(GrowableConstantPool constantPool, |
|
||||||
DataOutputStream output) throws IOException { |
|
||||||
output.writeShort(modifier); |
|
||||||
output.writeShort(constantPool.putUTF8(name)); |
|
||||||
output.writeShort(constantPool.putUTF8(typeSig)); |
|
||||||
writeAttributes(constantPool, output); |
|
||||||
} |
|
||||||
|
|
||||||
public void dropInfo(int howMuch) { |
|
||||||
if ((howMuch & KNOWNATTRIBS) != 0) { |
|
||||||
bytecode = null; |
|
||||||
exceptions = null; |
|
||||||
} |
|
||||||
if (bytecode != null) |
|
||||||
bytecode.dropInfo(howMuch); |
|
||||||
super.dropInfo(howMuch); |
|
||||||
} |
|
||||||
|
|
||||||
public ClassInfo getClazzInfo() { |
|
||||||
return clazzInfo; |
|
||||||
} |
|
||||||
|
|
||||||
public String getName() { |
|
||||||
return name; |
|
||||||
} |
|
||||||
|
|
||||||
public String getType() { |
|
||||||
return typeSig; |
|
||||||
} |
|
||||||
|
|
||||||
public int getModifiers() { |
|
||||||
return modifier; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isStatic() { |
|
||||||
return Modifier.isStatic(modifier); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isSynthetic() { |
|
||||||
return syntheticFlag; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isDeprecated() { |
|
||||||
return deprecatedFlag; |
|
||||||
} |
|
||||||
|
|
||||||
public BytecodeInfo getBytecode() { |
|
||||||
return bytecode; |
|
||||||
} |
|
||||||
|
|
||||||
public String[] getExceptions() { |
|
||||||
return exceptions; |
|
||||||
} |
|
||||||
|
|
||||||
public void setName(String newName) { |
|
||||||
name = newName; |
|
||||||
} |
|
||||||
|
|
||||||
public void setType(String newType) { |
|
||||||
typeSig = newType; |
|
||||||
} |
|
||||||
|
|
||||||
public void setModifiers(int newModifier) { |
|
||||||
modifier = newModifier; |
|
||||||
} |
|
||||||
|
|
||||||
public void setSynthetic(boolean flag) { |
|
||||||
syntheticFlag = flag; |
|
||||||
} |
|
||||||
|
|
||||||
public void setDeprecated(boolean flag) { |
|
||||||
deprecatedFlag = flag; |
|
||||||
} |
|
||||||
|
|
||||||
public void setBytecode(BytecodeInfo newBytecode) { |
|
||||||
clazzInfo.loadInfo(KNOWNATTRIBS); |
|
||||||
bytecode = newBytecode; |
|
||||||
} |
|
||||||
|
|
||||||
public void setExceptions(String[] newExceptions) { |
|
||||||
clazzInfo.loadInfo(KNOWNATTRIBS); |
|
||||||
exceptions = newExceptions; |
|
||||||
} |
|
||||||
|
|
||||||
public String toString() { |
|
||||||
return "Method "+Modifier.toString(modifier)+" "+ |
|
||||||
typeSig + " " + clazzInfo.getName() + "."+ name; |
|
||||||
} |
|
||||||
} |
|
@ -1,581 +0,0 @@ |
|||||||
/* SearchPath Copyright (C) 1998-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.bytecode; |
|
||||||
import java.io.ByteArrayInputStream; |
|
||||||
import java.io.File; |
|
||||||
import java.io.FileInputStream; |
|
||||||
import java.io.FileNotFoundException; |
|
||||||
import java.io.FilterInputStream; |
|
||||||
import java.io.IOException; |
|
||||||
import java.io.InputStream; |
|
||||||
import java.net.MalformedURLException; |
|
||||||
import java.net.URL; |
|
||||||
import java.net.URLConnection; |
|
||||||
import java.util.Enumeration; |
|
||||||
import java.util.Hashtable; |
|
||||||
import java.util.StringTokenizer; |
|
||||||
import java.util.Vector; |
|
||||||
import java.util.zip.ZipEntry; |
|
||||||
import java.util.zip.ZipFile; |
|
||||||
import java.util.zip.ZipInputStream; |
|
||||||
import jode.GlobalOptions; |
|
||||||
|
|
||||||
/** |
|
||||||
* This class represents a path of multiple directories and/or zip files, |
|
||||||
* where we can search for file names. |
|
||||||
* |
|
||||||
* @author Jochen Hoenicke |
|
||||||
*/ |
|
||||||
public class SearchPath { |
|
||||||
|
|
||||||
/** |
|
||||||
* We need a different pathSeparatorChar, since ':' (used for most |
|
||||||
* UNIX System) is used a protocol separator in URLs. |
|
||||||
* |
|
||||||
* We currently allow both pathSeparatorChar and |
|
||||||
* altPathSeparatorChar and decide if it is a protocol separator |
|
||||||
* by context. |
|
||||||
*/ |
|
||||||
public static final char altPathSeparatorChar = ','; |
|
||||||
URL[] bases; |
|
||||||
byte[][] urlzips; |
|
||||||
File[] dirs; |
|
||||||
ZipFile[] zips; |
|
||||||
String[] zipDirs; |
|
||||||
Hashtable[] zipEntries; |
|
||||||
|
|
||||||
private static void addEntry(Hashtable entries, String name) { |
|
||||||
String dir = ""; |
|
||||||
int pathsep = name.lastIndexOf("/"); |
|
||||||
if (pathsep != -1) { |
|
||||||
dir = name.substring(0, pathsep); |
|
||||||
name = name.substring(pathsep+1); |
|
||||||
} |
|
||||||
|
|
||||||
Vector dirContent = (Vector) entries.get(dir); |
|
||||||
if (dirContent == null) { |
|
||||||
dirContent = new Vector(); |
|
||||||
entries.put(dir, dirContent); |
|
||||||
if (dir != "") |
|
||||||
addEntry(entries, dir); |
|
||||||
} |
|
||||||
dirContent.addElement(name); |
|
||||||
} |
|
||||||
|
|
||||||
private void fillZipEntries(int nr) { |
|
||||||
Enumeration zipEnum = zips[nr].entries(); |
|
||||||
zipEntries[nr] = new Hashtable(); |
|
||||||
while (zipEnum.hasMoreElements()) { |
|
||||||
ZipEntry ze = (ZipEntry) zipEnum.nextElement(); |
|
||||||
String name = ze.getName(); |
|
||||||
// if (name.charAt(0) == '/')
|
|
||||||
// name = name.substring(1);
|
|
||||||
if (zipDirs[nr] != null) { |
|
||||||
if (!name.startsWith(zipDirs[nr])) |
|
||||||
continue; |
|
||||||
name = name.substring(zipDirs[nr].length()); |
|
||||||
} |
|
||||||
if (!ze.isDirectory() && name.endsWith(".class")) |
|
||||||
addEntry(zipEntries[nr], name); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void readURLZip(int nr, URLConnection conn) { |
|
||||||
int length = conn.getContentLength(); |
|
||||||
if (length <= 0) |
|
||||||
// Give a approximation if length is unknown
|
|
||||||
length = 10240; |
|
||||||
else |
|
||||||
// Increase the length by one, so we hopefully don't need
|
|
||||||
// to grow the array later (we need a little overshot to
|
|
||||||
// know when the end is reached).
|
|
||||||
length++; |
|
||||||
|
|
||||||
urlzips[nr] = new byte[length]; |
|
||||||
try { |
|
||||||
InputStream is = conn.getInputStream(); |
|
||||||
int pos = 0; |
|
||||||
for (;;) { |
|
||||||
// This is ugly, is.available() may return zero even
|
|
||||||
// if there are more bytes.
|
|
||||||
int avail = Math.max(is.available(), 1); |
|
||||||
if (pos + is.available() > urlzips[nr].length) { |
|
||||||
// grow the byte array.
|
|
||||||
byte[] newarr = new byte |
|
||||||
[Math.max(2*urlzips[nr].length, pos + is.available())]; |
|
||||||
System.arraycopy(urlzips[nr], 0, newarr, 0, pos); |
|
||||||
urlzips[nr] = newarr; |
|
||||||
} |
|
||||||
int count = is.read(urlzips[nr], pos, urlzips[nr].length-pos); |
|
||||||
if (count == -1) |
|
||||||
break; |
|
||||||
pos += count; |
|
||||||
} |
|
||||||
if (pos < urlzips[nr].length) { |
|
||||||
// shrink the byte array again.
|
|
||||||
byte[] newarr = new byte[pos]; |
|
||||||
System.arraycopy(urlzips[nr], 0, newarr, 0, pos); |
|
||||||
urlzips[nr] = newarr; |
|
||||||
} |
|
||||||
} catch (IOException ex) { |
|
||||||
GlobalOptions.err.println("IOException while reading " |
|
||||||
+"remote zip file "+bases[nr]); |
|
||||||
// disable entry
|
|
||||||
bases[nr] = null; |
|
||||||
urlzips[nr] = null; |
|
||||||
return; |
|
||||||
} |
|
||||||
try { |
|
||||||
// fill entries into hash table
|
|
||||||
ZipInputStream zis = new ZipInputStream |
|
||||||
(new ByteArrayInputStream(urlzips[nr])); |
|
||||||
zipEntries[nr] = new Hashtable(); |
|
||||||
ZipEntry ze; |
|
||||||
while ((ze = zis.getNextEntry()) != null) { |
|
||||||
String name = ze.getName(); |
|
||||||
// if (name.charAt(0) == '/')
|
|
||||||
// name = name.substring(1);
|
|
||||||
if (zipDirs[nr] != null) { |
|
||||||
if (!name.startsWith(zipDirs[nr])) |
|
||||||
continue; |
|
||||||
name = name.substring(zipDirs[nr].length()); |
|
||||||
} |
|
||||||
if (!ze.isDirectory() && name.endsWith(".class")) |
|
||||||
addEntry(zipEntries[nr], name); |
|
||||||
zis.closeEntry(); |
|
||||||
} |
|
||||||
zis.close(); |
|
||||||
} catch (IOException ex) { |
|
||||||
GlobalOptions.err.println("Remote zip file "+bases[nr] |
|
||||||
+" is corrupted."); |
|
||||||
// disable entry
|
|
||||||
bases[nr] = null; |
|
||||||
urlzips[nr] = null; |
|
||||||
zipEntries[nr] = null; |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a new search path for the given path. |
|
||||||
* @param path The path where we should search for files. They |
|
||||||
* should be separated by the system dependent pathSeparator. The |
|
||||||
* entries may also be zip or jar files. |
|
||||||
*/ |
|
||||||
public SearchPath(String path) { |
|
||||||
// Calculate a good approximation (rounded upwards) of the tokens
|
|
||||||
// in this path.
|
|
||||||
int length = 1; |
|
||||||
for (int index=path.indexOf(File.pathSeparatorChar); |
|
||||||
index != -1; length++) |
|
||||||
index = path.indexOf(File.pathSeparatorChar, index+1); |
|
||||||
if (File.pathSeparatorChar != altPathSeparatorChar) { |
|
||||||
for (int index=path.indexOf(altPathSeparatorChar); |
|
||||||
index != -1; length++) |
|
||||||
index = path.indexOf(altPathSeparatorChar, index+1); |
|
||||||
} |
|
||||||
bases = new URL[length]; |
|
||||||
urlzips = new byte[length][]; |
|
||||||
dirs = new File[length]; |
|
||||||
zips = new ZipFile[length]; |
|
||||||
zipEntries = new Hashtable[length]; |
|
||||||
zipDirs = new String[length]; |
|
||||||
int i = 0; |
|
||||||
for (int ptr=0; ptr < path.length(); ptr++, i++) { |
|
||||||
int next = ptr; |
|
||||||
while (next < path.length() |
|
||||||
&& path.charAt(next) != File.pathSeparatorChar |
|
||||||
&& path.charAt(next) != altPathSeparatorChar) |
|
||||||
next++; |
|
||||||
|
|
||||||
int index = ptr; |
|
||||||
colon_separator: |
|
||||||
while (next > ptr |
|
||||||
&& next < path.length() |
|
||||||
&& path.charAt(next) == ':') { |
|
||||||
// Check if this is a URL instead of a pathSeparator
|
|
||||||
// Since this is a while loop it allows nested urls like
|
|
||||||
// jar:ftp://ftp.foo.org/pub/foo.jar!/
|
|
||||||
|
|
||||||
while (index < next) { |
|
||||||
char c = path.charAt(index); |
|
||||||
// According to RFC 1738 letters, digits, '+', '-'
|
|
||||||
// and '.' are allowed SCHEMA characters. We
|
|
||||||
// disallow '.' because it is a good marker that
|
|
||||||
// the user has specified a filename instead of a
|
|
||||||
// URL.
|
|
||||||
if ((c < 'A' || c > 'Z') |
|
||||||
&& (c < 'a' || c > 'z') |
|
||||||
&& (c < '0' || c > '9') |
|
||||||
&& "+-".indexOf(c) == -1) { |
|
||||||
break colon_separator; |
|
||||||
} |
|
||||||
index++; |
|
||||||
} |
|
||||||
next++; |
|
||||||
index++; |
|
||||||
while (next < path.length() |
|
||||||
&& path.charAt(next) != File.pathSeparatorChar |
|
||||||
&& path.charAt(next) != altPathSeparatorChar) |
|
||||||
next++; |
|
||||||
} |
|
||||||
String token = path.substring(ptr, next); |
|
||||||
ptr = next; |
|
||||||
|
|
||||||
boolean mustBeJar = false; |
|
||||||
// We handle jar URL's ourself.
|
|
||||||
if (token.startsWith("jar:")) { |
|
||||||
index = 0; |
|
||||||
do { |
|
||||||
index = token.indexOf('!', index); |
|
||||||
} while (index != -1 && index != token.length()-1 |
|
||||||
&& token.charAt(index+1) != '/'); |
|
||||||
|
|
||||||
if (index == -1 || index == token.length()-1) { |
|
||||||
GlobalOptions.err.println("Warning: Illegal jar url " |
|
||||||
+ token + "."); |
|
||||||
continue; |
|
||||||
} |
|
||||||
zipDirs[i] = token.substring(index+2); |
|
||||||
if (!zipDirs[i].endsWith("/")) |
|
||||||
zipDirs[i] = zipDirs[i] + "/"; |
|
||||||
token = token.substring(4, index); |
|
||||||
mustBeJar = true; |
|
||||||
} |
|
||||||
index = token.indexOf(':'); |
|
||||||
if (index != -1 && index < token.length()-2 |
|
||||||
&& token.charAt(index+1) == '/' |
|
||||||
&& token.charAt(index+2) == '/') { |
|
||||||
// This looks like an URL.
|
|
||||||
try { |
|
||||||
bases[i] = new URL(token); |
|
||||||
try { |
|
||||||
URLConnection connection = bases[i].openConnection(); |
|
||||||
if (mustBeJar |
|
||||||
|| token.endsWith(".zip") || token.endsWith(".jar") |
|
||||||
|| connection.getContentType().endsWith("/zip")) { |
|
||||||
// This is a zip file. Read it into memory.
|
|
||||||
readURLZip(i, connection); |
|
||||||
} |
|
||||||
} catch (IOException ex) { |
|
||||||
// ignore
|
|
||||||
} catch (SecurityException ex) { |
|
||||||
GlobalOptions.err.println |
|
||||||
("Warning: Security exception while accessing " |
|
||||||
+ bases[i] + "."); |
|
||||||
} |
|
||||||
} catch (MalformedURLException ex) { |
|
||||||
/* disable entry */ |
|
||||||
bases[i] = null; |
|
||||||
dirs[i] = null; |
|
||||||
} |
|
||||||
} else { |
|
||||||
try { |
|
||||||
dirs[i] = new File(token); |
|
||||||
if (mustBeJar || !dirs[i].isDirectory()) { |
|
||||||
try { |
|
||||||
zips[i] = new ZipFile(dirs[i]); |
|
||||||
} catch (java.io.IOException ex) { |
|
||||||
/* disable this entry */ |
|
||||||
dirs[i] = null; |
|
||||||
} |
|
||||||
} |
|
||||||
} catch (SecurityException ex) { |
|
||||||
/* disable this entry */ |
|
||||||
GlobalOptions.err.println |
|
||||||
("Warning: SecurityException while accessing " |
|
||||||
+ token + "."); |
|
||||||
dirs[i] = null; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public boolean exists(String filename) { |
|
||||||
String localFileName = |
|
||||||
(java.io.File.separatorChar != '/') |
|
||||||
? filename.replace('/', java.io.File.separatorChar) |
|
||||||
: filename; |
|
||||||
for (int i=0; i<dirs.length; i++) { |
|
||||||
if (zipEntries[i] != null) { |
|
||||||
if (zipEntries[i].get(filename) != null) |
|
||||||
return true; |
|
||||||
|
|
||||||
String dir = ""; |
|
||||||
String name = filename; |
|
||||||
int index = filename.lastIndexOf('/'); |
|
||||||
if (index >= 0) { |
|
||||||
dir = filename.substring(0, index); |
|
||||||
name = filename.substring(index+1); |
|
||||||
} |
|
||||||
Vector directory = (Vector)zipEntries[i].get(dir); |
|
||||||
if (directory != null && directory.contains(name)) |
|
||||||
return true; |
|
||||||
continue; |
|
||||||
} |
|
||||||
if (bases[i] != null) { |
|
||||||
try { |
|
||||||
URL url = new URL(bases[i], filename); |
|
||||||
URLConnection conn = url.openConnection(); |
|
||||||
conn.connect(); |
|
||||||
conn.getInputStream().close(); |
|
||||||
return true; |
|
||||||
} catch (IOException ex) { |
|
||||||
/* ignore */ |
|
||||||
} |
|
||||||
continue; |
|
||||||
} |
|
||||||
if (dirs[i] == null) |
|
||||||
continue; |
|
||||||
if (zips[i] != null) { |
|
||||||
String fullname = zipDirs[i] != null |
|
||||||
? zipDirs[i] + filename : filename; |
|
||||||
ZipEntry ze = zips[i].getEntry(fullname); |
|
||||||
if (ze != null) |
|
||||||
return true; |
|
||||||
} else { |
|
||||||
try { |
|
||||||
File f = new File(dirs[i], localFileName); |
|
||||||
if (f.exists()) |
|
||||||
return true; |
|
||||||
} catch (SecurityException ex) { |
|
||||||
/* ignore and take next element */ |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Searches for a file in the search path. |
|
||||||
* @param filename the filename. The path components should be separated |
|
||||||
* by <code>/</code>. |
|
||||||
* @return An InputStream for the file. |
|
||||||
*/ |
|
||||||
public InputStream getFile(String filename) throws IOException { |
|
||||||
String localFileName = |
|
||||||
(java.io.File.separatorChar != '/') |
|
||||||
? filename.replace('/', java.io.File.separatorChar) |
|
||||||
: filename; |
|
||||||
for (int i=0; i<dirs.length; i++) { |
|
||||||
if (urlzips[i] != null) { |
|
||||||
ZipInputStream zis = new ZipInputStream |
|
||||||
(new ByteArrayInputStream(urlzips[i])); |
|
||||||
ZipEntry ze; |
|
||||||
String fullname = zipDirs[i] != null |
|
||||||
? zipDirs[i] + filename : filename; |
|
||||||
while ((ze = zis.getNextEntry()) != null) { |
|
||||||
if (ze.getName().equals(fullname)) { |
|
||||||
///#ifdef JDK11
|
|
||||||
/// // The skip method in jdk1.1.7 ZipInputStream
|
|
||||||
/// // is buggy. We return a wrapper that fixes
|
|
||||||
/// // this.
|
|
||||||
/// return new FilterInputStream(zis) {
|
|
||||||
/// private byte[] tmpbuf = new byte[512];
|
|
||||||
/// public long skip(long n) throws IOException {
|
|
||||||
/// long skipped = 0;
|
|
||||||
/// while (n > 0) {
|
|
||||||
/// int count = read(tmpbuf, 0,
|
|
||||||
/// (int)Math.min(n, 512L));
|
|
||||||
/// if (count == -1)
|
|
||||||
/// return skipped;
|
|
||||||
/// skipped += count;
|
|
||||||
/// n -= count;
|
|
||||||
/// }
|
|
||||||
/// return skipped;
|
|
||||||
/// }
|
|
||||||
/// };
|
|
||||||
///#else
|
|
||||||
return zis; |
|
||||||
///#endif
|
|
||||||
} |
|
||||||
zis.closeEntry(); |
|
||||||
} |
|
||||||
continue; |
|
||||||
} |
|
||||||
if (bases[i] != null) { |
|
||||||
try { |
|
||||||
URL url = new URL(bases[i], filename); |
|
||||||
URLConnection conn = url.openConnection(); |
|
||||||
conn.setAllowUserInteraction(true); |
|
||||||
return conn.getInputStream(); |
|
||||||
} catch (SecurityException ex) { |
|
||||||
GlobalOptions.err.println("Warning: SecurityException" |
|
||||||
+ " while accessing " |
|
||||||
+ bases[i] + filename); |
|
||||||
ex.printStackTrace(GlobalOptions.err); |
|
||||||
/* ignore and take next element */ |
|
||||||
} catch (FileNotFoundException ex) { |
|
||||||
/* ignore and take next element */ |
|
||||||
} |
|
||||||
continue; |
|
||||||
} |
|
||||||
if (dirs[i] == null) |
|
||||||
continue; |
|
||||||
if (zips[i] != null) { |
|
||||||
String fullname = zipDirs[i] != null |
|
||||||
? zipDirs[i] + filename : filename; |
|
||||||
ZipEntry ze = zips[i].getEntry(fullname); |
|
||||||
if (ze != null) |
|
||||||
return zips[i].getInputStream(ze); |
|
||||||
} else { |
|
||||||
try { |
|
||||||
File f = new File(dirs[i], localFileName); |
|
||||||
if (f.exists()) |
|
||||||
return new FileInputStream(f); |
|
||||||
} catch (SecurityException ex) { |
|
||||||
GlobalOptions.err.println("Warning: SecurityException" |
|
||||||
+ " while accessing " |
|
||||||
+ dirs[i] + localFileName); |
|
||||||
/* ignore and take next element */ |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
throw new FileNotFoundException(filename); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Searches for a filename in the search path and tells if it is a |
|
||||||
* directory. |
|
||||||
* @param filename the filename. The path components should be separated |
|
||||||
* by <code>/</code>. |
|
||||||
* @return true, if filename exists and is a directory, false otherwise. |
|
||||||
*/ |
|
||||||
public boolean isDirectory(String filename) { |
|
||||||
String localFileName = |
|
||||||
(java.io.File.separatorChar != '/') |
|
||||||
? filename.replace('/', java.io.File.separatorChar) |
|
||||||
: filename; |
|
||||||
for (int i=0; i<dirs.length; i++) { |
|
||||||
if (dirs[i] == null) |
|
||||||
continue; |
|
||||||
if (zips[i] != null && zipEntries[i] == null) |
|
||||||
fillZipEntries(i); |
|
||||||
|
|
||||||
if (zipEntries[i] != null) { |
|
||||||
if (zipEntries[i].containsKey(filename)) |
|
||||||
return true; |
|
||||||
} else { |
|
||||||
try { |
|
||||||
File f = new File(dirs[i], localFileName); |
|
||||||
if (f.exists()) |
|
||||||
return f.isDirectory(); |
|
||||||
} catch (SecurityException ex) { |
|
||||||
GlobalOptions.err.println("Warning: SecurityException" |
|
||||||
+ " while accessing " |
|
||||||
+ dirs[i] + localFileName); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Searches for all files in the given directory. |
|
||||||
* @param dirName the directory name. The path components should |
|
||||||
* be separated by <code>/</code>. |
|
||||||
* @return An enumeration with all files/directories in the given |
|
||||||
* directory. */ |
|
||||||
public Enumeration listFiles(final String dirName) { |
|
||||||
return new Enumeration() { |
|
||||||
int pathNr; |
|
||||||
Enumeration zipEnum; |
|
||||||
int fileNr; |
|
||||||
String localDirName = |
|
||||||
(java.io.File.separatorChar != '/') |
|
||||||
? dirName.replace('/', java.io.File.separatorChar) |
|
||||||
: dirName; |
|
||||||
File currentDir; |
|
||||||
String[] files; |
|
||||||
|
|
||||||
public String findNextFile() { |
|
||||||
while (true) { |
|
||||||
if (zipEnum != null) { |
|
||||||
while (zipEnum.hasMoreElements()) { |
|
||||||
return (String) zipEnum.nextElement(); |
|
||||||
} |
|
||||||
zipEnum = null; |
|
||||||
} |
|
||||||
if (files != null) { |
|
||||||
while (fileNr < files.length) { |
|
||||||
String name = files[fileNr++]; |
|
||||||
if (name.endsWith(".class")) { |
|
||||||
return name; |
|
||||||
} else if (name.indexOf(".") == -1) { |
|
||||||
/* ignore directories containing a dot. |
|
||||||
* they can't be a package directory. |
|
||||||
*/ |
|
||||||
File f = new File(currentDir, name); |
|
||||||
if (f.exists() && f.isDirectory()) |
|
||||||
return name; |
|
||||||
} |
|
||||||
} |
|
||||||
files = null; |
|
||||||
} |
|
||||||
if (pathNr == dirs.length) |
|
||||||
return null; |
|
||||||
|
|
||||||
if (zips[pathNr] != null && zipEntries[pathNr] == null) |
|
||||||
fillZipEntries(pathNr); |
|
||||||
|
|
||||||
if (zipEntries[pathNr] != null) { |
|
||||||
Vector entries = |
|
||||||
(Vector) zipEntries[pathNr].get(dirName); |
|
||||||
if (entries != null) |
|
||||||
zipEnum = entries.elements(); |
|
||||||
} else if (dirs[pathNr] != null) { |
|
||||||
try { |
|
||||||
File f = new File(dirs[pathNr], localDirName); |
|
||||||
if (f.exists() && f.isDirectory()) { |
|
||||||
currentDir = f; |
|
||||||
files = f.list(); |
|
||||||
fileNr = 0; |
|
||||||
} |
|
||||||
} catch (SecurityException ex) { |
|
||||||
GlobalOptions.err.println |
|
||||||
("Warning: SecurityException" |
|
||||||
+ " while accessing " |
|
||||||
+ dirs[pathNr] + localDirName); |
|
||||||
/* ignore and take next element */ |
|
||||||
} |
|
||||||
} |
|
||||||
pathNr++; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
String nextName; |
|
||||||
|
|
||||||
public boolean hasMoreElements() { |
|
||||||
return (nextName != null |
|
||||||
|| (nextName = findNextFile()) != null); |
|
||||||
} |
|
||||||
|
|
||||||
public Object nextElement() { |
|
||||||
if (nextName == null) |
|
||||||
return findNextFile(); |
|
||||||
else { |
|
||||||
String result = nextName; |
|
||||||
nextName = null; |
|
||||||
return result; |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
} |
|
@ -1,2 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
@ -1,116 +0,0 @@ |
|||||||
/* DeadCodeAnalysis Copyright (C) 1999-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.decompiler; |
|
||||||
import jode.bytecode.BytecodeInfo; |
|
||||||
import jode.bytecode.Instruction; |
|
||||||
import jode.bytecode.Handler; |
|
||||||
|
|
||||||
import @COLLECTIONS@.Iterator; |
|
||||||
|
|
||||||
public class DeadCodeAnalysis { |
|
||||||
|
|
||||||
private final static String REACHABLE = "R"; |
|
||||||
private final static String REACHCHANGED = "C"; |
|
||||||
|
|
||||||
private static void propagateReachability(BytecodeInfo code) { |
|
||||||
boolean changed; |
|
||||||
do { |
|
||||||
changed = false; |
|
||||||
for (Iterator iter = code.getInstructions().iterator(); |
|
||||||
iter.hasNext(); ) { |
|
||||||
Instruction instr = (Instruction) iter.next(); |
|
||||||
if (instr.getTmpInfo() == REACHCHANGED) { |
|
||||||
changed = true; |
|
||||||
instr.setTmpInfo(REACHABLE); |
|
||||||
Instruction[] succs = instr.getSuccs(); |
|
||||||
if (succs != null) |
|
||||||
for (int i=0; i< succs.length; i++) |
|
||||||
if (succs[i].getTmpInfo() == null) |
|
||||||
succs[i].setTmpInfo(REACHCHANGED); |
|
||||||
if (!instr.doesAlwaysJump() |
|
||||||
&& instr.getNextByAddr() != null) |
|
||||||
if (instr.getNextByAddr().getTmpInfo() == null) |
|
||||||
instr.getNextByAddr().setTmpInfo(REACHCHANGED); |
|
||||||
/*XXX code after jsr reachable iff ret is reachable...*/ |
|
||||||
if (instr.getOpcode() == Opcodes.opc_jsr) |
|
||||||
if (instr.getNextByAddr().getTmpInfo() == null) |
|
||||||
instr.getNextByAddr().setTmpInfo(REACHCHANGED); |
|
||||||
} |
|
||||||
} |
|
||||||
} while (changed); |
|
||||||
} |
|
||||||
|
|
||||||
public static void removeDeadCode(BytecodeInfo code) { |
|
||||||
((Instruction) code.getInstructions().get(0)).setTmpInfo(REACHCHANGED); |
|
||||||
propagateReachability(code); |
|
||||||
Handler[] handlers = code.getExceptionHandlers(); |
|
||||||
boolean changed; |
|
||||||
do { |
|
||||||
changed = false; |
|
||||||
for (int i=0; i < handlers.length; i++) { |
|
||||||
if (handlers[i].catcher.getTmpInfo() == null) { |
|
||||||
/* check if the try block is somewhere reachable |
|
||||||
* and mark the catcher as reachable then. |
|
||||||
*/ |
|
||||||
for (Instruction instr = handlers[i].start; |
|
||||||
instr != null; instr = instr.getNextByAddr()) { |
|
||||||
if (instr.getTmpInfo() != null) { |
|
||||||
handlers[i].catcher.setTmpInfo(REACHCHANGED); |
|
||||||
propagateReachability(code); |
|
||||||
changed = true; |
|
||||||
break; |
|
||||||
} |
|
||||||
if (instr == handlers[i].end) |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} while (changed); |
|
||||||
|
|
||||||
for (int i=0; i< handlers.length; i++) { |
|
||||||
/* A handler is not reachable iff the catcher is not reachable */ |
|
||||||
if (handlers[i].catcher.getTmpInfo() == null) { |
|
||||||
/* This is very seldom, so we can make it slow */ |
|
||||||
Handler[] newHandlers = new Handler[handlers.length - 1]; |
|
||||||
System.arraycopy(handlers, 0, newHandlers, 0, i); |
|
||||||
System.arraycopy(handlers, i+1, newHandlers, i, |
|
||||||
handlers.length - (i+1)); |
|
||||||
handlers = newHandlers; |
|
||||||
code.setExceptionHandlers(newHandlers); |
|
||||||
i--; |
|
||||||
} else { |
|
||||||
/* This works! */ |
|
||||||
while (handlers[i].start.getTmpInfo() == null) |
|
||||||
handlers[i].start = handlers[i].start.getNextByAddr(); |
|
||||||
while (handlers[i].end.getTmpInfo() == null) |
|
||||||
handlers[i].end = handlers[i].end.getPrevByAddr(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* Now remove the dead code and clean up tmpInfo */ |
|
||||||
for (Iterator i = code.getInstructions().iterator(); i.hasNext(); ) { |
|
||||||
Instruction instr = (Instruction) i.next(); |
|
||||||
if (instr.getTmpInfo() != null) |
|
||||||
instr.setTmpInfo(null); |
|
||||||
else |
|
||||||
i.remove(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,45 +0,0 @@ |
|||||||
/* LocalVarEntry Copyright (C) 1999-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.decompiler; |
|
||||||
import jode.type.Type; |
|
||||||
|
|
||||||
public class LocalVarEntry { |
|
||||||
String name; |
|
||||||
Type type; |
|
||||||
int startAddr; |
|
||||||
int endAddr; |
|
||||||
LocalVarEntry next; |
|
||||||
|
|
||||||
public LocalVarEntry(int s, int e, String n, Type t) { |
|
||||||
startAddr = s; |
|
||||||
endAddr = e; |
|
||||||
name = n; |
|
||||||
type = t; |
|
||||||
next = null; |
|
||||||
} |
|
||||||
|
|
||||||
public String getName() { |
|
||||||
return name; |
|
||||||
} |
|
||||||
|
|
||||||
public Type getType() { |
|
||||||
return type; |
|
||||||
} |
|
||||||
} |
|
@ -1,79 +0,0 @@ |
|||||||
/* LocalVariableRangeList Copyright (C) 1998-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.decompiler; |
|
||||||
import jode.GlobalOptions; |
|
||||||
import jode.type.Type; |
|
||||||
|
|
||||||
public class LocalVariableRangeList { |
|
||||||
|
|
||||||
LocalVarEntry list = null; |
|
||||||
|
|
||||||
LocalVariableRangeList() { |
|
||||||
} |
|
||||||
|
|
||||||
private void add(LocalVarEntry li) { |
|
||||||
LocalVarEntry prev = null; |
|
||||||
LocalVarEntry next = list; |
|
||||||
while (next != null && next.endAddr < li.startAddr) { |
|
||||||
prev = next; |
|
||||||
next = next.next; |
|
||||||
} |
|
||||||
/* prev.endAddr < li.startAddr <= next.endAddr |
|
||||||
*/ |
|
||||||
if (next != null && li.endAddr >= next.startAddr) { |
|
||||||
if (next.type.equals(li.type) |
|
||||||
&& next.name.equals(li.name)) { |
|
||||||
/* Same type, same name and overlapping range. |
|
||||||
* This is the same local: extend next to the common |
|
||||||
* range and don't add li. |
|
||||||
*/ |
|
||||||
next.startAddr = Math.min(next.startAddr, li.startAddr); |
|
||||||
next.endAddr = Math.max(next.endAddr, li.endAddr); |
|
||||||
return; |
|
||||||
} |
|
||||||
GlobalOptions.err.println("warning: non disjoint locals"); |
|
||||||
} |
|
||||||
li.next = next; |
|
||||||
if (prev == null) |
|
||||||
list = li; |
|
||||||
else |
|
||||||
prev.next = li; |
|
||||||
} |
|
||||||
|
|
||||||
private LocalVarEntry find(int addr) { |
|
||||||
LocalVarEntry li = list; |
|
||||||
while (li != null && li.endAddr < addr) |
|
||||||
li = li.next; |
|
||||||
if (li == null || li.startAddr > addr) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
return li; |
|
||||||
} |
|
||||||
|
|
||||||
public void addLocal(int startAddr, int endAddr, |
|
||||||
String name, Type type) { |
|
||||||
LocalVarEntry li = new LocalVarEntry(startAddr,endAddr,name,type); |
|
||||||
add (li); |
|
||||||
} |
|
||||||
|
|
||||||
public LocalVarEntry getInfo(int addr) { |
|
||||||
return find(addr); |
|
||||||
} |
|
||||||
} |
|
@ -1,43 +0,0 @@ |
|||||||
/* LocalVariableTable Copyright (C) 1998-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.decompiler; |
|
||||||
import jode.type.Type; |
|
||||||
import jode.bytecode.LocalVariableInfo; |
|
||||||
|
|
||||||
public class LocalVariableTable { |
|
||||||
LocalVariableRangeList[] locals; |
|
||||||
|
|
||||||
public LocalVariableTable(int maxLocals, LocalVariableInfo[] lvt) { |
|
||||||
locals = new LocalVariableRangeList[maxLocals]; |
|
||||||
for (int i=0; i < maxLocals; i++) |
|
||||||
locals[i] = new LocalVariableRangeList(); |
|
||||||
|
|
||||||
for (int i=0; i<lvt.length; i++) |
|
||||||
locals[lvt[i].slot].addLocal(lvt[i].start.getAddr(), |
|
||||||
lvt[i].end.getAddr(), |
|
||||||
lvt[i].name, Type.tType(lvt[i].type)); |
|
||||||
} |
|
||||||
|
|
||||||
public LocalVarEntry getLocal(int slot, int addr) |
|
||||||
throws ArrayIndexOutOfBoundsException |
|
||||||
{ |
|
||||||
return locals[slot].getInfo(addr); |
|
||||||
} |
|
||||||
} |
|
@ -1,51 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
JAR = @JAR@
|
|
||||||
JAVAC = @JAVAC@
|
|
||||||
JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\
|
|
||||||
-dependdir=$(top_builddir) -classpath=$(top_builddir):$(top_srcdir) \
|
|
||||||
-depfile=Makefile.dep
|
|
||||||
CLASSPATH = @CLASSPATH@
|
|
||||||
CLASSLIB = @CLASSLIB@
|
|
||||||
SUBSTCP = @SUBSTCP@
|
|
||||||
FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB))
|
|
||||||
|
|
||||||
MY_JAVA_FILES = \
|
|
||||||
Analyzer.java \
|
|
||||||
Applet.java \
|
|
||||||
ClassAnalyzer.java \
|
|
||||||
ClassDeclarer.java \
|
|
||||||
DeadCodeAnalysis.java \
|
|
||||||
Declarable.java \
|
|
||||||
Decompiler.java \
|
|
||||||
FieldAnalyzer.java \
|
|
||||||
ImportHandler.java \
|
|
||||||
LocalInfo.java \
|
|
||||||
LocalVarEntry.java \
|
|
||||||
LocalVariableRangeList.java \
|
|
||||||
LocalVariableTable.java \
|
|
||||||
Main.java \
|
|
||||||
MethodAnalyzer.java \
|
|
||||||
Opcodes.java \
|
|
||||||
Options.java \
|
|
||||||
OuterValueListener.java \
|
|
||||||
OuterValues.java \
|
|
||||||
ProgressListener.java \
|
|
||||||
Scope.java \
|
|
||||||
TabbedPrintWriter.java \
|
|
||||||
Window.java
|
|
||||||
|
|
||||||
noinst_DATA = $(MY_JAVA_FILES:.java=.class)
|
|
||||||
EXTRA_DIST = $(MY_JAVA_FILES)
|
|
||||||
|
|
||||||
@QUOTE@-include Makefile.dep |
|
||||||
|
|
||||||
%.class: %.java |
|
||||||
$(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $<
|
|
||||||
|
|
||||||
Makefile.dep: $(MY_JAVA_FILES:.java=.class) |
|
||||||
$(JAVADEP) $^
|
|
||||||
|
|
||||||
clean-local: |
|
||||||
@rm -f *.class
|
|
||||||
@rm -f *.dep
|
|
@ -1,2 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
@ -1,71 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
JAR = @JAR@
|
|
||||||
JAVAC = @JAVAC@
|
|
||||||
JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\
|
|
||||||
-dependdir=$(top_builddir) -classpath=$(top_builddir):$(top_srcdir) \
|
|
||||||
-depfile=Makefile.dep
|
|
||||||
CLASSPATH = @CLASSPATH@
|
|
||||||
CLASSLIB = @CLASSLIB@
|
|
||||||
SUBSTCP = @SUBSTCP@
|
|
||||||
FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB))
|
|
||||||
|
|
||||||
MY_JAVA_FILES = \
|
|
||||||
ArrayLengthOperator.java \
|
|
||||||
ArrayLoadOperator.java \
|
|
||||||
ArrayStoreOperator.java \
|
|
||||||
BinaryOperator.java \
|
|
||||||
CheckCastOperator.java \
|
|
||||||
CheckNullOperator.java \
|
|
||||||
ClassFieldOperator.java \
|
|
||||||
CombineableOperator.java \
|
|
||||||
CompareBinaryOperator.java \
|
|
||||||
CompareToIntOperator.java \
|
|
||||||
CompareUnaryOperator.java \
|
|
||||||
ConstOperator.java \
|
|
||||||
ConstantArrayOperator.java \
|
|
||||||
ConvertOperator.java \
|
|
||||||
Expression.java \
|
|
||||||
FieldOperator.java \
|
|
||||||
GetFieldOperator.java \
|
|
||||||
IIncOperator.java \
|
|
||||||
IfThenElseOperator.java \
|
|
||||||
InstanceOfOperator.java \
|
|
||||||
InvokeOperator.java \
|
|
||||||
LValueExpression.java \
|
|
||||||
LocalLoadOperator.java \
|
|
||||||
LocalStoreOperator.java \
|
|
||||||
LocalVarOperator.java \
|
|
||||||
MatchableOperator.java \
|
|
||||||
MonitorEnterOperator.java \
|
|
||||||
MonitorExitOperator.java \
|
|
||||||
NewArrayOperator.java \
|
|
||||||
NewOperator.java \
|
|
||||||
NoArgOperator.java \
|
|
||||||
NopOperator.java \
|
|
||||||
Operator.java \
|
|
||||||
OuterLocalOperator.java \
|
|
||||||
PopOperator.java \
|
|
||||||
PrePostFixOperator.java \
|
|
||||||
PutFieldOperator.java \
|
|
||||||
ShiftOperator.java \
|
|
||||||
SimpleOperator.java \
|
|
||||||
StoreInstruction.java \
|
|
||||||
StringAddOperator.java \
|
|
||||||
ThisOperator.java \
|
|
||||||
UnaryOperator.java
|
|
||||||
|
|
||||||
noinst_DATA = $(MY_JAVA_FILES:.java=.class)
|
|
||||||
EXTRA_DIST = $(MY_JAVA_FILES)
|
|
||||||
|
|
||||||
@QUOTE@-include Makefile.dep |
|
||||||
|
|
||||||
%.class: %.java |
|
||||||
$(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $<
|
|
||||||
|
|
||||||
Makefile.dep: $(MY_JAVA_FILES:.java=.class) |
|
||||||
$(JAVADEP) $^
|
|
||||||
|
|
||||||
clean-local: |
|
||||||
@rm -f *.class
|
|
||||||
@rm -f *.dep
|
|
@ -1,2 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
@ -1,69 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
JAR = @JAR@
|
|
||||||
JAVAC = @JAVAC@
|
|
||||||
JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\
|
|
||||||
-dependdir=$(top_builddir) -classpath=$(top_builddir):$(top_srcdir) \
|
|
||||||
-depfile=Makefile.dep
|
|
||||||
CLASSPATH = @CLASSPATH@
|
|
||||||
CLASSLIB = @CLASSLIB@
|
|
||||||
SUBSTCP = @SUBSTCP@
|
|
||||||
FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB))
|
|
||||||
|
|
||||||
MY_JAVA_FILES = \
|
|
||||||
BreakBlock.java \
|
|
||||||
BreakableBlock.java \
|
|
||||||
CaseBlock.java \
|
|
||||||
CatchBlock.java \
|
|
||||||
CombineIfGotoExpressions.java \
|
|
||||||
CompleteSynchronized.java \
|
|
||||||
ConditionalBlock.java \
|
|
||||||
ContinueBlock.java \
|
|
||||||
CreateAssignExpression.java \
|
|
||||||
CreateCheckNull.java \
|
|
||||||
CreateClassField.java \
|
|
||||||
CreateConstantArray.java \
|
|
||||||
CreateExpression.java \
|
|
||||||
CreateForInitializer.java \
|
|
||||||
CreateIfThenElseOperator.java \
|
|
||||||
CreateNewConstructor.java \
|
|
||||||
CreatePrePostIncExpression.java \
|
|
||||||
DescriptionBlock.java \
|
|
||||||
EmptyBlock.java \
|
|
||||||
FinallyBlock.java \
|
|
||||||
FlowBlock.java \
|
|
||||||
IfThenElseBlock.java \
|
|
||||||
InstructionBlock.java \
|
|
||||||
InstructionContainer.java \
|
|
||||||
JsrBlock.java \
|
|
||||||
Jump.java \
|
|
||||||
LoopBlock.java \
|
|
||||||
RetBlock.java \
|
|
||||||
ReturnBlock.java \
|
|
||||||
SequentialBlock.java \
|
|
||||||
SlotSet.java \
|
|
||||||
SpecialBlock.java \
|
|
||||||
StructuredBlock.java \
|
|
||||||
SwitchBlock.java \
|
|
||||||
SynchronizedBlock.java \
|
|
||||||
ThrowBlock.java \
|
|
||||||
TransformConstructors.java \
|
|
||||||
TransformExceptionHandlers.java \
|
|
||||||
TryBlock.java \
|
|
||||||
VariableSet.java \
|
|
||||||
VariableStack.java
|
|
||||||
|
|
||||||
noinst_DATA = $(MY_JAVA_FILES:.java=.class)
|
|
||||||
EXTRA_DIST = $(MY_JAVA_FILES)
|
|
||||||
|
|
||||||
@QUOTE@-include Makefile.dep |
|
||||||
|
|
||||||
%.class: %.java |
|
||||||
$(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $<
|
|
||||||
|
|
||||||
Makefile.dep: $(MY_JAVA_FILES:.java=.class) |
|
||||||
$(JAVADEP) $^
|
|
||||||
|
|
||||||
clean-local: |
|
||||||
@rm -f *.class
|
|
||||||
@rm -f *.dep
|
|
@ -1,2 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,37 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
JAR = @JAR@
|
|
||||||
JAVAC = @JAVAC@
|
|
||||||
JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\
|
|
||||||
-dependdir=$(top_builddir) -classpath=$(top_builddir):$(top_srcdir) \
|
|
||||||
-depfile=Makefile.dep
|
|
||||||
CLASSPATH = @CLASSPATH@
|
|
||||||
CLASSLIB = @CLASSLIB@
|
|
||||||
SUBSTCP = @SUBSTCP@
|
|
||||||
FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB))
|
|
||||||
|
|
||||||
MY_JAVA_FILES = \
|
|
||||||
CodeVerifier.java \
|
|
||||||
Interpreter.java \
|
|
||||||
InterpreterException.java \
|
|
||||||
NewObject.java \
|
|
||||||
RuntimeEnvironment.java \
|
|
||||||
SimpleRuntimeEnvironment.java \
|
|
||||||
SyntheticAnalyzer.java \
|
|
||||||
Value.java \
|
|
||||||
VerifyException.java
|
|
||||||
|
|
||||||
noinst_DATA = $(MY_JAVA_FILES:.java=.class)
|
|
||||||
EXTRA_DIST = $(MY_JAVA_FILES)
|
|
||||||
|
|
||||||
@QUOTE@-include Makefile.dep |
|
||||||
|
|
||||||
%.class: %.java |
|
||||||
$(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $<
|
|
||||||
|
|
||||||
Makefile.dep: $(MY_JAVA_FILES:.java=.class) |
|
||||||
$(JAVADEP) $^
|
|
||||||
|
|
||||||
clean-local: |
|
||||||
@rm -f *.class
|
|
||||||
@rm -f *.dep
|
|
@ -1,455 +0,0 @@ |
|||||||
/* SyntheticAnalyzer Copyright (C) 1999-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.jvm; |
|
||||||
import jode.GlobalOptions; |
|
||||||
import jode.bytecode.BytecodeInfo; |
|
||||||
import jode.bytecode.ClassInfo; |
|
||||||
import jode.bytecode.FieldInfo; |
|
||||||
import jode.bytecode.Handler; |
|
||||||
import jode.bytecode.Instruction; |
|
||||||
import jode.bytecode.MethodInfo; |
|
||||||
import jode.bytecode.Opcodes; |
|
||||||
import jode.bytecode.Reference; |
|
||||||
import jode.bytecode.TypeSignature; |
|
||||||
import jode.type.Type; |
|
||||||
import jode.type.MethodType; |
|
||||||
|
|
||||||
import java.lang.reflect.Modifier; |
|
||||||
|
|
||||||
import @COLLECTIONS@.Iterator; |
|
||||||
|
|
||||||
public class SyntheticAnalyzer implements Opcodes { |
|
||||||
public final static int UNKNOWN = 0; |
|
||||||
public final static int GETCLASS = 1; |
|
||||||
public final static int ACCESSGETFIELD = 2; |
|
||||||
public final static int ACCESSPUTFIELD = 3; |
|
||||||
public final static int ACCESSMETHOD = 4; |
|
||||||
public final static int ACCESSGETSTATIC = 5; |
|
||||||
public final static int ACCESSPUTSTATIC = 6; |
|
||||||
public final static int ACCESSSTATICMETHOD = 7; |
|
||||||
public final static int ACCESSCONSTRUCTOR = 8; |
|
||||||
public final static int ACCESSDUPPUTFIELD = 9; |
|
||||||
public final static int ACCESSDUPPUTSTATIC = 10; |
|
||||||
|
|
||||||
int kind = UNKNOWN; |
|
||||||
Reference reference; |
|
||||||
MethodInfo method; |
|
||||||
int unifyParam = -1; |
|
||||||
|
|
||||||
public SyntheticAnalyzer(MethodInfo method, boolean checkName) { |
|
||||||
this.method = method; |
|
||||||
if (method.getBytecode() == null) |
|
||||||
return; |
|
||||||
if (!checkName || method.getName().equals("class$")) |
|
||||||
if (checkGetClass()) |
|
||||||
return; |
|
||||||
if (!checkName || method.getName().startsWith("access$")) |
|
||||||
if (checkAccess()) |
|
||||||
return; |
|
||||||
if (method.getName().equals("<init>")) |
|
||||||
if (checkConstructorAccess()) |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
public int getKind() { |
|
||||||
return kind; |
|
||||||
} |
|
||||||
|
|
||||||
public Reference getReference() { |
|
||||||
return reference; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Gets the index of the dummy parameter for an ACCESSCONSTRUCTOR. |
|
||||||
* Normally the 1 but for inner classes it may be 2. |
|
||||||
*/ |
|
||||||
public int getUnifyParam() { |
|
||||||
return unifyParam; |
|
||||||
} |
|
||||||
|
|
||||||
private static final int[] getClassOpcodes = { |
|
||||||
opc_aload, opc_invokestatic, opc_areturn, |
|
||||||
opc_astore, opc_new, opc_dup, opc_aload, |
|
||||||
opc_invokevirtual, opc_invokespecial, opc_athrow |
|
||||||
}; |
|
||||||
private static final Reference[] getClassRefs = { |
|
||||||
null, Reference.getReference("Ljava/lang/Class;", "forName", |
|
||||||
"(Ljava/lang/String;)Ljava/lang/Class;"), |
|
||||||
null, null, null, null, null, |
|
||||||
Reference.getReference("Ljava/lang/Throwable;", "getMessage", |
|
||||||
"()Ljava/lang/String;"), |
|
||||||
Reference.getReference("Ljava/lang/NoClassDefFoundError;", "<init>", |
|
||||||
"(Ljava/lang/String;)V"), null |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
boolean checkGetClass() { |
|
||||||
if (!method.isStatic() |
|
||||||
|| !(method.getType() |
|
||||||
.equals("(Ljava/lang/String;)Ljava/lang/Class;"))) |
|
||||||
return false; |
|
||||||
|
|
||||||
BytecodeInfo bytecode = method.getBytecode(); |
|
||||||
|
|
||||||
Handler[] excHandlers = bytecode.getExceptionHandlers(); |
|
||||||
if (excHandlers.length != 1 |
|
||||||
|| !"java.lang.ClassNotFoundException".equals(excHandlers[0].type)) |
|
||||||
return false; |
|
||||||
|
|
||||||
int excSlot = -1; |
|
||||||
int i = 0; |
|
||||||
for (Iterator iter = bytecode.getInstructions().iterator(); iter.hasNext(); i++) { |
|
||||||
Instruction instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (i == getClassOpcodes.length |
|
||||||
|| instr.getOpcode() != getClassOpcodes[i]) |
|
||||||
return false; |
|
||||||
if (i == 0 && (instr.getLocalSlot() != 0 |
|
||||||
|| excHandlers[0].start != instr)) |
|
||||||
return false; |
|
||||||
if (i == 2 && excHandlers[0].end != instr) |
|
||||||
return false; |
|
||||||
if (i == 3) { |
|
||||||
if (excHandlers[0].catcher != instr) |
|
||||||
return false; |
|
||||||
excSlot = instr.getLocalSlot(); |
|
||||||
} |
|
||||||
if (i == 4 && !instr.getClazzType().equals |
|
||||||
("Ljava/lang/NoClassDefFoundError;")) |
|
||||||
return false; |
|
||||||
if (i == 6 && instr.getLocalSlot() != excSlot) |
|
||||||
return false; |
|
||||||
if (getClassRefs[i] != null |
|
||||||
&& !getClassRefs[i].equals(instr.getReference())) |
|
||||||
return false; |
|
||||||
} |
|
||||||
this.kind = GETCLASS; |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
private final int modifierMask = Modifier.PUBLIC | Modifier.STATIC; |
|
||||||
|
|
||||||
public boolean checkStaticAccess() { |
|
||||||
ClassInfo clazzInfo = method.getClazzInfo(); |
|
||||||
BytecodeInfo bytecode = method.getBytecode(); |
|
||||||
Iterator iter = bytecode.getInstructions().iterator(); |
|
||||||
boolean dupSeen = false; |
|
||||||
|
|
||||||
Instruction instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (instr.getOpcode() == opc_getstatic) { |
|
||||||
Reference ref = instr.getReference(); |
|
||||||
ClassInfo refClazz = TypeSignature.getClassInfo(ref.getClazz()); |
|
||||||
if (!refClazz.superClassOf(clazzInfo)) |
|
||||||
return false; |
|
||||||
FieldInfo refField |
|
||||||
= refClazz.findField(ref.getName(), ref.getType()); |
|
||||||
if (refField == null |
|
||||||
|| (refField.getModifiers() & modifierMask) != Modifier.STATIC) |
|
||||||
return false; |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (instr.getOpcode() < opc_ireturn |
|
||||||
|| instr.getOpcode() > opc_areturn) |
|
||||||
return false; |
|
||||||
/* For valid bytecode the type matches automatically */ |
|
||||||
reference = ref; |
|
||||||
kind = ACCESSGETSTATIC; |
|
||||||
return true; |
|
||||||
} |
|
||||||
int params = 0, slot = 0; |
|
||||||
while (instr.getOpcode() >= opc_iload |
|
||||||
&& instr.getOpcode() <= opc_aload |
|
||||||
&& instr.getLocalSlot() == slot) { |
|
||||||
params++; |
|
||||||
slot += (instr.getOpcode() == opc_lload |
|
||||||
|| instr.getOpcode() == opc_dload) ? 2 : 1; |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
} |
|
||||||
if (instr.getOpcode() == (opc_dup - 3) + 3 * slot) { |
|
||||||
/* This is probably a opc_dup or opc_dup2, |
|
||||||
* preceding a opc_putstatic |
|
||||||
*/ |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (instr.getOpcode() != opc_putstatic) |
|
||||||
return false; |
|
||||||
dupSeen = true; |
|
||||||
} |
|
||||||
if (instr.getOpcode() == opc_putstatic) { |
|
||||||
if (params != 1) |
|
||||||
return false; |
|
||||||
/* For valid bytecode the type of param matches automatically */ |
|
||||||
Reference ref = instr.getReference(); |
|
||||||
ClassInfo refClazz = TypeSignature.getClassInfo(ref.getClazz()); |
|
||||||
if (!refClazz.superClassOf(clazzInfo)) |
|
||||||
return false; |
|
||||||
FieldInfo refField |
|
||||||
= refClazz.findField(ref.getName(), ref.getType()); |
|
||||||
if (refField == null |
|
||||||
|| (refField.getModifiers() & modifierMask) != Modifier.STATIC) |
|
||||||
return false; |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (dupSeen) { |
|
||||||
if (instr.getOpcode() < opc_ireturn |
|
||||||
|| instr.getOpcode() > opc_areturn) |
|
||||||
return false; |
|
||||||
kind = ACCESSDUPPUTSTATIC; |
|
||||||
} else { |
|
||||||
if (instr.getOpcode() != opc_return) |
|
||||||
return false; |
|
||||||
kind = ACCESSPUTSTATIC; |
|
||||||
} |
|
||||||
reference = ref; |
|
||||||
return true; |
|
||||||
} |
|
||||||
if (instr.getOpcode() == opc_invokestatic) { |
|
||||||
Reference ref = instr.getReference(); |
|
||||||
ClassInfo refClazz = TypeSignature.getClassInfo(ref.getClazz()); |
|
||||||
if (!refClazz.superClassOf(clazzInfo)) |
|
||||||
return false; |
|
||||||
MethodInfo refMethod |
|
||||||
= refClazz.findMethod(ref.getName(), ref.getType()); |
|
||||||
MethodType refType = Type.tMethod(ref.getType()); |
|
||||||
if ((refMethod.getModifiers() & modifierMask) != Modifier.STATIC |
|
||||||
|| refType.getParameterTypes().length != params) |
|
||||||
return false; |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (refType.getReturnType() == Type.tVoid) { |
|
||||||
if (instr.getOpcode() != opc_return) |
|
||||||
return false; |
|
||||||
} else { |
|
||||||
if (instr.getOpcode() < opc_ireturn |
|
||||||
|| instr.getOpcode() > opc_areturn) |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
/* For valid bytecode the types matches automatically */ |
|
||||||
reference = ref; |
|
||||||
kind = ACCESSSTATICMETHOD; |
|
||||||
return true; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean checkAccess() { |
|
||||||
ClassInfo clazzInfo = method.getClazzInfo(); |
|
||||||
BytecodeInfo bytecode = method.getBytecode(); |
|
||||||
Handler[] excHandlers = bytecode.getExceptionHandlers(); |
|
||||||
boolean dupSeen = false; |
|
||||||
if (excHandlers != null && excHandlers.length != 0) |
|
||||||
return false; |
|
||||||
|
|
||||||
if (method.isStatic()) { |
|
||||||
if (checkStaticAccess()) |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
Iterator iter = bytecode.getInstructions().iterator(); |
|
||||||
Instruction instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (instr.getOpcode() != opc_aload || instr.getLocalSlot() != 0) |
|
||||||
return false; |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
|
|
||||||
if (instr.getOpcode() == opc_getfield) { |
|
||||||
Reference ref = instr.getReference(); |
|
||||||
ClassInfo refClazz = TypeSignature.getClassInfo(ref.getClazz()); |
|
||||||
if (!refClazz.superClassOf(clazzInfo)) |
|
||||||
return false; |
|
||||||
FieldInfo refField |
|
||||||
= refClazz.findField(ref.getName(), ref.getType()); |
|
||||||
if (refField == null |
|
||||||
|| (refField.getModifiers() & modifierMask) != 0) |
|
||||||
return false; |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (instr.getOpcode() < opc_ireturn |
|
||||||
|| instr.getOpcode() > opc_areturn) |
|
||||||
return false; |
|
||||||
/* For valid bytecode the type matches automatically */ |
|
||||||
reference = ref; |
|
||||||
kind = ACCESSGETFIELD; |
|
||||||
return true; |
|
||||||
} |
|
||||||
int params = 0, slot = 1; |
|
||||||
while (instr.getOpcode() >= opc_iload |
|
||||||
&& instr.getOpcode() <= opc_aload |
|
||||||
&& instr.getLocalSlot() == slot) { |
|
||||||
params++; |
|
||||||
slot += (instr.getOpcode() == opc_lload |
|
||||||
|| instr.getOpcode() == opc_dload) ? 2 : 1; |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
} |
|
||||||
if (instr.getOpcode() == (opc_dup_x1 - 6) + 3 * slot) { |
|
||||||
/* This is probably a opc_dup_x1 or opc_dup2_x1, |
|
||||||
* preceding a opc_putfield |
|
||||||
*/ |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (instr.getOpcode() != opc_putfield) |
|
||||||
return false; |
|
||||||
dupSeen = true; |
|
||||||
} |
|
||||||
if (instr.getOpcode() == opc_putfield) { |
|
||||||
if (params != 1) |
|
||||||
return false; |
|
||||||
/* For valid bytecode the type of param matches automatically */ |
|
||||||
Reference ref = instr.getReference(); |
|
||||||
ClassInfo refClazz = TypeSignature.getClassInfo(ref.getClazz()); |
|
||||||
if (!refClazz.superClassOf(clazzInfo)) |
|
||||||
return false; |
|
||||||
FieldInfo refField |
|
||||||
= refClazz.findField(ref.getName(), ref.getType()); |
|
||||||
if (refField == null |
|
||||||
|| (refField.getModifiers() & modifierMask) != 0) |
|
||||||
return false; |
|
||||||
|
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (dupSeen) { |
|
||||||
if (instr.getOpcode() < opc_ireturn |
|
||||||
|| instr.getOpcode() > opc_areturn) |
|
||||||
return false; |
|
||||||
kind = ACCESSDUPPUTFIELD; |
|
||||||
} else { |
|
||||||
if (instr.getOpcode() != opc_return) |
|
||||||
return false; |
|
||||||
kind = ACCESSPUTFIELD; |
|
||||||
} |
|
||||||
reference = ref; |
|
||||||
return true; |
|
||||||
} |
|
||||||
if (instr.getOpcode() == opc_invokespecial) { |
|
||||||
Reference ref = instr.getReference(); |
|
||||||
ClassInfo refClazz = TypeSignature.getClassInfo(ref.getClazz()); |
|
||||||
if (!refClazz.superClassOf(clazzInfo)) |
|
||||||
return false; |
|
||||||
MethodInfo refMethod |
|
||||||
= refClazz.findMethod(ref.getName(), ref.getType()); |
|
||||||
MethodType refType = Type.tMethod(ref.getType()); |
|
||||||
if ((refMethod.getModifiers() & modifierMask) != 0 |
|
||||||
|| refType.getParameterTypes().length != params) |
|
||||||
return false; |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (refType.getReturnType() == Type.tVoid) { |
|
||||||
if (instr.getOpcode() != opc_return) |
|
||||||
return false; |
|
||||||
} else { |
|
||||||
if (instr.getOpcode() < opc_ireturn |
|
||||||
|| instr.getOpcode() > opc_areturn) |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
/* For valid bytecode the types matches automatically */ |
|
||||||
reference = ref; |
|
||||||
kind = ACCESSMETHOD; |
|
||||||
return true; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean checkConstructorAccess() { |
|
||||||
ClassInfo clazzInfo = method.getClazzInfo(); |
|
||||||
BytecodeInfo bytecode = method.getBytecode(); |
|
||||||
String[] paramTypes |
|
||||||
= TypeSignature.getParameterTypes(method.getType()); |
|
||||||
Handler[] excHandlers = bytecode.getExceptionHandlers(); |
|
||||||
if (excHandlers != null && excHandlers.length != 0) |
|
||||||
return false; |
|
||||||
Iterator iter = bytecode.getInstructions().iterator(); |
|
||||||
|
|
||||||
Instruction instr = (Instruction) iter.next(); |
|
||||||
while (instr.getOpcode() == opc_nop && iter.hasNext()) |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
int params = 0, slot = 0; |
|
||||||
while (instr.getOpcode() >= opc_iload |
|
||||||
&& instr.getOpcode() <= opc_aload) { |
|
||||||
|
|
||||||
if (instr.getLocalSlot() > slot |
|
||||||
&& unifyParam == -1 && params > 0 |
|
||||||
&& paramTypes[params - 1].charAt(0) == 'L') { |
|
||||||
unifyParam = params; |
|
||||||
params++; |
|
||||||
slot++; |
|
||||||
} |
|
||||||
if (instr.getLocalSlot() != slot) |
|
||||||
return false; |
|
||||||
|
|
||||||
params++; |
|
||||||
slot += (instr.getOpcode() == opc_lload |
|
||||||
|| instr.getOpcode() == opc_dload) ? 2 : 1; |
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
} |
|
||||||
if (params > 0 && instr.getOpcode() == opc_invokespecial) { |
|
||||||
|
|
||||||
if (unifyParam == -1 && params <= paramTypes.length |
|
||||||
&& paramTypes[params - 1].charAt(0) == 'L') |
|
||||||
unifyParam = params++; |
|
||||||
|
|
||||||
Reference ref = instr.getReference(); |
|
||||||
ClassInfo refClazz = TypeSignature.getClassInfo(ref.getClazz()); |
|
||||||
if (refClazz != clazzInfo) |
|
||||||
return false; |
|
||||||
MethodInfo refMethod |
|
||||||
= refClazz.findMethod(ref.getName(), ref.getType()); |
|
||||||
MethodType refType = Type.tMethod(ref.getType()); |
|
||||||
if ((refMethod.getModifiers() & modifierMask) != 0 |
|
||||||
|| !refMethod.getName().equals("<init>") |
|
||||||
|| unifyParam == -1 |
|
||||||
|| refType.getParameterTypes().length != params - 2) |
|
||||||
return false; |
|
||||||
|
|
||||||
instr = (Instruction) iter.next(); |
|
||||||
if (instr.getOpcode() != opc_return) |
|
||||||
return false; |
|
||||||
|
|
||||||
/* We don't check if types matches. No problem since we only |
|
||||||
* need to make sure, this constructor doesn't do anything |
|
||||||
* more than relay to the real one. |
|
||||||
*/ |
|
||||||
reference = ref; |
|
||||||
kind = ACCESSCONSTRUCTOR; |
|
||||||
return true; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
@ -1,2 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
@ -1,47 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
SUBDIRS = modules
|
|
||||||
|
|
||||||
JAR = @JAR@
|
|
||||||
JAVAC = @JAVAC@
|
|
||||||
JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\
|
|
||||||
-dependdir=$(top_builddir) -classpath=$(top_builddir):$(top_srcdir) \
|
|
||||||
-depfile=Makefile.dep
|
|
||||||
CLASSPATH = @CLASSPATH@
|
|
||||||
CLASSLIB = @CLASSLIB@
|
|
||||||
SUBSTCP = @SUBSTCP@
|
|
||||||
FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB))
|
|
||||||
|
|
||||||
MY_JAVA_FILES = \
|
|
||||||
ClassBundle.java \
|
|
||||||
ClassIdentifier.java \
|
|
||||||
CodeAnalyzer.java \
|
|
||||||
CodeTransformer.java \
|
|
||||||
ConstantRuntimeEnvironment.java \
|
|
||||||
FieldIdentifier.java \
|
|
||||||
Identifier.java \
|
|
||||||
IdentifierMatcher.java \
|
|
||||||
LocalIdentifier.java \
|
|
||||||
Main.java \
|
|
||||||
MethodIdentifier.java \
|
|
||||||
OptionHandler.java \
|
|
||||||
PackageIdentifier.java \
|
|
||||||
ParseException.java \
|
|
||||||
Renamer.java \
|
|
||||||
ScriptParser.java \
|
|
||||||
TranslationTable.java
|
|
||||||
|
|
||||||
noinst_DATA = $(MY_JAVA_FILES:.java=.class)
|
|
||||||
EXTRA_DIST = $(MY_JAVA_FILES)
|
|
||||||
|
|
||||||
@QUOTE@-include Makefile.dep |
|
||||||
|
|
||||||
%.class: %.java |
|
||||||
$(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $<
|
|
||||||
|
|
||||||
Makefile.dep: $(MY_JAVA_FILES:.java=.class) |
|
||||||
$(JAVADEP) $^
|
|
||||||
|
|
||||||
clean-local: |
|
||||||
@rm -f *.class
|
|
||||||
@rm -f *.dep
|
|
@ -1,2 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
File diff suppressed because it is too large
Load Diff
@ -1,936 +0,0 @@ |
|||||||
/* LocalOptimizer Copyright (C) 1999-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU General Public License |
|
||||||
* along with this program; see the file COPYING. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.obfuscator.modules; |
|
||||||
import java.util.*; |
|
||||||
import jode.bytecode.*; |
|
||||||
import jode.obfuscator.*; |
|
||||||
import jode.AssertError; |
|
||||||
import jode.GlobalOptions; |
|
||||||
|
|
||||||
import @COLLECTIONS@.Iterator; |
|
||||||
import @COLLECTIONS@.ListIterator; |
|
||||||
|
|
||||||
/** |
|
||||||
* This class takes some bytecode and tries to minimize the number |
|
||||||
* of locals used. It will also remove unnecessary stores. |
|
||||||
* |
|
||||||
* This class can only work on verified code. There should also be no |
|
||||||
* deadcode, since the verifier doesn't check that deadcode behaves |
|
||||||
* okay. |
|
||||||
* |
|
||||||
* This is done in two phases. First we determine which locals are |
|
||||||
* the same, and which locals have a overlapping life time. In the |
|
||||||
* second phase we will then redistribute the locals with a coloring |
|
||||||
* graph algorithm. |
|
||||||
* |
|
||||||
* The idea for the first phase is: For each read we follow the |
|
||||||
* instruction flow backward to find the corresponding writes. We can |
|
||||||
* also merge with another control flow that has a different read, in |
|
||||||
* this case we merge with that read, too. |
|
||||||
* |
|
||||||
* The tricky part is the subroutine handling. We follow the local |
|
||||||
* that is used in a ret and find the corresponding jsr target (there |
|
||||||
* must be only one, if the verifier should accept this class). While |
|
||||||
* we do this we remember in the info of the ret, which locals are |
|
||||||
* used in that subroutine. |
|
||||||
* |
|
||||||
* When we know the jsr target<->ret correlation, we promote from the |
|
||||||
* nextByAddr of every jsr the locals that are accessed by the |
|
||||||
* subroutine to the corresponding ret and the others to the jsr. Also |
|
||||||
* we will promote all reads from the jsr targets to the jsr. |
|
||||||
* |
|
||||||
* If you think this might be to complicated, keep in mind that jsr's |
|
||||||
* are not only left by the ret instructions, but also "spontanously" |
|
||||||
* (by not reading the return address again). |
|
||||||
*/ |
|
||||||
public class LocalOptimizer implements Opcodes, CodeTransformer { |
|
||||||
|
|
||||||
/** |
|
||||||
* This class keeps track of which locals must be the same, which |
|
||||||
* name and type each local (if there is a local variable table) and |
|
||||||
* which other locals have an intersecting life time. |
|
||||||
*/ |
|
||||||
class LocalInfo { |
|
||||||
LocalInfo shadow = null; |
|
||||||
|
|
||||||
public LocalInfo getReal() { |
|
||||||
LocalInfo real = this; |
|
||||||
while (real.shadow != null) |
|
||||||
real = real.shadow; |
|
||||||
return real; |
|
||||||
} |
|
||||||
|
|
||||||
String name; |
|
||||||
String type; |
|
||||||
Vector usingInstrs = new Vector(); |
|
||||||
Vector conflictingLocals = new Vector(); |
|
||||||
int size; |
|
||||||
int newSlot = -1; |
|
||||||
|
|
||||||
LocalInfo() { |
|
||||||
} |
|
||||||
|
|
||||||
LocalInfo(InstrInfo instr) { |
|
||||||
usingInstrs.addElement(instr); |
|
||||||
} |
|
||||||
|
|
||||||
void conflictsWith(LocalInfo l) { |
|
||||||
if (shadow != null) { |
|
||||||
getReal().conflictsWith(l); |
|
||||||
} else { |
|
||||||
l = l.getReal(); |
|
||||||
if (!conflictingLocals.contains(l)) { |
|
||||||
conflictingLocals.addElement(l); |
|
||||||
l.conflictingLocals.addElement(this); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void combineInto(LocalInfo l) { |
|
||||||
if (shadow != null) { |
|
||||||
getReal().combineInto(l); |
|
||||||
return; |
|
||||||
} |
|
||||||
l = l.getReal(); |
|
||||||
if (this == l) |
|
||||||
return; |
|
||||||
shadow = l; |
|
||||||
if (shadow.name == null) { |
|
||||||
shadow.name = name; |
|
||||||
shadow.type = type; |
|
||||||
} |
|
||||||
Enumeration enum = usingInstrs.elements(); |
|
||||||
while (enum.hasMoreElements()) { |
|
||||||
InstrInfo instr = (InstrInfo) enum.nextElement(); |
|
||||||
instr.local = l; |
|
||||||
l.usingInstrs.addElement(instr); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public int getFirstAddr() { |
|
||||||
int minAddr = Integer.MAX_VALUE; |
|
||||||
Enumeration enum = usingInstrs.elements(); |
|
||||||
while (enum.hasMoreElements()) { |
|
||||||
InstrInfo info = (InstrInfo) enum.nextElement(); |
|
||||||
if (info.instr.getAddr() < minAddr) |
|
||||||
minAddr = info.instr.getAddr(); |
|
||||||
} |
|
||||||
return minAddr; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private static class TodoQueue { |
|
||||||
public final InstrInfo LAST = new InstrInfo(); |
|
||||||
InstrInfo first = LAST; |
|
||||||
|
|
||||||
public void add(InstrInfo info) { |
|
||||||
if (info.nextTodo == null) { |
|
||||||
/* only enqueue if not already on queue */ |
|
||||||
info.nextTodo = first; |
|
||||||
first = info; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isEmpty() { |
|
||||||
return first == LAST; |
|
||||||
} |
|
||||||
|
|
||||||
public InstrInfo remove() { |
|
||||||
if (first == LAST) |
|
||||||
throw new NoSuchElementException(); |
|
||||||
InstrInfo result = first; |
|
||||||
first = result.nextTodo; |
|
||||||
result.nextTodo = null; |
|
||||||
return result; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* This class contains information for each instruction. |
|
||||||
*/ |
|
||||||
static class InstrInfo { |
|
||||||
/** |
|
||||||
* The next changed InstrInfo, or null, if this instr info did |
|
||||||
* not changed. |
|
||||||
*/ |
|
||||||
InstrInfo nextTodo; |
|
||||||
|
|
||||||
/** |
|
||||||
* The LocalInfo that this instruction manipulates, or null |
|
||||||
* if this is not an ret, iinc, load or store instruction. |
|
||||||
*/ |
|
||||||
LocalInfo local; |
|
||||||
/** |
|
||||||
* For each slot, this contains the InstrInfo of one of the |
|
||||||
* next Instruction, that may read from that slot, without |
|
||||||
* prior writing. */ |
|
||||||
InstrInfo[] nextReads; |
|
||||||
|
|
||||||
/** |
|
||||||
* This only has a value for ret instructions. In that case |
|
||||||
* this bitset contains all locals, that may be used between |
|
||||||
* jsr and ret. |
|
||||||
*/ |
|
||||||
BitSet usedBySub; |
|
||||||
/** |
|
||||||
* For each slot if get() is true, no instruction may read |
|
||||||
* this slot, since it may contain different locals, depending |
|
||||||
* on flow. |
|
||||||
*/ |
|
||||||
LocalInfo[] lifeLocals; |
|
||||||
/** |
|
||||||
* If instruction is the destination of a jsr, this contains |
|
||||||
* the single allowed ret instruction info, or null if there |
|
||||||
* is no ret at all (or not yet detected). |
|
||||||
*/ |
|
||||||
InstrInfo retInfo; |
|
||||||
/** |
|
||||||
* If this instruction is a ret, this contains the single |
|
||||||
* allowed jsr target to which this ret belongs. |
|
||||||
*/ |
|
||||||
InstrInfo jsrTargetInfo; |
|
||||||
/** |
|
||||||
* The Instruction of this info |
|
||||||
*/ |
|
||||||
Instruction instr; |
|
||||||
/** |
|
||||||
* The next info in the chain. |
|
||||||
*/ |
|
||||||
InstrInfo nextInfo; |
|
||||||
} |
|
||||||
|
|
||||||
BytecodeInfo bc; |
|
||||||
|
|
||||||
TodoQueue changedInfos; |
|
||||||
InstrInfo firstInfo; |
|
||||||
Hashtable instrInfos; |
|
||||||
boolean produceLVT; |
|
||||||
int maxlocals; |
|
||||||
|
|
||||||
LocalInfo[] paramLocals; |
|
||||||
|
|
||||||
public LocalOptimizer() { |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* Merges the given vector to a new vector. Both vectors may |
|
||||||
* be null in which case they are interpreted as empty vectors. |
|
||||||
* The vectors will never changed, but the result may be one |
|
||||||
* of the given vectors. |
|
||||||
*/ |
|
||||||
Vector merge(Vector v1, Vector v2) { |
|
||||||
if (v1 == null || v1.isEmpty()) |
|
||||||
return v2; |
|
||||||
if (v2 == null || v2.isEmpty()) |
|
||||||
return v1; |
|
||||||
Vector result = (Vector) v1.clone(); |
|
||||||
Enumeration enum = v2.elements(); |
|
||||||
while (enum.hasMoreElements()) { |
|
||||||
Object elem = enum.nextElement(); |
|
||||||
if (!result.contains(elem)) |
|
||||||
result.addElement(elem); |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
void promoteReads(InstrInfo info, Instruction preInstr, |
|
||||||
BitSet mergeSet, boolean inverted) { |
|
||||||
InstrInfo preInfo = (InstrInfo) instrInfos.get(preInstr); |
|
||||||
int omitLocal = -1; |
|
||||||
if (preInstr.getOpcode() >= opc_istore |
|
||||||
&& preInstr.getOpcode() <= opc_astore) { |
|
||||||
/* This is a store */ |
|
||||||
omitLocal = preInstr.getLocalSlot(); |
|
||||||
if (info.nextReads[omitLocal] != null) |
|
||||||
preInfo.local.combineInto(info.nextReads[omitLocal].local); |
|
||||||
} |
|
||||||
for (int i=0; i < maxlocals; i++) { |
|
||||||
if (info.nextReads[i] != null && i != omitLocal |
|
||||||
&& (mergeSet == null || mergeSet.get(i) != inverted)) { |
|
||||||
|
|
||||||
if (preInfo.nextReads[i] == null) { |
|
||||||
preInfo.nextReads[i] = info.nextReads[i]; |
|
||||||
changedInfos.add(preInfo); |
|
||||||
} else { |
|
||||||
preInfo.nextReads[i].local |
|
||||||
.combineInto(info.nextReads[i].local); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void promoteReads(InstrInfo info, Instruction preInstr) { |
|
||||||
promoteReads(info, preInstr, null, false); |
|
||||||
} |
|
||||||
|
|
||||||
public LocalVariableInfo findLVTEntry(LocalVariableInfo[] lvt, |
|
||||||
int slot, int addr) { |
|
||||||
LocalVariableInfo match = null; |
|
||||||
for (int i=0; i < lvt.length; i++) { |
|
||||||
if (lvt[i].slot == slot |
|
||||||
&& lvt[i].start.getAddr() <= addr |
|
||||||
&& lvt[i].end.getAddr() >= addr) { |
|
||||||
if (match != null |
|
||||||
&& (!match.name.equals(lvt[i].name) |
|
||||||
|| !match.type.equals(lvt[i].type))) { |
|
||||||
/* Multiple matches..., give no info */ |
|
||||||
return null; |
|
||||||
} |
|
||||||
match = lvt[i]; |
|
||||||
} |
|
||||||
} |
|
||||||
return match; |
|
||||||
} |
|
||||||
|
|
||||||
public LocalVariableInfo findLVTEntry(LocalVariableInfo[] lvt, |
|
||||||
Instruction instr) { |
|
||||||
int addr; |
|
||||||
if (instr.getOpcode() >= opc_istore |
|
||||||
&& instr.getOpcode() <= opc_astore) |
|
||||||
addr = instr.getNextAddr(); |
|
||||||
else |
|
||||||
addr = instr.getAddr(); |
|
||||||
return findLVTEntry(lvt, instr.getLocalSlot(), addr); |
|
||||||
} |
|
||||||
|
|
||||||
public void calcLocalInfo() { |
|
||||||
maxlocals = bc.getMaxLocals(); |
|
||||||
Handler[] handlers = bc.getExceptionHandlers(); |
|
||||||
LocalVariableInfo[] lvt = bc.getLocalVariableTable(); |
|
||||||
if (lvt != null) |
|
||||||
produceLVT = true; |
|
||||||
|
|
||||||
/* Initialize paramLocals */ |
|
||||||
{ |
|
||||||
String methodType = bc.getMethodInfo().getType(); |
|
||||||
int paramCount = (bc.getMethodInfo().isStatic() ? 0 : 1) |
|
||||||
+ TypeSignature.getArgumentSize(methodType); |
|
||||||
paramLocals = new LocalInfo[paramCount]; |
|
||||||
int slot = 0; |
|
||||||
if (!bc.getMethodInfo().isStatic()) { |
|
||||||
LocalInfo local = new LocalInfo(); |
|
||||||
if (lvt != null) { |
|
||||||
LocalVariableInfo lvi = findLVTEntry(lvt, 0, 0); |
|
||||||
if (lvi != null) { |
|
||||||
local.name = lvi.name; |
|
||||||
local.type = lvi.type; |
|
||||||
} |
|
||||||
} |
|
||||||
local.size = 1; |
|
||||||
paramLocals[slot++] = local; |
|
||||||
} |
|
||||||
int pos = 1; |
|
||||||
while (pos < methodType.length() |
|
||||||
&& methodType.charAt(pos) != ')') { |
|
||||||
|
|
||||||
LocalInfo local = new LocalInfo(); |
|
||||||
if (lvt != null) { |
|
||||||
LocalVariableInfo lvi = findLVTEntry(lvt, slot, 0); |
|
||||||
if (lvi != null) { |
|
||||||
local.name = lvi.name; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
int start = pos; |
|
||||||
pos = TypeSignature.skipType(methodType, pos); |
|
||||||
local.type = methodType.substring(start, pos); |
|
||||||
local.size = TypeSignature.getTypeSize(local.type); |
|
||||||
paramLocals[slot] = local; |
|
||||||
slot += local.size; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* Initialize the InstrInfos and LocalInfos |
|
||||||
*/ |
|
||||||
changedInfos = new TodoQueue(); |
|
||||||
instrInfos = new Hashtable(); |
|
||||||
{ |
|
||||||
InstrInfo info = firstInfo = new InstrInfo(); |
|
||||||
Iterator i = bc.getInstructions().iterator(); |
|
||||||
while (true) { |
|
||||||
Instruction instr = (Instruction) i.next(); |
|
||||||
instrInfos.put(instr, info); |
|
||||||
info.instr = instr; |
|
||||||
info.nextReads = new InstrInfo[maxlocals]; |
|
||||||
if (instr.hasLocalSlot()) { |
|
||||||
info.local = new LocalInfo(info); |
|
||||||
if (lvt != null) { |
|
||||||
LocalVariableInfo lvi = findLVTEntry(lvt, instr); |
|
||||||
if (lvi != null) { |
|
||||||
info.local.name = lvi.name; |
|
||||||
info.local.type = lvi.type; |
|
||||||
} |
|
||||||
} |
|
||||||
info.local.size = 1; |
|
||||||
switch (instr.getOpcode()) { |
|
||||||
case opc_lload: case opc_dload: |
|
||||||
info.local.size = 2; |
|
||||||
/* fall through */ |
|
||||||
case opc_iload: case opc_fload: case opc_aload: |
|
||||||
case opc_iinc: |
|
||||||
/* this is a load instruction */ |
|
||||||
info.nextReads[instr.getLocalSlot()] = info; |
|
||||||
changedInfos.add(info); |
|
||||||
break; |
|
||||||
|
|
||||||
case opc_ret: |
|
||||||
/* this is a ret instruction */ |
|
||||||
info.usedBySub = new BitSet(); |
|
||||||
info.nextReads[instr.getLocalSlot()] = info; |
|
||||||
changedInfos.add(info); |
|
||||||
break; |
|
||||||
|
|
||||||
case opc_lstore: case opc_dstore: |
|
||||||
info.local.size = 2; |
|
||||||
//case opc_istore: case opc_fstore: case opc_astore:
|
|
||||||
} |
|
||||||
} |
|
||||||
if (!i.hasNext()) |
|
||||||
break; |
|
||||||
info = info.nextInfo = new InstrInfo(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* find out which locals are the same. |
|
||||||
*/ |
|
||||||
while (!changedInfos.isEmpty()) { |
|
||||||
InstrInfo info = changedInfos.remove(); |
|
||||||
Instruction instr = info.instr; |
|
||||||
|
|
||||||
/* Mark the local as used in all ret instructions */ |
|
||||||
if (instr.hasLocalSlot()) { |
|
||||||
int slot = instr.getLocalSlot(); |
|
||||||
for (int i=0; i< maxlocals; i++) { |
|
||||||
InstrInfo retInfo = info.nextReads[i]; |
|
||||||
if (retInfo != null |
|
||||||
&& retInfo.instr.getOpcode() == opc_ret |
|
||||||
&& !retInfo.usedBySub.get(slot)) { |
|
||||||
retInfo.usedBySub.set(slot); |
|
||||||
if (retInfo.jsrTargetInfo != null) |
|
||||||
changedInfos.add(retInfo.jsrTargetInfo); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
Instruction prevInstr = instr.getPrevByAddr(); |
|
||||||
if (prevInstr != null) { |
|
||||||
if (!prevInstr.doesAlwaysJump()) |
|
||||||
promoteReads(info, prevInstr); |
|
||||||
else if (prevInstr.getOpcode() == opc_jsr) { |
|
||||||
/* Prev instr is a jsr, promote reads to the |
|
||||||
* corresponding ret. |
|
||||||
*/ |
|
||||||
InstrInfo jsrInfo = |
|
||||||
(InstrInfo) instrInfos.get(prevInstr.getSingleSucc()); |
|
||||||
if (jsrInfo.retInfo != null) { |
|
||||||
/* Now promote reads that are modified by the |
|
||||||
* subroutine to the ret, and those that are not |
|
||||||
* to the jsr instruction. |
|
||||||
*/ |
|
||||||
promoteReads(info, jsrInfo.retInfo.instr, |
|
||||||
jsrInfo.retInfo.usedBySub, false); |
|
||||||
promoteReads(info, prevInstr, |
|
||||||
jsrInfo.retInfo.usedBySub, true); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (instr.getPreds() != null) { |
|
||||||
for (int i = 0; i < instr.getPreds().length; i++) { |
|
||||||
Instruction predInstr = instr.getPreds()[i]; |
|
||||||
if (instr.getPreds()[i].getOpcode() == opc_jsr) { |
|
||||||
/* This is the target of a jsr instr. |
|
||||||
*/ |
|
||||||
if (info.instr.getOpcode() != opc_astore) { |
|
||||||
/* XXX Grrr, the bytecode verifier doesn't |
|
||||||
* test if a jsr starts with astore. So |
|
||||||
* it is possible to do something else |
|
||||||
* before putting the ret address into a |
|
||||||
* local. */ |
|
||||||
throw new AssertError("Non standard jsr"); |
|
||||||
} |
|
||||||
InstrInfo retInfo = info.nextInfo.nextReads |
|
||||||
[info.instr.getLocalSlot()]; |
|
||||||
|
|
||||||
if (retInfo != null) { |
|
||||||
if (retInfo.instr.getOpcode() != opc_ret) |
|
||||||
throw new AssertError |
|
||||||
("reading return address"); |
|
||||||
|
|
||||||
info.retInfo = retInfo; |
|
||||||
retInfo.jsrTargetInfo = info; |
|
||||||
|
|
||||||
/* Now promote reads from the instruction |
|
||||||
* after the jsr to the ret instruction if |
|
||||||
* they are modified by the subroutine, |
|
||||||
* and to the jsr instruction otherwise. |
|
||||||
*/ |
|
||||||
Instruction nextInstr = predInstr.getNextByAddr(); |
|
||||||
InstrInfo nextInfo |
|
||||||
= (InstrInfo) instrInfos.get(nextInstr); |
|
||||||
|
|
||||||
promoteReads(nextInfo, retInfo.instr, |
|
||||||
retInfo.usedBySub, false); |
|
||||||
|
|
||||||
promoteReads(nextInfo, predInstr, |
|
||||||
retInfo.usedBySub, true); |
|
||||||
} |
|
||||||
} |
|
||||||
promoteReads(info, instr.getPreds()[i]); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
for (int i=0; i < handlers.length; i++) { |
|
||||||
if (handlers[i].catcher == instr) { |
|
||||||
for (Instruction preInstr = handlers[i].start; |
|
||||||
preInstr != handlers[i].end.getNextByAddr(); |
|
||||||
preInstr = preInstr.getNextByAddr()) { |
|
||||||
promoteReads(info, preInstr); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
changedInfos = null; |
|
||||||
|
|
||||||
/* Now merge with the parameters |
|
||||||
* The params should be the locals in firstInfo.nextReads |
|
||||||
*/ |
|
||||||
for (int i=0; i< paramLocals.length; i++) { |
|
||||||
if (firstInfo.nextReads[i] != null) { |
|
||||||
firstInfo.nextReads[i].local.combineInto(paramLocals[i]); |
|
||||||
paramLocals[i] = paramLocals[i].getReal(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void stripLocals() { |
|
||||||
ListIterator iter = bc.getInstructions().listIterator(); |
|
||||||
for (InstrInfo info = firstInfo; info != null; info = info.nextInfo) { |
|
||||||
Instruction instr = (Instruction) iter.next(); |
|
||||||
if (info.local != null && info.local.usingInstrs.size() == 1) { |
|
||||||
/* If this is a store, whose value is never read; it can |
|
||||||
* be removed, i.e replaced by a pop. */ |
|
||||||
switch (instr.getOpcode()) { |
|
||||||
case opc_istore: |
|
||||||
case opc_fstore: |
|
||||||
case opc_astore: |
|
||||||
iter.set(new Instruction(opc_pop)); |
|
||||||
break; |
|
||||||
case opc_lstore: |
|
||||||
case opc_dstore: |
|
||||||
iter.set(new Instruction(opc_pop2)); |
|
||||||
break; |
|
||||||
default: |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void distributeLocals(Vector locals) { |
|
||||||
if (locals.size() == 0) |
|
||||||
return; |
|
||||||
|
|
||||||
/* Find the local with the least conflicts. */ |
|
||||||
int min = Integer.MAX_VALUE; |
|
||||||
LocalInfo bestLocal = null; |
|
||||||
Enumeration enum = locals.elements(); |
|
||||||
while (enum.hasMoreElements()) { |
|
||||||
LocalInfo li = (LocalInfo) enum.nextElement(); |
|
||||||
int conflicts = 0; |
|
||||||
Enumeration conflenum = li.conflictingLocals.elements(); |
|
||||||
while (conflenum.hasMoreElements()) { |
|
||||||
if (((LocalInfo)conflenum.nextElement()).newSlot != -2) |
|
||||||
conflicts++; |
|
||||||
} |
|
||||||
if (conflicts < min) { |
|
||||||
min = conflicts; |
|
||||||
bestLocal = li; |
|
||||||
} |
|
||||||
} |
|
||||||
/* Mark the local as taken */ |
|
||||||
locals.removeElement(bestLocal); |
|
||||||
bestLocal.newSlot = -2; |
|
||||||
/* Now distribute the remaining locals recursively. */ |
|
||||||
distributeLocals(locals); |
|
||||||
|
|
||||||
/* Finally find a new slot */ |
|
||||||
next_slot: |
|
||||||
for (int slot = 0; ; slot++) { |
|
||||||
Enumeration conflenum = bestLocal.conflictingLocals.elements(); |
|
||||||
while (conflenum.hasMoreElements()) { |
|
||||||
LocalInfo conflLocal = (LocalInfo)conflenum.nextElement(); |
|
||||||
if (bestLocal.size == 2 && conflLocal.newSlot == slot+1) { |
|
||||||
slot++; |
|
||||||
continue next_slot; |
|
||||||
} |
|
||||||
if (conflLocal.size == 2 && conflLocal.newSlot+1 == slot) |
|
||||||
continue next_slot; |
|
||||||
if (conflLocal.newSlot == slot) { |
|
||||||
if (conflLocal.size == 2) |
|
||||||
slot++; |
|
||||||
continue next_slot; |
|
||||||
} |
|
||||||
} |
|
||||||
bestLocal.newSlot = slot; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void distributeLocals() { |
|
||||||
/* give locals new slots. This is a graph coloring |
|
||||||
* algorithm (the optimal solution is NP complete, but this |
|
||||||
* should be a good approximation). |
|
||||||
*/ |
|
||||||
|
|
||||||
/* first give the params the same slot as they had before. |
|
||||||
*/ |
|
||||||
for (int i=0; i<paramLocals.length; i++) |
|
||||||
if (paramLocals[i] != null) |
|
||||||
paramLocals[i].newSlot = i; |
|
||||||
|
|
||||||
/* Now calculate the conflict settings. |
|
||||||
*/ |
|
||||||
for (InstrInfo info = firstInfo; info != null; info = info.nextInfo) { |
|
||||||
if (info.instr.getOpcode() >= BytecodeInfo.opc_istore |
|
||||||
&& info.instr.getOpcode() <= BytecodeInfo.opc_astore) { |
|
||||||
/* This is a store. It conflicts with every local, whose |
|
||||||
* value will be read without write. |
|
||||||
* |
|
||||||
* If this is inside a ret, it also conflicts with |
|
||||||
* locals, that are not used inside, and where any jsr |
|
||||||
* would conflict with. |
|
||||||
*/ |
|
||||||
for (int i=0; i < maxlocals; i++) { |
|
||||||
if (i != info.instr.getLocalSlot() |
|
||||||
&& info.nextReads[i] != null) |
|
||||||
info.local.conflictsWith(info.nextReads[i].local); |
|
||||||
if (info.nextInfo.nextReads[i] != null |
|
||||||
&& info.nextInfo.nextReads[i].jsrTargetInfo != null) { |
|
||||||
Instruction[] jsrs = info.nextInfo.nextReads[i] |
|
||||||
.jsrTargetInfo.instr.getPreds(); |
|
||||||
for (int j=0; j< jsrs.length; j++) { |
|
||||||
InstrInfo jsrInfo |
|
||||||
= (InstrInfo) instrInfos.get(jsrs[j]); |
|
||||||
for (int k=0; k < maxlocals; k++) { |
|
||||||
if (!info.nextInfo.nextReads[i].usedBySub |
|
||||||
.get(k) |
|
||||||
&& jsrInfo.nextReads[k] != null) |
|
||||||
info.local.conflictsWith |
|
||||||
(jsrInfo.nextReads[k].local); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* Now put the locals that need a color into a vector. |
|
||||||
*/ |
|
||||||
Vector locals = new Vector(); |
|
||||||
for (InstrInfo info = firstInfo; info != null; info = info.nextInfo) { |
|
||||||
if (info.local != null |
|
||||||
&& info.local.newSlot == -1 |
|
||||||
&& !locals.contains(info.local)) |
|
||||||
locals.addElement(info.local); |
|
||||||
} |
|
||||||
|
|
||||||
/* Now distribute slots recursive. |
|
||||||
*/ |
|
||||||
distributeLocals(locals); |
|
||||||
|
|
||||||
/* Update the instructions. |
|
||||||
*/ |
|
||||||
for (InstrInfo info = firstInfo; info != null; info = info.nextInfo) { |
|
||||||
if (info.local != null) |
|
||||||
info.instr.setLocalSlot(info.local.newSlot); |
|
||||||
} |
|
||||||
|
|
||||||
/* Update LocalVariableTable |
|
||||||
*/ |
|
||||||
if (produceLVT) |
|
||||||
buildNewLVT(); |
|
||||||
} |
|
||||||
|
|
||||||
private InstrInfo CONFLICT = new InstrInfo(); |
|
||||||
|
|
||||||
boolean promoteLifeLocals(LocalInfo[] newLife, InstrInfo nextInfo) { |
|
||||||
if (nextInfo.lifeLocals == null) { |
|
||||||
nextInfo.lifeLocals = (LocalInfo[]) newLife.clone(); |
|
||||||
return true; |
|
||||||
} |
|
||||||
boolean changed = false; |
|
||||||
for (int i=0; i< maxlocals; i++) { |
|
||||||
LocalInfo local = nextInfo.lifeLocals[i]; |
|
||||||
if (local == null) |
|
||||||
/* A conflict has already happened, or this slot |
|
||||||
* may not have been initialized. */ |
|
||||||
continue; |
|
||||||
|
|
||||||
local = local.getReal(); |
|
||||||
LocalInfo newLocal = newLife[i]; |
|
||||||
if (newLocal != null) |
|
||||||
newLocal = newLocal.getReal(); |
|
||||||
if (local != newLocal) { |
|
||||||
nextInfo.lifeLocals[i] = null; |
|
||||||
changed = true; |
|
||||||
} |
|
||||||
} |
|
||||||
return changed; |
|
||||||
} |
|
||||||
|
|
||||||
public void buildNewLVT() { |
|
||||||
/* First we recalculate the usedBySub, to use the new local numbers. |
|
||||||
*/ |
|
||||||
for (InstrInfo info = firstInfo; info != null; info = info.nextInfo) |
|
||||||
if (info.usedBySub != null) |
|
||||||
info.usedBySub = new BitSet(); |
|
||||||
for (InstrInfo info = firstInfo; info != null; info = info.nextInfo) { |
|
||||||
if (info.local != null) { |
|
||||||
for (int i=0; i < info.nextReads.length; i++) { |
|
||||||
if (info.nextReads[i] != null |
|
||||||
&& info.nextReads[i].instr.getOpcode() == opc_ret) |
|
||||||
info.nextReads[i].usedBySub.set(info.local.newSlot); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* Now we begin with the first Instruction and follow program flow. |
|
||||||
* We remember which locals are life in lifeLocals. |
|
||||||
*/ |
|
||||||
|
|
||||||
firstInfo.lifeLocals = new LocalInfo[maxlocals]; |
|
||||||
for (int i=0; i < paramLocals.length; i++) |
|
||||||
firstInfo.lifeLocals[i] = paramLocals[i]; |
|
||||||
|
|
||||||
Stack changedInfo = new Stack(); |
|
||||||
changedInfo.push(firstInfo); |
|
||||||
Handler[] handlers = bc.getExceptionHandlers(); |
|
||||||
while (!changedInfo.isEmpty()) { |
|
||||||
InstrInfo info = (InstrInfo) changedInfo.pop(); |
|
||||||
Instruction instr = info.instr; |
|
||||||
LocalInfo[] newLife = info.lifeLocals; |
|
||||||
if (instr.hasLocalSlot()) { |
|
||||||
int slot = instr.getLocalSlot(); |
|
||||||
LocalInfo instrLocal = info.local.getReal(); |
|
||||||
newLife = (LocalInfo[]) newLife.clone(); |
|
||||||
newLife[slot] = instrLocal; |
|
||||||
if (instrLocal.name != null) { |
|
||||||
for (int j=0; j< newLife.length; j++) { |
|
||||||
if (j != slot |
|
||||||
&& newLife[j] != null |
|
||||||
&& instrLocal.name.equals(newLife[j].name)) { |
|
||||||
/* This local changed the slot. */ |
|
||||||
newLife[j] = null; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (!instr.doesAlwaysJump()) { |
|
||||||
InstrInfo nextInfo = info.nextInfo; |
|
||||||
if (promoteLifeLocals(newLife, nextInfo)) |
|
||||||
changedInfo.push(nextInfo); |
|
||||||
} |
|
||||||
if (instr.hasSuccs()) { |
|
||||||
Instruction[] succs = instr.getSuccs(); |
|
||||||
for (int i = 0; i < succs.length; i++) { |
|
||||||
InstrInfo nextInfo |
|
||||||
= (InstrInfo) instrInfos.get(succs[i]); |
|
||||||
if (promoteLifeLocals(newLife, nextInfo)) |
|
||||||
changedInfo.push(nextInfo); |
|
||||||
} |
|
||||||
} |
|
||||||
for (int i=0; i < handlers.length; i++) { |
|
||||||
if (handlers[i].start.compareTo(instr) <= 0 |
|
||||||
&& handlers[i].end.compareTo(instr) >= 0) { |
|
||||||
InstrInfo nextInfo |
|
||||||
= (InstrInfo) instrInfos.get(handlers[i].catcher); |
|
||||||
if (promoteLifeLocals(newLife, nextInfo)) |
|
||||||
changedInfo.push(nextInfo); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (info.instr.getOpcode() == opc_jsr) { |
|
||||||
/* On a jsr we do a special merge */ |
|
||||||
|
|
||||||
Instruction jsrTargetInstr = info.instr.getSingleSucc(); |
|
||||||
InstrInfo jsrTargetInfo |
|
||||||
= (InstrInfo) instrInfos.get(jsrTargetInstr); |
|
||||||
InstrInfo retInfo = jsrTargetInfo.retInfo; |
|
||||||
if (retInfo != null && retInfo.lifeLocals != null) { |
|
||||||
LocalInfo[] retLife = (LocalInfo[]) newLife.clone(); |
|
||||||
for (int i=0; i< maxlocals; i++) { |
|
||||||
if (retInfo.usedBySub.get(i)) |
|
||||||
retLife[i] = retInfo.lifeLocals[i]; |
|
||||||
} |
|
||||||
if (promoteLifeLocals(retLife, info.nextInfo)) |
|
||||||
changedInfo.push(info.nextInfo); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (info.jsrTargetInfo != null) { |
|
||||||
/* On a ret we do a special merge */ |
|
||||||
|
|
||||||
Instruction jsrTargetInstr = info.jsrTargetInfo.instr; |
|
||||||
for (int j=0; j< jsrTargetInstr.getPreds().length; j++) { |
|
||||||
InstrInfo jsrInfo |
|
||||||
= (InstrInfo) instrInfos.get(jsrTargetInstr.getPreds()[j]); |
|
||||||
|
|
||||||
if (jsrInfo.lifeLocals == null) |
|
||||||
/* life locals are not calculated, yet */ |
|
||||||
continue; |
|
||||||
LocalInfo[] retLife = (LocalInfo[]) newLife.clone(); |
|
||||||
for (int i=0; i< maxlocals; i++) { |
|
||||||
if (!info.usedBySub.get(i)) |
|
||||||
retLife[i] = jsrInfo.lifeLocals[i]; |
|
||||||
} |
|
||||||
if (promoteLifeLocals(retLife, jsrInfo.nextInfo)) |
|
||||||
changedInfo.push(jsrInfo.nextInfo); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
Vector lvtEntries = new Vector(); |
|
||||||
LocalVariableInfo[] lvi = new LocalVariableInfo[maxlocals]; |
|
||||||
LocalInfo[] currentLocal = new LocalInfo[maxlocals]; |
|
||||||
for (int i=0; i< paramLocals.length; i++) { |
|
||||||
if (paramLocals[i] != null) { |
|
||||||
currentLocal[i] = paramLocals[i]; |
|
||||||
if (currentLocal[i].name != null) { |
|
||||||
lvi[i] = new LocalVariableInfo(); |
|
||||||
lvtEntries.addElement(lvi[i]); |
|
||||||
lvi[i].name = currentLocal[i].name; /* XXX obfuscation? */ |
|
||||||
lvi[i].type = Main.getClassBundle() |
|
||||||
.getTypeAlias(currentLocal[i].type); |
|
||||||
lvi[i].start = (Instruction) bc.getInstructions().get(0); |
|
||||||
lvi[i].slot = i; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
Instruction lastInstr = null; |
|
||||||
for (InstrInfo info = firstInfo; info != null; info = info.nextInfo) { |
|
||||||
for (int i=0; i< maxlocals; i++) { |
|
||||||
LocalInfo lcl = info.lifeLocals != null ? info.lifeLocals[i] |
|
||||||
: null; |
|
||||||
if (lcl != currentLocal[i] |
|
||||||
&& (lcl == null || currentLocal[i] == null |
|
||||||
|| lcl.name == null || lcl.type == null |
|
||||||
|| !lcl.name.equals(currentLocal[i].name) |
|
||||||
|| !lcl.type.equals(currentLocal[i].type))) { |
|
||||||
if (lvi[i] != null) { |
|
||||||
lvi[i].end = info.instr.getPrevByAddr(); |
|
||||||
} |
|
||||||
lvi[i] = null; |
|
||||||
currentLocal[i] = lcl; |
|
||||||
if (currentLocal[i] != null |
|
||||||
&& currentLocal[i].name != null |
|
||||||
&& currentLocal[i].type != null) { |
|
||||||
lvi[i] = new LocalVariableInfo(); |
|
||||||
lvtEntries.addElement(lvi[i]); |
|
||||||
lvi[i].name = currentLocal[i].name; |
|
||||||
lvi[i].type = Main.getClassBundle() |
|
||||||
.getTypeAlias(currentLocal[i].type); |
|
||||||
lvi[i].start = info.instr; |
|
||||||
lvi[i].slot = i; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
lastInstr = info.instr; |
|
||||||
} |
|
||||||
for (int i=0; i< maxlocals; i++) { |
|
||||||
if (lvi[i] != null) |
|
||||||
lvi[i].end = lastInstr; |
|
||||||
} |
|
||||||
LocalVariableInfo[] lvt = new LocalVariableInfo[lvtEntries.size()]; |
|
||||||
lvtEntries.copyInto(lvt); |
|
||||||
bc.setLocalVariableTable(lvt); |
|
||||||
} |
|
||||||
|
|
||||||
public void dumpLocals() { |
|
||||||
Vector locals = new Vector(); |
|
||||||
for (InstrInfo info = firstInfo; info != null; info = info.nextInfo) { |
|
||||||
GlobalOptions.err.println(info.instr.getDescription()); |
|
||||||
GlobalOptions.err.print("nextReads: "); |
|
||||||
for (int i=0; i<maxlocals; i++) |
|
||||||
if (info.nextReads[i] == null) |
|
||||||
GlobalOptions.err.print("-,"); |
|
||||||
else |
|
||||||
GlobalOptions.err.print(info.nextReads[i].instr.getAddr()+","); |
|
||||||
if (info.usedBySub != null) |
|
||||||
GlobalOptions.err.print(" usedBySub: "+info.usedBySub); |
|
||||||
if (info.retInfo != null) |
|
||||||
GlobalOptions.err.print(" ret info: " |
|
||||||
+info.retInfo.instr.getAddr()); |
|
||||||
if (info.jsrTargetInfo != null) |
|
||||||
GlobalOptions.err.print(" jsr info: " |
|
||||||
+info.jsrTargetInfo.instr.getAddr()); |
|
||||||
|
|
||||||
GlobalOptions.err.println(); |
|
||||||
if (info.local != null && !locals.contains(info.local)) |
|
||||||
locals.addElement(info.local); |
|
||||||
} |
|
||||||
Enumeration enum = locals.elements(); |
|
||||||
while (enum.hasMoreElements()) { |
|
||||||
LocalInfo li = (LocalInfo) enum.nextElement(); |
|
||||||
int slot = ((InstrInfo)li.usingInstrs.elementAt(0)) |
|
||||||
.instr.getLocalSlot(); |
|
||||||
GlobalOptions.err.print("Slot: "+slot+" conflicts:"); |
|
||||||
Enumeration enum1 = li.conflictingLocals.elements(); |
|
||||||
while (enum1.hasMoreElements()) { |
|
||||||
LocalInfo cfl = (LocalInfo)enum1.nextElement(); |
|
||||||
GlobalOptions.err.print(cfl.getFirstAddr()+", "); |
|
||||||
} |
|
||||||
GlobalOptions.err.println(); |
|
||||||
GlobalOptions.err.print(li.getFirstAddr()); |
|
||||||
GlobalOptions.err.print(" instrs: "); |
|
||||||
Enumeration enum2 = li.usingInstrs.elements(); |
|
||||||
while (enum2.hasMoreElements()) |
|
||||||
GlobalOptions.err.print(((InstrInfo)enum2.nextElement()) |
|
||||||
.instr.getAddr()+", "); |
|
||||||
GlobalOptions.err.println(); |
|
||||||
} |
|
||||||
GlobalOptions.err.println("-----------"); |
|
||||||
} |
|
||||||
|
|
||||||
public void transformCode(BytecodeInfo bytecode) { |
|
||||||
this.bc = bytecode; |
|
||||||
calcLocalInfo(); |
|
||||||
if ((GlobalOptions.debuggingFlags |
|
||||||
& GlobalOptions.DEBUG_LOCALS) != 0) { |
|
||||||
GlobalOptions.err.println("Before Local Optimization: "); |
|
||||||
dumpLocals(); |
|
||||||
} |
|
||||||
stripLocals(); |
|
||||||
distributeLocals(); |
|
||||||
|
|
||||||
if ((GlobalOptions.debuggingFlags |
|
||||||
& GlobalOptions.DEBUG_LOCALS) != 0) { |
|
||||||
GlobalOptions.err.println("After Local Optimization: "); |
|
||||||
dumpLocals(); |
|
||||||
} |
|
||||||
|
|
||||||
firstInfo = null; |
|
||||||
changedInfos = null; |
|
||||||
instrInfos = null; |
|
||||||
paramLocals = null; |
|
||||||
} |
|
||||||
} |
|
@ -1,41 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
JAR = @JAR@
|
|
||||||
JAVAC = @JAVAC@
|
|
||||||
JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\
|
|
||||||
-dependdir=$(top_builddir) -classpath=$(top_builddir):$(top_srcdir) \
|
|
||||||
-depfile=Makefile.dep
|
|
||||||
CLASSPATH = @CLASSPATH@
|
|
||||||
CLASSLIB = @CLASSLIB@
|
|
||||||
SUBSTCP = @SUBSTCP@
|
|
||||||
FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB))
|
|
||||||
|
|
||||||
MY_JAVA_FILES = \
|
|
||||||
ConstantAnalyzer.java \
|
|
||||||
KeywordRenamer.java \
|
|
||||||
LocalOptimizer.java \
|
|
||||||
ModifierMatcher.java \
|
|
||||||
MultiIdentifierMatcher.java \
|
|
||||||
NameSwapper.java \
|
|
||||||
RemovePopAnalyzer.java \
|
|
||||||
SerializePreserver.java \
|
|
||||||
SimpleAnalyzer.java \
|
|
||||||
StrongRenamer.java \
|
|
||||||
UniqueRenamer.java \
|
|
||||||
WildCard.java
|
|
||||||
# LocalizeFieldTransformer.java
|
|
||||||
|
|
||||||
noinst_DATA = $(MY_JAVA_FILES:.java=.class)
|
|
||||||
EXTRA_DIST = $(MY_JAVA_FILES)
|
|
||||||
|
|
||||||
@QUOTE@-include Makefile.dep |
|
||||||
|
|
||||||
%.class: %.java |
|
||||||
$(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $<
|
|
||||||
|
|
||||||
Makefile.dep: $(MY_JAVA_FILES:.java=.class) |
|
||||||
$(JAVADEP) $^
|
|
||||||
|
|
||||||
clean-local: |
|
||||||
@rm -f *.class
|
|
||||||
@rm -f *.dep
|
|
@ -1,308 +0,0 @@ |
|||||||
/* RemovePopAnalyzer Copyright (C) 1999-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU General Public License |
|
||||||
* along with this program; see the file COPYING. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.obfuscator.modules; |
|
||||||
import jode.bytecode.*; |
|
||||||
import jode.obfuscator.*; |
|
||||||
import jode.AssertError; |
|
||||||
import jode.GlobalOptions; |
|
||||||
|
|
||||||
import @COLLECTIONS@.ListIterator; |
|
||||||
|
|
||||||
public class RemovePopAnalyzer implements CodeTransformer, Opcodes { |
|
||||||
public RemovePopAnalyzer() { |
|
||||||
} |
|
||||||
|
|
||||||
public void transformCode(BytecodeInfo bytecode) { |
|
||||||
int poppush[] = new int[2]; |
|
||||||
ListIterator iter = bytecode.getInstructions().listIterator(); |
|
||||||
next_pop: |
|
||||||
while (iter.hasNext()) { |
|
||||||
Instruction popInstr = (Instruction) iter.next(); |
|
||||||
boolean isPop2 = false; |
|
||||||
switch (popInstr.getOpcode()) { |
|
||||||
case opc_nop: { |
|
||||||
iter.remove(); |
|
||||||
continue; |
|
||||||
} |
|
||||||
|
|
||||||
case opc_pop2: |
|
||||||
isPop2 = true; |
|
||||||
case opc_pop: |
|
||||||
if (popInstr.getPreds() != null) |
|
||||||
// Can't handle pop with multiple predecessors
|
|
||||||
continue next_pop; |
|
||||||
Handler[] handlers = bytecode.getExceptionHandlers(); |
|
||||||
for (int i=0; i < handlers.length; i++) |
|
||||||
if (handlers[i].catcher == popInstr) |
|
||||||
continue next_pop; |
|
||||||
|
|
||||||
// remove pop, we will insert it again if something
|
|
||||||
// bad happened.
|
|
||||||
iter.remove(); |
|
||||||
|
|
||||||
// remember position of pop, so we can insert it again.
|
|
||||||
Instruction popPrevious = (Instruction) iter.previous(); |
|
||||||
Instruction instr = popPrevious; |
|
||||||
int count = 0; |
|
||||||
while (true) { |
|
||||||
if (instr.getSuccs() != null |
|
||||||
|| instr.doesAlwaysJump()) { |
|
||||||
instr = null; |
|
||||||
break; |
|
||||||
} |
|
||||||
instr.getStackPopPush(poppush); |
|
||||||
|
|
||||||
if (count < poppush[1]) { |
|
||||||
if (count == 0) |
|
||||||
break; |
|
||||||
|
|
||||||
int opcode = instr.getOpcode(); |
|
||||||
/* If this is a dup and the instruction popped is the |
|
||||||
* duplicated element, remove the dup and the pop |
|
||||||
*/ |
|
||||||
if (count <= 3 && opcode == (opc_dup + count - 1)) { |
|
||||||
iter.remove(); |
|
||||||
if (!isPop2) |
|
||||||
continue next_pop; |
|
||||||
|
|
||||||
// We have to consider a pop instead of a
|
|
||||||
// pop2 now.
|
|
||||||
popInstr = new Instruction(opc_pop); |
|
||||||
isPop2 = false; |
|
||||||
instr = (Instruction) iter.previous(); |
|
||||||
continue; |
|
||||||
} |
|
||||||
|
|
||||||
if (isPop2 |
|
||||||
&& count > 1 && count <= 4 |
|
||||||
&& opcode == (opc_dup2 + count-2)) { |
|
||||||
iter.remove(); |
|
||||||
continue next_pop; |
|
||||||
} |
|
||||||
/* Otherwise popping is not possible */ |
|
||||||
instr = null; |
|
||||||
break; |
|
||||||
} |
|
||||||
count += poppush[0] - poppush[1]; |
|
||||||
instr = (Instruction) iter.previous(); |
|
||||||
} |
|
||||||
|
|
||||||
if (instr == null) { |
|
||||||
// We insert the pop at the previous position
|
|
||||||
while (iter.next() != popPrevious) |
|
||||||
{} |
|
||||||
if (!isPop2 && popPrevious.getOpcode() == opc_pop) { |
|
||||||
// merge pop with popPrevious
|
|
||||||
iter.set(new Instruction(opc_pop2)); |
|
||||||
} else |
|
||||||
iter.add(popInstr); |
|
||||||
continue; |
|
||||||
} |
|
||||||
int opcode = instr.getOpcode(); |
|
||||||
switch (opcode) { |
|
||||||
case opc_ldc2_w: |
|
||||||
case opc_lload: case opc_dload: |
|
||||||
if (!isPop2) |
|
||||||
throw new AssertError("pop on long"); |
|
||||||
iter.remove(); |
|
||||||
continue; |
|
||||||
case opc_ldc: |
|
||||||
case opc_iload: case opc_fload: case opc_aload: |
|
||||||
case opc_dup: |
|
||||||
case opc_new: |
|
||||||
if (isPop2) |
|
||||||
iter.set(new Instruction(opc_pop)); |
|
||||||
else |
|
||||||
iter.remove(); |
|
||||||
continue; |
|
||||||
case opc_iaload: case opc_faload: case opc_aaload: |
|
||||||
case opc_baload: case opc_caload: case opc_saload: |
|
||||||
case opc_iadd: case opc_fadd: |
|
||||||
case opc_isub: case opc_fsub: |
|
||||||
case opc_imul: case opc_fmul: |
|
||||||
case opc_idiv: case opc_fdiv: |
|
||||||
case opc_irem: case opc_frem: |
|
||||||
case opc_iand: case opc_ior : case opc_ixor: |
|
||||||
case opc_ishl: case opc_ishr: case opc_iushr: |
|
||||||
case opc_fcmpl: case opc_fcmpg: |
|
||||||
/* We have to pop one entry more. */ |
|
||||||
iter.next(); |
|
||||||
iter.add(popInstr); |
|
||||||
iter.previous(); |
|
||||||
iter.previous(); |
|
||||||
iter.set(new Instruction(opc_pop)); |
|
||||||
continue; |
|
||||||
|
|
||||||
case opc_dup_x1: |
|
||||||
iter.set(new Instruction(opc_swap)); |
|
||||||
iter.next(); |
|
||||||
if (isPop2) |
|
||||||
iter.add(new Instruction(opc_pop)); |
|
||||||
continue; |
|
||||||
|
|
||||||
case opc_dup2: |
|
||||||
if (isPop2) { |
|
||||||
iter.remove(); |
|
||||||
continue; |
|
||||||
} |
|
||||||
break; |
|
||||||
case opc_swap: |
|
||||||
if (isPop2) { |
|
||||||
iter.set(popInstr); |
|
||||||
continue; |
|
||||||
} |
|
||||||
break; |
|
||||||
|
|
||||||
case opc_lneg: case opc_dneg: |
|
||||||
case opc_l2d: case opc_d2l: |
|
||||||
case opc_laload: case opc_daload: |
|
||||||
if (!isPop2) |
|
||||||
throw new AssertError("pop on long"); |
|
||||||
/* fall through */ |
|
||||||
case opc_ineg: case opc_fneg: |
|
||||||
case opc_i2f: case opc_f2i: |
|
||||||
case opc_i2b: case opc_i2c: case opc_i2s: |
|
||||||
case opc_newarray: case opc_anewarray: |
|
||||||
case opc_arraylength: |
|
||||||
case opc_instanceof: |
|
||||||
iter.set(popInstr); |
|
||||||
continue; |
|
||||||
|
|
||||||
case opc_l2i: case opc_l2f: |
|
||||||
case opc_d2i: case opc_d2f: |
|
||||||
if (isPop2) { |
|
||||||
iter.next(); |
|
||||||
iter.add(new Instruction(opc_pop)); |
|
||||||
iter.previous(); |
|
||||||
iter.previous(); |
|
||||||
} |
|
||||||
iter.set(new Instruction(opc_pop2)); |
|
||||||
continue; |
|
||||||
|
|
||||||
case opc_ladd: case opc_dadd: |
|
||||||
case opc_lsub: case opc_dsub: |
|
||||||
case opc_lmul: case opc_dmul: |
|
||||||
case opc_ldiv: case opc_ddiv: |
|
||||||
case opc_lrem: case opc_drem: |
|
||||||
case opc_land: case opc_lor : case opc_lxor: |
|
||||||
if (!isPop2) |
|
||||||
throw new AssertError("pop on long"); |
|
||||||
iter.next(); |
|
||||||
iter.add(popInstr); |
|
||||||
iter.previous(); |
|
||||||
iter.previous(); |
|
||||||
iter.set(new Instruction(opc_pop2)); |
|
||||||
continue; |
|
||||||
case opc_lshl: case opc_lshr: case opc_lushr: |
|
||||||
if (!isPop2) |
|
||||||
throw new AssertError("pop on long"); |
|
||||||
iter.next(); |
|
||||||
iter.add(popInstr); |
|
||||||
iter.previous(); |
|
||||||
iter.previous(); |
|
||||||
iter.set(new Instruction(opc_pop)); |
|
||||||
continue; |
|
||||||
|
|
||||||
case opc_i2l: case opc_i2d: |
|
||||||
case opc_f2l: case opc_f2d: |
|
||||||
if (!isPop2) |
|
||||||
throw new AssertError("pop on long"); |
|
||||||
iter.set(new Instruction(opc_pop)); |
|
||||||
continue; |
|
||||||
|
|
||||||
case opc_lcmp: |
|
||||||
case opc_dcmpl: case opc_dcmpg: |
|
||||||
iter.next(); |
|
||||||
iter.add(new Instruction(opc_pop2)); |
|
||||||
if (isPop2) { |
|
||||||
iter.add(new Instruction(opc_pop)); |
|
||||||
iter.previous(); |
|
||||||
} |
|
||||||
iter.previous(); |
|
||||||
iter.previous(); |
|
||||||
iter.set(new Instruction(opc_pop2)); |
|
||||||
continue; |
|
||||||
|
|
||||||
case opc_getstatic: |
|
||||||
case opc_getfield: { |
|
||||||
Reference ref = instr.getReference(); |
|
||||||
int size = TypeSignature.getTypeSize(ref.getType()); |
|
||||||
if (size == 2 && !isPop2) |
|
||||||
throw new AssertError("pop on long"); |
|
||||||
if (opcode == opc_getfield) |
|
||||||
size--; |
|
||||||
switch (size) { |
|
||||||
case 0: |
|
||||||
iter.set(popInstr); |
|
||||||
break; |
|
||||||
case 1: |
|
||||||
if (isPop2) { |
|
||||||
iter.set(new Instruction(opc_pop)); |
|
||||||
break; |
|
||||||
} |
|
||||||
/* fall through */ |
|
||||||
case 2: |
|
||||||
iter.remove(); |
|
||||||
} |
|
||||||
continue; |
|
||||||
} |
|
||||||
|
|
||||||
case opc_multianewarray: { |
|
||||||
int dims = instr.getDimensions(); |
|
||||||
if (--dims > 0) { |
|
||||||
iter.next(); |
|
||||||
while (dims-- > 0) { |
|
||||||
iter.add(new Instruction(opc_pop)); |
|
||||||
iter.previous(); |
|
||||||
} |
|
||||||
iter.previous(); |
|
||||||
} |
|
||||||
iter.set(popInstr); |
|
||||||
continue; |
|
||||||
} |
|
||||||
|
|
||||||
case opc_invokevirtual: |
|
||||||
case opc_invokespecial: |
|
||||||
case opc_invokestatic: |
|
||||||
case opc_invokeinterface: |
|
||||||
if (TypeSignature.getReturnSize |
|
||||||
(instr.getReference().getType()) != 1) |
|
||||||
break; |
|
||||||
/* fall through */ |
|
||||||
case opc_checkcast: |
|
||||||
if (isPop2) { |
|
||||||
/* This is/may be a double pop on a single value |
|
||||||
* split it and continue with second half |
|
||||||
*/ |
|
||||||
iter.next(); |
|
||||||
iter.add(new Instruction(opc_pop)); |
|
||||||
iter.add(new Instruction(opc_pop)); |
|
||||||
iter.previous(); |
|
||||||
continue; |
|
||||||
} |
|
||||||
} |
|
||||||
// append the pop behind the unresolvable opcode.
|
|
||||||
iter.next(); |
|
||||||
iter.add(popInstr); |
|
||||||
continue; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,201 +0,0 @@ |
|||||||
/* SimpleAnalyzer Copyright (C) 1999-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU General Public License |
|
||||||
* along with this program; see the file COPYING. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.obfuscator.modules; |
|
||||||
import jode.bytecode.Handler; |
|
||||||
import jode.bytecode.Opcodes; |
|
||||||
import jode.bytecode.ClassInfo; |
|
||||||
import jode.bytecode.BytecodeInfo; |
|
||||||
import jode.bytecode.Instruction; |
|
||||||
import jode.bytecode.Reference; |
|
||||||
import jode.bytecode.TypeSignature; |
|
||||||
import jode.obfuscator.Identifier; |
|
||||||
import jode.obfuscator.*; |
|
||||||
import jode.GlobalOptions; |
|
||||||
|
|
||||||
import @COLLECTIONS@.Iterator; |
|
||||||
import @COLLECTIONS@.ListIterator; |
|
||||||
|
|
||||||
public class SimpleAnalyzer implements CodeAnalyzer, Opcodes { |
|
||||||
|
|
||||||
private ClassInfo canonizeIfaceRef(ClassInfo clazz, Reference ref) { |
|
||||||
while (clazz != null) { |
|
||||||
if (clazz.findMethod(ref.getName(), ref.getType()) != null) |
|
||||||
return clazz; |
|
||||||
ClassInfo[] ifaces = clazz.getInterfaces(); |
|
||||||
for (int i = 0; i < ifaces.length; i++) { |
|
||||||
ClassInfo realClass = canonizeIfaceRef(ifaces[i], ref); |
|
||||||
if (realClass != null) |
|
||||||
return realClass; |
|
||||||
} |
|
||||||
clazz = clazz.getSuperclass(); |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public Identifier canonizeReference(Instruction instr) { |
|
||||||
Reference ref = instr.getReference(); |
|
||||||
Identifier ident = Main.getClassBundle().getIdentifier(ref); |
|
||||||
String clName = ref.getClazz(); |
|
||||||
String realClazzName; |
|
||||||
if (ident != null) { |
|
||||||
ClassIdentifier clazz = (ClassIdentifier)ident.getParent(); |
|
||||||
realClazzName = "L" + (clazz.getFullName() |
|
||||||
.replace('.', '/')) + ";"; |
|
||||||
} else { |
|
||||||
/* We have to look at the ClassInfo's instead, to |
|
||||||
* point to the right method. |
|
||||||
*/ |
|
||||||
ClassInfo clazz; |
|
||||||
if (clName.charAt(0) == '[') { |
|
||||||
/* Arrays don't define new methods (well clone(), |
|
||||||
* but that can be ignored). |
|
||||||
*/ |
|
||||||
clazz = ClassInfo.javaLangObject; |
|
||||||
} else { |
|
||||||
clazz = ClassInfo.forName |
|
||||||
(clName.substring(1, clName.length()-1) |
|
||||||
.replace('/','.')); |
|
||||||
} |
|
||||||
if (instr.getOpcode() == opc_invokeinterface) { |
|
||||||
clazz = canonizeIfaceRef(clazz, ref); |
|
||||||
} else if (instr.getOpcode() >= opc_invokevirtual) { |
|
||||||
while (clazz != null |
|
||||||
&& clazz.findMethod(ref.getName(), |
|
||||||
ref.getType()) == null) |
|
||||||
clazz = clazz.getSuperclass(); |
|
||||||
} else { |
|
||||||
while (clazz != null |
|
||||||
&& clazz.findField(ref.getName(), |
|
||||||
ref.getType()) == null) |
|
||||||
clazz = clazz.getSuperclass(); |
|
||||||
} |
|
||||||
|
|
||||||
if (clazz == null) { |
|
||||||
GlobalOptions.err.println("WARNING: Can't find reference: " |
|
||||||
+ref); |
|
||||||
realClazzName = clName; |
|
||||||
} else |
|
||||||
realClazzName = "L" + clazz.getName().replace('.', '/') + ";"; |
|
||||||
} |
|
||||||
if (!realClazzName.equals(ref.getClazz())) { |
|
||||||
ref = Reference.getReference(realClazzName, |
|
||||||
ref.getName(), ref.getType()); |
|
||||||
instr.setReference(ref); |
|
||||||
} |
|
||||||
return ident; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* Reads the opcodes out of the code info and determine its |
|
||||||
* references |
|
||||||
* @return an enumeration of the references. |
|
||||||
*/ |
|
||||||
public void analyzeCode(MethodIdentifier m, BytecodeInfo bytecode) { |
|
||||||
for (Iterator iter = bytecode.getInstructions().iterator(); |
|
||||||
iter.hasNext(); ) { |
|
||||||
Instruction instr = (Instruction) iter.next(); |
|
||||||
switch (instr.getOpcode()) { |
|
||||||
case opc_checkcast: |
|
||||||
case opc_instanceof: |
|
||||||
case opc_multianewarray: { |
|
||||||
String clName = instr.getClazzType(); |
|
||||||
int i = 0; |
|
||||||
while (i < clName.length() && clName.charAt(i) == '[') |
|
||||||
i++; |
|
||||||
if (i < clName.length() && clName.charAt(i) == 'L') { |
|
||||||
clName = clName.substring(i+1, clName.length()-1) |
|
||||||
.replace('/','.'); |
|
||||||
Main.getClassBundle().reachableClass(clName); |
|
||||||
} |
|
||||||
break; |
|
||||||
} |
|
||||||
case opc_invokespecial: |
|
||||||
case opc_invokestatic: |
|
||||||
case opc_invokeinterface: |
|
||||||
case opc_invokevirtual: |
|
||||||
case opc_putstatic: |
|
||||||
case opc_putfield: |
|
||||||
m.setGlobalSideEffects(); |
|
||||||
/* fall through */ |
|
||||||
case opc_getstatic: |
|
||||||
case opc_getfield: { |
|
||||||
Identifier ident = canonizeReference(instr); |
|
||||||
if (ident != null) { |
|
||||||
if (instr.getOpcode() == opc_putstatic |
|
||||||
|| instr.getOpcode() == opc_putfield) { |
|
||||||
FieldIdentifier fi = (FieldIdentifier) ident; |
|
||||||
if (fi != null && !fi.isNotConstant()) |
|
||||||
fi.setNotConstant(); |
|
||||||
} else if (instr.getOpcode() == opc_invokevirtual |
|
||||||
|| instr.getOpcode() == opc_invokeinterface) { |
|
||||||
((ClassIdentifier) ident.getParent()) |
|
||||||
.reachableReference(instr.getReference(), true); |
|
||||||
} else { |
|
||||||
ident.setReachable(); |
|
||||||
} |
|
||||||
} |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
Handler[] handlers = bytecode.getExceptionHandlers(); |
|
||||||
for (int i=0; i< handlers.length; i++) { |
|
||||||
if (handlers[i].type != null) |
|
||||||
Main.getClassBundle() |
|
||||||
.reachableClass(handlers[i].type); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void transformCode(BytecodeInfo bytecode) { |
|
||||||
for (ListIterator iter = bytecode.getInstructions().listIterator(); |
|
||||||
iter.hasNext(); ) { |
|
||||||
Instruction instr = (Instruction) iter.next(); |
|
||||||
if (instr.getOpcode() == opc_putstatic |
|
||||||
|| instr.getOpcode() == opc_putfield) { |
|
||||||
Reference ref = instr.getReference(); |
|
||||||
FieldIdentifier fi = (FieldIdentifier) |
|
||||||
Main.getClassBundle().getIdentifier(ref); |
|
||||||
if (fi != null |
|
||||||
&& (Main.stripping & Main.STRIP_UNREACH) != 0 |
|
||||||
&& !fi.isReachable()) { |
|
||||||
/* Replace instruction with pop opcodes. */ |
|
||||||
int stacksize = |
|
||||||
(instr.getOpcode() |
|
||||||
== Instruction.opc_putstatic) ? 0 : 1; |
|
||||||
stacksize += TypeSignature.getTypeSize(ref.getType()); |
|
||||||
switch (stacksize) { |
|
||||||
case 1: |
|
||||||
iter.set(new Instruction(Instruction.opc_pop)); |
|
||||||
break; |
|
||||||
case 2: |
|
||||||
iter.set(new Instruction(Instruction.opc_pop2)); |
|
||||||
break; |
|
||||||
case 3: |
|
||||||
iter.set(new Instruction(Instruction.opc_pop2)); |
|
||||||
iter.add(new Instruction(Instruction.opc_pop)); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,2 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
@ -1,31 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
JAR = @JAR@
|
|
||||||
JAVAC = @JAVAC@
|
|
||||||
JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\
|
|
||||||
-dependdir=$(top_builddir) -classpath=$(top_builddir):$(top_srcdir) \
|
|
||||||
-depfile=Makefile.dep
|
|
||||||
CLASSPATH = @CLASSPATH@
|
|
||||||
CLASSLIB = @CLASSLIB@
|
|
||||||
SUBSTCP = @SUBSTCP@
|
|
||||||
FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB))
|
|
||||||
|
|
||||||
MY_JAVA_FILES = \
|
|
||||||
Main.java \
|
|
||||||
HierarchyTreeModel.java \
|
|
||||||
PackagesTreeModel.java
|
|
||||||
|
|
||||||
noinst_DATA = $(MY_JAVA_FILES:.java=.class)
|
|
||||||
EXTRA_DIST = $(MY_JAVA_FILES)
|
|
||||||
|
|
||||||
@QUOTE@-include Makefile.dep |
|
||||||
|
|
||||||
%.class: %.java |
|
||||||
$(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $<
|
|
||||||
|
|
||||||
Makefile.dep: $(MY_JAVA_FILES:.java=.class) |
|
||||||
$(JAVADEP) $^
|
|
||||||
|
|
||||||
clean-local: |
|
||||||
@rm -f *.class
|
|
||||||
@rm -f *.dep
|
|
@ -1,2 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
@ -1,619 +0,0 @@ |
|||||||
/* ClassInterfacesType Copyright (C) 1998-2002 Jochen Hoenicke. |
|
||||||
* |
|
||||||
* This program is free software; you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU Lesser General Public License as published by |
|
||||||
* the Free Software Foundation; either version 2, or (at your option) |
|
||||||
* any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU Lesser General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU Lesser General Public License |
|
||||||
* along with this program; see the file COPYING.LESSER. If not, write to |
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
||||||
* |
|
||||||
* $Id$ |
|
||||||
*/ |
|
||||||
|
|
||||||
package jode.type; |
|
||||||
import jode.bytecode.ClassInfo; |
|
||||||
import java.util.Vector; |
|
||||||
import java.util.Stack; |
|
||||||
import java.util.Hashtable; |
|
||||||
|
|
||||||
/** |
|
||||||
* This class represents a type aproximation, consisting of multiple |
|
||||||
* interfaces and a class type.<p> |
|
||||||
* |
|
||||||
* If this is the bottom boundary, this specifies, which class our |
|
||||||
* type must extend and which interfaces it must implement. |
|
||||||
* |
|
||||||
* If this is the top boundary, this gives all interfaces and classes |
|
||||||
* that may extend the type. I.e. at least one interface or class extends |
|
||||||
* the searched type. |
|
||||||
* |
|
||||||
* @author Jochen Hoenicke */ |
|
||||||
public class ClassInterfacesType extends ReferenceType { |
|
||||||
|
|
||||||
ClassInfo clazz; |
|
||||||
ClassInfo ifaces[]; |
|
||||||
|
|
||||||
public ClassInfo getClazz() { |
|
||||||
return clazz != null ? clazz : ClassInfo.javaLangObject; |
|
||||||
} |
|
||||||
|
|
||||||
public ClassInterfacesType(String clazzName) { |
|
||||||
super(TC_CLASS); |
|
||||||
ClassInfo clazz = ClassInfo.forName(clazzName); |
|
||||||
if (clazz.isInterface()) { |
|
||||||
this.clazz = null; |
|
||||||
ifaces = new ClassInfo[] {clazz}; |
|
||||||
} else { |
|
||||||
this.clazz = |
|
||||||
(clazz == ClassInfo.javaLangObject) ? null : clazz; |
|
||||||
ifaces = new ClassInfo[0]; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public ClassInterfacesType(ClassInfo clazz) { |
|
||||||
super(TC_CLASS); |
|
||||||
if (clazz.isInterface()) { |
|
||||||
this.clazz = null; |
|
||||||
ifaces = new ClassInfo[] { clazz }; |
|
||||||
} else { |
|
||||||
this.clazz = |
|
||||||
(clazz == ClassInfo.javaLangObject) ? null : clazz; |
|
||||||
ifaces = new ClassInfo[0]; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public ClassInterfacesType(ClassInfo clazz, ClassInfo[] ifaces) { |
|
||||||
super(TC_CLASS); |
|
||||||
this.clazz = clazz; |
|
||||||
this.ifaces = ifaces; |
|
||||||
} |
|
||||||
|
|
||||||
static ClassInterfacesType create(ClassInfo clazz, ClassInfo[] ifaces) { |
|
||||||
/* Make sure that every {java.lang.Object} equals tObject */ |
|
||||||
if (ifaces.length == 0 && clazz == null) |
|
||||||
return tObject; |
|
||||||
if (ifaces.length == 0) |
|
||||||
return tClass(clazz); |
|
||||||
if (ifaces.length == 1 && clazz == null) |
|
||||||
return tClass(ifaces[0]); |
|
||||||
return new ClassInterfacesType(clazz, ifaces); |
|
||||||
} |
|
||||||
|
|
||||||
public Type getSubType() { |
|
||||||
if ((clazz == null && ifaces.length == 1) |
|
||||||
|| ifaces.length == 0) |
|
||||||
return tRange(this, tNull); |
|
||||||
|
|
||||||
/* We don't implement the set of types, that are castable to some |
|
||||||
* of the given classes or interfaces. |
|
||||||
*/ |
|
||||||
throw new jode.AssertError |
|
||||||
("getSubType called on set of classes and interfaces!"); |
|
||||||
} |
|
||||||
|
|
||||||
public Type getHint() { |
|
||||||
if (ifaces.length == 0 |
|
||||||
|| (clazz == null && ifaces.length == 1)) |
|
||||||
return this; |
|
||||||
if (clazz != null) |
|
||||||
return Type.tClass(clazz.getName()); |
|
||||||
else |
|
||||||
return Type.tClass(ifaces[0].getName()); |
|
||||||
} |
|
||||||
|
|
||||||
public Type getCanonic() { |
|
||||||
if (ifaces.length == 0 |
|
||||||
|| (clazz == null && ifaces.length == 1)) |
|
||||||
return this; |
|
||||||
if (clazz != null) |
|
||||||
return Type.tClass(clazz.getName()); |
|
||||||
else |
|
||||||
return Type.tClass(ifaces[0].getName()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Create the type corresponding to the range from bottomType to |
|
||||||
* this. Checks if the given type range may be not empty. This |
|
||||||
* means, that bottom.clazz is extended by this.clazz and that all |
|
||||||
* interfaces in bottom are implemented by an interface or by |
|
||||||
* clazz. |
|
||||||
* @param bottom the start point of the range |
|
||||||
* @return the range type, or tError if range is empty. |
|
||||||
*/ |
|
||||||
public Type createRangeType(ReferenceType bottomType) { |
|
||||||
if (bottomType.typecode != TC_CLASS) |
|
||||||
return tError; |
|
||||||
|
|
||||||
ClassInterfacesType bottom = (ClassInterfacesType) bottomType; |
|
||||||
|
|
||||||
if (bottomType == tObject) |
|
||||||
return (this == tObject) ? tObject : tRange(tObject, this); |
|
||||||
|
|
||||||
if (bottom.clazz != null) { |
|
||||||
/* The searched type must be a class type. |
|
||||||
*/ |
|
||||||
if (!bottom.clazz.superClassOf(this.clazz)) |
|
||||||
return tError; |
|
||||||
|
|
||||||
/* All interfaces must be implemented by this.clazz |
|
||||||
*/ |
|
||||||
for (int i=0; i < bottom.ifaces.length; i++) { |
|
||||||
if (!bottom.ifaces[i].implementedBy(this.clazz)) |
|
||||||
return tError; |
|
||||||
} |
|
||||||
|
|
||||||
if (bottom.clazz == this.clazz |
|
||||||
&& bottom.ifaces.length == 0) |
|
||||||
return bottom; |
|
||||||
|
|
||||||
if (this.ifaces.length != 0) |
|
||||||
return tRange(bottom, create(this.clazz, new ClassInfo[0])); |
|
||||||
return tRange(bottom, this); |
|
||||||
|
|
||||||
} else { |
|
||||||
|
|
||||||
/* Now bottom.clazz is null (or tObject), find all |
|
||||||
* classes/interfaces that implement all bottom.ifaces. |
|
||||||
*/ |
|
||||||
|
|
||||||
ClassInfo clazz = this.clazz; |
|
||||||
if (clazz != null) { |
|
||||||
for (int i=0; i < bottom.ifaces.length; i++) { |
|
||||||
if (!bottom.ifaces[i].implementedBy(clazz)) { |
|
||||||
clazz = null; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* If bottom is a single interface and equals some top |
|
||||||
* interface, then bottom is the only possible type. |
|
||||||
*/ |
|
||||||
if (clazz == null && bottom.ifaces.length == 1) { |
|
||||||
for (int i=0; i< this.ifaces.length; i++) { |
|
||||||
if (this.ifaces[i] == bottom.ifaces[0]) |
|
||||||
return bottom; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
ClassInfo[] ifaces = new ClassInfo[this.ifaces.length]; |
|
||||||
int count = 0; |
|
||||||
big_loop: |
|
||||||
for (int j=0; j < this.ifaces.length; j++) { |
|
||||||
for (int i=0; i < bottom.ifaces.length; i++) { |
|
||||||
if (!bottom.ifaces[i].implementedBy(this.ifaces[j])) |
|
||||||
continue big_loop; |
|
||||||
} |
|
||||||
ifaces[count++] = (this.ifaces[j]); |
|
||||||
} |
|
||||||
|
|
||||||
if (clazz == null && count == 0) { |
|
||||||
/* There are no more possible interfaces or classes left. |
|
||||||
* This is a type error. |
|
||||||
*/ |
|
||||||
return tError; |
|
||||||
} else if (count < ifaces.length) { |
|
||||||
ClassInfo[] shortIfaces = new ClassInfo[count]; |
|
||||||
System.arraycopy(ifaces, 0, shortIfaces, 0, count); |
|
||||||
ifaces = shortIfaces; |
|
||||||
} else if (clazz == this.clazz) |
|
||||||
return tRange(bottom, this); |
|
||||||
return tRange(bottom, create(clazz, ifaces)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the specialized type of this and type. |
|
||||||
* We have two classes and multiple interfaces. The result |
|
||||||
* should be the object that extends both objects |
|
||||||
* and the union of all interfaces. |
|
||||||
*/ |
|
||||||
public Type getSpecializedType(Type type) { |
|
||||||
int code = type.typecode; |
|
||||||
if (code == TC_RANGE) { |
|
||||||
type = ((RangeType) type).getBottom(); |
|
||||||
code = type.typecode; |
|
||||||
} |
|
||||||
if (code == TC_NULL) |
|
||||||
return this; |
|
||||||
if (code == TC_ARRAY) |
|
||||||
return ((ArrayType) type).getSpecializedType(this); |
|
||||||
if (code != TC_CLASS) |
|
||||||
return tError; |
|
||||||
|
|
||||||
ClassInterfacesType other = (ClassInterfacesType) type; |
|
||||||
ClassInfo clazz; |
|
||||||
|
|
||||||
/* First determine the clazz, one of the two classes must be a sub |
|
||||||
* class of the other or null. |
|
||||||
*/ |
|
||||||
|
|
||||||
if (this.clazz == null) |
|
||||||
clazz = other.clazz; |
|
||||||
else if (other.clazz == null) |
|
||||||
clazz = this.clazz; |
|
||||||
else if (this.clazz.superClassOf(other.clazz)) |
|
||||||
clazz = other.clazz; |
|
||||||
else if (other.clazz.superClassOf(this.clazz)) |
|
||||||
clazz = this.clazz; |
|
||||||
else |
|
||||||
return tError; |
|
||||||
|
|
||||||
/* Most times (99.9999999 %) one of the two classes is already |
|
||||||
* more specialized. Optimize for this case. (I know of one |
|
||||||
* class where at one intersection this doesn't succeed) |
|
||||||
*/ |
|
||||||
if (clazz == this.clazz |
|
||||||
&& implementsAllIfaces(this.clazz, this.ifaces, other.ifaces)) |
|
||||||
return this; |
|
||||||
else if (clazz == other.clazz |
|
||||||
&& implementsAllIfaces(other.clazz, other.ifaces, |
|
||||||
this.ifaces)) |
|
||||||
return other; |
|
||||||
|
|
||||||
/* The interfaces are simply the union of both interfaces set. |
|
||||||
* But we can simplify this, if an interface is implemented by |
|
||||||
* another or by the class, we can omit it. |
|
||||||
*/ |
|
||||||
Vector ifaces = new Vector(); |
|
||||||
big_loop_this: |
|
||||||
for (int i=0; i< this.ifaces.length; i++) { |
|
||||||
ClassInfo iface = this.ifaces[i]; |
|
||||||
if (clazz != null && iface.implementedBy(clazz)) { |
|
||||||
continue big_loop_this; |
|
||||||
} |
|
||||||
for (int j=0; j<other.ifaces.length; j++) { |
|
||||||
if (iface.implementedBy(other.ifaces[j])) { |
|
||||||
continue big_loop_this; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* This interface is not implemented by any of the other |
|
||||||
* ifaces. Add it to the interfaces vector. |
|
||||||
*/ |
|
||||||
ifaces.addElement(iface); |
|
||||||
} |
|
||||||
big_loop_other: |
|
||||||
for (int i=0; i< other.ifaces.length; i++) { |
|
||||||
ClassInfo iface = other.ifaces[i]; |
|
||||||
if (clazz != null && iface.implementedBy(clazz)) { |
|
||||||
continue big_loop_other; |
|
||||||
} |
|
||||||
for (int j=0; j<ifaces.size(); j++) { |
|
||||||
if (iface.implementedBy((ClassInfo) |
|
||||||
ifaces.elementAt(j))) { |
|
||||||
continue big_loop_other; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* This interface is not implemented by any of the other |
|
||||||
* ifaces. Add it to the interfaces vector. |
|
||||||
*/ |
|
||||||
ifaces.addElement(iface); |
|
||||||
} |
|
||||||
|
|
||||||
ClassInfo[] ifaceArray = new ClassInfo[ifaces.size()]; |
|
||||||
ifaces.copyInto(ifaceArray); |
|
||||||
return create(clazz, ifaceArray); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the generalized type of this and type. We have two |
|
||||||
* classes and multiple interfaces. The result should be the |
|
||||||
* object that is the the super class of both objects and all |
|
||||||
* interfaces, that one class or interface of each type |
|
||||||
* implements. */ |
|
||||||
public Type getGeneralizedType(Type type) { |
|
||||||
int code = type.typecode; |
|
||||||
if (code == TC_RANGE) { |
|
||||||
type = ((RangeType) type).getTop(); |
|
||||||
code = type.typecode; |
|
||||||
} |
|
||||||
if (code == TC_NULL) |
|
||||||
return this; |
|
||||||
if (code == TC_ARRAY) |
|
||||||
return ((ArrayType) type).getGeneralizedType(this); |
|
||||||
if (code != TC_CLASS) |
|
||||||
return tError; |
|
||||||
ClassInterfacesType other = (ClassInterfacesType) type; |
|
||||||
ClassInfo clazz; |
|
||||||
|
|
||||||
/* First the easy part, determine the clazz */ |
|
||||||
if (this.clazz == null || other.clazz == null) |
|
||||||
clazz = null; |
|
||||||
else { |
|
||||||
clazz = this.clazz; |
|
||||||
|
|
||||||
while(clazz != null) { |
|
||||||
if (clazz.superClassOf(other.clazz)) |
|
||||||
break; |
|
||||||
clazz = clazz.getSuperclass(); |
|
||||||
} |
|
||||||
if (clazz == ClassInfo.javaLangObject) |
|
||||||
clazz = null; |
|
||||||
} |
|
||||||
|
|
||||||
if (clazz == this.clazz |
|
||||||
&& implementsAllIfaces(other.clazz, other.ifaces, this.ifaces)) |
|
||||||
return this; |
|
||||||
else if (clazz == other.clazz |
|
||||||
&& implementsAllIfaces(this.clazz, this.ifaces, other.ifaces)) |
|
||||||
return other; |
|
||||||
|
|
||||||
/* Now the more complicated part: find all interfaces, that are |
|
||||||
* implemented by one interface or class in each group. |
|
||||||
* |
|
||||||
* First get all interfaces of this.clazz and this.ifaces. |
|
||||||
*/ |
|
||||||
|
|
||||||
Stack allIfaces = new Stack(); |
|
||||||
if (this.clazz != null) { |
|
||||||
ClassInfo c = this.clazz; |
|
||||||
while (clazz != c) { |
|
||||||
ClassInfo clazzIfaces[] = c.getInterfaces(); |
|
||||||
for (int i=0; i<clazzIfaces.length; i++) |
|
||||||
allIfaces.push(clazzIfaces[i]); |
|
||||||
c = c.getSuperclass(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
Vector ifaces = new Vector(); |
|
||||||
|
|
||||||
for (int i=0; i<this.ifaces.length; i++) |
|
||||||
allIfaces.push(this.ifaces[i]); |
|
||||||
|
|
||||||
/* Now consider each interface. If any clazz or interface
|
|
||||||
* in other implements it, add it to the ifaces vector. |
|
||||||
* Otherwise consider all sub interfaces. |
|
||||||
*/ |
|
||||||
iface_loop: |
|
||||||
while (!allIfaces.isEmpty()) { |
|
||||||
ClassInfo iface = (ClassInfo) allIfaces.pop(); |
|
||||||
if ((clazz != null && iface.implementedBy(clazz)) |
|
||||||
|| ifaces.contains(iface)) |
|
||||||
/* We can skip this, as clazz or ifaces already imply it. |
|
||||||
*/ |
|
||||||
continue iface_loop; |
|
||||||
|
|
||||||
if (other.clazz != null && iface.implementedBy(other.clazz)) { |
|
||||||
ifaces.addElement(iface); |
|
||||||
continue iface_loop; |
|
||||||
} |
|
||||||
for (int i=0; i<other.ifaces.length; i++) { |
|
||||||
if (iface.implementedBy(other.ifaces[i])) { |
|
||||||
ifaces.addElement(iface); |
|
||||||
continue iface_loop; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* This interface is not implemented by any of the other |
|
||||||
* ifaces. Try its parent interfaces now. |
|
||||||
*/ |
|
||||||
ClassInfo clazzIfaces[] = iface.getInterfaces(); |
|
||||||
for (int i=0; i<clazzIfaces.length; i++) |
|
||||||
allIfaces.push(clazzIfaces[i]); |
|
||||||
} |
|
||||||
|
|
||||||
ClassInfo[] ifaceArray = new ClassInfo[ifaces.size()]; |
|
||||||
ifaces.copyInto(ifaceArray); |
|
||||||
return create(clazz, ifaceArray); |
|
||||||
} |
|
||||||
|
|
||||||
public String getTypeSignature() { |
|
||||||
if (clazz != null) |
|
||||||
return "L" + clazz.getName().replace('.','/') + ";"; |
|
||||||
else if (ifaces.length > 0) |
|
||||||
return "L" + ifaces[0].getName().replace('.','/') + ";"; |
|
||||||
else |
|
||||||
return "Ljava/lang/Object;"; |
|
||||||
} |
|
||||||
|
|
||||||
public Class getTypeClass() throws ClassNotFoundException { |
|
||||||
if (clazz != null) |
|
||||||
return Class.forName(clazz.getName()); |
|
||||||
else if (ifaces.length > 0) |
|
||||||
return Class.forName(ifaces[0].getName()); |
|
||||||
else |
|
||||||
return Class.forName("java.lang.Object"); |
|
||||||
} |
|
||||||
|
|
||||||
public ClassInfo getClassInfo() { |
|
||||||
if (clazz != null) |
|
||||||
return clazz; |
|
||||||
else if (ifaces.length > 0) |
|
||||||
return ifaces[0]; |
|
||||||
else |
|
||||||
return ClassInfo.javaLangObject; |
|
||||||
} |
|
||||||
|
|
||||||
public String toString() |
|
||||||
{ |
|
||||||
if (this == tObject) |
|
||||||
return "java.lang.Object"; |
|
||||||
|
|
||||||
if (ifaces.length == 0) |
|
||||||
return clazz.getName(); |
|
||||||
if (clazz == null && ifaces.length == 1) |
|
||||||
return ifaces[0].getName(); |
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer("{"); |
|
||||||
String comma = ""; |
|
||||||
if (clazz != null) { |
|
||||||
sb = sb.append(clazz.getName()); |
|
||||||
comma = ", "; |
|
||||||
} |
|
||||||
for (int i=0; i< ifaces.length; i++) { |
|
||||||
sb.append(comma).append(ifaces[i].getName()); |
|
||||||
comma = ", "; |
|
||||||
} |
|
||||||
return sb.append("}").toString(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Checks if we need to cast to a middle type, before we can cast from |
|
||||||
* fromType to this type. |
|
||||||
* @return the middle type, or null if it is not necessary. |
|
||||||
*/ |
|
||||||
public Type getCastHelper(Type fromType) { |
|
||||||
Type hintType = fromType.getHint(); |
|
||||||
switch (hintType.getTypeCode()) { |
|
||||||
case TC_ARRAY: |
|
||||||
if (clazz == null |
|
||||||
&& implementsAllIfaces(null, ArrayType.arrayIfaces, |
|
||||||
this.ifaces)) |
|
||||||
return null; |
|
||||||
else |
|
||||||
return tObject; |
|
||||||
case TC_CLASS: |
|
||||||
ClassInterfacesType hint = (ClassInterfacesType) hintType; |
|
||||||
if (hint.clazz == null || clazz == null |
|
||||||
|| clazz.superClassOf(hint.clazz) |
|
||||||
|| hint.clazz.superClassOf(clazz)) |
|
||||||
return null; |
|
||||||
ClassInfo superClazz = clazz.getSuperclass(); |
|
||||||
while (superClazz != null |
|
||||||
&& !superClazz.superClassOf(hint.clazz)) { |
|
||||||
superClazz = superClazz.getSuperclass(); |
|
||||||
} |
|
||||||
return tClass(superClazz.getName()); |
|
||||||
case TC_UNKNOWN: |
|
||||||
return null; |
|
||||||
} |
|
||||||
return tObject; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Checks if this type represents a valid type instead of a list |
|
||||||
* of minimum types. |
|
||||||
*/ |
|
||||||
public boolean isValidType() { |
|
||||||
return ifaces.length == 0 |
|
||||||
|| (clazz == null && ifaces.length == 1); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Checks if this is a class or array type (but not a null type). |
|
||||||
* @XXX remove this? |
|
||||||
* @return true if this is a class or array type. |
|
||||||
*/ |
|
||||||
public boolean isClassType() { |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
private final static Hashtable keywords = new Hashtable(); |
|
||||||
static { |
|
||||||
keywords.put("abstract", Boolean.TRUE); |
|
||||||
keywords.put("default", Boolean.TRUE); |
|
||||||
keywords.put("if", Boolean.TRUE); |
|
||||||
keywords.put("private", Boolean.TRUE); |
|
||||||
keywords.put("throw", Boolean.TRUE); |
|
||||||
keywords.put("boolean", Boolean.TRUE); |
|
||||||
keywords.put("do", Boolean.TRUE); |
|
||||||
keywords.put("implements", Boolean.TRUE); |
|
||||||
keywords.put("protected", Boolean.TRUE); |
|
||||||
keywords.put("throws", Boolean.TRUE); |
|
||||||
keywords.put("break", Boolean.TRUE); |
|
||||||
keywords.put("double", Boolean.TRUE); |
|
||||||
keywords.put("import", Boolean.TRUE); |
|
||||||
keywords.put("public", Boolean.TRUE); |
|
||||||
keywords.put("transient", Boolean.TRUE); |
|
||||||
keywords.put("byte", Boolean.TRUE); |
|
||||||
keywords.put("else", Boolean.TRUE); |
|
||||||
keywords.put("instanceof", Boolean.TRUE); |
|
||||||
keywords.put("return", Boolean.TRUE); |
|
||||||
keywords.put("try", Boolean.TRUE); |
|
||||||
keywords.put("case", Boolean.TRUE); |
|
||||||
keywords.put("extends", Boolean.TRUE); |
|
||||||
keywords.put("int", Boolean.TRUE); |
|
||||||
keywords.put("short", Boolean.TRUE); |
|
||||||
keywords.put("void", Boolean.TRUE); |
|
||||||
keywords.put("catch", Boolean.TRUE); |
|
||||||
keywords.put("final", Boolean.TRUE); |
|
||||||
keywords.put("interface", Boolean.TRUE); |
|
||||||
keywords.put("static", Boolean.TRUE); |
|
||||||
keywords.put("volatile", Boolean.TRUE); |
|
||||||
keywords.put("char", Boolean.TRUE); |
|
||||||
keywords.put("finally", Boolean.TRUE); |
|
||||||
keywords.put("long", Boolean.TRUE); |
|
||||||
keywords.put("super", Boolean.TRUE); |
|
||||||
keywords.put("while", Boolean.TRUE); |
|
||||||
keywords.put("class", Boolean.TRUE); |
|
||||||
keywords.put("float", Boolean.TRUE); |
|
||||||
keywords.put("native", Boolean.TRUE); |
|
||||||
keywords.put("switch", Boolean.TRUE); |
|
||||||
keywords.put("const", Boolean.TRUE); |
|
||||||
keywords.put("for", Boolean.TRUE); |
|
||||||
keywords.put("new", Boolean.TRUE); |
|
||||||
keywords.put("synchronized", Boolean.TRUE); |
|
||||||
keywords.put("continue", Boolean.TRUE); |
|
||||||
keywords.put("goto", Boolean.TRUE); |
|
||||||
keywords.put("package", Boolean.TRUE); |
|
||||||
keywords.put("this", Boolean.TRUE); |
|
||||||
keywords.put("strictfp", Boolean.TRUE); |
|
||||||
keywords.put("null", Boolean.TRUE); |
|
||||||
keywords.put("true", Boolean.TRUE); |
|
||||||
keywords.put("false", Boolean.TRUE); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Generates the default name, that is the `natural' choice for |
|
||||||
* local of this type. |
|
||||||
* @return the default name of a local of this type. |
|
||||||
*/ |
|
||||||
public String getDefaultName() { |
|
||||||
ClassInfo type; |
|
||||||
if (clazz != null) |
|
||||||
type = clazz; |
|
||||||
else if (ifaces.length > 0) |
|
||||||
type = ifaces[0]; |
|
||||||
else |
|
||||||
type = ClassInfo.javaLangObject; |
|
||||||
String name = type.getName(); |
|
||||||
int dot = Math.max(name.lastIndexOf('.'), name.lastIndexOf('$')); |
|
||||||
if (dot >= 0) |
|
||||||
name = name.substring(dot+1); |
|
||||||
if (Character.isUpperCase(name.charAt(0))) { |
|
||||||
name = name.toLowerCase(); |
|
||||||
if (keywords.get(name) != null) |
|
||||||
return "var_" + name; |
|
||||||
return name; |
|
||||||
} else |
|
||||||
return "var_" + name; |
|
||||||
} |
|
||||||
|
|
||||||
public int hashCode() { |
|
||||||
int hash = clazz == null ? 0 : clazz.hashCode(); |
|
||||||
for (int i=0; i < ifaces.length; i++) { |
|
||||||
hash ^= ifaces[i].hashCode(); |
|
||||||
} |
|
||||||
return hash; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean equals(Object o) { |
|
||||||
if (o == this) |
|
||||||
return true; |
|
||||||
if (o instanceof Type && ((Type)o).typecode == TC_CLASS) { |
|
||||||
ClassInterfacesType type = (ClassInterfacesType) o; |
|
||||||
if (type.clazz == clazz |
|
||||||
&& type.ifaces.length == ifaces.length) { |
|
||||||
big_loop: |
|
||||||
for (int i=0; i< type.ifaces.length; i++) { |
|
||||||
for (int j=0; j<ifaces.length; j++) { |
|
||||||
if (type.ifaces[i] == ifaces[j]) |
|
||||||
continue big_loop; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
@ -1,36 +0,0 @@ |
|||||||
## Input file for automake to generate the Makefile.in used by configure
|
|
||||||
|
|
||||||
JAR = @JAR@
|
|
||||||
JAVAC = @JAVAC@
|
|
||||||
JAVADEP = $(top_builddir)/javaDependencies.pl -subdir=$(subdir)\
|
|
||||||
-dependdir=$(top_builddir) -classpath=$(top_builddir):$(top_srcdir) \
|
|
||||||
-depfile=Makefile.dep
|
|
||||||
CLASSPATH = @CLASSPATH@
|
|
||||||
CLASSLIB = @CLASSLIB@
|
|
||||||
SUBSTCP = @SUBSTCP@
|
|
||||||
FULL_CLASSPATH := $(shell $(SUBSTCP) $(top_srcdir):$(top_builddir):$(CLASSPATH):$(CLASSLIB))
|
|
||||||
|
|
||||||
MY_JAVA_FILES = \
|
|
||||||
ArrayType.java \
|
|
||||||
ClassInterfacesType.java \
|
|
||||||
IntegerType.java \
|
|
||||||
MethodType.java \
|
|
||||||
NullType.java \
|
|
||||||
RangeType.java \
|
|
||||||
ReferenceType.java \
|
|
||||||
Type.java
|
|
||||||
|
|
||||||
noinst_DATA = $(MY_JAVA_FILES:.java=.class)
|
|
||||||
EXTRA_DIST = $(MY_JAVA_FILES)
|
|
||||||
|
|
||||||
@QUOTE@-include Makefile.dep |
|
||||||
|
|
||||||
%.class: %.java |
|
||||||
$(JAVAC) -classpath $(FULL_CLASSPATH) -d $(top_builddir) $<
|
|
||||||
|
|
||||||
Makefile.dep: $(MY_JAVA_FILES:.java=.class) |
|
||||||
$(JAVADEP) $^
|
|
||||||
|
|
||||||
clean-local: |
|
||||||
@rm -f *.class
|
|
||||||
@rm -f *.dep
|
|
@ -1,2 +0,0 @@ |
|||||||
Makefile |
|
||||||
Makefile.in |
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue