Skip to content

Commit 0a92389

Browse files
committed
Added more tests and code cleanups
1 parent 5f115a2 commit 0a92389

13 files changed

Lines changed: 558 additions & 114 deletions

File tree

.github/workflows/build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build Workflow
2+
on:
3+
push:
4+
branches: [ main ]
5+
jobs:
6+
build:
7+
if: github.repository == 'mirkosertic/MetaIR'
8+
environment: ci
9+
runs-on: 'ubuntu-latest'
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-java@v4
13+
with:
14+
java-version: 24
15+
distribution: "temurin"
16+
cache: maven
17+
- run: |
18+
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
19+
gpg --list-secret-keys --keyid-format LONG
20+
- run: mvn --no-transfer-progress --batch-mode --settings .mvn/settings.xml clean javadoc:jar deploy -P signed
21+
env:
22+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
23+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
24+
GPG_KEY_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }}

.github/workflows/maven.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
target/
22
.idea
3-
.mvn
43
.dot
54
.yaml

.mvn/settings.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
5+
<servers>
6+
<server>
7+
<id>maven-snapshots</id>
8+
<username>${env.SONATYPE_USERNAME}</username>
9+
<password>${env.SONATYPE_PASSWORD}</password>
10+
</server>
11+
12+
<server>
13+
<id>maven-releases</id>
14+
<username>${env.SONATYPE_USERNAME}</username>
15+
<password>${env.SONATYPE_PASSWORD}</password>
16+
</server>
17+
18+
<server>
19+
<id>central</id>
20+
<username>${env.SONATYPE_USERNAME}</username>
21+
<password>${env.SONATYPE_PASSWORD}</password>
22+
</server>
23+
24+
<server>
25+
<id>gpg.passphrase</id>
26+
<passphrase>${env.GPG_KEY_PASSPHRASE}</passphrase>
27+
</server>
28+
</servers>
29+
30+
<profiles>
31+
<profile>
32+
<activation>
33+
<activeByDefault>true</activeByDefault>
34+
</activation>
35+
<id>signed-release</id>
36+
<properties>
37+
<gpg.keyname>0D9F1DB8</gpg.keyname>
38+
</properties>
39+
</profile>
40+
</profiles>
41+
42+
</settings>

pom.xml

Lines changed: 134 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,45 @@
77
<groupId>de.mirkosertic</groupId>
88
<artifactId>metair</artifactId>
99
<version>1.0-SNAPSHOT</version>
10+
<name>MetaIR</name>
11+
<description>A showcase for the MetaIR and JVM bytecode reverse engineering </description>
12+
<packaging>jar</packaging>
13+
<url>https://github.com/mirkosertic/MetaIR</url>
14+
15+
<licenses>
16+
<license>
17+
<name>Apache License, Version 2.0</name>
18+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
19+
</license>
20+
</licenses>
21+
22+
<organization>
23+
<name>Systemprogrammierung Mirko Sertic</name>
24+
<url>http://www.mirkosertic.de</url>
25+
</organization>
26+
27+
<developers>
28+
<developer>
29+
<name>Mirko Sertic</name>
30+
<email>mirko@mirkosertic.de</email>
31+
<roles>
32+
<role>Developer</role>
33+
</roles>
34+
</developer>
35+
</developers>
36+
37+
<scm>
38+
<url>https://github.com/mirkosertic/MetaIR</url>
39+
<connection>scm:git:https://github.com/mirkosertic/MetaIR.git</connection>
40+
<developerConnection>scm:git:https://github.com/mirkosertic/MetaIR.git</developerConnection>
41+
</scm>
1042

1143
<properties>
12-
<maven.compiler.source>24</maven.compiler.source>
13-
<maven.compiler.target>24</maven.compiler.target>
44+
<java.version>24</java.version>
1445
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1546
<junit.version>5.13.4</junit.version>
1647
</properties>
1748

