Skip to content

Commit cc1b394

Browse files
committed
Bugfixes.
1 parent 30b6caf commit cc1b394

File tree

14 files changed

+67
-32
lines changed

14 files changed

+67
-32
lines changed

jphp-core/api-docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Compiler and Launcher for JPHP.
99

1010
### Install
1111
```
12-
12+
1313
```
1414

1515
### API

jphp-core/api-docs/README.ru.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Compiler and Launcher for JPHP.
99

1010
### Установка
1111
```
12-
12+
1313
```
1414

1515
### АПИ

jphp-core/package.php.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
name: jphp-core
3-
version: 1.2.5
3+
version: 1.2.6
44
description: Compiler and Launcher for JPHP.
55

66
deps:
7-
jphp-runtime: '~1.2.5'
7+
jphp-runtime: '~1.2.6'
88

99

1010
plugins: [Doc, Hub]

jphp-core/src/org/develnext/jphp/core/compiler/jvm/statement/ClassStmtCompiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ protected void writeInitEnvironment() {
583583
expressionCompiler.writePushConstString(entity.getName());
584584
expressionCompiler.writePushConstString(entity.getLowerName());
585585
}
586-
expressionCompiler.writePushConstBoolean(true);
586+
expressionCompiler.writePushConstBoolean(false);
587587
expressionCompiler.writeSysDynamicCall(
588588
Environment.class, "fetchClass", ClassEntity.class, String.class, String.class, Boolean.TYPE
589589
);

jphp-runtime/api-docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Runtime for JPHP + Standard library.
99

1010
### Install
1111
```
12-
12+
1313
```
1414

1515
### API

jphp-runtime/api-docs/README.ru.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Runtime for JPHP + Standard library.
99

1010
### Установка
1111
```
12-
12+
1313
```
1414

1515
### АПИ

jphp-runtime/package.php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
name: jphp-runtime
3-
version: 1.2.5
3+
version: 1.2.6
44
description: Runtime for JPHP + Standard library.
55

66
plugins: [Doc, Hub]

jphp-runtime/src/php/runtime/env/CompileScope.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,17 @@ public ClassEntity fetchUserClass(Class<? extends IObject> clazz) {
460460
}
461461

462462
public ClassEntity fetchUserClass(String name) {
463-
return fetchUserClass(name, name.toLowerCase());
463+
return fetchUserClass(name, name.toLowerCase(), true);
464464
}
465465

466466
public ClassEntity fetchUserClass(String name, String nameLower) {
467+
return fetchUserClass(name, nameLower, true);
468+
}
469+
470+
public ClassEntity fetchUserClass(String name, String nameLower, boolean autoLoad) {
467471
ClassEntity entity;
468472

469-
if (classEntityFetchHandler != null) {
473+
if (autoLoad && classEntityFetchHandler != null) {
470474
for (EntityFetchHandler handler : classEntityFetchHandler) {
471475
handler.fetch(this, name, nameLower);
472476
}

jphp-runtime/src/php/runtime/env/Environment.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,13 +651,18 @@ public ClassEntity fetchClass(String name, String nameL, boolean autoLoad) {
651651
entity = classMap.get(nameL); // try retry!
652652

653653
if (entity == null) {
654-
entity = scope.fetchUserClass(name, nameL);
654+
entity = scope.fetchUserClass(name, nameL, autoLoad);
655655

656656
if (entity != null) {
657657
try {
658658
entity.initEnvironment(this);
659659
} catch (Throwable throwable) {
660-
throw new CriticalException(throwable);
660+
// nop.
661+
if (throwable instanceof BaseBaseException) {
662+
error(ErrorType.E_CORE_ERROR, "Failed to init environment for class " + name);
663+
} else {
664+
error(ErrorType.E_CORE_ERROR, "Failed to init environment for class " + name + ": " + throwable.getMessage());
665+
}
661666
}
662667
classMap.put(entity.getLowerName(), entity);
663668
return entity;

jphp-runtime/src/php/runtime/ext/core/classes/WrapModule.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,29 +206,37 @@ public Memory dumpJVMClasses(Environment env, Memory... args) throws IOException
206206

207207
ArrayMemory classes = new ArrayMemory();
208208
for (ClassEntity classEntity : module.getClasses()) {
209-
File file = saveJavaClass(entityClassFile.apply(classEntity), classEntity.getData());
210-
classes.put(classEntity.getName(), file.toString());
209+
if (classEntity.getData() != null) {
210+
File file = saveJavaClass(entityClassFile.apply(classEntity), classEntity.getData());
211+
classes.put(classEntity.getName(), file.toString());
212+
}
211213
}
212214
result.put("classes", classes);
213215

214216
ArrayMemory functions = new ArrayMemory();
215217
for (FunctionEntity functionEntity : module.getFunctions()) {
216-
File file = saveJavaClass(entityClassFile.apply(functionEntity), functionEntity.getData());
217-
functions.put(functionEntity.getName(), file.toString());
218+
if (functionEntity.getData() != null) {
219+
File file = saveJavaClass(entityClassFile.apply(functionEntity), functionEntity.getData());
220+
functions.put(functionEntity.getName(), file.toString());
221+
}
218222
}
219223
result.put("functions", functions);
220224

221225
ArrayMemory closures = new ArrayMemory();
222226
for (ClosureEntity one : module.getClosures()) {
223-
File file = saveJavaClass(entityClassFile.apply(one), one.getData());
224-
closures.add(file.toString());
227+
if (one.getData() != null) {
228+
File file = saveJavaClass(entityClassFile.apply(one), one.getData());
229+
closures.add(file.toString());
230+
}
225231
}
226232
result.put("closures", closures);
227233

228234
ArrayMemory generators = new ArrayMemory();
229235
for (GeneratorEntity one : module.getGenerators()) {
230-
File file = saveJavaClass(entityClassFile.apply(one), one.getData());
231-
generators.add(file.toString());
236+
if (one.getData() != null) {
237+
File file = saveJavaClass(entityClassFile.apply(one), one.getData());
238+
generators.add(file.toString());
239+
}
232240
}
233241
result.put("generators", generators);
234242

0 commit comments

Comments
 (0)