18-
<scm>
19-
<url>https://github.com/mirkosertic/MetaIR.git</url>
20-
</scm>
21-
2249
<dependencies>
2350
<dependency>
2451
<groupId>org.junit.jupiter</groupId>
@@ -38,4 +65,105 @@
3865
<scope>test</scope>
3966
</dependency>
4067
</dependencies>
68+
69+
<build>
70+
<pluginManagement>
71+
<plugins>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-javadoc-plugin</artifactId>
75+
<version>3.11.2</version>
76+
<configuration>
77+
<source>8</source>
78+
</configuration>
79+
</plugin>
80+
<plugin>
81+
<groupId>org.apache.maven.plugins</groupId>
82+
<artifactId>maven-source-plugin</artifactId>
83+
<version>3.3.1</version>
84+
</plugin>
85+
<plugin>
86+
<groupId>org.apache.maven.plugins</groupId>
87+
<artifactId>maven-compiler-plugin</artifactId>
88+
<version>3.14.0</version>
89+
<configuration>
90+
<source>${java.version}</source>
91+
<target>${java.version}</target>
92+
</configuration>
93+
</plugin>
94+
</plugins>
95+
</pluginManagement>
96+
97+
<plugins>
98+
<plugin>
99+
<groupId>org.sonatype.central</groupId>
100+
<artifactId>central-publishing-maven-plugin</artifactId>
101+
<version>0.7.0</version>
102+
<extensions>true</extensions>
103+
<configuration>
104+
<publishingServerId>central</publishingServerId>
105+
<autoPublish>true</autoPublish>
106+
<waitUntil>published</waitUntil>
107+
</configuration>
108+
</plugin>
109+
110+
<plugin>
111+
<groupId>org.apache.maven.plugins</groupId>
112+
<artifactId>maven-surefire-plugin</artifactId>
113+
<version>3.5.3</version>
114+
</plugin>
115+
116+
<plugin>
117+
<groupId>org.apache.maven.plugins</groupId>
118+
<artifactId>maven-source-plugin</artifactId>
119+
<executions>
120+
<execution>
121+
<id>attach-sources</id>
122+
<goals>
123+
<goal>jar</goal>
124+
</goals>
125+
</execution>
126+
</executions>
127+
</plugin>
128+
129+
<plugin>
130+
<groupId>org.apache.maven.plugins</groupId>
131+
<artifactId>maven-release-plugin</artifactId>
132+
<version>3.1.1</version>
133+
<configuration>
134+
<tagNameFormat>@{project.version}</tagNameFormat>
135+
</configuration>
136+
</plugin>
137+
</plugins>
138+
</build>
139+
140+
<profiles>
141+
<profile>
142+
<id>signed</id>
143+
<build>
144+
<plugins>
145+
<plugin>
146+
<groupId>org.apache.maven.plugins</groupId>
147+
<artifactId>maven-gpg-plugin</artifactId>
148+
<version>3.2.7</version>
149+
<executions>
150+
<execution>
151+
<id>sign-artifacts</id>
152+
<phase>verify</phase>
153+
<goals>
154+
<goal>sign</goal>
155+
</goals>
156+
</execution>
157+
</executions>
158+
<configuration>
159+
<gpgArguments>
160+
<arg>--pinentry-mode</arg>
161+
<arg>loopback</arg>
162+
</gpgArguments>
163+
</configuration>
164+
</plugin>
165+
</plugins>
166+
</build>
167+
</profile>
168+
</profiles>
41169
</project>

src/main/java/de/mirkosertic/metair/ir/Invocation.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public abstract class Invocation extends Value {
1212
public final MethodTypeDesc typeDesc;
1313

1414
Invocation(final ClassDesc ownerType, final Value target, final String name, final MethodTypeDesc methodTypeDesc, final List<Value> arguments) {
15-
super(methodTypeDesc.returnType());
15+
super(TypeUtils.jvmInternalTypeOf(methodTypeDesc.returnType()));
1616

1717
if (target.type.isPrimitive()) {
1818
illegalArgument("Cannot invoke a method on a primitive value");
@@ -23,7 +23,9 @@ public abstract class Invocation extends Value {
2323
}
2424

2525
for (int i = 0; i < arguments.size(); i++) {
26-
if (methodTypeDesc.parameterType(i).isPrimitive() && !arguments.get(i).type.equals(methodTypeDesc.parameterType(i))) {
26+
if (methodTypeDesc.parameterType(i).isPrimitive() && !TypeUtils.jvmInternalTypeOf(arguments.get(i).type).equals(TypeUtils.jvmInternalTypeOf(methodTypeDesc.parameterType(i)))) {
27+
// TODO: Convert byte, char, short, boolean rsp. type check it
28+
// TODO: Floating point conversion if required...
2729
illegalArgument("Parameter " + i + " of method " + name + " is a " + TypeUtils.toString(methodTypeDesc.parameterType(i)) + " type, but got " + TypeUtils.toString(arguments.get(i).type));
2830
}
2931
}

0 commit comments

Comments
 (0)